@openviking/react 0.1.2 → 0.1.4

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 (249) hide show
  1. package/LICENSE.arco-design +21 -0
  2. package/README.md +25 -15
  3. package/dist/0~0.js +19 -0
  4. package/dist/2~0.js +2360 -0
  5. package/dist/2~0.js.LICENSE.txt +23 -0
  6. package/dist/3c~0.js +2206 -0
  7. package/dist/3~0.js +1205 -1982
  8. package/dist/4~0.js +18 -0
  9. package/dist/9~0.js +43 -0
  10. package/dist/ae~0.js +487 -0
  11. package/dist/ark-message-list-view~0.js +530 -119
  12. package/dist/a~0.js +1289 -10
  13. package/dist/c7~0.js +38 -2
  14. package/dist/ck~0.js +23 -0
  15. package/dist/client/index.d.ts +2 -1
  16. package/dist/client/paths.d.ts +64 -0
  17. package/dist/client/provider.d.ts +5 -3
  18. package/dist/client/response.d.ts +31 -0
  19. package/dist/client/sse.d.ts +39 -0
  20. package/dist/client/stream.d.ts +26 -0
  21. package/dist/client/types.d.ts +109 -5
  22. package/dist/client.js +2 -239
  23. package/dist/components/agent-connect/agent-connect-copy.d.ts +19 -33
  24. package/dist/components/agent-connect/agent-connect-design.d.ts +1935 -167
  25. package/dist/components/agent-connect/agent-connect-instructions.d.ts +135 -0
  26. package/dist/components/agent-connect/locales/en-US.d.ts +20 -0
  27. package/dist/components/agent-connect/locales/zh-CN.d.ts +3 -0
  28. package/dist/components/agent-connect/style.css +14 -2
  29. package/dist/components/agent-connect/types.d.ts +2 -1
  30. package/dist/components/directory-tour/directory-tour.d.ts +3 -0
  31. package/dist/components/directory-tour/index.d.ts +3 -0
  32. package/dist/components/directory-tour/locales/en-US.d.ts +3 -0
  33. package/dist/components/directory-tour/locales/zh-CN.d.ts +3 -0
  34. package/dist/components/directory-tour/steps.d.ts +5 -0
  35. package/dist/components/directory-tour/style.css +237 -0
  36. package/dist/components/directory-tour/style.js +0 -0
  37. package/dist/components/directory-tour/types.d.ts +42 -0
  38. package/dist/components/directory-tour/use-tour-anchor.d.ts +5 -0
  39. package/dist/components/directory-tour/use-tour-position.d.ts +12 -0
  40. package/dist/components/directory-tour.js +40 -0
  41. package/dist/components/file-browser-entries/file-browser-entries-icons.d.ts +18 -0
  42. package/dist/components/file-browser-entries/file-browser-entries.d.ts +14 -0
  43. package/dist/components/file-browser-entries/index.d.ts +1 -0
  44. package/dist/components/file-browser-entries/labels.d.ts +3 -0
  45. package/dist/components/file-browser-entries/locales/en-US.d.ts +6 -0
  46. package/dist/components/file-browser-entries/locales/zh-CN.d.ts +6 -0
  47. package/dist/components/file-browser-entries/style.css +905 -0
  48. package/dist/components/file-browser-entries/style.js +0 -0
  49. package/dist/components/file-browser-entries/types.d.ts +63 -0
  50. package/dist/components/file-browser-entries.js +1 -0
  51. package/dist/components/file-preview/file-preview-adapters.d.ts +2 -1
  52. package/dist/components/file-preview/file-preview-body.d.ts +2 -1
  53. package/dist/components/file-preview/file-preview-breadcrumb-menu.d.ts +2 -1
  54. package/dist/components/file-preview/file-preview-breadcrumb.d.ts +2 -1
  55. package/dist/components/file-preview/file-preview-directory.d.ts +33 -0
  56. package/dist/components/file-preview/file-preview-handle-adapters.d.ts +2 -1
  57. package/dist/components/file-preview/file-preview-header.d.ts +25 -3
  58. package/dist/components/file-preview/file-preview-image-frame.d.ts +5 -0
  59. package/dist/components/file-preview/file-preview-labels.d.ts +2 -14
  60. package/dist/components/file-preview/file-preview-level-tabs.d.ts +7 -0
  61. package/dist/components/file-preview/file-preview-markdown-images.d.ts +13 -0
  62. package/dist/components/file-preview/file-preview-panels.d.ts +44 -0
  63. package/dist/components/file-preview/file-preview-state.d.ts +10 -3
  64. package/dist/components/file-preview/file-preview-viewer.d.ts +2 -1
  65. package/dist/components/file-preview/file-preview.d.ts +1 -1
  66. package/dist/components/file-preview/index.d.ts +2 -1
  67. package/dist/components/file-preview/level-selection.d.ts +25 -0
  68. package/dist/components/file-preview/locales/en-US.d.ts +16 -0
  69. package/dist/components/file-preview/locales/zh-CN.d.ts +16 -0
  70. package/dist/components/file-preview/style.css +234 -3
  71. package/dist/components/file-preview/types.d.ts +134 -11
  72. package/dist/components/file-preview/use-directory-level.d.ts +30 -0
  73. package/dist/components/file-preview/use-file-preview-actions-context.d.ts +6 -2
  74. package/dist/components/file-preview/use-file-preview-actions.d.ts +1 -1
  75. package/dist/components/file-preview/use-file-preview-levels.d.ts +7 -0
  76. package/dist/components/file-preview/use-file-preview-view-state.d.ts +15 -0
  77. package/dist/components/file-preview.js +1 -1
  78. package/dist/components/file-tree/file-tree-info-labels.d.ts +0 -15
  79. package/dist/components/file-tree/file-tree-info-tooltip.d.ts +7 -7
  80. package/dist/components/file-tree/file-tree-labels.d.ts +4 -0
  81. package/dist/components/file-tree/file-tree-row-context.d.ts +0 -5
  82. package/dist/components/file-tree/file-tree-row-shared.d.ts +1 -4
  83. package/dist/components/file-tree/file-tree-toolbar.d.ts +11 -0
  84. package/dist/components/file-tree/file-tree-tooltip-surface.d.ts +8 -8
  85. package/dist/components/file-tree/locales/en-US.d.ts +69 -0
  86. package/dist/components/file-tree/locales/zh-CN.d.ts +69 -0
  87. package/dist/components/file-tree/style.css +207 -42
  88. package/dist/components/file-tree/types.d.ts +58 -10
  89. package/dist/components/file-tree/use-file-tree-actions.d.ts +4 -1
  90. package/dist/components/scope-switcher/labels.d.ts +3 -0
  91. package/dist/components/scope-switcher/locales/en-US.d.ts +8 -0
  92. package/dist/components/scope-switcher/locales/zh-CN.d.ts +8 -0
  93. package/dist/components/scope-switcher/scope-panel.d.ts +1 -1
  94. package/dist/components/scope-switcher/scope-switcher.d.ts +1 -1
  95. package/dist/components/scope-switcher/style.css +14 -2
  96. package/dist/components/scope-switcher/types.d.ts +11 -5
  97. package/dist/components/style.css +10144 -6840
  98. package/dist/components/tui/locales/en-US.d.ts +35 -0
  99. package/dist/components/tui/locales/zh-CN.d.ts +35 -0
  100. package/dist/components/tui/style.css +310 -18
  101. package/dist/components/tui/tui-copy-button.d.ts +1 -1
  102. package/dist/components/tui/tui-empty.d.ts +25 -0
  103. package/dist/components/tui/tui-labels.d.ts +2 -2
  104. package/dist/components/tui/tui.d.ts +1 -1
  105. package/dist/components/tui/types.d.ts +35 -12
  106. package/dist/components/tui.js +1 -1
  107. package/dist/components/viking-bot/ark-adapter.d.ts +2 -0
  108. package/dist/components/viking-bot/ark-message-body.d.ts +1 -7
  109. package/dist/components/viking-bot/ark-message-list-view.d.ts +1 -1
  110. package/dist/components/viking-bot/ark-message-row.d.ts +3 -1
  111. package/dist/components/viking-bot/bot-popover.d.ts +9 -0
  112. package/dist/components/viking-bot/capabilities.d.ts +49 -0
  113. package/dist/components/viking-bot/composer-attachments.d.ts +13 -0
  114. package/dist/components/viking-bot/composer-controls.d.ts +10 -0
  115. package/dist/components/viking-bot/composer-footer.d.ts +17 -0
  116. package/dist/components/viking-bot/composer-references.d.ts +20 -0
  117. package/dist/components/viking-bot/composer-text.d.ts +10 -0
  118. package/dist/components/viking-bot/index.d.ts +3 -1
  119. package/dist/components/viking-bot/interaction/ask-human-fields.d.ts +1 -1
  120. package/dist/components/viking-bot/interaction/labels.d.ts +2 -1
  121. package/dist/components/viking-bot/interaction/locales/en-US.d.ts +17 -0
  122. package/dist/components/viking-bot/interaction/locales/zh-CN.d.ts +17 -0
  123. package/dist/components/viking-bot/interaction/types.d.ts +8 -3
  124. package/dist/components/viking-bot/interaction/viking-bot-interaction.d.ts +1 -1
  125. package/dist/components/viking-bot/labels.d.ts +2 -0
  126. package/dist/components/viking-bot/locales/en-US.d.ts +40 -0
  127. package/dist/components/viking-bot/locales/zh-CN.d.ts +40 -0
  128. package/dist/components/viking-bot/markdown-links.d.ts +27 -0
  129. package/dist/components/viking-bot/message-activity.d.ts +7 -0
  130. package/dist/components/viking-bot/message-code-block.d.ts +8 -0
  131. package/dist/components/viking-bot/message-footer.d.ts +8 -0
  132. package/dist/components/viking-bot/message-markdown.d.ts +9 -0
  133. package/dist/components/viking-bot/model.d.ts +37 -3
  134. package/dist/components/viking-bot/quick-input-tracker.d.ts +16 -0
  135. package/dist/components/viking-bot/quick-inputs.d.ts +6 -0
  136. package/dist/components/viking-bot/reference-picker.d.ts +16 -0
  137. package/dist/components/viking-bot/session-actions.d.ts +11 -0
  138. package/dist/components/viking-bot/style.css +1486 -48
  139. package/dist/components/viking-bot/tool-activity.d.ts +9 -0
  140. package/dist/components/viking-bot/tool-result-links.d.ts +6 -0
  141. package/dist/components/viking-bot/types.d.ts +21 -9
  142. package/dist/components/viking-bot/use-quick-input.d.ts +17 -0
  143. package/dist/components/viking-bot/viking-bot.d.ts +1 -6
  144. package/dist/components/viking-bot/welcome.d.ts +8 -0
  145. package/dist/components/viking-bot.js +1 -1
  146. package/dist/c~0.js +533 -66
  147. package/dist/e~0.js +333 -0
  148. package/dist/file-preview-viewer~0.js +90 -8
  149. package/dist/f~0.js +39 -47
  150. package/dist/h~0.js +5 -1
  151. package/dist/icons/console-icons.d.ts +12 -0
  152. package/dist/icons/index.d.ts +2 -0
  153. package/dist/icons/viking-bot-icons.d.ts +6 -0
  154. package/dist/icons.js +1 -0
  155. package/dist/index.d.ts +4 -0
  156. package/dist/index.js +3 -1
  157. package/dist/k~0.js +1 -0
  158. package/dist/lg~0.js +155 -0
  159. package/dist/lk~0.js +37 -8
  160. package/dist/l~0.js +1447 -25
  161. package/dist/modules/console/command-messages.d.ts +19 -0
  162. package/dist/modules/console/command-parser.d.ts +15 -0
  163. package/dist/modules/console/command-specs.d.ts +15 -0
  164. package/dist/modules/console/commands.d.ts +6 -0
  165. package/dist/modules/console/console-history.d.ts +10 -0
  166. package/dist/modules/console/console-toolbar.d.ts +18 -0
  167. package/dist/modules/console/console.d.ts +1 -3
  168. package/dist/modules/console/controller.d.ts +17 -0
  169. package/dist/modules/console/index.d.ts +2 -0
  170. package/dist/modules/console/labels.d.ts +61 -0
  171. package/dist/modules/console/locales/en-US.d.ts +49 -0
  172. package/dist/modules/console/locales/zh-CN.d.ts +3 -0
  173. package/dist/modules/console/localize-records.d.ts +11 -0
  174. package/dist/modules/console/results.d.ts +2 -0
  175. package/dist/modules/console/style.css +10905 -15
  176. package/dist/modules/console/types.d.ts +59 -80
  177. package/dist/modules/console/use-console.d.ts +3 -0
  178. package/dist/modules/console.js +1 -1
  179. package/dist/modules/file-browser/file-browser-detail-icons.d.ts +10 -0
  180. package/dist/modules/file-browser/file-browser-detail.d.ts +34 -0
  181. package/dist/modules/file-browser/file-browser-empty.d.ts +3 -0
  182. package/dist/modules/file-browser/file-browser-failure.d.ts +22 -0
  183. package/dist/modules/file-browser/file-browser-icons.d.ts +18 -0
  184. package/dist/modules/file-browser/file-browser-labels.d.ts +27 -0
  185. package/dist/modules/file-browser/file-browser-layout.d.ts +27 -0
  186. package/dist/modules/file-browser/file-browser-toolbar.d.ts +17 -0
  187. package/dist/modules/file-browser/file-browser-tree-pane.d.ts +32 -0
  188. package/dist/modules/file-browser/file-browser.d.ts +14 -5
  189. package/dist/modules/file-browser/find-result.d.ts +24 -0
  190. package/dist/modules/file-browser/fs-directories.d.ts +33 -0
  191. package/dist/modules/file-browser/fs-file-kind.d.ts +19 -0
  192. package/dist/modules/file-browser/fs-icon.d.ts +17 -0
  193. package/dist/modules/file-browser/fs-model.d.ts +106 -0
  194. package/dist/modules/file-browser/fs-page.d.ts +16 -0
  195. package/dist/modules/file-browser/fs-path.d.ts +16 -0
  196. package/dist/modules/file-browser/fs-read-directory.d.ts +16 -0
  197. package/dist/modules/file-browser/fs-scope.d.ts +22 -0
  198. package/dist/modules/file-browser/fs-stat.d.ts +25 -0
  199. package/dist/modules/file-browser/index.d.ts +3 -1
  200. package/dist/modules/file-browser/locales/en-US.d.ts +25 -0
  201. package/dist/modules/file-browser/locales/zh-CN.d.ts +25 -0
  202. package/dist/modules/file-browser/style.css +6388 -41
  203. package/dist/modules/file-browser/types.d.ts +206 -52
  204. package/dist/modules/file-browser/use-container-width.d.ts +17 -0
  205. package/dist/modules/file-browser/use-file-browser.d.ts +54 -0
  206. package/dist/modules/file-browser/use-fs-preview.d.ts +65 -0
  207. package/dist/modules/file-browser/use-fs-search.d.ts +35 -0
  208. package/dist/modules/file-browser/use-fs-tree.d.ts +43 -0
  209. package/dist/modules/file-browser/use-request-scope.d.ts +39 -0
  210. package/dist/modules/file-browser.js +1 -1
  211. package/dist/modules/scope-cascade/labels.d.ts +6 -0
  212. package/dist/modules/scope-cascade/locales/en-US.d.ts +6 -0
  213. package/dist/modules/scope-cascade/locales/zh-CN.d.ts +3 -0
  214. package/dist/modules/scope-cascade/scope-cascade.d.ts +1 -1
  215. package/dist/modules/scope-cascade/style.css +14 -2
  216. package/dist/modules/scope-cascade/types.d.ts +3 -0
  217. package/dist/modules/style.css +17338 -77
  218. package/dist/nx~0.js +15 -0
  219. package/dist/n~0.js +403 -144
  220. package/dist/o~0.js +106 -0
  221. package/dist/p~0.js +27 -0
  222. package/dist/rslib-runtime~0.js +42 -0
  223. package/dist/r~0.js +152 -0
  224. package/dist/shared/components/divider/divider.d.ts +18 -0
  225. package/dist/shared/components/divider/index.d.ts +1 -0
  226. package/dist/shared/components/divider/types.d.ts +35 -0
  227. package/dist/shared/components/drawer/drawer.d.ts +13 -0
  228. package/dist/shared/components/drawer/index.d.ts +1 -0
  229. package/dist/shared/components/overlay/types.d.ts +7 -0
  230. package/dist/shared/components/{tooltip/use-tooltip-position.d.ts → overlay/use-overlay-position.d.ts} +6 -6
  231. package/dist/shared/components/popover/index.d.ts +1 -0
  232. package/dist/shared/components/popover/popover.d.ts +23 -0
  233. package/dist/shared/components/popover/types.d.ts +50 -0
  234. package/dist/shared/components/resizable/clamp.d.ts +13 -0
  235. package/dist/shared/components/resizable/index.d.ts +2 -0
  236. package/dist/shared/components/resizable/resizable-handle.d.ts +25 -0
  237. package/dist/shared/components/resizable/types.d.ts +48 -0
  238. package/dist/shared/components/tooltip/types.d.ts +5 -5
  239. package/dist/shared/components/tooltip/use-portal-theme.d.ts +3 -0
  240. package/dist/shared/locale.d.ts +6 -0
  241. package/dist/style.css +27753 -7176
  242. package/dist/u~0.js +75 -58
  243. package/dist/viking-bot-composer~0.js +434 -77
  244. package/dist/viking-bot-interaction~0.js +11 -11
  245. package/package.json +18 -4
  246. package/dist/components/file-tree/file-tree-tooltip.d.ts +0 -17
  247. package/dist/components/tui/tui-labels-zh.d.ts +0 -2
  248. package/dist/g~0.js +0 -1207
  249. package/dist/modules/file-browser/file-browser-toolbar-button.d.ts +0 -10
package/dist/3c~0.js ADDED
@@ -0,0 +1,2206 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Children, createContext, isValidElement, useCallback, useContext, useEffect, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
3
+ import react_markdown, { defaultUrlTransform } from "react-markdown";
4
+ import remark_gfm from "remark-gfm";
5
+ import { ArrowRightIcon } from "./k~0.js";
6
+ import { resolveLocale } from "./nx~0.js";
7
+ import { checkreact } from "./0~0.js";
8
+ import { Tooltip } from "./r~0.js";
9
+ function getTuiCommandInputText(command) {
10
+ return command.inputText?.trim() || command.name;
11
+ }
12
+ function matchTuiCommandInput(value, commands) {
13
+ const content = value.trimStart();
14
+ const leadingWhitespace = value.slice(0, value.length - content.length);
15
+ const matches = commands.flatMap((command)=>{
16
+ const names = [
17
+ command.name,
18
+ ...command.aliases ?? []
19
+ ];
20
+ return [
21
+ getTuiCommandInputText(command),
22
+ ...names,
23
+ ...names.map((name)=>`/${name}`)
24
+ ].flatMap((prefix)=>{
25
+ const words = prefix.trim().split(/[ \t]+/);
26
+ const pattern = words.map((word)=>word.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')).join('[ \t]+');
27
+ const match = pattern && new RegExp(`^${pattern}(?=$|\\s)`, 'i').exec(content);
28
+ return match ? [
29
+ {
30
+ command,
31
+ leadingWhitespace,
32
+ prefix: match[0],
33
+ rest: content.slice(match[0].length)
34
+ }
35
+ ] : [];
36
+ });
37
+ });
38
+ return matches.sort((left, right)=>right.prefix.length - left.prefix.length)[0];
39
+ }
40
+ function formatTuiCommandInput(value, commands) {
41
+ const match = matchTuiCommandInput(value, commands);
42
+ return match ? `${match.leadingWhitespace}${getTuiCommandInputText(match.command)}${match.rest}` : value;
43
+ }
44
+ function getTuiArgumentHints(command) {
45
+ const params = command.params ?? [];
46
+ const positional = params.filter((param)=>!param.label.startsWith('-'));
47
+ if (positional.length) return positional;
48
+ return [
49
+ ...params.filter((param)=>param.required),
50
+ ...(command.options ?? []).filter((option)=>option.required).map((option)=>({
51
+ label: option.token,
52
+ description: option.description
53
+ }))
54
+ ];
55
+ }
56
+ function TuiParamHint({ command, labels, onPick }) {
57
+ const examples = command.examples?.map((example)=>'string' == typeof example ? {
58
+ value: example,
59
+ label: example
60
+ } : example);
61
+ const params = [
62
+ ...(command.params ?? []).map((param)=>({
63
+ name: param.label,
64
+ description: param.description,
65
+ required: param.required ?? false,
66
+ defaultValue: param.defaultValue
67
+ })),
68
+ ...(command.options ?? []).map((option)=>({
69
+ name: option.token,
70
+ description: option.description,
71
+ required: option.required ?? false,
72
+ defaultValue: option.defaultValue
73
+ }))
74
+ ];
75
+ return /*#__PURE__*/ jsxs("div", {
76
+ className: "ov-tui__hint",
77
+ children: [
78
+ /*#__PURE__*/ jsxs("div", {
79
+ className: "ov-tui__hint-head",
80
+ children: [
81
+ /*#__PURE__*/ jsxs("code", {
82
+ className: "ov-tui__hint-name",
83
+ children: [
84
+ "/",
85
+ command.name
86
+ ]
87
+ }),
88
+ /*#__PURE__*/ jsx("span", {
89
+ className: "ov-tui__hint-desc",
90
+ children: command.description
91
+ })
92
+ ]
93
+ }),
94
+ examples?.length ? /*#__PURE__*/ jsxs("div", {
95
+ className: "ov-tui__hint-group",
96
+ children: [
97
+ /*#__PURE__*/ jsx("div", {
98
+ className: "ov-tui__hint-label",
99
+ children: labels.examples
100
+ }),
101
+ examples.map((example, index)=>/*#__PURE__*/ jsxs("button", {
102
+ type: "button",
103
+ className: "ov-tui__hint-example",
104
+ onMouseDown: (event)=>event.preventDefault(),
105
+ onClick: ()=>onPick(example.value),
106
+ children: [
107
+ /*#__PURE__*/ jsx("span", {
108
+ className: "ov-tui__hint-example-index",
109
+ "aria-hidden": "true",
110
+ children: index + 1
111
+ }),
112
+ /*#__PURE__*/ jsx("span", {
113
+ children: example.label ?? example.value
114
+ })
115
+ ]
116
+ }, example.value))
117
+ ]
118
+ }) : null,
119
+ /*#__PURE__*/ jsxs("div", {
120
+ className: "ov-tui__hint-group",
121
+ children: [
122
+ /*#__PURE__*/ jsx("div", {
123
+ className: "ov-tui__hint-section-title",
124
+ children: labels.parameters
125
+ }),
126
+ /*#__PURE__*/ jsx("code", {
127
+ className: "ov-tui__hint-usage",
128
+ children: command.usage
129
+ }),
130
+ params.length ? /*#__PURE__*/ jsx("div", {
131
+ className: "ov-tui__hint-table-frame",
132
+ children: /*#__PURE__*/ jsxs("table", {
133
+ className: "ov-tui__hint-table",
134
+ children: [
135
+ /*#__PURE__*/ jsx("thead", {
136
+ children: /*#__PURE__*/ jsxs("tr", {
137
+ children: [
138
+ /*#__PURE__*/ jsx("th", {
139
+ children: labels.parameter
140
+ }),
141
+ /*#__PURE__*/ jsx("th", {
142
+ children: labels.required
143
+ }),
144
+ /*#__PURE__*/ jsx("th", {
145
+ children: labels.description
146
+ }),
147
+ /*#__PURE__*/ jsx("th", {
148
+ children: labels.defaultValue
149
+ })
150
+ ]
151
+ })
152
+ }),
153
+ /*#__PURE__*/ jsx("tbody", {
154
+ children: params.map((param)=>/*#__PURE__*/ jsxs("tr", {
155
+ children: [
156
+ /*#__PURE__*/ jsx("td", {
157
+ children: /*#__PURE__*/ jsx("code", {
158
+ children: param.name
159
+ })
160
+ }),
161
+ /*#__PURE__*/ jsx("td", {
162
+ children: param.required ? labels.yes : labels.no
163
+ }),
164
+ /*#__PURE__*/ jsx("td", {
165
+ children: param.description
166
+ }),
167
+ /*#__PURE__*/ jsx("td", {
168
+ children: param.defaultValue ?? '—'
169
+ })
170
+ ]
171
+ }, param.name))
172
+ })
173
+ ]
174
+ })
175
+ }) : /*#__PURE__*/ jsx("div", {
176
+ className: "ov-tui__hint-empty",
177
+ children: labels.noParameters
178
+ })
179
+ ]
180
+ })
181
+ ]
182
+ });
183
+ }
184
+ function useTuiAssistPosition(anchorRef, open, onDismiss) {
185
+ const panelRef = useRef(null);
186
+ const anchorName = `--ov-tui-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
187
+ useEffect(()=>{
188
+ const panel = panelRef.current;
189
+ const anchor = anchorRef.current;
190
+ if (!open || !panel || !anchor) return;
191
+ const dismiss = ()=>onDismiss(anchor.querySelector('textarea')?.value ?? '');
192
+ const outside = (event)=>{
193
+ if (event.target instanceof Node && !panel.contains(event.target) && !anchor.contains(event.target)) dismiss();
194
+ };
195
+ const escape = (event)=>{
196
+ if (event.isComposing || 229 === event.keyCode) return;
197
+ if ('Escape' === event.key && (anchor.contains(document.activeElement) || panel.contains(document.activeElement))) {
198
+ event.preventDefault();
199
+ dismiss();
200
+ }
201
+ };
202
+ document.addEventListener('pointerdown', outside);
203
+ document.addEventListener('keydown', escape);
204
+ if (!('popover' in HTMLElement.prototype)) {
205
+ panel.removeAttribute('popover');
206
+ panel.dataset.inline = '';
207
+ return ()=>{
208
+ document.removeEventListener('pointerdown', outside);
209
+ document.removeEventListener('keydown', escape);
210
+ };
211
+ }
212
+ const nativeAnchors = CSS.supports('position-area', 'block-start span-inline-end');
213
+ const previousAnchor = anchor.style.getPropertyValue('anchor-name');
214
+ anchor.style.setProperty('anchor-name', anchorName);
215
+ panel.style.setProperty('position-anchor', anchorName);
216
+ panel.dataset.floating = '';
217
+ const place = ()=>{
218
+ const rect = anchor.getBoundingClientRect();
219
+ const above = Math.max(0, rect.top - 20);
220
+ const below = Math.max(0, window.innerHeight - rect.bottom - 20);
221
+ const onTop = above >= 160 || above >= below;
222
+ const available = Math.max(80, onTop ? above : below);
223
+ const width = Math.min(rect.width, window.innerWidth - 24);
224
+ const left = Math.max(12, Math.min(rect.left, window.innerWidth - width - 12));
225
+ panel.style.width = `${width}px`;
226
+ panel.style.setProperty('--ov-ui-tui-assist-height', `${Math.min(420, available)}px`);
227
+ const right = window.innerWidth - left - width;
228
+ panel.dataset.side = left >= 334 ? 'left' : right >= 334 ? 'right' : 'stack';
229
+ panel.style.setProperty('--ov-ui-tui-assist-detail-width', `${Math.min(400, (left >= 334 ? left : right) - 14)}px`);
230
+ panel.dataset.placement = onTop ? 'above' : 'below';
231
+ if (nativeAnchors) panel.style.setProperty('position-area', `${onTop ? 'block-start' : 'block-end'} span-inline-end`);
232
+ else {
233
+ panel.style.left = `${left}px`;
234
+ panel.style.top = onTop ? 'auto' : `${rect.bottom + 8}px`;
235
+ panel.style.bottom = onTop ? `${window.innerHeight - rect.top + 8}px` : 'auto';
236
+ }
237
+ };
238
+ place();
239
+ panel.showPopover();
240
+ const observer = new ResizeObserver(place);
241
+ observer.observe(anchor);
242
+ observer.observe(panel);
243
+ window.addEventListener('resize', place);
244
+ window.addEventListener('scroll', place, true);
245
+ return ()=>{
246
+ observer.disconnect();
247
+ window.removeEventListener('resize', place);
248
+ window.removeEventListener('scroll', place, true);
249
+ document.removeEventListener('pointerdown', outside);
250
+ document.removeEventListener('keydown', escape);
251
+ anchor.style.setProperty('anchor-name', previousAnchor);
252
+ if (panel.matches(':popover-open')) panel.hidePopover();
253
+ };
254
+ }, [
255
+ anchorRef,
256
+ anchorName,
257
+ open,
258
+ onDismiss
259
+ ]);
260
+ return panelRef;
261
+ }
262
+ function Highlighted({ text, keyword }) {
263
+ const normalized = keyword.trim().toLowerCase();
264
+ const index = normalized ? text.toLowerCase().indexOf(normalized) : -1;
265
+ if (index < 0) return /*#__PURE__*/ jsx(Fragment, {
266
+ children: text
267
+ });
268
+ return /*#__PURE__*/ jsxs(Fragment, {
269
+ children: [
270
+ text.slice(0, index),
271
+ /*#__PURE__*/ jsx("mark", {
272
+ className: "ov-tui__mark",
273
+ children: text.slice(index, index + normalized.length)
274
+ }),
275
+ text.slice(index + normalized.length)
276
+ ]
277
+ });
278
+ }
279
+ function TuiAssist({ anchorRef, assistId, labels, completion, activeIndex, onActiveIndexChange, onPick, onDismiss }) {
280
+ const options = completion.options;
281
+ const keyword = completion.query.keyword;
282
+ const selected = options[activeIndex];
283
+ const command = selected;
284
+ const open = completion.showSuggestions;
285
+ const panelRef = useTuiAssistPosition(anchorRef, open, onDismiss);
286
+ const listRef = useRef(null);
287
+ useEffect(()=>{
288
+ const list = listRef.current;
289
+ const option = list?.querySelector('[aria-selected="true"]');
290
+ if (!list || !option) return;
291
+ const listBox = list.getBoundingClientRect();
292
+ const optionBox = option.getBoundingClientRect();
293
+ if (optionBox.top < listBox.top) list.scrollTop -= listBox.top - optionBox.top;
294
+ if (optionBox.bottom > listBox.bottom) list.scrollTop += optionBox.bottom - listBox.bottom;
295
+ }, [
296
+ activeIndex,
297
+ options
298
+ ]);
299
+ if (!open) return null;
300
+ return /*#__PURE__*/ jsxs("div", {
301
+ ref: panelRef,
302
+ className: "ov-tui__assist",
303
+ popover: "manual",
304
+ "data-details-only": !options.length || void 0,
305
+ children: [
306
+ command ? /*#__PURE__*/ jsx("div", {
307
+ className: "ov-tui__assist-detail",
308
+ children: /*#__PURE__*/ jsx(TuiParamHint, {
309
+ command: command,
310
+ labels: labels,
311
+ onPick: onPick
312
+ })
313
+ }) : null,
314
+ options.length ? /*#__PURE__*/ jsx("div", {
315
+ className: "ov-tui__suggestions",
316
+ ref: listRef,
317
+ role: "listbox",
318
+ id: assistId,
319
+ "aria-label": labels.suggestions,
320
+ children: completion.suggestions.map((section)=>/*#__PURE__*/ jsxs("div", {
321
+ className: "ov-tui__suggestion-group",
322
+ children: [
323
+ /*#__PURE__*/ jsx("div", {
324
+ className: "ov-tui__suggestion-label",
325
+ children: section.group.label
326
+ }),
327
+ section.commands.map((item)=>{
328
+ const index = options.indexOf(item);
329
+ return /*#__PURE__*/ jsxs("button", {
330
+ id: `${assistId}-${index}`,
331
+ type: "button",
332
+ role: "option",
333
+ "aria-selected": item === selected,
334
+ className: "ov-tui__suggestion",
335
+ onMouseEnter: ()=>onActiveIndexChange(index),
336
+ onFocus: ()=>onActiveIndexChange(index),
337
+ onMouseDown: (event)=>event.preventDefault(),
338
+ onClick: ()=>onPick(`${getTuiCommandInputText(item)} `),
339
+ children: [
340
+ /*#__PURE__*/ jsx("code", {
341
+ className: "ov-tui__suggestion-name",
342
+ children: /*#__PURE__*/ jsx(Highlighted, {
343
+ text: item.name,
344
+ keyword: keyword
345
+ })
346
+ }),
347
+ /*#__PURE__*/ jsx("span", {
348
+ className: "ov-tui__suggestion-desc",
349
+ title: item.summary ?? item.description,
350
+ children: /*#__PURE__*/ jsx(Highlighted, {
351
+ text: item.summary ?? item.description,
352
+ keyword: keyword
353
+ })
354
+ })
355
+ ]
356
+ }, item.name);
357
+ })
358
+ ]
359
+ }, section.group.key))
360
+ }) : command ? null : /*#__PURE__*/ jsx("div", {
361
+ className: "ov-tui__no-suggestions",
362
+ role: "status",
363
+ children: labels.noSuggestions
364
+ })
365
+ ]
366
+ });
367
+ }
368
+ const LEADING_SLASH = /^\s*\//;
369
+ const COMMAND_NAME = /^([^\s]*)([\s\S]*)$/;
370
+ function parseTuiCommandInput(value) {
371
+ if (!LEADING_SLASH.test(value)) return null;
372
+ const body = value.replace(LEADING_SLASH, '');
373
+ const matched = COMMAND_NAME.exec(body);
374
+ if (!matched) return null;
375
+ const name = matched[1] ?? '';
376
+ const rest = matched[2] ?? '';
377
+ return {
378
+ name,
379
+ rest,
380
+ hasTrailingSpace: /^\s/.test(rest)
381
+ };
382
+ }
383
+ function resolveTuiSkeleton(command) {
384
+ return command?.skeleton ?? 'generic';
385
+ }
386
+ function findTuiCommand(text, commands) {
387
+ return matchTuiCommandInput(text, commands)?.command;
388
+ }
389
+ function filterTuiCommands(keyword, commands) {
390
+ const normalized = keyword.trim().toLowerCase();
391
+ if (!normalized) return commands;
392
+ return commands.filter((command)=>command.name.toLowerCase().includes(normalized) || (command.summary ?? command.description).toLowerCase().includes(normalized) || command.aliases?.some((alias)=>alias.toLowerCase().includes(normalized)));
393
+ }
394
+ function groupTuiCommands(commands, groups = []) {
395
+ const known = new Map(groups.map((group)=>[
396
+ group.key,
397
+ group
398
+ ]));
399
+ for (const command of commands){
400
+ const key = command.group ?? '';
401
+ if (!known.has(key)) known.set(key, {
402
+ key,
403
+ label: key
404
+ });
405
+ }
406
+ return Array.from(known.values(), (group)=>({
407
+ group,
408
+ commands: commands.filter((command)=>(command.group ?? '') === group.key)
409
+ })).filter((section)=>section.commands.length > 0);
410
+ }
411
+ const EMPTY_QUERY = {
412
+ keyword: '',
413
+ scope: null,
414
+ matches: [],
415
+ automatic: false,
416
+ canOpenPalette: false,
417
+ colorInput: false
418
+ };
419
+ const normalize = (text)=>text.replace(/[ \t]+/g, ' ');
420
+ function getTuiCommandQuery(value, commands) {
421
+ if (!commands.length || /[\r\n]/.test(value)) return EMPTY_QUERY;
422
+ const slash = parseTuiCommandInput(value);
423
+ const content = normalize(value.trimStart().slice(slash ? 1 : 0));
424
+ if (!slash && !content) return EMPTY_QUERY;
425
+ const boundary = content.lastIndexOf(' ') + 1;
426
+ const head = content.slice(0, boundary);
427
+ const keyword = content.slice(boundary);
428
+ const entries = commands.flatMap((command)=>(slash ? [
429
+ command.name,
430
+ ...command.aliases ?? []
431
+ ] : [
432
+ getTuiCommandInputText(command)
433
+ ]).map((text)=>({
434
+ command,
435
+ text: normalize(text)
436
+ })));
437
+ const definitions = (items)=>[
438
+ ...new Set(items.map((entry)=>entry.command))
439
+ ];
440
+ const scoped = entries.filter((entry)=>entry.text.toLowerCase().startsWith(head.toLowerCase()));
441
+ if (!scoped.length) return EMPTY_QUERY;
442
+ const matching = scoped.filter((entry)=>entry.text.toLowerCase().startsWith(content.toLowerCase()));
443
+ const input = matchTuiCommandInput(value, commands);
444
+ if (input && (!slash || input.rest) && !matching.some((entry)=>entry.text.length > content.trimEnd().length)) return EMPTY_QUERY;
445
+ const base = {
446
+ ...EMPTY_QUERY,
447
+ keyword,
448
+ scope: slash ? '/' : head.trimEnd(),
449
+ automatic: Boolean(slash)
450
+ };
451
+ if (slash) return {
452
+ ...base,
453
+ matches: head ? matching.length ? definitions(matching) : filterTuiCommands(keyword, definitions(scoped)) : filterTuiCommands(keyword, commands)
454
+ };
455
+ if (!keyword) return {
456
+ ...base,
457
+ matches: matching.map((entry)=>entry.command),
458
+ canOpenPalette: matching.length > 0,
459
+ colorInput: matching.length > 0
460
+ };
461
+ const words = content.split(' ').length;
462
+ if (matching.length && matching.every((entry)=>entry.text.split(' ').length > words)) {
463
+ const targets = [
464
+ ...new Set(matching.map((entry)=>entry.text.split(' ').slice(0, words).join(' ')))
465
+ ];
466
+ const target = 1 === targets.length ? targets[0] : void 0;
467
+ return {
468
+ ...base,
469
+ matches: matching.map((entry)=>entry.command),
470
+ colorInput: true,
471
+ prefixTarget: target,
472
+ canOpenPalette: !target || target.toLowerCase() === content.toLowerCase()
473
+ };
474
+ }
475
+ return {
476
+ ...base,
477
+ matches: matching.length ? matching.map((entry)=>entry.command) : filterTuiCommands(keyword, scoped.map((entry)=>entry.command)),
478
+ colorInput: matching.length > 0
479
+ };
480
+ }
481
+ function getTuiInlineCompletion(value, query, selected, paletteOpen = false) {
482
+ const leading = value.slice(0, value.length - value.trimStart().length);
483
+ const content = normalize(value.trimStart());
484
+ if (query.prefixTarget) {
485
+ const suffix = query.prefixTarget.slice(content.length);
486
+ return suffix ? {
487
+ kind: 'prefix',
488
+ suffix,
489
+ value: `${leading}${query.prefixTarget}`
490
+ } : void 0;
491
+ }
492
+ if (!selected || !query.keyword && (!paletteOpen || '/' === query.scope)) return;
493
+ if ('/' === query.scope) {
494
+ const typed = content.slice(1);
495
+ const name = [
496
+ selected.name,
497
+ ...selected.aliases ?? []
498
+ ].map(normalize).find((name)=>name.toLowerCase().startsWith(typed.toLowerCase()));
499
+ const suffix = name?.slice(typed.length);
500
+ return suffix ? {
501
+ kind: 'command',
502
+ suffix,
503
+ value: `${leading}${getTuiCommandInputText(selected)} `
504
+ } : void 0;
505
+ }
506
+ const text = getTuiCommandInputText(selected);
507
+ const normalized = normalize(text);
508
+ if (!normalized.toLowerCase().startsWith(content.toLowerCase())) return;
509
+ const suffix = normalized.slice(content.length);
510
+ return suffix ? {
511
+ kind: 'command',
512
+ suffix,
513
+ value: `${leading}${text} `
514
+ } : void 0;
515
+ }
516
+ function useTuiComposerKeyboard({ inputRef, value, history, completion, inline, disabled, readOnly, canSubmit, activeIndex, onActiveIndexChange, onValueChange, onSubmit, onDismiss, onRequestPalette }) {
517
+ const historyKey = JSON.stringify(history);
518
+ const historyRef = useMemo(()=>({
519
+ current: {
520
+ historyKey,
521
+ offset: -1,
522
+ draft: '',
523
+ value: ''
524
+ }
525
+ }), [
526
+ historyKey
527
+ ]);
528
+ const change = (next)=>{
529
+ historyRef.current.offset = -1;
530
+ onValueChange?.(next);
531
+ };
532
+ const accept = (next)=>{
533
+ change(next);
534
+ inputRef.current?.focus({
535
+ preventScroll: true
536
+ });
537
+ };
538
+ const handleKeyDown = (event)=>{
539
+ if (event.nativeEvent.isComposing || 229 === event.nativeEvent.keyCode) return;
540
+ const input = event.currentTarget;
541
+ const atEnd = input.selectionStart === input.selectionEnd && input.selectionEnd === value.length;
542
+ if ('Tab' === event.key) {
543
+ if (event.shiftKey || event.ctrlKey || event.altKey || event.metaKey) return;
544
+ event.preventDefault();
545
+ if (!atEnd) return;
546
+ }
547
+ const options = completion.options;
548
+ const listOpen = completion.showSuggestions;
549
+ if ('Escape' === event.key && (inline || listOpen)) {
550
+ event.preventDefault();
551
+ onDismiss(value);
552
+ return;
553
+ }
554
+ if (!disabled && !readOnly) {
555
+ if ('Tab' === event.key && inline?.kind === 'prefix') {
556
+ event.preventDefault();
557
+ accept(inline.value);
558
+ return;
559
+ }
560
+ if (' ' === event.key && atEnd && inline?.kind === 'prefix' && !event.shiftKey && !event.ctrlKey && !event.altKey && !event.metaKey) {
561
+ event.preventDefault();
562
+ accept(`${inline.value} `);
563
+ return;
564
+ }
565
+ if ('Tab' === event.key && completion.query.canOpenPalette && !listOpen) {
566
+ event.preventDefault();
567
+ onRequestPalette();
568
+ return;
569
+ }
570
+ if (listOpen && options.length) {
571
+ if ('ArrowDown' === event.key || 'ArrowUp' === event.key) {
572
+ event.preventDefault();
573
+ const delta = 'ArrowDown' === event.key ? 1 : -1;
574
+ onActiveIndexChange((index)=>index < 0 ? delta > 0 ? 0 : options.length - 1 : (index + delta + options.length) % options.length);
575
+ return;
576
+ }
577
+ const spaceCommand = ' ' === event.key && atEnd ? matchTuiCommandInput(value, options)?.command : void 0;
578
+ if ('Tab' === event.key || 'Enter' === event.key && !event.shiftKey || spaceCommand) {
579
+ event.preventDefault();
580
+ const picked = spaceCommand ?? options[activeIndex];
581
+ if (picked) accept(`${getTuiCommandInputText(picked)} `);
582
+ else if ('Tab' === event.key && inline) accept(inline.value);
583
+ return;
584
+ }
585
+ }
586
+ if ('Tab' === event.key && inline) {
587
+ event.preventDefault();
588
+ accept(inline.value);
589
+ return;
590
+ }
591
+ }
592
+ const previous = historyRef.current;
593
+ const browsing = previous.offset >= 0 && previous.value === value;
594
+ if (!disabled && !readOnly && history.length > 0 && input.selectionStart === input.selectionEnd && !event.shiftKey && ('ArrowUp' === event.key && !value.slice(0, input.selectionStart).includes('\n') || 'ArrowDown' === event.key && browsing && !value.slice(input.selectionEnd).includes('\n'))) {
595
+ event.preventDefault();
596
+ const offset = Math.max(-1, Math.min(history.length - 1, (browsing ? previous.offset : -1) + ('ArrowUp' === event.key ? 1 : -1)));
597
+ const draft = browsing ? previous.draft : value;
598
+ const next = offset < 0 ? draft : history[history.length - 1 - offset];
599
+ historyRef.current = {
600
+ historyKey,
601
+ offset,
602
+ draft,
603
+ value: next
604
+ };
605
+ onValueChange?.(next);
606
+ onDismiss(next);
607
+ inputRef.current?.focus({
608
+ preventScroll: true
609
+ });
610
+ return;
611
+ }
612
+ if ('Enter' === event.key && !event.shiftKey) {
613
+ event.preventDefault();
614
+ if (value.trim() && !disabled && !readOnly && canSubmit) onSubmit?.(value.trim());
615
+ }
616
+ };
617
+ return {
618
+ change,
619
+ handleKeyDown
620
+ };
621
+ }
622
+ const TUI_URI_PATTERN = /viking:\/\/[^\s"'<>`]+/g;
623
+ const TUI_PROSE_URI_PATTERN = /viking:\/\/[^\s,,。;;、"'<>()[\]]+/g;
624
+ function getTuiSafeHref(uri) {
625
+ const href = uri?.trim();
626
+ return href && /^(?:viking|https?):\/\/[^\s]+$/i.test(href) ? href : void 0;
627
+ }
628
+ async function copyTuiText(text) {
629
+ if ("u" < typeof navigator) return false;
630
+ try {
631
+ if (navigator.clipboard?.writeText) {
632
+ await navigator.clipboard.writeText(text);
633
+ return true;
634
+ }
635
+ } catch {}
636
+ return false;
637
+ }
638
+ function formatTuiJson(text) {
639
+ const trimmed = text.trim();
640
+ if (!trimmed || !/^[[{]/.test(trimmed)) return text;
641
+ try {
642
+ JSON.parse(trimmed);
643
+ } catch {
644
+ return text;
645
+ }
646
+ const tokens = trimmed.match(/"(?:\\.|[^"\\])*"|[^\s]/g) ?? [];
647
+ let depth = 0;
648
+ let output = '';
649
+ const newline = ()=>`\n${' '.repeat(depth)}`;
650
+ for (const [index, token] of tokens.entries())if ('{' === token || '[' === token) {
651
+ output += token;
652
+ depth++;
653
+ if ('}' !== tokens[index + 1] && ']' !== tokens[index + 1]) output += newline();
654
+ } else if ('}' === token || ']' === token) {
655
+ depth--;
656
+ if ('{' !== tokens[index - 1] && '[' !== tokens[index - 1]) output += newline();
657
+ output += token;
658
+ } else if (',' === token) output += `,${newline()}`;
659
+ else if (':' === token) output += ': ';
660
+ else output += token;
661
+ return output;
662
+ }
663
+ function TuiUriLink({ uri, children, onOpenUri, editor = false, className = 'ov-tui__link' }) {
664
+ const href = getTuiSafeHref(uri);
665
+ if (!href) return /*#__PURE__*/ jsx(Fragment, {
666
+ children: children
667
+ });
668
+ return /*#__PURE__*/ jsx("a", {
669
+ href: href,
670
+ className: className,
671
+ onMouseDown: editor ? (event)=>event.preventDefault() : void 0,
672
+ onClick: onOpenUri ? (event)=>{
673
+ event.preventDefault();
674
+ onOpenUri(href);
675
+ } : void 0,
676
+ children: children
677
+ });
678
+ }
679
+ function TuiUriText({ text, onOpenUri, editor = false, mode }) {
680
+ const parts = [];
681
+ let cursor = 0;
682
+ const pattern = new RegExp(('prose' === mode ? TUI_PROSE_URI_PATTERN : TUI_URI_PATTERN).source, 'gi');
683
+ const plain = (value, key)=>editor ? /*#__PURE__*/ jsx("span", {
684
+ "aria-hidden": "true",
685
+ children: value
686
+ }, key) : value;
687
+ for (const matched of text.matchAll(pattern)){
688
+ const index = matched.index ?? 0;
689
+ const uri = 'prose' === mode ? matched[0].replace(/[.!?;;::!?]+$/u, '') : matched[0];
690
+ if (index > cursor) parts.push(plain(text.slice(cursor, index), cursor));
691
+ parts.push(/*#__PURE__*/ jsx(TuiUriLink, {
692
+ uri: uri,
693
+ onOpenUri: onOpenUri,
694
+ editor: editor,
695
+ children: uri
696
+ }, `${index}-${uri}`));
697
+ cursor = index + uri.length;
698
+ }
699
+ if (!parts.length) return /*#__PURE__*/ jsx(Fragment, {
700
+ children: plain(text, 0)
701
+ });
702
+ if (cursor < text.length) parts.push(plain(text.slice(cursor), cursor));
703
+ return /*#__PURE__*/ jsx(Fragment, {
704
+ children: parts
705
+ });
706
+ }
707
+ function TuiCommandText({ text, name, namespaceOnly = false }) {
708
+ const namedStart = name ? text.length - name.length : -1;
709
+ const matchesName = namedStart >= 0 && text.slice(namedStart).toLowerCase() === name?.toLowerCase() && (0 === namedStart || /\s/.test(text[namedStart - 1]));
710
+ const lastToken = text.search(/\S+$/);
711
+ const start = namespaceOnly ? text.length : matchesName ? namedStart : lastToken < 0 ? text.length : lastToken;
712
+ return /*#__PURE__*/ jsxs(Fragment, {
713
+ children: [
714
+ start > 0 ? /*#__PURE__*/ jsx("span", {
715
+ className: "ov-tui__command-prefix",
716
+ children: text.slice(0, start)
717
+ }) : null,
718
+ start < text.length ? /*#__PURE__*/ jsx("span", {
719
+ className: "ov-tui__command-name",
720
+ children: text.slice(start)
721
+ }) : null
722
+ ]
723
+ });
724
+ }
725
+ function TuiInputMirror({ value, input, inline, colorInput, onOpenUri, onScroll, mirrorRef, hintId }) {
726
+ const hints = input && !input.rest.trim() ? getTuiArgumentHints(input.command) : [];
727
+ return /*#__PURE__*/ jsxs(Fragment, {
728
+ children: [
729
+ /*#__PURE__*/ jsxs("span", {
730
+ className: "ov-tui__input-mirror",
731
+ ref: mirrorRef,
732
+ onScroll: onScroll,
733
+ children: [
734
+ input ? /*#__PURE__*/ jsxs(Fragment, {
735
+ children: [
736
+ input.leadingWhitespace,
737
+ /*#__PURE__*/ jsx("span", {
738
+ "aria-hidden": "true",
739
+ children: /*#__PURE__*/ jsx("span", {
740
+ className: "ov-tui__input-command",
741
+ children: /*#__PURE__*/ jsx(TuiCommandText, {
742
+ text: input.prefix,
743
+ name: input.command.name
744
+ })
745
+ })
746
+ }),
747
+ /*#__PURE__*/ jsx(TuiUriText, {
748
+ text: input.rest,
749
+ mode: "literal",
750
+ onOpenUri: onOpenUri,
751
+ editor: true
752
+ })
753
+ ]
754
+ }) : colorInput ? /*#__PURE__*/ jsx("span", {
755
+ className: "ov-tui__input-command",
756
+ "aria-hidden": "true",
757
+ children: /*#__PURE__*/ jsx(TuiCommandText, {
758
+ text: value,
759
+ namespaceOnly: inline?.kind !== 'command'
760
+ })
761
+ }) : /*#__PURE__*/ jsx(TuiUriText, {
762
+ text: value,
763
+ mode: "literal",
764
+ onOpenUri: onOpenUri,
765
+ editor: true
766
+ }),
767
+ /*#__PURE__*/ jsxs("span", {
768
+ "aria-hidden": "true",
769
+ children: [
770
+ inline ? /*#__PURE__*/ jsx("span", {
771
+ className: "ov-tui__input-completion",
772
+ children: inline.suffix
773
+ }) : null,
774
+ hints.length ? /*#__PURE__*/ jsxs("span", {
775
+ className: "ov-tui__input-arguments",
776
+ children: [
777
+ input?.rest.endsWith(' ') ? '' : ' ',
778
+ hints.map((hint)=>hint.label).join(' ')
779
+ ]
780
+ }) : null,
781
+ value.endsWith('\n') ? '\u200b' : null
782
+ ]
783
+ })
784
+ ]
785
+ }),
786
+ /*#__PURE__*/ jsxs("span", {
787
+ id: hintId,
788
+ className: "ov-tui__input-hint-description",
789
+ "aria-live": inline?.kind === 'prefix' ? 'polite' : void 0,
790
+ children: [
791
+ inline?.value,
792
+ hints.map((hint)=>`${hint.label}: ${hint.description}`).join('; ')
793
+ ]
794
+ })
795
+ ]
796
+ });
797
+ }
798
+ function TuiComposer({ anchorRef, assistId, onFocus, onDismiss, onRequestPalette, value, history, labels, completion, disabled, readOnly, canSubmit, activeIndex, onActiveIndexChange, onValueChange, onSubmit, onOpenUri }) {
799
+ const inputRef = useRef(null);
800
+ const inputId = useId();
801
+ const mirrorRef = useRef(null);
802
+ const showSuggestions = completion.showSuggestions && completion.options.length > 0;
803
+ const preview = completion.options[activeIndex] ?? (completion.query.keyword ? completion.options[0] : void 0);
804
+ const inline = completion.enabled ? getTuiInlineCompletion(value, completion.query, preview, completion.showSuggestions) : void 0;
805
+ const keyboard = useTuiComposerKeyboard({
806
+ inputRef,
807
+ value,
808
+ history,
809
+ completion,
810
+ inline,
811
+ disabled,
812
+ readOnly,
813
+ canSubmit,
814
+ activeIndex,
815
+ onActiveIndexChange,
816
+ onValueChange,
817
+ onSubmit,
818
+ onDismiss,
819
+ onRequestPalette
820
+ });
821
+ return /*#__PURE__*/ jsxs("div", {
822
+ ref: anchorRef,
823
+ className: "ov-tui__composer",
824
+ "data-disabled": disabled || void 0,
825
+ children: [
826
+ /*#__PURE__*/ jsxs("div", {
827
+ className: "ov-tui__input-row",
828
+ "data-value": `${value}\n`,
829
+ children: [
830
+ /*#__PURE__*/ jsx("label", {
831
+ className: "ov-tui__input-label",
832
+ htmlFor: inputId,
833
+ children: labels.placeholder
834
+ }),
835
+ /*#__PURE__*/ jsx(TuiInputMirror, {
836
+ value: value,
837
+ input: completion.activeInput,
838
+ inline: inline,
839
+ colorInput: completion.query.colorInput,
840
+ onOpenUri: onOpenUri,
841
+ onScroll: (event)=>{
842
+ if (inputRef.current) {
843
+ inputRef.current.scrollTop = event.currentTarget.scrollTop;
844
+ inputRef.current.scrollLeft = event.currentTarget.scrollLeft;
845
+ }
846
+ },
847
+ mirrorRef: mirrorRef,
848
+ hintId: `${inputId}-hint`
849
+ }),
850
+ /*#__PURE__*/ jsx("textarea", {
851
+ id: inputId,
852
+ name: "command",
853
+ ref: inputRef,
854
+ className: "ov-tui__input",
855
+ rows: 1,
856
+ value: value,
857
+ placeholder: labels.placeholder,
858
+ readOnly: readOnly,
859
+ disabled: disabled,
860
+ autoCapitalize: "off",
861
+ autoCorrect: "off",
862
+ spellCheck: false,
863
+ enterKeyHint: "send",
864
+ onFocus: onFocus,
865
+ "aria-describedby": `${inputId}-shortcuts ${inputId}-hint`,
866
+ "aria-autocomplete": inline ? 'both' : 'list',
867
+ "aria-haspopup": "listbox",
868
+ "aria-controls": showSuggestions ? assistId : void 0,
869
+ "aria-activedescendant": showSuggestions && activeIndex >= 0 ? `${assistId}-${activeIndex}` : void 0,
870
+ onChange: (event)=>keyboard.change(event.target.value),
871
+ onScroll: (event)=>{
872
+ if (mirrorRef.current) {
873
+ mirrorRef.current.scrollTop = event.currentTarget.scrollTop;
874
+ mirrorRef.current.scrollLeft = event.currentTarget.scrollLeft;
875
+ }
876
+ },
877
+ onKeyDown: keyboard.handleKeyDown
878
+ })
879
+ ]
880
+ }),
881
+ /*#__PURE__*/ jsxs("div", {
882
+ className: "ov-tui__shortcuts",
883
+ id: `${inputId}-shortcuts`,
884
+ children: [
885
+ /*#__PURE__*/ jsxs("span", {
886
+ className: "ov-tui__shortcut",
887
+ children: [
888
+ /*#__PURE__*/ jsx("kbd", {
889
+ children: "/"
890
+ }),
891
+ labels.allCommands
892
+ ]
893
+ }),
894
+ /*#__PURE__*/ jsxs("span", {
895
+ className: "ov-tui__shortcut",
896
+ children: [
897
+ /*#__PURE__*/ jsx("kbd", {
898
+ children: "↑"
899
+ }),
900
+ labels.historyCommands
901
+ ]
902
+ }),
903
+ /*#__PURE__*/ jsxs("span", {
904
+ className: "ov-tui__shortcut",
905
+ children: [
906
+ /*#__PURE__*/ jsx("kbd", {
907
+ children: "↵"
908
+ }),
909
+ labels.send
910
+ ]
911
+ })
912
+ ]
913
+ }),
914
+ disabled ? /*#__PURE__*/ jsx("div", {
915
+ className: "ov-tui__unavailable",
916
+ role: "status",
917
+ children: labels.unavailableMessage
918
+ }) : null
919
+ ]
920
+ });
921
+ }
922
+ function pickTuiCommands(names = [], commands) {
923
+ const byName = new Map(commands.map((command)=>[
924
+ command.name,
925
+ command
926
+ ]));
927
+ return [
928
+ ...new Set(names)
929
+ ].flatMap((name)=>byName.get(name) ?? []);
930
+ }
931
+ function TuiEmptyRegion({ emptyState, commands, labels, disabled, onPick }) {
932
+ if (void 0 !== emptyState) return null === emptyState ? null : /*#__PURE__*/ jsx("div", {
933
+ className: "ov-tui__empty",
934
+ children: emptyState
935
+ });
936
+ if (!commands.length) return null;
937
+ return /*#__PURE__*/ jsxs("div", {
938
+ className: "ov-tui__empty ov-tui__empty--hero",
939
+ children: [
940
+ /*#__PURE__*/ jsx("h3", {
941
+ className: "ov-tui__empty-title",
942
+ children: labels.emptyTitle
943
+ }),
944
+ /*#__PURE__*/ jsx("p", {
945
+ className: "ov-tui__empty-subtitle",
946
+ children: labels.emptyDescription
947
+ }),
948
+ /*#__PURE__*/ jsx("p", {
949
+ className: "ov-tui__empty-quick-label",
950
+ children: labels.quickStart
951
+ }),
952
+ /*#__PURE__*/ jsx("ul", {
953
+ className: "ov-tui__empty-list",
954
+ children: commands.map((command)=>/*#__PURE__*/ jsx("li", {
955
+ className: "ov-tui__empty-item",
956
+ children: /*#__PURE__*/ jsxs("button", {
957
+ type: "button",
958
+ className: "ov-tui__empty-action",
959
+ disabled: disabled,
960
+ onClick: ()=>onPick(command),
961
+ children: [
962
+ /*#__PURE__*/ jsx(ArrowRightIcon, {
963
+ width: 14,
964
+ height: 14,
965
+ focusable: "false"
966
+ }),
967
+ /*#__PURE__*/ jsx("span", {
968
+ className: "ov-tui__empty-name",
969
+ children: command.name
970
+ }),
971
+ /*#__PURE__*/ jsx("span", {
972
+ className: "ov-tui__empty-desc",
973
+ children: command.summary ?? command.description
974
+ })
975
+ ]
976
+ })
977
+ }, command.name))
978
+ })
979
+ ]
980
+ });
981
+ }
982
+ const messages = {
983
+ placeholder: '>_ Enter CLI commands, e.g. ov find OpenViking',
984
+ unavailableMessage: 'Commands are unavailable right now.',
985
+ send: 'Send',
986
+ allCommands: 'All commands',
987
+ historyCommands: 'History',
988
+ suggestions: 'Command suggestions',
989
+ noSuggestions: 'No matching commands',
990
+ pending: 'Running',
991
+ success: 'Succeeded',
992
+ error: 'Failed',
993
+ copy: 'Copy',
994
+ copied: 'Copied',
995
+ emptyTitle: 'OpenViking CLI',
996
+ emptyDescription: 'Work directly with your context through the CLI',
997
+ quickStart: 'Quick start:',
998
+ noResult: 'No result returned',
999
+ justNow: 'Just now',
1000
+ formatMinutesAgo: (minutes)=>`${minutes} minute${1 === minutes ? '' : 's'} ago`,
1001
+ formatHoursAgo: (hours)=>`${hours} hour${1 === hours ? '' : 's'} ago`,
1002
+ availableCommands: 'Available commands',
1003
+ helpHint: 'Type / to open the command palette.',
1004
+ parameters: 'Parameters',
1005
+ examples: 'Examples',
1006
+ noParameters: 'No parameters',
1007
+ loadMore: 'Load more',
1008
+ resource: 'Resource',
1009
+ parameter: 'Parameter',
1010
+ required: 'Required',
1011
+ description: "Description",
1012
+ defaultValue: 'Default',
1013
+ yes: 'Yes',
1014
+ no: 'No'
1015
+ };
1016
+ const en_US = messages;
1017
+ const zh_CN_messages = {
1018
+ placeholder: '>_ 输入 CLI 命令,如 ov find OpenViking',
1019
+ unavailableMessage: '当前无法执行命令。',
1020
+ send: '发送',
1021
+ allCommands: '全部指令',
1022
+ historyCommands: '历史指令',
1023
+ suggestions: '命令建议',
1024
+ noSuggestions: '没有匹配的命令',
1025
+ pending: '执行中',
1026
+ success: '执行成功',
1027
+ error: '执行失败',
1028
+ copy: '复制',
1029
+ copied: '复制成功',
1030
+ emptyTitle: 'OpenViking CLI',
1031
+ emptyDescription: 'CLI 直接操作上下文',
1032
+ quickStart: '快速体验:',
1033
+ noResult: '暂无返回结果',
1034
+ justNow: '刚刚',
1035
+ formatMinutesAgo: (minutes)=>`${minutes} 分钟前`,
1036
+ formatHoursAgo: (hours)=>`${hours} 小时前`,
1037
+ availableCommands: '可用命令',
1038
+ helpHint: '输入 / 可打开命令面板。',
1039
+ parameters: '参数详情',
1040
+ examples: '快速体验',
1041
+ noParameters: '此命令不需要参数',
1042
+ loadMore: '加载更多',
1043
+ resource: '资源',
1044
+ parameter: '参数',
1045
+ required: '必填',
1046
+ description: '说明',
1047
+ defaultValue: '默认值',
1048
+ yes: '是',
1049
+ no: '否'
1050
+ };
1051
+ const zh_CN = zh_CN_messages;
1052
+ const LOCALES = {
1053
+ 'en-US': en_US,
1054
+ 'zh-CN': zh_CN
1055
+ };
1056
+ function resolveTuiLabels(labels, locale = 'en-US') {
1057
+ return resolveLocale(LOCALES, locale, labels);
1058
+ }
1059
+ function TuiCommandHelp({ content, onPick, labels }) {
1060
+ return /*#__PURE__*/ jsxs("div", {
1061
+ className: "ov-tui__help",
1062
+ children: [
1063
+ /*#__PURE__*/ jsx("div", {
1064
+ className: "ov-tui__help-lead",
1065
+ children: labels.availableCommands
1066
+ }),
1067
+ content.sections.map((section)=>/*#__PURE__*/ jsxs("section", {
1068
+ className: "ov-tui__help-section",
1069
+ children: [
1070
+ /*#__PURE__*/ jsx("div", {
1071
+ className: "ov-tui__help-section-label",
1072
+ children: section.label
1073
+ }),
1074
+ /*#__PURE__*/ jsx("div", {
1075
+ className: "ov-tui__help-items",
1076
+ children: section.items.map((item)=>/*#__PURE__*/ jsxs("button", {
1077
+ type: "button",
1078
+ className: "ov-tui__help-item",
1079
+ disabled: !onPick,
1080
+ onClick: ()=>onPick?.(item.name),
1081
+ children: [
1082
+ /*#__PURE__*/ jsx("span", {
1083
+ className: "ov-tui__help-name",
1084
+ children: item.name
1085
+ }),
1086
+ item.description ? /*#__PURE__*/ jsx("span", {
1087
+ className: "ov-tui__help-desc",
1088
+ children: item.description
1089
+ }) : null
1090
+ ]
1091
+ }, item.key))
1092
+ })
1093
+ ]
1094
+ }, section.key)),
1095
+ /*#__PURE__*/ jsx("div", {
1096
+ className: "ov-tui__help-footer",
1097
+ children: labels.helpHint
1098
+ })
1099
+ ]
1100
+ });
1101
+ }
1102
+ function formatTuiRecordTime(record, labels, now = Date.now()) {
1103
+ const timestamp = record.createdAtMs;
1104
+ if ('number' != typeof timestamp || !Number.isFinite(timestamp)) return record.createdAt;
1105
+ const date = new Date(timestamp);
1106
+ if (!Number.isFinite(date.getTime())) return record.createdAt;
1107
+ const elapsed = Math.max(0, now - timestamp);
1108
+ if (elapsed < 60000) return labels.justNow;
1109
+ if (elapsed < 3600000) return labels.formatMinutesAgo(Math.floor(elapsed / 60000));
1110
+ if (elapsed < 86400000) return labels.formatHoursAgo(Math.floor(elapsed / 3600000));
1111
+ const pad = (value)=>String(value).padStart(2, '0');
1112
+ return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
1113
+ }
1114
+ const subscribe = ()=>()=>{};
1115
+ const clientSnapshot = ()=>true;
1116
+ const serverSnapshot = ()=>false;
1117
+ function TuiRecordTime({ record, labels }) {
1118
+ const client = useSyncExternalStore(subscribe, clientSnapshot, serverSnapshot);
1119
+ const text = client ? formatTuiRecordTime(record, labels) : record.createdAt;
1120
+ return text ? /*#__PURE__*/ jsx("span", {
1121
+ className: "ov-tui__bubble-time",
1122
+ children: text
1123
+ }) : null;
1124
+ }
1125
+ const SvgCopy = (props)=>/*#__PURE__*/ jsxs("svg", {
1126
+ xmlns: "http://www.w3.org/2000/svg",
1127
+ width: 16,
1128
+ height: 16,
1129
+ fill: "none",
1130
+ viewBox: "0 0 16 16",
1131
+ ...props,
1132
+ children: [
1133
+ /*#__PURE__*/ jsx("rect", {
1134
+ width: 8,
1135
+ height: 8,
1136
+ x: 5.5,
1137
+ y: 5.5,
1138
+ stroke: "currentColor",
1139
+ strokeWidth: 1.2,
1140
+ rx: 1.5
1141
+ }),
1142
+ /*#__PURE__*/ jsx("path", {
1143
+ stroke: "currentColor",
1144
+ strokeLinecap: "round",
1145
+ strokeWidth: 1.2,
1146
+ d: "M10.5 3.5V3A1.5 1.5 0 0 0 9 1.5H3A1.5 1.5 0 0 0 1.5 3v6A1.5 1.5 0 0 0 3 10.5h.5"
1147
+ })
1148
+ ]
1149
+ });
1150
+ const copyreact = SvgCopy;
1151
+ function TuiCopyButton({ text, label, copiedLabel, onCopy, className }) {
1152
+ const [copied, setCopied] = useState(false);
1153
+ const resetTimer = useRef(void 0);
1154
+ useEffect(()=>()=>window.clearTimeout(resetTimer.current), []);
1155
+ const handleCopy = ()=>{
1156
+ copyTuiText(text).then((succeeded)=>{
1157
+ if (!succeeded) return;
1158
+ window.clearTimeout(resetTimer.current);
1159
+ setCopied(true);
1160
+ onCopy?.(text);
1161
+ resetTimer.current = window.setTimeout(()=>setCopied(false), 1500);
1162
+ });
1163
+ };
1164
+ return /*#__PURE__*/ jsx(Tooltip, {
1165
+ content: copied ? copiedLabel : label,
1166
+ children: /*#__PURE__*/ jsx("button", {
1167
+ type: "button",
1168
+ className: [
1169
+ 'ov-tui__copy',
1170
+ className
1171
+ ].filter(Boolean).join(' '),
1172
+ "aria-label": copied ? copiedLabel : label,
1173
+ onClick: handleCopy,
1174
+ children: copied ? /*#__PURE__*/ jsx(checkreact, {
1175
+ "aria-hidden": "true",
1176
+ focusable: "false"
1177
+ }) : /*#__PURE__*/ jsx(copyreact, {
1178
+ "aria-hidden": "true",
1179
+ focusable: "false"
1180
+ })
1181
+ })
1182
+ });
1183
+ }
1184
+ function TuiCodeBlock({ text, labels, onCopy, onOpenUri }) {
1185
+ return /*#__PURE__*/ jsxs("div", {
1186
+ className: "ov-tui__code-block",
1187
+ children: [
1188
+ /*#__PURE__*/ jsx(TuiCopyButton, {
1189
+ className: "ov-tui__copy--inline",
1190
+ text: text,
1191
+ label: labels.copy,
1192
+ copiedLabel: labels.copied,
1193
+ onCopy: onCopy
1194
+ }),
1195
+ /*#__PURE__*/ jsx("pre", {
1196
+ className: "ov-tui__code-content",
1197
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1198
+ text: formatTuiJson(text),
1199
+ mode: "literal",
1200
+ onOpenUri: onOpenUri
1201
+ })
1202
+ })
1203
+ ]
1204
+ });
1205
+ }
1206
+ const TuiMarkdownContext = /*#__PURE__*/ createContext(null);
1207
+ const InsideLink = /*#__PURE__*/ createContext(false);
1208
+ function textOf(children) {
1209
+ if ('string' == typeof children || 'number' == typeof children) return String(children);
1210
+ if (Array.isArray(children)) return children.map(textOf).join('');
1211
+ if (/*#__PURE__*/ isValidElement(children)) return textOf(children.props.children);
1212
+ return '';
1213
+ }
1214
+ function LinkedText({ children }) {
1215
+ const options = useContext(TuiMarkdownContext);
1216
+ const insideLink = useContext(InsideLink);
1217
+ return /*#__PURE__*/ jsx(Fragment, {
1218
+ children: insideLink ? children : Children.map(children, (child)=>'string' == typeof child ? /*#__PURE__*/ jsx(TuiUriText, {
1219
+ text: child,
1220
+ mode: "prose",
1221
+ onOpenUri: options.onOpenUri
1222
+ }) : child)
1223
+ });
1224
+ }
1225
+ function MarkdownCode({ children }) {
1226
+ const options = useContext(TuiMarkdownContext);
1227
+ const insideLink = useContext(InsideLink);
1228
+ return /*#__PURE__*/ jsx("code", {
1229
+ children: insideLink ? children : /*#__PURE__*/ jsx(TuiUriText, {
1230
+ text: textOf(children),
1231
+ mode: "literal",
1232
+ onOpenUri: options.onOpenUri
1233
+ })
1234
+ });
1235
+ }
1236
+ function MarkdownPre({ children }) {
1237
+ const options = useContext(TuiMarkdownContext);
1238
+ return /*#__PURE__*/ jsx(TuiCodeBlock, {
1239
+ text: textOf(children).replace(/\n$/, ''),
1240
+ ...options
1241
+ });
1242
+ }
1243
+ function MarkdownLink({ children, href, title }) {
1244
+ const { onOpenUri } = useContext(TuiMarkdownContext);
1245
+ const isViking = /^viking:/i.test(href ?? '');
1246
+ const target = isViking ? getTuiSafeHref(href) : href;
1247
+ return /*#__PURE__*/ jsx(InsideLink.Provider, {
1248
+ value: true,
1249
+ children: target ? /*#__PURE__*/ jsx("a", {
1250
+ href: target,
1251
+ title: title,
1252
+ className: isViking ? 'ov-tui__link' : void 0,
1253
+ target: isViking ? void 0 : '_blank',
1254
+ rel: isViking ? void 0 : 'noreferrer',
1255
+ onClick: isViking && onOpenUri ? (event)=>{
1256
+ event.preventDefault();
1257
+ onOpenUri(target);
1258
+ } : void 0,
1259
+ children: children
1260
+ }) : children
1261
+ });
1262
+ }
1263
+ const TUI_MARKDOWN_COMPONENTS = {
1264
+ p: ({ children })=>/*#__PURE__*/ jsx("p", {
1265
+ children: /*#__PURE__*/ jsx(LinkedText, {
1266
+ children: children
1267
+ })
1268
+ }),
1269
+ li: ({ children })=>/*#__PURE__*/ jsx("li", {
1270
+ children: /*#__PURE__*/ jsx(LinkedText, {
1271
+ children: children
1272
+ })
1273
+ }),
1274
+ h1: ({ children })=>/*#__PURE__*/ jsx("h1", {
1275
+ children: /*#__PURE__*/ jsx(LinkedText, {
1276
+ children: children
1277
+ })
1278
+ }),
1279
+ h2: ({ children })=>/*#__PURE__*/ jsx("h2", {
1280
+ children: /*#__PURE__*/ jsx(LinkedText, {
1281
+ children: children
1282
+ })
1283
+ }),
1284
+ h3: ({ children })=>/*#__PURE__*/ jsx("h3", {
1285
+ children: /*#__PURE__*/ jsx(LinkedText, {
1286
+ children: children
1287
+ })
1288
+ }),
1289
+ h4: ({ children })=>/*#__PURE__*/ jsx("h4", {
1290
+ children: /*#__PURE__*/ jsx(LinkedText, {
1291
+ children: children
1292
+ })
1293
+ }),
1294
+ h5: ({ children })=>/*#__PURE__*/ jsx("h5", {
1295
+ children: /*#__PURE__*/ jsx(LinkedText, {
1296
+ children: children
1297
+ })
1298
+ }),
1299
+ h6: ({ children })=>/*#__PURE__*/ jsx("h6", {
1300
+ children: /*#__PURE__*/ jsx(LinkedText, {
1301
+ children: children
1302
+ })
1303
+ }),
1304
+ strong: ({ children })=>/*#__PURE__*/ jsx("strong", {
1305
+ children: /*#__PURE__*/ jsx(LinkedText, {
1306
+ children: children
1307
+ })
1308
+ }),
1309
+ em: ({ children })=>/*#__PURE__*/ jsx("em", {
1310
+ children: /*#__PURE__*/ jsx(LinkedText, {
1311
+ children: children
1312
+ })
1313
+ }),
1314
+ del: ({ children })=>/*#__PURE__*/ jsx("del", {
1315
+ children: /*#__PURE__*/ jsx(LinkedText, {
1316
+ children: children
1317
+ })
1318
+ }),
1319
+ td: ({ children, style })=>/*#__PURE__*/ jsx("td", {
1320
+ style: style,
1321
+ children: /*#__PURE__*/ jsx(LinkedText, {
1322
+ children: children
1323
+ })
1324
+ }),
1325
+ th: ({ children, style })=>/*#__PURE__*/ jsx("th", {
1326
+ style: style,
1327
+ children: /*#__PURE__*/ jsx(LinkedText, {
1328
+ children: children
1329
+ })
1330
+ }),
1331
+ code: MarkdownCode,
1332
+ pre: MarkdownPre,
1333
+ a: MarkdownLink,
1334
+ table: ({ children })=>/*#__PURE__*/ jsx("div", {
1335
+ className: "ov-tui__table-frame",
1336
+ children: /*#__PURE__*/ jsx("table", {
1337
+ children: children
1338
+ })
1339
+ })
1340
+ };
1341
+ function TuiMarkdown({ text, ...options }) {
1342
+ return /*#__PURE__*/ jsx(TuiMarkdownContext.Provider, {
1343
+ value: options,
1344
+ children: /*#__PURE__*/ jsx("div", {
1345
+ className: "ov-tui__markdown",
1346
+ children: /*#__PURE__*/ jsx(react_markdown, {
1347
+ remarkPlugins: [
1348
+ [
1349
+ remark_gfm,
1350
+ {
1351
+ singleTilde: false
1352
+ }
1353
+ ]
1354
+ ],
1355
+ urlTransform: (url)=>/^viking:/i.test(url) ? getTuiSafeHref(url) ?? '' : defaultUrlTransform(url),
1356
+ components: TUI_MARKDOWN_COMPONENTS,
1357
+ children: text
1358
+ })
1359
+ })
1360
+ });
1361
+ }
1362
+ function getVisibleTuiResultTitle(title, command) {
1363
+ if (!title || !command) return title;
1364
+ const candidate = title.trim().replace(/^\*\*([\s\S]*)\*\*$/, '$1').replace(/^\/+/, '').trim();
1365
+ const match = matchTuiCommandInput(candidate, [
1366
+ command
1367
+ ]);
1368
+ return match && !match.rest.trim() ? void 0 : title;
1369
+ }
1370
+ function getTuiResultText(text, command) {
1371
+ const heading = text.match(/^\s*(\*\*\/?[^\r\n]+\*\*|\/[^\r\n]+)\r?\n(?:[ \t]*\r?\n)?/);
1372
+ return heading && void 0 === getVisibleTuiResultTitle(heading[1], command) ? text.slice(heading[0].length) : text;
1373
+ }
1374
+ function isTuiJson(text) {
1375
+ const first = text.trimStart().charAt(0);
1376
+ if ('{' !== first && '[' !== first) return false;
1377
+ try {
1378
+ JSON.parse(text);
1379
+ return true;
1380
+ } catch {
1381
+ return false;
1382
+ }
1383
+ }
1384
+ function TuiResourcePreview({ content, onOpenUri, onCopy, labels }) {
1385
+ const metaLabel = content.meta?.filter(Boolean).join(' · ') || content.description;
1386
+ const target = content.navigationUri ?? content.uri;
1387
+ return /*#__PURE__*/ jsxs("div", {
1388
+ className: "ov-tui__preview",
1389
+ children: [
1390
+ metaLabel ? /*#__PURE__*/ jsx("div", {
1391
+ className: "ov-tui__result-meta",
1392
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1393
+ text: metaLabel,
1394
+ mode: "prose",
1395
+ onOpenUri: onOpenUri
1396
+ })
1397
+ }) : null,
1398
+ content.title ? /*#__PURE__*/ jsx("div", {
1399
+ className: "ov-tui__card-title",
1400
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1401
+ text: content.title,
1402
+ mode: "literal",
1403
+ onOpenUri: onOpenUri
1404
+ })
1405
+ }) : null,
1406
+ /*#__PURE__*/ jsxs("div", {
1407
+ className: "ov-tui__preview-body",
1408
+ children: [
1409
+ content.uri ? /*#__PURE__*/ jsx(TuiUriLink, {
1410
+ uri: target,
1411
+ onOpenUri: onOpenUri,
1412
+ className: "ov-tui__link ov-tui__preview-uri",
1413
+ children: content.uri
1414
+ }) : null,
1415
+ isTuiJson(content.content) ? /*#__PURE__*/ jsx(TuiCodeBlock, {
1416
+ text: content.content,
1417
+ labels: labels,
1418
+ onCopy: onCopy,
1419
+ onOpenUri: onOpenUri
1420
+ }) : /*#__PURE__*/ jsx("pre", {
1421
+ className: "ov-tui__preview-content",
1422
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1423
+ text: content.content,
1424
+ mode: "literal",
1425
+ onOpenUri: onOpenUri
1426
+ })
1427
+ })
1428
+ ]
1429
+ })
1430
+ ]
1431
+ });
1432
+ }
1433
+ const PAGE_SIZE = 20;
1434
+ function TreeIdentity({ item, onOpenUri }) {
1435
+ return /*#__PURE__*/ jsxs(Fragment, {
1436
+ children: [
1437
+ /*#__PURE__*/ jsx("span", {
1438
+ className: "ov-tui__tree-title",
1439
+ children: item.uri ? /*#__PURE__*/ jsx(TuiUriLink, {
1440
+ uri: item.uri,
1441
+ onOpenUri: onOpenUri,
1442
+ children: item.title
1443
+ }) : /*#__PURE__*/ jsx(TuiUriText, {
1444
+ text: item.title,
1445
+ mode: "literal",
1446
+ onOpenUri: onOpenUri
1447
+ })
1448
+ }),
1449
+ item.metaLabel ? /*#__PURE__*/ jsx("span", {
1450
+ className: "ov-tui__tree-meta",
1451
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1452
+ text: item.metaLabel,
1453
+ mode: "prose",
1454
+ onOpenUri: onOpenUri
1455
+ })
1456
+ }) : null
1457
+ ]
1458
+ });
1459
+ }
1460
+ function TuiResourceTree({ content, onOpenUri, loadMoreLabel, noResultLabel, resourceLabel }) {
1461
+ const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
1462
+ const columns = Array.from(new Set(content.items.flatMap((item)=>item.detailRows?.map((row)=>row.label) ?? [])));
1463
+ const visibleItems = content.items.slice(0, visibleCount);
1464
+ const hiddenCount = content.items.length - visibleItems.length;
1465
+ return /*#__PURE__*/ jsxs("div", {
1466
+ className: "ov-tui__tree",
1467
+ children: [
1468
+ content.title ? /*#__PURE__*/ jsx("div", {
1469
+ className: "ov-tui__card-title",
1470
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1471
+ text: content.title,
1472
+ mode: "literal",
1473
+ onOpenUri: onOpenUri
1474
+ })
1475
+ }) : null,
1476
+ content.items.length ? null : /*#__PURE__*/ jsx("div", {
1477
+ className: "ov-tui__no-result",
1478
+ children: noResultLabel
1479
+ }),
1480
+ columns.length ? /*#__PURE__*/ jsx("div", {
1481
+ className: "ov-tui__table-frame",
1482
+ children: /*#__PURE__*/ jsxs("table", {
1483
+ className: "ov-tui__table",
1484
+ children: [
1485
+ /*#__PURE__*/ jsx("thead", {
1486
+ children: /*#__PURE__*/ jsxs("tr", {
1487
+ children: [
1488
+ /*#__PURE__*/ jsx("th", {
1489
+ scope: "col",
1490
+ children: resourceLabel
1491
+ }),
1492
+ columns.map((column)=>/*#__PURE__*/ jsx("th", {
1493
+ scope: "col",
1494
+ children: column
1495
+ }, column))
1496
+ ]
1497
+ })
1498
+ }),
1499
+ /*#__PURE__*/ jsx("tbody", {
1500
+ children: visibleItems.map((item)=>/*#__PURE__*/ jsxs("tr", {
1501
+ children: [
1502
+ /*#__PURE__*/ jsx("td", {
1503
+ children: /*#__PURE__*/ jsx(TreeIdentity, {
1504
+ item: item,
1505
+ onOpenUri: onOpenUri
1506
+ })
1507
+ }),
1508
+ columns.map((column)=>{
1509
+ const value = item.detailRows?.find((row)=>row.label === column)?.value ?? '';
1510
+ return /*#__PURE__*/ jsx("td", {
1511
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1512
+ text: value,
1513
+ mode: "literal",
1514
+ onOpenUri: onOpenUri
1515
+ })
1516
+ }, column);
1517
+ })
1518
+ ]
1519
+ }, item.id))
1520
+ })
1521
+ ]
1522
+ })
1523
+ }) : /*#__PURE__*/ jsx("div", {
1524
+ className: "ov-tui__tree-items",
1525
+ children: visibleItems.map((item)=>/*#__PURE__*/ jsx("div", {
1526
+ className: "ov-tui__tree-item",
1527
+ children: /*#__PURE__*/ jsx(TreeIdentity, {
1528
+ item: item,
1529
+ onOpenUri: onOpenUri
1530
+ })
1531
+ }, item.id))
1532
+ }),
1533
+ hiddenCount > 0 ? /*#__PURE__*/ jsxs("button", {
1534
+ type: "button",
1535
+ className: "ov-tui__load-more",
1536
+ onClick: ()=>setVisibleCount((count)=>count + PAGE_SIZE),
1537
+ children: [
1538
+ loadMoreLabel,
1539
+ " (",
1540
+ hiddenCount,
1541
+ ")"
1542
+ ]
1543
+ }) : null
1544
+ ]
1545
+ });
1546
+ }
1547
+ function TuiResultHeader({ command, status, label }) {
1548
+ return /*#__PURE__*/ jsxs("header", {
1549
+ className: "ov-tui__result-head",
1550
+ children: [
1551
+ /*#__PURE__*/ jsx("span", {
1552
+ className: "ov-tui__result-state",
1553
+ "data-status": status,
1554
+ role: "img",
1555
+ "aria-label": label
1556
+ }),
1557
+ /*#__PURE__*/ jsx("span", {
1558
+ className: "ov-tui__result-command",
1559
+ children: command
1560
+ })
1561
+ ]
1562
+ });
1563
+ }
1564
+ function ScoreDetails({ item }) {
1565
+ const [hovered, setHovered] = useState(false);
1566
+ const [pinned, setPinned] = useState(false);
1567
+ if (!item.scoreDetails) return /*#__PURE__*/ jsx("span", {
1568
+ className: "ov-tui__search-score",
1569
+ children: item.scoreLabel
1570
+ });
1571
+ const open = hovered || pinned;
1572
+ return /*#__PURE__*/ jsxs("span", {
1573
+ className: "ov-tui__search-score-wrap",
1574
+ children: [
1575
+ /*#__PURE__*/ jsx("button", {
1576
+ type: "button",
1577
+ className: "ov-tui__search-score",
1578
+ "aria-expanded": open,
1579
+ onClick: ()=>setPinned((current)=>!current),
1580
+ onMouseEnter: ()=>setHovered(true),
1581
+ onMouseLeave: ()=>setHovered(false),
1582
+ onFocus: ()=>setHovered(true),
1583
+ onBlur: ()=>{
1584
+ setHovered(false);
1585
+ setPinned(false);
1586
+ },
1587
+ children: item.scoreLabel
1588
+ }),
1589
+ open ? /*#__PURE__*/ jsx("span", {
1590
+ role: "tooltip",
1591
+ className: "ov-tui__score-details",
1592
+ children: item.scoreDetails
1593
+ }) : null
1594
+ ]
1595
+ });
1596
+ }
1597
+ function ResourceUri({ text }) {
1598
+ const boundary = text.lastIndexOf('/');
1599
+ return boundary > 9 ? /*#__PURE__*/ jsxs("span", {
1600
+ className: "ov-tui__search-uri",
1601
+ children: [
1602
+ /*#__PURE__*/ jsx("span", {
1603
+ className: "ov-tui__search-uri-prefix",
1604
+ children: text.slice(0, boundary + 1)
1605
+ }),
1606
+ /*#__PURE__*/ jsx("span", {
1607
+ className: "ov-tui__search-uri-suffix",
1608
+ children: text.slice(boundary + 1)
1609
+ })
1610
+ ]
1611
+ }) : /*#__PURE__*/ jsx("span", {
1612
+ className: "ov-tui__search-uri-full",
1613
+ children: text
1614
+ });
1615
+ }
1616
+ function SearchRow({ item, onOpenUri }) {
1617
+ return /*#__PURE__*/ jsxs(Fragment, {
1618
+ children: [
1619
+ item.scoreLabel || item.typeLabel ? /*#__PURE__*/ jsxs("span", {
1620
+ className: "ov-tui__search-metrics",
1621
+ children: [
1622
+ item.scoreLabel ? /*#__PURE__*/ jsx(ScoreDetails, {
1623
+ item: item
1624
+ }) : null,
1625
+ item.typeLabel ? /*#__PURE__*/ jsx("span", {
1626
+ className: "ov-tui__search-type",
1627
+ children: item.typeLabel
1628
+ }) : null
1629
+ ]
1630
+ }) : null,
1631
+ /*#__PURE__*/ jsxs("span", {
1632
+ className: "ov-tui__search-body",
1633
+ children: [
1634
+ /*#__PURE__*/ jsxs("span", {
1635
+ className: "ov-tui__search-main",
1636
+ children: [
1637
+ /*#__PURE__*/ jsx("span", {
1638
+ className: "ov-tui__search-title",
1639
+ title: item.uri ?? item.title,
1640
+ children: item.uri ? /*#__PURE__*/ jsx(TuiUriLink, {
1641
+ uri: item.uri,
1642
+ onOpenUri: onOpenUri,
1643
+ className: "ov-tui__link ov-tui__search-open",
1644
+ children: /*#__PURE__*/ jsx(ResourceUri, {
1645
+ text: item.uri
1646
+ })
1647
+ }) : /*#__PURE__*/ jsx(TuiUriText, {
1648
+ text: item.title,
1649
+ mode: "literal",
1650
+ onOpenUri: onOpenUri
1651
+ })
1652
+ }),
1653
+ item.levelLabel ? /*#__PURE__*/ jsx("span", {
1654
+ className: "ov-tui__search-level",
1655
+ children: item.levelLabel
1656
+ }) : null
1657
+ ]
1658
+ }),
1659
+ item.preview ? /*#__PURE__*/ jsx("span", {
1660
+ className: "ov-tui__search-preview",
1661
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1662
+ text: item.preview,
1663
+ mode: "prose",
1664
+ onOpenUri: onOpenUri
1665
+ })
1666
+ }) : null,
1667
+ item.metaLabel ? /*#__PURE__*/ jsx("span", {
1668
+ className: "ov-tui__search-meta",
1669
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1670
+ text: item.metaLabel,
1671
+ mode: "prose",
1672
+ onOpenUri: onOpenUri
1673
+ })
1674
+ }) : null
1675
+ ]
1676
+ })
1677
+ ]
1678
+ });
1679
+ }
1680
+ function TuiSearchList({ content, onOpenUri, noResultLabel }) {
1681
+ return /*#__PURE__*/ jsxs("div", {
1682
+ className: "ov-tui__search",
1683
+ children: [
1684
+ content.summary ? /*#__PURE__*/ jsx("div", {
1685
+ className: "ov-tui__search-summary",
1686
+ children: 'string' == typeof content.summary ? /*#__PURE__*/ jsx(TuiUriText, {
1687
+ text: content.summary,
1688
+ mode: "prose",
1689
+ onOpenUri: onOpenUri
1690
+ }) : content.summary
1691
+ }) : null,
1692
+ content.items.length ? /*#__PURE__*/ jsx("div", {
1693
+ className: "ov-tui__search-items",
1694
+ children: content.items.map((item)=>/*#__PURE__*/ jsx("article", {
1695
+ className: "ov-tui__search-item",
1696
+ children: /*#__PURE__*/ jsx(SearchRow, {
1697
+ item: item,
1698
+ onOpenUri: onOpenUri
1699
+ })
1700
+ }, item.id))
1701
+ }) : /*#__PURE__*/ jsx("div", {
1702
+ className: "ov-tui__no-result",
1703
+ children: noResultLabel
1704
+ })
1705
+ ]
1706
+ });
1707
+ }
1708
+ function Line({ width }) {
1709
+ return /*#__PURE__*/ jsx("span", {
1710
+ className: "ov-tui__skeleton-line",
1711
+ style: {
1712
+ width
1713
+ }
1714
+ });
1715
+ }
1716
+ function TuiSkeleton({ kind }) {
1717
+ if ('search' === kind) return /*#__PURE__*/ jsxs("div", {
1718
+ className: "ov-tui__skeleton",
1719
+ "aria-hidden": "true",
1720
+ children: [
1721
+ /*#__PURE__*/ jsxs("div", {
1722
+ className: "ov-tui__skeleton-summary",
1723
+ children: [
1724
+ /*#__PURE__*/ jsx(Line, {
1725
+ width: "100%"
1726
+ }),
1727
+ /*#__PURE__*/ jsx(Line, {
1728
+ width: "56%"
1729
+ })
1730
+ ]
1731
+ }),
1732
+ [
1733
+ 0,
1734
+ 1,
1735
+ 2
1736
+ ].map((index)=>/*#__PURE__*/ jsxs("div", {
1737
+ className: "ov-tui__skeleton-item",
1738
+ children: [
1739
+ /*#__PURE__*/ jsx("span", {
1740
+ className: "ov-tui__skeleton-icon"
1741
+ }),
1742
+ /*#__PURE__*/ jsxs("span", {
1743
+ className: "ov-tui__skeleton-lines",
1744
+ children: [
1745
+ /*#__PURE__*/ jsx(Line, {
1746
+ width: "72%"
1747
+ }),
1748
+ /*#__PURE__*/ jsx(Line, {
1749
+ width: "44%"
1750
+ })
1751
+ ]
1752
+ })
1753
+ ]
1754
+ }, index))
1755
+ ]
1756
+ });
1757
+ if ('tree' === kind) return /*#__PURE__*/ jsx("div", {
1758
+ className: "ov-tui__skeleton",
1759
+ "aria-hidden": "true",
1760
+ children: [
1761
+ 0,
1762
+ 1,
1763
+ 2,
1764
+ 3
1765
+ ].map((index)=>/*#__PURE__*/ jsx("div", {
1766
+ className: "ov-tui__skeleton-row",
1767
+ children: /*#__PURE__*/ jsx(Line, {
1768
+ width: index % 2 ? '52%' : '68%'
1769
+ })
1770
+ }, index))
1771
+ });
1772
+ if ('status' === kind) return /*#__PURE__*/ jsx("div", {
1773
+ className: "ov-tui__skeleton",
1774
+ "aria-hidden": "true",
1775
+ children: [
1776
+ 0,
1777
+ 1,
1778
+ 2
1779
+ ].map((index)=>/*#__PURE__*/ jsxs("div", {
1780
+ className: "ov-tui__skeleton-row",
1781
+ children: [
1782
+ /*#__PURE__*/ jsx(Line, {
1783
+ width: "28%"
1784
+ }),
1785
+ /*#__PURE__*/ jsx(Line, {
1786
+ width: "46%"
1787
+ })
1788
+ ]
1789
+ }, index))
1790
+ });
1791
+ if ('resource' === kind) return /*#__PURE__*/ jsxs("div", {
1792
+ className: "ov-tui__skeleton",
1793
+ "aria-hidden": "true",
1794
+ children: [
1795
+ /*#__PURE__*/ jsx(Line, {
1796
+ width: "38%"
1797
+ }),
1798
+ /*#__PURE__*/ jsxs("div", {
1799
+ className: "ov-tui__skeleton-block",
1800
+ children: [
1801
+ /*#__PURE__*/ jsx(Line, {
1802
+ width: "100%"
1803
+ }),
1804
+ /*#__PURE__*/ jsx(Line, {
1805
+ width: "92%"
1806
+ }),
1807
+ /*#__PURE__*/ jsx(Line, {
1808
+ width: "76%"
1809
+ })
1810
+ ]
1811
+ })
1812
+ ]
1813
+ });
1814
+ if ('write' === kind) return /*#__PURE__*/ jsxs("div", {
1815
+ className: "ov-tui__skeleton",
1816
+ "aria-hidden": "true",
1817
+ children: [
1818
+ /*#__PURE__*/ jsx("div", {
1819
+ className: "ov-tui__skeleton-row",
1820
+ children: /*#__PURE__*/ jsx(Line, {
1821
+ width: "64%"
1822
+ })
1823
+ }),
1824
+ /*#__PURE__*/ jsx("div", {
1825
+ className: "ov-tui__skeleton-row",
1826
+ children: /*#__PURE__*/ jsx(Line, {
1827
+ width: "42%"
1828
+ })
1829
+ })
1830
+ ]
1831
+ });
1832
+ return /*#__PURE__*/ jsx("div", {
1833
+ className: "ov-tui__skeleton",
1834
+ "aria-hidden": "true",
1835
+ children: /*#__PURE__*/ jsxs("div", {
1836
+ className: "ov-tui__skeleton-summary",
1837
+ children: [
1838
+ /*#__PURE__*/ jsx(Line, {
1839
+ width: "100%"
1840
+ }),
1841
+ /*#__PURE__*/ jsx(Line, {
1842
+ width: "64%"
1843
+ })
1844
+ ]
1845
+ })
1846
+ });
1847
+ }
1848
+ function TuiStatusCard({ content, onOpenUri }) {
1849
+ return /*#__PURE__*/ jsxs("div", {
1850
+ className: "ov-tui__status",
1851
+ children: [
1852
+ content.title ? /*#__PURE__*/ jsx("div", {
1853
+ className: "ov-tui__card-title",
1854
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1855
+ text: content.title,
1856
+ mode: "prose",
1857
+ onOpenUri: onOpenUri
1858
+ })
1859
+ }) : null,
1860
+ /*#__PURE__*/ jsx("dl", {
1861
+ className: "ov-tui__status-rows",
1862
+ children: content.rows.map((row)=>/*#__PURE__*/ jsxs("div", {
1863
+ className: "ov-tui__status-row",
1864
+ "data-variant": row.variant ?? 'inline',
1865
+ children: [
1866
+ /*#__PURE__*/ jsx("dt", {
1867
+ className: "ov-tui__status-label",
1868
+ children: row.label
1869
+ }),
1870
+ /*#__PURE__*/ jsx("dd", {
1871
+ className: "ov-tui__status-value",
1872
+ children: 'string' == typeof row.value ? /*#__PURE__*/ jsx(TuiUriText, {
1873
+ text: row.value,
1874
+ mode: "literal",
1875
+ onOpenUri: onOpenUri
1876
+ }) : row.value
1877
+ })
1878
+ ]
1879
+ }, row.label))
1880
+ })
1881
+ ]
1882
+ });
1883
+ }
1884
+ function TuiWriteResult({ content, onOpenUri }) {
1885
+ return /*#__PURE__*/ jsxs("div", {
1886
+ className: "ov-tui__write",
1887
+ children: [
1888
+ content.title ? /*#__PURE__*/ jsx("div", {
1889
+ className: "ov-tui__card-title",
1890
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1891
+ text: content.title,
1892
+ mode: "prose",
1893
+ onOpenUri: onOpenUri
1894
+ })
1895
+ }) : null,
1896
+ /*#__PURE__*/ jsx("div", {
1897
+ className: "ov-tui__write-lines",
1898
+ children: content.lines.map((line, index)=>/*#__PURE__*/ jsx("div", {
1899
+ className: "ov-tui__write-line",
1900
+ children: 'string' == typeof line ? /*#__PURE__*/ jsx(TuiUriText, {
1901
+ text: line,
1902
+ mode: "prose",
1903
+ onOpenUri: onOpenUri
1904
+ }) : line
1905
+ }, index))
1906
+ })
1907
+ ]
1908
+ });
1909
+ }
1910
+ function RecordBody({ record, command, labels, onOpenUri, onCopy, onPickCommand }) {
1911
+ const { content } = record;
1912
+ if ('pending' === record.status) return /*#__PURE__*/ jsx(TuiSkeleton, {
1913
+ kind: resolveTuiSkeleton(command)
1914
+ });
1915
+ if (!content) return /*#__PURE__*/ jsx("div", {
1916
+ className: "ov-tui__muted",
1917
+ children: 'error' === record.status ? labels.error : labels.noResult
1918
+ });
1919
+ switch(content.variant){
1920
+ case 'search-list':
1921
+ return /*#__PURE__*/ jsx(TuiSearchList, {
1922
+ content: content,
1923
+ onOpenUri: onOpenUri,
1924
+ noResultLabel: labels.noResult
1925
+ });
1926
+ case 'resource-preview':
1927
+ return /*#__PURE__*/ jsx(TuiResourcePreview, {
1928
+ content: {
1929
+ ...content,
1930
+ title: getVisibleTuiResultTitle(content.title, command) ?? ''
1931
+ },
1932
+ labels: labels,
1933
+ onCopy: onCopy,
1934
+ onOpenUri: onOpenUri
1935
+ });
1936
+ case 'resource-tree':
1937
+ return /*#__PURE__*/ jsx(TuiResourceTree, {
1938
+ content: {
1939
+ ...content,
1940
+ title: getVisibleTuiResultTitle(content.title, command)
1941
+ },
1942
+ onOpenUri: onOpenUri,
1943
+ resourceLabel: labels.resource,
1944
+ loadMoreLabel: labels.loadMore,
1945
+ noResultLabel: labels.noResult
1946
+ });
1947
+ case 'status':
1948
+ return /*#__PURE__*/ jsx(TuiStatusCard, {
1949
+ content: {
1950
+ ...content,
1951
+ title: getVisibleTuiResultTitle(content.title, command)
1952
+ },
1953
+ onOpenUri: onOpenUri
1954
+ });
1955
+ case 'write-result':
1956
+ return /*#__PURE__*/ jsx(TuiWriteResult, {
1957
+ content: {
1958
+ ...content,
1959
+ title: getVisibleTuiResultTitle(content.title, command)
1960
+ },
1961
+ onOpenUri: onOpenUri
1962
+ });
1963
+ case 'command-help':
1964
+ return /*#__PURE__*/ jsx(TuiCommandHelp, {
1965
+ content: content,
1966
+ onPick: onPickCommand,
1967
+ labels: labels
1968
+ });
1969
+ default:
1970
+ {
1971
+ const text = getTuiResultText(formatTuiJson(content.text), command);
1972
+ return /*#__PURE__*/ jsx("div", {
1973
+ className: "ov-tui__text",
1974
+ children: 'markdown' === content.format ? /*#__PURE__*/ jsx(TuiMarkdown, {
1975
+ text: text,
1976
+ labels: labels,
1977
+ onCopy: onCopy,
1978
+ onOpenUri: onOpenUri
1979
+ }) : isTuiJson(text) ? /*#__PURE__*/ jsx(TuiCodeBlock, {
1980
+ text: text,
1981
+ labels: labels,
1982
+ onCopy: onCopy,
1983
+ onOpenUri: onOpenUri
1984
+ }) : /*#__PURE__*/ jsx("pre", {
1985
+ className: "ov-tui__plain",
1986
+ children: /*#__PURE__*/ jsx(TuiUriText, {
1987
+ text: text,
1988
+ mode: "prose",
1989
+ onOpenUri: onOpenUri
1990
+ })
1991
+ })
1992
+ });
1993
+ }
1994
+ }
1995
+ }
1996
+ const STATUS_TEXT = {
1997
+ pending: 'pending',
1998
+ success: 'success',
1999
+ error: 'error'
2000
+ };
2001
+ function TuiRecordItem(props) {
2002
+ const { record, labels } = props;
2003
+ const statusLabel = labels[STATUS_TEXT[record.status]];
2004
+ const input = props.command ? matchTuiCommandInput(record.command, [
2005
+ props.command
2006
+ ]) : void 0;
2007
+ const prefix = input ? getTuiCommandInputText(input.command) : '';
2008
+ return /*#__PURE__*/ jsxs("div", {
2009
+ className: "ov-tui__record",
2010
+ "data-status": record.status,
2011
+ children: [
2012
+ /*#__PURE__*/ jsxs("div", {
2013
+ className: "ov-tui__bubble",
2014
+ children: [
2015
+ /*#__PURE__*/ jsx("code", {
2016
+ className: "ov-tui__bubble-text",
2017
+ children: input ? /*#__PURE__*/ jsxs(Fragment, {
2018
+ children: [
2019
+ input.leadingWhitespace,
2020
+ /*#__PURE__*/ jsx("span", {
2021
+ className: "ov-tui__bubble-command",
2022
+ children: /*#__PURE__*/ jsx(TuiCommandText, {
2023
+ text: prefix,
2024
+ name: input.command.name
2025
+ })
2026
+ }),
2027
+ /*#__PURE__*/ jsx(TuiUriText, {
2028
+ text: input.rest,
2029
+ mode: "literal",
2030
+ onOpenUri: props.onOpenUri
2031
+ })
2032
+ ]
2033
+ }) : /*#__PURE__*/ jsx(TuiUriText, {
2034
+ text: record.command,
2035
+ mode: "literal",
2036
+ onOpenUri: props.onOpenUri
2037
+ })
2038
+ }),
2039
+ record.createdAt || void 0 !== record.createdAtMs ? /*#__PURE__*/ jsx(TuiRecordTime, {
2040
+ record: record,
2041
+ labels: labels
2042
+ }) : null
2043
+ ]
2044
+ }),
2045
+ /*#__PURE__*/ jsxs("article", {
2046
+ className: "ov-tui__result",
2047
+ children: [
2048
+ /*#__PURE__*/ jsx(TuiResultHeader, {
2049
+ command: prefix || record.command,
2050
+ status: record.status,
2051
+ label: statusLabel
2052
+ }),
2053
+ /*#__PURE__*/ jsx("div", {
2054
+ className: "ov-tui__result-body",
2055
+ children: /*#__PURE__*/ jsx(RecordBody, {
2056
+ ...props
2057
+ })
2058
+ })
2059
+ ]
2060
+ })
2061
+ ]
2062
+ });
2063
+ }
2064
+ function useTuiCompletion(value, enabled, commands, groups = [], paletteScope = null) {
2065
+ const query = getTuiCommandQuery(value, commands);
2066
+ const suggestions = groupTuiCommands(enabled ? query.matches : [], groups);
2067
+ return {
2068
+ query,
2069
+ suggestions,
2070
+ options: suggestions.flatMap((section)=>section.commands),
2071
+ enabled,
2072
+ activeInput: '/' === query.scope ? void 0 : matchTuiCommandInput(value, commands),
2073
+ showSuggestions: enabled && (query.automatic || null !== query.scope && paletteScope === query.scope)
2074
+ };
2075
+ }
2076
+ function Tui({ records, value, disabled = false, emptyState, quickCommands, locale = 'en-US', commands = [], commandGroups = [], onValueChange, onSubmit, onOpenUri, onCopy, labels, className, ...rest }) {
2077
+ const text = resolveTuiLabels(labels, locale);
2078
+ const bodyRef = useRef(null);
2079
+ const followOutput = useRef(true);
2080
+ const composerRef = useRef(null);
2081
+ const assistId = useId();
2082
+ const [dismissedValue, setDismissedValue] = useState(null);
2083
+ const [paletteScope, setPaletteScope] = useState(null);
2084
+ const [selection, setSelection] = useState({
2085
+ queryKey: value,
2086
+ index: -1
2087
+ });
2088
+ const dismissCompletion = useCallback((next)=>{
2089
+ setDismissedValue(next);
2090
+ setPaletteScope(null);
2091
+ setSelection({
2092
+ queryKey: next,
2093
+ index: -1
2094
+ });
2095
+ }, []);
2096
+ const updateValue = (next)=>{
2097
+ setDismissedValue(null);
2098
+ setSelection({
2099
+ queryKey: next,
2100
+ index: -1
2101
+ });
2102
+ if (getTuiCommandQuery(next, commands).scope !== paletteScope) setPaletteScope(null);
2103
+ onValueChange?.(next);
2104
+ };
2105
+ const readOnly = !onValueChange;
2106
+ const fillCommand = (next)=>{
2107
+ if (disabled || readOnly) return;
2108
+ updateValue(formatTuiCommandInput(next, commands));
2109
+ composerRef.current?.querySelector('textarea')?.focus({
2110
+ preventScroll: true
2111
+ });
2112
+ };
2113
+ const completion = useTuiCompletion(value, !disabled && !readOnly && dismissedValue !== value, commands, commandGroups, paletteScope);
2114
+ const queryKey = value;
2115
+ const activeIndex = selection.queryKey === queryKey && selection.index < completion.options.length ? selection.index : -1;
2116
+ const setActiveIndexSafely = useCallback((next)=>{
2117
+ setSelection((current)=>{
2118
+ const index = current.queryKey === queryKey && current.index < completion.options.length ? current.index : -1;
2119
+ return {
2120
+ queryKey,
2121
+ index: 'function' == typeof next ? next(index) : next
2122
+ };
2123
+ });
2124
+ }, [
2125
+ queryKey,
2126
+ completion.options.length
2127
+ ]);
2128
+ useEffect(()=>{
2129
+ const body = bodyRef.current;
2130
+ if (body && followOutput.current) body.scrollTop = body.scrollHeight;
2131
+ }, [
2132
+ records
2133
+ ]);
2134
+ return /*#__PURE__*/ jsxs("div", {
2135
+ className: [
2136
+ 'ov-tui',
2137
+ className
2138
+ ].filter(Boolean).join(' '),
2139
+ ...rest,
2140
+ children: [
2141
+ /*#__PURE__*/ jsx("div", {
2142
+ ref: bodyRef,
2143
+ className: "ov-tui__body",
2144
+ onScroll: (event)=>{
2145
+ const body = event.currentTarget;
2146
+ followOutput.current = body.scrollHeight - body.scrollTop - body.clientHeight <= 24;
2147
+ },
2148
+ children: records.length ? records.map((record)=>/*#__PURE__*/ jsx(TuiRecordItem, {
2149
+ record: record,
2150
+ command: findTuiCommand(record.command, commands),
2151
+ labels: text,
2152
+ onOpenUri: onOpenUri,
2153
+ onCopy: onCopy,
2154
+ onPickCommand: disabled || readOnly ? void 0 : (command)=>fillCommand(`${command} `)
2155
+ }, record.id)) : /*#__PURE__*/ jsx(TuiEmptyRegion, {
2156
+ emptyState: emptyState,
2157
+ commands: pickTuiCommands(quickCommands, commands),
2158
+ labels: text,
2159
+ disabled: disabled || readOnly,
2160
+ onPick: (command)=>fillCommand(`${command.name} `)
2161
+ })
2162
+ }),
2163
+ /*#__PURE__*/ jsx(TuiAssist, {
2164
+ assistId: assistId,
2165
+ anchorRef: composerRef,
2166
+ onDismiss: dismissCompletion,
2167
+ labels: text,
2168
+ completion: completion,
2169
+ activeIndex: activeIndex,
2170
+ onActiveIndexChange: setActiveIndexSafely,
2171
+ onPick: fillCommand
2172
+ }),
2173
+ /*#__PURE__*/ jsx(TuiComposer, {
2174
+ onDismiss: dismissCompletion,
2175
+ onRequestPalette: ()=>{
2176
+ setDismissedValue(null);
2177
+ setSelection({
2178
+ queryKey: value,
2179
+ index: -1
2180
+ });
2181
+ setPaletteScope(completion.query.scope);
2182
+ },
2183
+ assistId: assistId,
2184
+ anchorRef: composerRef,
2185
+ onFocus: ()=>setDismissedValue(null),
2186
+ value: value,
2187
+ history: records.map((record)=>formatTuiCommandInput(record.command, commands)),
2188
+ labels: text,
2189
+ completion: completion,
2190
+ disabled: disabled,
2191
+ readOnly: readOnly,
2192
+ canSubmit: Boolean(onSubmit) && !readOnly,
2193
+ activeIndex: activeIndex,
2194
+ onActiveIndexChange: setActiveIndexSafely,
2195
+ onValueChange: onValueChange ? updateValue : void 0,
2196
+ onSubmit: (command)=>{
2197
+ if (disabled || readOnly) return;
2198
+ followOutput.current = true;
2199
+ onSubmit?.(command);
2200
+ },
2201
+ onOpenUri: onOpenUri
2202
+ })
2203
+ ]
2204
+ });
2205
+ }
2206
+ export { Tui };