@seekbuddy/dsh-ui 0.0.0-stage → 0.2.0-beta.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 (213) hide show
  1. package/CHANGELOG.md +83 -0
  2. package/LICENSE +22 -0
  3. package/README.md +175 -2
  4. package/README.zh.md +176 -0
  5. package/THIRD_PARTY_NOTICES.md +42 -0
  6. package/UPSTREAM.md +59 -0
  7. package/dist/blocks.js +1617 -0
  8. package/dist/chunks/chunk-23KOEBWJ.js +104 -0
  9. package/dist/chunks/chunk-6SGSJ5KW.js +57 -0
  10. package/dist/chunks/chunk-7NH2UOZO.js +155 -0
  11. package/dist/chunks/chunk-7SKW4S35.js +66 -0
  12. package/dist/chunks/chunk-B3EEK7A2.js +408 -0
  13. package/dist/chunks/chunk-CEBTQO6W.js +24 -0
  14. package/dist/chunks/chunk-ENKPNYOB.js +26 -0
  15. package/dist/chunks/chunk-EWAZFWLW.js +27 -0
  16. package/dist/chunks/chunk-F352IICS.js +57 -0
  17. package/dist/chunks/chunk-FFJ6TCCF.js +31 -0
  18. package/dist/chunks/chunk-FZXK4LTI.js +129 -0
  19. package/dist/chunks/chunk-JA3XDLIA.js +1115 -0
  20. package/dist/chunks/chunk-L7XALG4J.js +36 -0
  21. package/dist/chunks/chunk-OCAQFVT3.js +3172 -0
  22. package/dist/chunks/chunk-RAXDA2PT.js +202 -0
  23. package/dist/chunks/chunk-RNVSCTW7.js +24 -0
  24. package/dist/chunks/chunk-RZOP2PFC.js +152 -0
  25. package/dist/chunks/chunk-SN6RSUWC.js +61 -0
  26. package/dist/chunks/chunk-SNVSQWCU.js +22 -0
  27. package/dist/chunks/chunk-SO3DCAWG.js +170 -0
  28. package/dist/chunks/chunk-UAEFKTV3.js +144 -0
  29. package/dist/chunks/chunk-UGEORMLD.js +89 -0
  30. package/dist/chunks/chunk-W6FLI3AK.js +112 -0
  31. package/dist/chunks/chunk-WX46TSKP.js +328 -0
  32. package/dist/chunks/chunk-XL33IPCV.js +261 -0
  33. package/dist/chunks/chunk-XW4L4ZGL.js +967 -0
  34. package/dist/chunks/chunk-YOBY6PSL.js +850 -0
  35. package/dist/chunks/chunk-ZA47FP7C.js +7 -0
  36. package/dist/icons.js +859 -0
  37. package/dist/index.js +1675 -0
  38. package/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
  39. package/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
  40. package/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
  41. package/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
  42. package/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
  43. package/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
  44. package/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
  45. package/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
  46. package/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
  47. package/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
  48. package/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
  49. package/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
  50. package/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
  51. package/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
  52. package/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
  53. package/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
  54. package/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
  55. package/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
  56. package/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
  57. package/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
  58. package/dist/katex.css +1 -0
  59. package/dist/katex.css.d.ts +2 -0
  60. package/dist/markdown.js +225 -0
  61. package/dist/meta.json +7575 -0
  62. package/dist/root-inputs.json +86 -0
  63. package/dist/seekbuddy-card.js +7 -0
  64. package/dist/seekbuddy-empty.js +8 -0
  65. package/dist/seekbuddy-internal/DangerButton.js +7 -0
  66. package/dist/seekbuddy-internal/Mark.js +7 -0
  67. package/dist/seekbuddy-internal/Message.js +10 -0
  68. package/dist/seekbuddy-internal/Pagination.js +9 -0
  69. package/dist/seekbuddy-internal/StatusBadge.js +7 -0
  70. package/dist/seekbuddy-internal/SubtleButton.js +7 -0
  71. package/dist/seekbuddy-internal/Switch.js +7 -0
  72. package/dist/seekbuddy-internal/Upload.js +7 -0
  73. package/dist/seekbuddy-internal/date/Calendar.js +8 -0
  74. package/dist/seekbuddy-internal/date/DatePicker.js +9 -0
  75. package/dist/seekbuddy-internal/date/DateRangePicker.js +9 -0
  76. package/dist/seekbuddy-internal/date/TimePicker.js +8 -0
  77. package/dist/seekbuddy-internal/date/fields.js +16 -0
  78. package/dist/seekbuddy-internal/qr/QrCode.js +7 -0
  79. package/dist/seekbuddy-spinner.js +7 -0
  80. package/dist/seekbuddy-tabs.js +7 -0
  81. package/dist/seekbuddy-timeline.js +8 -0
  82. package/dist/seekbuddy.js +89 -0
  83. package/dist/theme-bootstrap.js +13 -0
  84. package/dist/theme.js +37 -0
  85. package/dist/tokens.css +974 -0
  86. package/dist/tokens.css.d.ts +2 -0
  87. package/dist/types/AnimatedRows.d.ts +45 -0
  88. package/dist/types/Button.d.ts +18 -0
  89. package/dist/types/Checkbox.d.ts +19 -0
  90. package/dist/types/CodeFileIcon.d.ts +11 -0
  91. package/dist/types/CodeToolbar.d.ts +29 -0
  92. package/dist/types/CommandText.d.ts +15 -0
  93. package/dist/types/ConfigField.d.ts +32 -0
  94. package/dist/types/ConnectionIndicator.d.ts +25 -0
  95. package/dist/types/DetailDocument.d.ts +77 -0
  96. package/dist/types/DiffBlock.d.ts +51 -0
  97. package/dist/types/DisclosureRow.d.ts +37 -0
  98. package/dist/types/DraggableImage.d.ts +18 -0
  99. package/dist/types/FileTypeIcon.d.ts +42 -0
  100. package/dist/types/FoldToggle.d.ts +19 -0
  101. package/dist/types/HoverCard.d.ts +44 -0
  102. package/dist/types/HoverCardGroup.d.ts +24 -0
  103. package/dist/types/ImageLightbox.d.ts +29 -0
  104. package/dist/types/ImagePreview.d.ts +11 -0
  105. package/dist/types/InlineEditor.d.ts +22 -0
  106. package/dist/types/Input.d.ts +11 -0
  107. package/dist/types/JsonTree.d.ts +58 -0
  108. package/dist/types/LinkIcon.d.ts +33 -0
  109. package/dist/types/Menu.d.ts +163 -0
  110. package/dist/types/MenuGroup.d.ts +21 -0
  111. package/dist/types/MenuSurface.d.ts +24 -0
  112. package/dist/types/Modal.d.ts +43 -0
  113. package/dist/types/PermissionIcon.d.ts +50 -0
  114. package/dist/types/Pill.d.ts +12 -0
  115. package/dist/types/QuotePreview.d.ts +23 -0
  116. package/dist/types/ReadBlock.d.ts +47 -0
  117. package/dist/types/ReferenceIcon.d.ts +20 -0
  118. package/dist/types/RiskConfirmation.d.ts +19 -0
  119. package/dist/types/SearchBlock.d.ts +71 -0
  120. package/dist/types/SegmentedControl.d.ts +34 -0
  121. package/dist/types/SegmentedTabs.d.ts +27 -0
  122. package/dist/types/ShortcutKeys.d.ts +10 -0
  123. package/dist/types/SiteGlyph.d.ts +24 -0
  124. package/dist/types/StateDot.d.ts +19 -0
  125. package/dist/types/Switch.d.ts +19 -0
  126. package/dist/types/Tag.d.ts +31 -0
  127. package/dist/types/TerminalBlock.d.ts +85 -0
  128. package/dist/types/TextShimmer.d.ts +22 -0
  129. package/dist/types/Toast.d.ts +48 -0
  130. package/dist/types/Tooltip.d.ts +69 -0
  131. package/dist/types/UserMessageBubble.d.ts +10 -0
  132. package/dist/types/WebBlock.d.ts +60 -0
  133. package/dist/types/ZoomControls.d.ts +26 -0
  134. package/dist/types/ansi.d.ts +16 -0
  135. package/dist/types/blocks.d.ts +21 -0
  136. package/dist/types/clipboard.d.ts +8 -0
  137. package/dist/types/code-file-icon-artwork.d.ts +53 -0
  138. package/dist/types/code-file-types.d.ts +29 -0
  139. package/dist/types/code-highlighting.d.ts +11 -0
  140. package/dist/types/css-modules.d.ts +6 -0
  141. package/dist/types/darwin-desktop.d.ts +8 -0
  142. package/dist/types/document-zoom.d.ts +16 -0
  143. package/dist/types/file-drag-actions.d.ts +36 -0
  144. package/dist/types/file-size.d.ts +7 -0
  145. package/dist/types/focus.d.ts +15 -0
  146. package/dist/types/guide-artwork.d.ts +14 -0
  147. package/dist/types/head-tail-cap.d.ts +22 -0
  148. package/dist/types/icons/artwork.d.ts +421 -0
  149. package/dist/types/icons/index.d.ts +397 -0
  150. package/dist/types/icons/props.d.ts +8 -0
  151. package/dist/types/icons/shared-artwork.d.ts +36 -0
  152. package/dist/types/icons.d.ts +6 -0
  153. package/dist/types/image-drag.d.ts +16 -0
  154. package/dist/types/index.d.ts +71 -0
  155. package/dist/types/input-modality.d.ts +18 -0
  156. package/dist/types/keyboard-composition.d.ts +10 -0
  157. package/dist/types/markdown/CodeBlock.d.ts +34 -0
  158. package/dist/types/markdown/JsonBlock.d.ts +7 -0
  159. package/dist/types/markdown/MarkdownDelegate.d.ts +68 -0
  160. package/dist/types/markdown/MarkdownText.d.ts +54 -0
  161. package/dist/types/markdown/cjkFriendlyStrong.d.ts +8 -0
  162. package/dist/types/markdown/file-link.d.ts +22 -0
  163. package/dist/types/markdown/highlight.d.ts +169 -0
  164. package/dist/types/markdown/incremental.d.ts +79 -0
  165. package/dist/types/markdown/katex.d.ts +18 -0
  166. package/dist/types/markdown/local-image-syntax.d.ts +9 -0
  167. package/dist/types/markdown/mathCompatibility.d.ts +10 -0
  168. package/dist/types/markdown/parse.d.ts +24 -0
  169. package/dist/types/markdown/plain-text.d.ts +21 -0
  170. package/dist/types/markdown/quote-text.d.ts +7 -0
  171. package/dist/types/markdown/render.d.ts +145 -0
  172. package/dist/types/markdown/useViewportHighlighting.d.ts +10 -0
  173. package/dist/types/markdown/windows-path-destinations.d.ts +10 -0
  174. package/dist/types/markdown.d.ts +12 -0
  175. package/dist/types/overlay-top-margin.d.ts +14 -0
  176. package/dist/types/plugin-artwork.d.ts +16 -0
  177. package/dist/types/pointer-grace.d.ts +21 -0
  178. package/dist/types/rank-by-name.d.ts +21 -0
  179. package/dist/types/relative-time.d.ts +22 -0
  180. package/dist/types/seekbuddy/Card.d.ts +28 -0
  181. package/dist/types/seekbuddy/DangerButton.d.ts +31 -0
  182. package/dist/types/seekbuddy/Empty.d.ts +34 -0
  183. package/dist/types/seekbuddy/Mark.d.ts +27 -0
  184. package/dist/types/seekbuddy/Message.d.ts +52 -0
  185. package/dist/types/seekbuddy/Pagination.d.ts +66 -0
  186. package/dist/types/seekbuddy/Spinner.d.ts +20 -0
  187. package/dist/types/seekbuddy/StatusBadge.d.ts +33 -0
  188. package/dist/types/seekbuddy/SubtleButton.d.ts +30 -0
  189. package/dist/types/seekbuddy/Switch.d.ts +36 -0
  190. package/dist/types/seekbuddy/Tabs.d.ts +49 -0
  191. package/dist/types/seekbuddy/Timeline.d.ts +42 -0
  192. package/dist/types/seekbuddy/Upload.d.ts +101 -0
  193. package/dist/types/seekbuddy/date/Calendar.d.ts +94 -0
  194. package/dist/types/seekbuddy/date/DatePicker.d.ts +29 -0
  195. package/dist/types/seekbuddy/date/DateRangePicker.d.ts +41 -0
  196. package/dist/types/seekbuddy/date/TimePicker.d.ts +35 -0
  197. package/dist/types/seekbuddy/date/date.d.ts +79 -0
  198. package/dist/types/seekbuddy/date/fields.d.ts +45 -0
  199. package/dist/types/seekbuddy/index.d.ts +49 -0
  200. package/dist/types/seekbuddy/qr/QrCode.d.ts +37 -0
  201. package/dist/types/seekbuddy/qr/qr.d.ts +38 -0
  202. package/dist/types/theme-bootstrap.d.ts +3 -0
  203. package/dist/types/theme-core.d.ts +14 -0
  204. package/dist/types/theme.d.ts +4 -0
  205. package/dist/types/tooltip-placement.d.ts +34 -0
  206. package/dist/types/use-clipboard-copy.d.ts +13 -0
  207. package/dist/types/useAnchoredMaxHeight.d.ts +13 -0
  208. package/dist/types/useAnchoredPosition.d.ts +35 -0
  209. package/dist/types/useDismissOnOutsidePointer.d.ts +10 -0
  210. package/dist/types/useModalLayer.d.ts +26 -0
  211. package/dist/types/useRowDragPreview.d.ts +19 -0
  212. package/dist/types/user-text.d.ts +31 -0
  213. package/package.json +151 -4
package/dist/blocks.js ADDED
@@ -0,0 +1,1617 @@
1
+ import {
2
+ Menu,
3
+ Pill,
4
+ useClipboardCopy
5
+ } from "./chunks/chunk-YOBY6PSL.js";
6
+ import {
7
+ CodeCard_module_default,
8
+ CodeToolbar,
9
+ FileTypeIcon,
10
+ LinkIconMedium,
11
+ LinkIconRegular,
12
+ MarkdownText,
13
+ classifyFileType,
14
+ classifyLinkPath,
15
+ fileExtension,
16
+ grammarLoadCount,
17
+ highlightLines,
18
+ subscribeGrammarLoaded,
19
+ useViewportHighlighting
20
+ } from "./chunks/chunk-OCAQFVT3.js";
21
+ import {
22
+ StateDot,
23
+ writeClipboard
24
+ } from "./chunks/chunk-JA3XDLIA.js";
25
+ import {
26
+ IconCheckOutlineRegular,
27
+ IconCopyOutlineRegular,
28
+ IconWrapLinesOutlineRegular
29
+ } from "./chunks/chunk-XW4L4ZGL.js";
30
+ import "./chunks/chunk-ZA47FP7C.js";
31
+
32
+ // src/JsonTree.tsx
33
+ import clsx from "clsx";
34
+ import { useCallback, useEffect, useId, useLayoutEffect, useRef, useState, useSyncExternalStore } from "react";
35
+
36
+ // .build/css/JsonTree.module.mjs
37
+ var id = "@seekbuddy/dsh-ui/JsonTree.module.css";
38
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id + '"]')) {
39
+ const element = document.createElement("style");
40
+ element.setAttribute("data-dsh-ui-primitives", id);
41
+ element.textContent = '.vOc5Ca_root{--json-tree-property:#881391;--json-tree-string:#c41a16;--json-tree-number:#1c00cf;--json-tree-keyword:#1c00cf;--json-tree-punctuation:#202124;--json-tree-icon:#5f6368;--json-tree-hover:#3c40430a;min-width:0;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-1);font:12px/16px var(--ds-font-family-code);overscroll-behavior-x:contain;overscroll-behavior-y:auto;position:relative;overflow:auto}body[data-ds-dark-theme] .vOc5Ca_root{--json-tree-property:#5db0d7;--json-tree-string:#f28b82;--json-tree-number:#99c8ff;--json-tree-keyword:#99c8ff;--json-tree-punctuation:#e8eaed;--json-tree-icon:#9aa0a6;--json-tree-hover:#e8eaed0d}.vOc5Ca_container{box-sizing:border-box;white-space:pre;width:100%;min-width:0;margin:0;padding:6px 8px 8px}.vOc5Ca_expandedTopLevel{box-sizing:border-box;width:100%;min-width:0;padding:6px 8px 8px 14px}.vOc5Ca_expandedTopLevel:has(>.vOc5Ca_topLevelBracket[data-json-root-row][data-json-copy-active]){background:var(--json-tree-hover)}@media (hover:hover){.vOc5Ca_expandedTopLevel:has(>.vOc5Ca_topLevelBracket[data-json-root-row]:hover){background:var(--json-tree-hover)}}.vOc5Ca_expandedTopLevelContainer{padding:0}.vOc5Ca_row.vOc5Ca_topLevelBracket{margin-left:0;padding-left:0}.vOc5Ca_children{margin:0;padding:0;list-style:none}.vOc5Ca_row{box-sizing:border-box;overflow-wrap:anywhere;white-space:pre-wrap;min-width:0;min-height:16px;margin:0;padding:0 0 0 10px;list-style:none;position:relative}.vOc5Ca_row:not(.vOc5Ca_topLevelBracket)[data-json-copy-active]:after,.vOc5Ca_row:has(>.vOc5Ca_expander:focus-visible):after{z-index:0;height:var(--json-tree-row-height,16px);background:var(--json-tree-hover);content:"";pointer-events:none;position:absolute;top:0;left:0;right:0}@media (hover:hover){.vOc5Ca_row:not(.vOc5Ca_topLevelBracket):hover:not(:has(.vOc5Ca_row:hover)):after{z-index:0;height:var(--json-tree-row-height,16px);background:var(--json-tree-hover);content:"";pointer-events:none;position:absolute;top:0;left:0;right:0}}.vOc5Ca_row>span:not(.vOc5Ca_expander,.vOc5Ca_copySlot){z-index:1;position:relative}.vOc5Ca_label{color:var(--json-tree-property);margin-right:3px;font-weight:400}.vOc5Ca_clickableLabel{cursor:pointer}.vOc5Ca_stringValue{color:var(--json-tree-string)}.vOc5Ca_stringField{z-index:1;display:flow-root;position:relative}.vOc5Ca_stringText{max-height:calc(var(--json-tree-collapsed-lines) * 16px);text-indent:-12px;word-break:break-all;padding-left:12px;display:block;overflow:hidden}.vOc5Ca_stringRaw{color:var(--dsw-alias-label-primary);font:inherit;overflow-wrap:normal;white-space:pre;word-break:normal;margin:4px 0 0 12px;overflow:auto}.vOc5Ca_stringActions{justify-content:flex-end;align-items:center;gap:4px;width:fit-content;height:16px;display:flex;position:absolute;top:1px;right:4px}.vOc5Ca_stringRaw[data-wrap=true]{overflow-wrap:anywhere;white-space:pre-wrap;word-break:break-all}.vOc5Ca_stringActions>.vOc5Ca_copySlot{opacity:1;pointer-events:auto}.vOc5Ca_stringToggleSlot{float:right;height:calc(var(--json-tree-collapsed-lines) * 16px);shape-outside:inset(calc((var(--json-tree-collapsed-lines) - 1) * 16px) 0 0);pointer-events:none;align-items:flex-end;margin-left:2px;display:flex}.vOc5Ca_stringToggle{color:var(--dsw-alias-label-secondary);font:inherit;text-indent:0;white-space:nowrap;cursor:pointer;pointer-events:auto;background:0 0;border:0;align-items:baseline;gap:2px;margin:0;padding:0;display:inline-flex}@media (hover:hover){.vOc5Ca_stringToggle:hover{color:var(--dsw-alias-label-primary)}}.vOc5Ca_stringToggle:focus-visible{outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:1px}.vOc5Ca_row:has(>.vOc5Ca_stringField){--json-tree-row-height:100%}.vOc5Ca_summary{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.vOc5Ca_numberValue{color:var(--json-tree-number)}.vOc5Ca_keywordValue{color:var(--json-tree-keyword)}.vOc5Ca_otherValue{color:var(--dsw-alias-label-secondary)}.vOc5Ca_punctuation,.vOc5Ca_preview,.vOc5Ca_previewProperty{color:var(--json-tree-punctuation)}.vOc5Ca_previewEllipsis{color:var(--dsw-alias-label-tertiary)}.vOc5Ca_copySlot{opacity:0;pointer-events:none;width:20px;height:16px;display:inline-flex}.vOc5Ca_row>.vOc5Ca_copySlot{z-index:2;position:absolute;top:0;right:0}.vOc5Ca_row:has(>.vOc5Ca_stringField)>.vOc5Ca_copySlot{top:auto;bottom:0}.vOc5Ca_row:has(>.vOc5Ca_copySlot)>.vOc5Ca_stringField .vOc5Ca_stringToggleSlot{padding-right:24px}.vOc5Ca_row[data-json-copy-active]>.vOc5Ca_copySlot,.vOc5Ca_copySlot:focus-within{opacity:1;pointer-events:auto}@media (hover:hover){.vOc5Ca_row:hover:not(:has(.vOc5Ca_row:hover))>.vOc5Ca_copySlot{opacity:1;pointer-events:auto}}.vOc5Ca_actionButton{box-sizing:border-box;border-radius:var(--dsw-radius-xs);width:20px;height:16px;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:0;justify-content:center;align-items:center;margin:0;padding:0;display:inline-flex}@media (hover:hover){.vOc5Ca_actionButton:hover{color:var(--dsw-alias-label-primary)}}.vOc5Ca_actionButton[aria-pressed=true]{color:var(--dsw-alias-state-business-primary)}.vOc5Ca_actionButton:focus-visible{outline:1px solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-1px}.vOc5Ca_actionButton[data-state=failed]{color:var(--dsw-alias-state-error-primary)}.vOc5Ca_expander{z-index:2;box-sizing:border-box;width:8px;height:16px;color:var(--json-tree-icon);cursor:pointer;user-select:none;justify-content:flex-start;align-items:center;margin:0;display:inline-flex;position:absolute;top:0;left:0}.vOc5Ca_expander:before{content:"";transform-origin:33.333%;border-top:4px solid #0000;border-bottom:4px solid #0000;border-left:6px solid;width:0;height:0;transform:scale(.75)}.vOc5Ca_collapseIcon:before{transform:rotate(90deg)scale(.75)}@media (hover:hover){.vOc5Ca_expander:hover{color:var(--dsw-alias-label-primary)}}.vOc5Ca_expander:focus-visible{outline:none}.vOc5Ca_collapsedContent{color:var(--json-tree-punctuation);cursor:pointer;margin:0 1px}.vOc5Ca_collapsedContent:after{content:"\u2026"}@media (hover:none){.vOc5Ca_copySlot{opacity:1;pointer-events:auto}.vOc5Ca_row:has(>.vOc5Ca_copySlot){padding-right:24px}}';
42
+ document.head.appendChild(element);
43
+ }
44
+ var JsonTree_module_default = { "container": "vOc5Ca_container", "collapseIcon": "vOc5Ca_collapseIcon", "row": "vOc5Ca_row", "stringToggle": "vOc5Ca_stringToggle", "previewProperty": "vOc5Ca_previewProperty", "expander": "vOc5Ca_expander", "label": "vOc5Ca_label", "clickableLabel": "vOc5Ca_clickableLabel", "summary": "vOc5Ca_summary", "numberValue": "vOc5Ca_numberValue", "actionButton": "vOc5Ca_actionButton", "copySlot": "vOc5Ca_copySlot", "expandedTopLevelContainer": "vOc5Ca_expandedTopLevelContainer", "expandedTopLevel": "vOc5Ca_expandedTopLevel", "keywordValue": "vOc5Ca_keywordValue", "preview": "vOc5Ca_preview", "stringRaw": "vOc5Ca_stringRaw", "topLevelBracket": "vOc5Ca_topLevelBracket", "collapsedContent": "vOc5Ca_collapsedContent", "root": "vOc5Ca_root", "stringText": "vOc5Ca_stringText", "children": "vOc5Ca_children", "stringValue": "vOc5Ca_stringValue", "stringActions": "vOc5Ca_stringActions", "punctuation": "vOc5Ca_punctuation", "stringToggleSlot": "vOc5Ca_stringToggleSlot", "stringField": "vOc5Ca_stringField", "previewEllipsis": "vOc5Ca_previewEllipsis", "otherValue": "vOc5Ca_otherValue" };
45
+
46
+ // src/JsonTree.tsx
47
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
48
+ var OBJECT_PREVIEW_LIMIT = 4;
49
+ var ARRAY_PREVIEW_LIMIT = 5;
50
+ var PREVIEW_DEPTH_LIMIT = 2;
51
+ function valueCopyMenuItems(labels) {
52
+ return [
53
+ { id: "value", label: labels.copyValue },
54
+ { id: "json", label: labels.copyJson },
55
+ { id: "path", label: labels.copyPath }
56
+ ];
57
+ }
58
+ function objectCopyMenuItems(labels) {
59
+ return [
60
+ { id: "prettyJson", label: labels.copyPrettyJson },
61
+ { id: "json", label: labels.copyCompactJson },
62
+ { id: "path", label: labels.copyPath }
63
+ ];
64
+ }
65
+ function createCopyStore() {
66
+ let current;
67
+ const listeners = /* @__PURE__ */ new Map();
68
+ return {
69
+ get: () => current,
70
+ set(next) {
71
+ const previous = current?.id;
72
+ current = next;
73
+ for (const id8 of /* @__PURE__ */ new Set([previous, next?.id])) {
74
+ if (id8 === void 0) continue;
75
+ for (const listener of listeners.get(id8) ?? []) listener();
76
+ }
77
+ },
78
+ subscribe(id8, listener) {
79
+ let row = listeners.get(id8);
80
+ if (row === void 0) listeners.set(id8, row = /* @__PURE__ */ new Set());
81
+ row.add(listener);
82
+ return () => {
83
+ row.delete(listener);
84
+ if (row.size === 0) listeners.delete(id8);
85
+ };
86
+ }
87
+ };
88
+ }
89
+ function JsonCopyAction({
90
+ store,
91
+ target,
92
+ persistent,
93
+ labels,
94
+ onCopy,
95
+ onClose
96
+ }) {
97
+ const id8 = pathId(target.path);
98
+ const subscribe = useCallback((listener) => store.subscribe(id8, listener), [id8, store]);
99
+ const getSnapshot = () => {
100
+ const current = store.get();
101
+ return current?.id === id8 ? current : void 0;
102
+ };
103
+ const snapshot = useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
104
+ const buttonRef = useRef(null);
105
+ const state = snapshot?.state ?? "idle";
106
+ const object = typeof target.value === "object" && target.value !== null;
107
+ const copyTitle = state === "copied" ? labels.copied : state === "failed" ? labels.copyFailed : object ? labels.copyPrettyJson : labels.copyValue;
108
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.copySlot, children: (persistent || snapshot !== void 0) && /* @__PURE__ */ jsx(
109
+ Menu,
110
+ {
111
+ open: snapshot?.menuOpen === true,
112
+ compact: true,
113
+ portal: true,
114
+ align: "end",
115
+ anchor: /* @__PURE__ */ jsx(
116
+ "button",
117
+ {
118
+ ref: buttonRef,
119
+ type: "button",
120
+ className: JsonTree_module_default.actionButton,
121
+ "data-json-copy-button": true,
122
+ "data-state": state,
123
+ "aria-label": copyTitle,
124
+ title: labels.copyButtonTitle(copyTitle),
125
+ onClick: () => void onCopy(target, object ? "prettyJson" : "value"),
126
+ onContextMenu: (event) => {
127
+ event.preventDefault();
128
+ event.stopPropagation();
129
+ store.set({ id: id8, target, state, menuOpen: true });
130
+ },
131
+ children: state === "copied" ? /* @__PURE__ */ jsx(IconCheckOutlineRegular, { size: 12 }) : /* @__PURE__ */ jsx(IconCopyOutlineRegular, { size: 12 })
132
+ }
133
+ ),
134
+ items: object ? objectCopyMenuItems(labels) : valueCopyMenuItems(labels),
135
+ onSelect: (mode) => {
136
+ void onCopy(target, mode);
137
+ },
138
+ onClose,
139
+ getAnchorRect: () => buttonRef.current.getBoundingClientRect()
140
+ }
141
+ ) });
142
+ }
143
+ function isExpandableValue(value) {
144
+ return typeof value === "object" && value !== null && !(value instanceof Date);
145
+ }
146
+ function entriesOf(value) {
147
+ if (Array.isArray(value)) {
148
+ return value.map((item, index) => [String(index), item]);
149
+ }
150
+ return Object.keys(value).map((key) => [key, value[key]]);
151
+ }
152
+ function bracketOf(value) {
153
+ return Array.isArray(value) ? ["[", "]"] : ["{", "}"];
154
+ }
155
+ function previewPrimitive(value) {
156
+ if (value === null) return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.keywordValue, children: "null" });
157
+ if (typeof value === "string") {
158
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.stringValue, children: JSON.stringify(value) });
159
+ }
160
+ if (typeof value === "number") {
161
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.numberValue, children: String(value) });
162
+ }
163
+ if (typeof value === "boolean") {
164
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.keywordValue, children: String(value) });
165
+ }
166
+ if (typeof value === "bigint") {
167
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: value.toString() });
168
+ }
169
+ if (typeof value === "undefined") {
170
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: "undefined" });
171
+ }
172
+ if (typeof value === "symbol") {
173
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: value.description ?? "Symbol" });
174
+ }
175
+ if (typeof value === "function") {
176
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: value.name || "Function" });
177
+ }
178
+ return null;
179
+ }
180
+ function previewValue(value, depth) {
181
+ if (!isExpandableValue(value)) return previewPrimitive(value);
182
+ const array = Array.isArray(value);
183
+ const entries = entriesOf(value);
184
+ const limit = array ? ARRAY_PREVIEW_LIMIT : OBJECT_PREVIEW_LIMIT;
185
+ const visible = entries.slice(0, limit);
186
+ const [open, close] = bracketOf(value);
187
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
188
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: open }),
189
+ depth >= PREVIEW_DEPTH_LIMIT ? /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.previewEllipsis, children: "\u2026" }) : visible.map(([key, item], index) => /* @__PURE__ */ jsxs("span", { children: [
190
+ index > 0 && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: ", " }),
191
+ !array && /* @__PURE__ */ jsxs(Fragment, { children: [
192
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.previewProperty, children: key }),
193
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: ": " })
194
+ ] }),
195
+ previewValue(item, depth + 1)
196
+ ] }, key)),
197
+ depth < PREVIEW_DEPTH_LIMIT && entries.length > limit && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.previewEllipsis, children: ", \u2026" }),
198
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: close })
199
+ ] });
200
+ }
201
+ function primitiveValue(value) {
202
+ if (value === null) return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.keywordValue, children: "null" });
203
+ if (typeof value === "string") {
204
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.stringValue, children: JSON.stringify(value) });
205
+ }
206
+ if (typeof value === "boolean") {
207
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.keywordValue, children: String(value) });
208
+ }
209
+ if (typeof value === "number") {
210
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.numberValue, children: String(value) });
211
+ }
212
+ if (typeof value === "bigint") {
213
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.numberValue, children: `${value.toString()}n` });
214
+ }
215
+ if (value instanceof Date) {
216
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: value.toISOString() });
217
+ }
218
+ if (typeof value === "function") {
219
+ return /* @__PURE__ */ jsxs("span", { className: JsonTree_module_default.otherValue, children: [
220
+ "function() ",
221
+ "{ }"
222
+ ] });
223
+ }
224
+ if (typeof value === "undefined") {
225
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: "undefined" });
226
+ }
227
+ return /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.otherValue, children: value.toString() });
228
+ }
229
+ function fieldText(field) {
230
+ return field === "" ? '""' : field;
231
+ }
232
+ function pathId(path) {
233
+ return path.map((part) => typeof part === "number" ? `n${String(part)}` : `s${String(part.length)}:${part}`).join("/");
234
+ }
235
+ function claimFocus(button) {
236
+ button.focus();
237
+ }
238
+ function moveFocus(button, direction) {
239
+ const tree = button.closest('[role="tree"]');
240
+ if (tree === null) return;
241
+ const expanders = Array.from(tree.querySelectorAll("[data-json-expander]"));
242
+ const current = expanders.indexOf(button);
243
+ if (current < 0 || expanders.length === 0) return;
244
+ const next = (current + direction + expanders.length) % expanders.length;
245
+ const nextExpander = expanders[next];
246
+ if (nextExpander !== void 0) claimFocus(nextExpander);
247
+ }
248
+ function NodeField({
249
+ field,
250
+ expandable,
251
+ onToggle
252
+ }) {
253
+ if (field === void 0) return null;
254
+ return /* @__PURE__ */ jsxs("span", { className: clsx(JsonTree_module_default.label, expandable && JsonTree_module_default.clickableLabel), onClick: expandable ? onToggle : void 0, children: [
255
+ fieldText(field),
256
+ ":"
257
+ ] });
258
+ }
259
+ function JsonString({
260
+ collapsedStringLines,
261
+ stringWrapping,
262
+ field,
263
+ labels,
264
+ lastElement,
265
+ renderCopy,
266
+ value
267
+ }) {
268
+ const contentsId = useId();
269
+ const contentRef = useRef(null);
270
+ const rawRef = useRef(null);
271
+ const [expanded, setExpanded] = useState(false);
272
+ const [wrapped, setWrapped] = useState(false);
273
+ const [truncated, setTruncated] = useState(false);
274
+ useLayoutEffect(() => {
275
+ if (expanded) return;
276
+ const content = contentRef.current;
277
+ const measure = () => {
278
+ const lineHeight = Number.parseFloat(getComputedStyle(content).lineHeight);
279
+ setTruncated(content.scrollHeight > lineHeight * collapsedStringLines);
280
+ };
281
+ measure();
282
+ if (typeof ResizeObserver === "undefined") return;
283
+ const observer = new ResizeObserver(measure);
284
+ observer.observe(content);
285
+ return () => {
286
+ observer.disconnect();
287
+ };
288
+ }, [collapsedStringLines, expanded, field, lastElement, value]);
289
+ useLayoutEffect(() => {
290
+ if (!expanded) return;
291
+ const raw = rawRef.current;
292
+ const clips = [];
293
+ const tree = raw.closest(`.${JsonTree_module_default.root}`);
294
+ for (let parent = tree.parentElement; parent !== null; parent = parent.parentElement) {
295
+ if (/auto|scroll|hidden|clip/.test(getComputedStyle(parent).overflowY)) clips.push(parent);
296
+ }
297
+ const measure = () => {
298
+ let top = 0;
299
+ let bottom = window.innerHeight;
300
+ for (const clip of clips) {
301
+ const rect = clip.getBoundingClientRect();
302
+ const style = getComputedStyle(clip);
303
+ top = Math.max(top, rect.top + clip.clientTop);
304
+ bottom = Math.min(
305
+ bottom,
306
+ rect.top + clip.clientTop + clip.clientHeight - Number.parseFloat(style.paddingBottom)
307
+ );
308
+ }
309
+ const available = bottom - Math.max(top, raw.getBoundingClientRect().top);
310
+ raw.style.maxHeight = `${Math.max(16, available - 4)}px`;
311
+ };
312
+ measure();
313
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
314
+ observer?.observe(raw);
315
+ for (const clip of clips) observer?.observe(clip);
316
+ window.addEventListener("resize", measure);
317
+ window.addEventListener("scroll", measure, true);
318
+ return () => {
319
+ observer?.disconnect();
320
+ window.removeEventListener("resize", measure);
321
+ window.removeEventListener("scroll", measure, true);
322
+ };
323
+ }, [expanded, value]);
324
+ if (expanded) {
325
+ const fieldId = `${contentsId}-field`;
326
+ return /* @__PURE__ */ jsxs("div", { className: JsonTree_module_default.stringField, "data-expanded": true, children: [
327
+ field !== void 0 && /* @__PURE__ */ jsxs("span", { id: fieldId, className: JsonTree_module_default.label, children: [
328
+ fieldText(field),
329
+ ":"
330
+ ] }),
331
+ /* @__PURE__ */ jsx(
332
+ "pre",
333
+ {
334
+ ref: rawRef,
335
+ id: contentsId,
336
+ className: JsonTree_module_default.stringRaw,
337
+ "data-wrap": wrapped,
338
+ tabIndex: 0,
339
+ "aria-labelledby": field === void 0 ? void 0 : fieldId,
340
+ children: value
341
+ }
342
+ ),
343
+ !lastElement && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: "," }),
344
+ /* @__PURE__ */ jsxs("div", { className: JsonTree_module_default.stringActions, children: [
345
+ stringWrapping !== void 0 && /* @__PURE__ */ jsx(
346
+ "button",
347
+ {
348
+ type: "button",
349
+ className: JsonTree_module_default.actionButton,
350
+ "aria-label": stringWrapping.label,
351
+ title: stringWrapping.label,
352
+ "aria-pressed": wrapped,
353
+ "aria-controls": contentsId,
354
+ onClick: () => {
355
+ const next = !wrapped;
356
+ setWrapped(next);
357
+ stringWrapping.setDefault(next);
358
+ },
359
+ children: /* @__PURE__ */ jsx(IconWrapLinesOutlineRegular, { size: 12 })
360
+ }
361
+ ),
362
+ /* @__PURE__ */ jsx(
363
+ "button",
364
+ {
365
+ type: "button",
366
+ className: JsonTree_module_default.actionButton,
367
+ "aria-label": labels.collapseNode,
368
+ title: labels.collapseNode,
369
+ "aria-expanded": true,
370
+ "aria-controls": contentsId,
371
+ onClick: () => {
372
+ setExpanded(false);
373
+ },
374
+ children: /* @__PURE__ */ jsx("svg", { width: "12", height: "12", viewBox: "0 0 16 16", fill: "none", stroke: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M9.5 1.5V6.5H14.5M1.5 9.5H6.5V14.5" }) })
375
+ }
376
+ ),
377
+ renderCopy?.(true)
378
+ ] })
379
+ ] });
380
+ }
381
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
382
+ renderCopy?.(),
383
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.stringField, "data-expanded": expanded, children: /* @__PURE__ */ jsxs("span", { ref: contentRef, id: contentsId, className: JsonTree_module_default.stringText, children: [
384
+ truncated && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.stringToggleSlot, children: /* @__PURE__ */ jsxs(
385
+ "button",
386
+ {
387
+ type: "button",
388
+ className: JsonTree_module_default.stringToggle,
389
+ "aria-label": labels.expandNode,
390
+ "aria-expanded": false,
391
+ "aria-controls": contentsId,
392
+ onClick: () => {
393
+ setWrapped(stringWrapping?.getDefault() ?? false);
394
+ setExpanded(true);
395
+ },
396
+ children: [
397
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", children: "\u2026" }),
398
+ labels.expandNode
399
+ ]
400
+ }
401
+ ) }),
402
+ field !== void 0 && /* @__PURE__ */ jsxs("span", { className: JsonTree_module_default.label, children: [
403
+ fieldText(field),
404
+ ":"
405
+ ] }),
406
+ primitiveValue(value),
407
+ !lastElement && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: "," })
408
+ ] }) })
409
+ ] });
410
+ }
411
+ function JsonTreeNode({
412
+ collapsedStringLines,
413
+ stringWrapping,
414
+ field,
415
+ initialExpanded,
416
+ labels,
417
+ lastElement,
418
+ onClaimTabStop,
419
+ onRowHover,
420
+ path,
421
+ renderCopy,
422
+ tabStopId,
423
+ value
424
+ }) {
425
+ const contentsId = useId();
426
+ const expanderRef = useRef(null);
427
+ const [expanded, setExpanded] = useState(initialExpanded);
428
+ const nodeId = pathId(path);
429
+ const container = isExpandableValue(value);
430
+ const entries = container ? entriesOf(value) : [];
431
+ const expandable = entries.length > 0;
432
+ const toggle = () => {
433
+ setExpanded((current) => !current);
434
+ claimFocus(expanderRef.current);
435
+ };
436
+ const onExpanderKeyDown = (event) => {
437
+ if (event.key === "ArrowRight" || event.key === "ArrowLeft") {
438
+ event.preventDefault();
439
+ setExpanded(event.key === "ArrowRight");
440
+ return;
441
+ }
442
+ if (event.key === "ArrowUp" || event.key === "ArrowDown") {
443
+ event.preventDefault();
444
+ moveFocus(event.currentTarget, event.key === "ArrowUp" ? -1 : 1);
445
+ }
446
+ };
447
+ const row = (children, ariaExpanded) => /* @__PURE__ */ jsxs(
448
+ "div",
449
+ {
450
+ className: JsonTree_module_default.row,
451
+ role: "treeitem",
452
+ "aria-expanded": ariaExpanded,
453
+ onMouseOver: (event) => {
454
+ event.stopPropagation();
455
+ onRowHover(event.currentTarget, { path, value });
456
+ },
457
+ children: [
458
+ typeof value !== "string" && renderCopy?.({ path, value }),
459
+ children
460
+ ]
461
+ }
462
+ );
463
+ if (typeof value === "string") {
464
+ return row(
465
+ /* @__PURE__ */ jsx(
466
+ JsonString,
467
+ {
468
+ collapsedStringLines,
469
+ stringWrapping,
470
+ field,
471
+ value,
472
+ labels,
473
+ lastElement,
474
+ renderCopy: renderCopy === void 0 ? void 0 : (persistent) => renderCopy({ path, value }, persistent)
475
+ }
476
+ )
477
+ );
478
+ }
479
+ if (!container) {
480
+ return row(
481
+ /* @__PURE__ */ jsxs(Fragment, { children: [
482
+ /* @__PURE__ */ jsx(NodeField, { field, expandable: false, onToggle: toggle }),
483
+ primitiveValue(value),
484
+ !lastElement && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: "," })
485
+ ] })
486
+ );
487
+ }
488
+ const [open, close] = bracketOf(value);
489
+ if (!expandable) {
490
+ return row(
491
+ /* @__PURE__ */ jsxs(Fragment, { children: [
492
+ /* @__PURE__ */ jsx(NodeField, { field, expandable: false, onToggle: toggle }),
493
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: open }),
494
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: close }),
495
+ !lastElement && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: "," })
496
+ ] })
497
+ );
498
+ }
499
+ return row(
500
+ /* @__PURE__ */ jsxs(Fragment, { children: [
501
+ /* @__PURE__ */ jsx(
502
+ "span",
503
+ {
504
+ ref: expanderRef,
505
+ className: clsx(JsonTree_module_default.expander, expanded ? JsonTree_module_default.collapseIcon : JsonTree_module_default.expandIcon),
506
+ "data-json-expander": true,
507
+ role: "button",
508
+ "aria-label": expanded ? labels.collapseNode : labels.expandNode,
509
+ "aria-expanded": expanded,
510
+ "aria-controls": expanded ? contentsId : void 0,
511
+ tabIndex: tabStopId === nodeId ? 0 : -1,
512
+ onFocus: () => {
513
+ onClaimTabStop(nodeId);
514
+ },
515
+ onClick: toggle,
516
+ onKeyDown: onExpanderKeyDown
517
+ }
518
+ ),
519
+ /* @__PURE__ */ jsxs("span", { className: JsonTree_module_default.summary, children: [
520
+ /* @__PURE__ */ jsx(NodeField, { field, expandable: true, onToggle: toggle }),
521
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.preview, children: previewValue(value, 0) }),
522
+ !lastElement && /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: "," })
523
+ ] }),
524
+ expanded && /* @__PURE__ */ jsx("ul", { id: contentsId, role: "group", className: JsonTree_module_default.children, children: entries.map(([key, item], index) => /* @__PURE__ */ jsx(
525
+ JsonTreeNode,
526
+ {
527
+ collapsedStringLines,
528
+ stringWrapping,
529
+ field: key,
530
+ value: item,
531
+ path: [...path, Array.isArray(value) ? index : key],
532
+ labels,
533
+ lastElement: index === entries.length - 1,
534
+ initialExpanded: false,
535
+ tabStopId,
536
+ onClaimTabStop,
537
+ onRowHover,
538
+ renderCopy
539
+ },
540
+ key
541
+ )) })
542
+ ] }),
543
+ expanded
544
+ );
545
+ }
546
+ function formattedPath(path) {
547
+ return path.reduce((result, part) => {
548
+ if (typeof part === "number") return `${result}[${String(part)}]`;
549
+ return /^[A-Za-z_$][\w$]*$/.test(part) ? `${result}.${part}` : `${result}[${JSON.stringify(part)}]`;
550
+ }, "$");
551
+ }
552
+ function copyText(target, mode) {
553
+ if (mode === "path") return formattedPath(target.path);
554
+ if (mode === "prettyJson") return JSON.stringify(target.value, null, 2);
555
+ if (mode === "json") return JSON.stringify(target.value);
556
+ if (typeof target.value === "string") return target.value;
557
+ if (typeof target.value === "undefined") return "undefined";
558
+ if (typeof target.value === "bigint") return target.value.toString();
559
+ if (typeof target.value === "symbol") return target.value.description ?? "Symbol";
560
+ if (typeof target.value === "function") return target.value.name || "Function";
561
+ return JSON.stringify(target.value);
562
+ }
563
+ function JsonTree({
564
+ data,
565
+ label,
566
+ className,
567
+ collapsedStringLines = 3,
568
+ stringWrapping,
569
+ copyable = true,
570
+ expandTopLevel = true,
571
+ labels
572
+ }) {
573
+ const rootEntries = entriesOf(data);
574
+ const firstExpandableIndex = rootEntries.findIndex(
575
+ ([, value]) => isExpandableValue(value) && entriesOf(value).length > 0
576
+ );
577
+ const firstExpandableEntry = rootEntries[firstExpandableIndex];
578
+ const initialTabStopId = expandTopLevel ? firstExpandableEntry === void 0 ? null : pathId([Array.isArray(data) ? firstExpandableIndex : firstExpandableEntry[0]]) : isExpandableValue(data) && rootEntries.length > 0 ? pathId([]) : null;
579
+ const activeRowRef = useRef(void 0);
580
+ const resetTimer = useRef(void 0);
581
+ const copySequence = useRef(0);
582
+ const [copyStore] = useState(createCopyStore);
583
+ const [tabStopId, setTabStopId] = useState(initialTabStopId);
584
+ const setActiveRow = (row) => {
585
+ activeRowRef.current?.removeAttribute("data-json-copy-active");
586
+ activeRowRef.current = row;
587
+ row?.setAttribute("data-json-copy-active", "");
588
+ };
589
+ const clearCopyTarget = () => {
590
+ copySequence.current += 1;
591
+ if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
592
+ setActiveRow(void 0);
593
+ copyStore.set(void 0);
594
+ };
595
+ useEffect(
596
+ () => () => {
597
+ copySequence.current += 1;
598
+ if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
599
+ activeRowRef.current?.removeAttribute("data-json-copy-active");
600
+ },
601
+ []
602
+ );
603
+ useEffect(() => {
604
+ clearCopyTarget();
605
+ setTabStopId(initialTabStopId);
606
+ }, [data, expandTopLevel, initialTabStopId]);
607
+ const handleRowHover = (row, target) => {
608
+ if (!copyable || copyStore.get()?.menuOpen) return;
609
+ if (activeRowRef.current === row) return;
610
+ setActiveRow(row);
611
+ copyStore.set({ id: pathId(target.path), target, state: "idle", menuOpen: false });
612
+ };
613
+ const handleRootMouseOver = (event) => {
614
+ if (!copyable || copyStore.get()?.menuOpen) return;
615
+ if (!(event.target instanceof Element)) return;
616
+ if (event.target.closest("[data-json-copy-button]") === null) clearCopyTarget();
617
+ };
618
+ const copy = async (target, mode) => {
619
+ const sequence = ++copySequence.current;
620
+ const snapshot = {
621
+ id: pathId(target.path),
622
+ target,
623
+ state: "idle",
624
+ menuOpen: false
625
+ };
626
+ copyStore.set(snapshot);
627
+ let state;
628
+ try {
629
+ await navigator.clipboard.writeText(copyText(target, mode));
630
+ state = "copied";
631
+ } catch {
632
+ state = "failed";
633
+ }
634
+ const current = copyStore.get();
635
+ if (sequence !== copySequence.current || current?.target !== target) return;
636
+ copyStore.set({ ...current, state });
637
+ if (resetTimer.current !== void 0) clearTimeout(resetTimer.current);
638
+ resetTimer.current = setTimeout(() => {
639
+ const current2 = copyStore.get();
640
+ if (current2?.target === target) copyStore.set({ ...current2, state: "idle" });
641
+ }, 1500);
642
+ };
643
+ const [rootOpen, rootClose] = bracketOf(data);
644
+ const renderCopy = copyable ? (target, persistent = false) => /* @__PURE__ */ jsx(
645
+ JsonCopyAction,
646
+ {
647
+ store: copyStore,
648
+ target,
649
+ persistent,
650
+ labels,
651
+ onCopy: copy,
652
+ onClose: clearCopyTarget
653
+ }
654
+ ) : void 0;
655
+ return /* @__PURE__ */ jsx(
656
+ "div",
657
+ {
658
+ className: clsx(JsonTree_module_default.root, className),
659
+ style: { "--json-tree-collapsed-lines": collapsedStringLines },
660
+ onMouseOver: handleRootMouseOver,
661
+ onMouseLeave: () => {
662
+ if (!copyStore.get()?.menuOpen) clearCopyTarget();
663
+ },
664
+ children: expandTopLevel ? /* @__PURE__ */ jsxs("div", { className: JsonTree_module_default.expandedTopLevel, children: [
665
+ /* @__PURE__ */ jsxs(
666
+ "div",
667
+ {
668
+ className: clsx(JsonTree_module_default.row, JsonTree_module_default.topLevelBracket),
669
+ "data-json-root-row": true,
670
+ onMouseOver: (event) => {
671
+ event.stopPropagation();
672
+ handleRowHover(event.currentTarget, { path: [], value: data });
673
+ },
674
+ children: [
675
+ renderCopy?.({ path: [], value: data }),
676
+ /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: rootOpen })
677
+ ]
678
+ }
679
+ ),
680
+ /* @__PURE__ */ jsx("div", { "aria-label": label, className: clsx(JsonTree_module_default.container, JsonTree_module_default.expandedTopLevelContainer), role: "tree", children: rootEntries.map(([key, value], index) => /* @__PURE__ */ jsx(
681
+ JsonTreeNode,
682
+ {
683
+ collapsedStringLines,
684
+ stringWrapping,
685
+ field: key,
686
+ value,
687
+ path: [Array.isArray(data) ? index : key],
688
+ labels,
689
+ lastElement: index === rootEntries.length - 1,
690
+ initialExpanded: false,
691
+ tabStopId,
692
+ onClaimTabStop: setTabStopId,
693
+ onRowHover: handleRowHover,
694
+ renderCopy
695
+ },
696
+ key
697
+ )) }),
698
+ /* @__PURE__ */ jsx("div", { className: clsx(JsonTree_module_default.row, JsonTree_module_default.topLevelBracket), children: /* @__PURE__ */ jsx("span", { className: JsonTree_module_default.punctuation, children: rootClose }) })
699
+ ] }) : /* @__PURE__ */ jsx("div", { "aria-label": label, className: JsonTree_module_default.container, role: "tree", children: /* @__PURE__ */ jsx(
700
+ JsonTreeNode,
701
+ {
702
+ collapsedStringLines,
703
+ stringWrapping,
704
+ value: data,
705
+ path: [],
706
+ labels,
707
+ lastElement: true,
708
+ initialExpanded: true,
709
+ tabStopId,
710
+ onClaimTabStop: setTabStopId,
711
+ onRowHover: handleRowHover,
712
+ renderCopy
713
+ }
714
+ ) })
715
+ }
716
+ );
717
+ }
718
+
719
+ // src/TerminalBlock.tsx
720
+ import { useCallback as useCallback2, useMemo, useState as useState3 } from "react";
721
+ import clsx3 from "clsx";
722
+
723
+ // src/ansi.ts
724
+ import Anser from "anser";
725
+ var TOKEN_BY_BASIC_RGB = {
726
+ "0,0,0": "var(--dsw-alias-label-primary)",
727
+ "255,255,255": "var(--dsw-alias-label-primary)",
728
+ "85,85,85": "var(--dsw-alias-label-tertiary)",
729
+ "187,0,0": "var(--dsw-alias-state-error-primary)",
730
+ "255,85,85": "var(--dsw-alias-state-error-secondary)",
731
+ "0,187,0": "var(--dsw-alias-state-success-primary)",
732
+ "0,255,0": "var(--dsw-alias-state-success-secondary)",
733
+ "187,187,0": "var(--dsw-alias-state-warn-primary)",
734
+ "255,255,85": "var(--dsw-alias-state-warn-secondary)",
735
+ "0,0,187": "var(--dsw-alias-state-business-primary)",
736
+ "85,85,255": "var(--dsw-static-blue-400)",
737
+ "0,187,187": "var(--dsw-static-blue-600)",
738
+ "85,255,255": "var(--dsw-static-blue-500)"
739
+ };
740
+ var STYLE_BY_DECORATION = {
741
+ bold: { fontWeight: 700 },
742
+ dim: { opacity: 0.7 },
743
+ italic: { fontStyle: "italic" },
744
+ underline: { textDecoration: "underline" },
745
+ strikethrough: { textDecoration: "line-through" },
746
+ hidden: { visibility: "hidden" }
747
+ };
748
+ var OSC_SEQUENCE = /\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)?/g;
749
+ var NON_CSI_ESCAPE = /\u001b(?!\[)[\u0020-\u002f]*[\u0030-\u007e]?/g;
750
+ var INERT_CONTROL = /[\u0000-\u0007\u000b-\u001a\u001c-\u001f\u007f]/g;
751
+ var NEEDS_REPLAY = /\r|\u0008|\u001b\[[\u0030-\u003f]*[\u0020-\u002f]*K/;
752
+ var SGR_SEQUENCE = /\u001b\[([\u0030-\u003f]*)[\u0020-\u002f]*m/g;
753
+ var TAB_WIDTH = 8;
754
+ var ZERO_WIDTH = /^[\p{Mn}\p{Me}\p{Cf}\u200b-\u200f\u2060]$/u;
755
+ var WIDE_CHAR = new RegExp(
756
+ "\\p{Script=Han}|\\p{Script=Hiragana}|\\p{Script=Katakana}|\\p{Script=Hangul}|\\p{Emoji_Presentation}|[\\uff01-\\uff60\\u3000-\\u303e]",
757
+ "u"
758
+ );
759
+ function isWide(char) {
760
+ const code = char.codePointAt(0);
761
+ if (code === void 0 || code < 4352) return false;
762
+ return WIDE_CHAR.test(char);
763
+ }
764
+ var SGR_NONE = { fg: "", bg: "", attrs: [] };
765
+ var ATTR_CLOSERS = {
766
+ 22: ["1", "2"],
767
+ 23: ["3"],
768
+ 24: ["4"],
769
+ 25: ["5", "6"],
770
+ 27: ["7"],
771
+ 28: ["8"],
772
+ 29: ["9"]
773
+ };
774
+ function foldSgr(state, params) {
775
+ const codes = params === "" ? ["0"] : params.split(";");
776
+ let next = state;
777
+ for (let index = 0; index < codes.length; index++) {
778
+ const code = String(codes[index]);
779
+ if (code === "" || code === "0") {
780
+ next = SGR_NONE;
781
+ continue;
782
+ }
783
+ if (code === "38" || code === "48") {
784
+ const kind = codes[index + 1] ?? "";
785
+ const span = kind === "2" ? 4 : kind === "5" ? 2 : 0;
786
+ const value = codes.slice(index, index + span + 1).join(";");
787
+ next = code === "38" ? { ...next, fg: value } : { ...next, bg: value };
788
+ index += span;
789
+ continue;
790
+ }
791
+ const closes = ATTR_CLOSERS[code];
792
+ if (closes !== void 0) {
793
+ next = { ...next, attrs: next.attrs.filter((attr) => !closes.includes(attr)) };
794
+ continue;
795
+ }
796
+ const numeric = Number(code);
797
+ if (code === "39") {
798
+ next = { ...next, fg: "" };
799
+ continue;
800
+ }
801
+ if (code === "49") {
802
+ next = { ...next, bg: "" };
803
+ continue;
804
+ }
805
+ if (numeric >= 30 && numeric <= 37 || numeric >= 90 && numeric <= 97) {
806
+ next = { ...next, fg: code };
807
+ continue;
808
+ }
809
+ if (numeric >= 40 && numeric <= 47 || numeric >= 100 && numeric <= 107) {
810
+ next = { ...next, bg: code };
811
+ continue;
812
+ }
813
+ if (!next.attrs.includes(code)) next = { ...next, attrs: [...next.attrs, code] };
814
+ }
815
+ return next;
816
+ }
817
+ function openSgr(state) {
818
+ const codes = [...state.attrs];
819
+ if (state.fg !== "") codes.push(state.fg);
820
+ if (state.bg !== "") codes.push(state.bg);
821
+ return codes.length === 0 ? "" : `\x1B[${codes.join(";")}m`;
822
+ }
823
+ function sameSgr(a, b) {
824
+ return a.fg === b.fg && a.bg === b.bg && a.attrs.length === b.attrs.length && a.attrs.every((attr, index) => attr === b.attrs[index]);
825
+ }
826
+ function replayLine(line, entrySgr) {
827
+ const csi = /\u001b\[([\u0030-\u003f]*)[\u0020-\u002f]*([\u0040-\u007e])/g;
828
+ const columns = [];
829
+ let cursor = 0;
830
+ let sgr = entrySgr;
831
+ let at = 0;
832
+ const clear = (index, fill) => {
833
+ const cell = columns[index];
834
+ if (cell?.spacer === true && index > 0) columns[index - 1] = { sgr, char: fill };
835
+ else if (cell !== void 0 && isWide(cell.char) && columns[index + 1]?.spacer === true) {
836
+ columns[index + 1] = { sgr, char: fill };
837
+ }
838
+ columns[index] = { sgr, char: fill };
839
+ };
840
+ const consume = (chunk) => {
841
+ for (const char of chunk) {
842
+ if (char === "\r") {
843
+ cursor = 0;
844
+ continue;
845
+ }
846
+ if (char === "\b") {
847
+ cursor = Math.max(0, cursor - 1);
848
+ continue;
849
+ }
850
+ if (char === " ") {
851
+ const stop = cursor + TAB_WIDTH - cursor % TAB_WIDTH;
852
+ for (; cursor < stop; cursor++) columns[cursor] ?? (columns[cursor] = { sgr, char: " " });
853
+ continue;
854
+ }
855
+ if (ZERO_WIDTH.test(char)) {
856
+ const base = cursor > 0 ? columns[cursor - 1] : void 0;
857
+ if (base !== void 0) columns[cursor - 1] = { sgr: base.sgr, char: base.char + char };
858
+ continue;
859
+ }
860
+ clear(cursor, " ");
861
+ columns[cursor] = { sgr, char };
862
+ cursor++;
863
+ if (isWide(char)) {
864
+ columns[cursor] = { sgr, char: "", spacer: true };
865
+ cursor++;
866
+ }
867
+ }
868
+ };
869
+ for (const match of line.matchAll(csi)) {
870
+ consume(line.slice(at, match.index));
871
+ at = match.index + match[0].length;
872
+ const params = String(match[1]);
873
+ const final = String(match[2]);
874
+ if (final === "K") {
875
+ const mode = String(params.split(";")[0]);
876
+ if (mode === "1") for (let index = 0; index <= cursor; index++) clear(index, " ");
877
+ else columns.length = mode === "2" ? 0 : cursor;
878
+ continue;
879
+ }
880
+ if (final !== "m") continue;
881
+ sgr = foldSgr(sgr, params);
882
+ }
883
+ consume(line.slice(at));
884
+ let out = "";
885
+ let active = entrySgr;
886
+ for (let index = 0; index < columns.length; index++) {
887
+ const column = columns[index] ?? { sgr: SGR_NONE, char: " " };
888
+ if (!sameSgr(column.sgr, active)) {
889
+ if (!sameSgr(active, SGR_NONE)) out += "\x1B[0m";
890
+ out += openSgr(column.sgr);
891
+ active = column.sgr;
892
+ }
893
+ const leadIntact = index > 0 && isWide(columns[index - 1]?.char ?? "");
894
+ out += column.spacer === true && !leadIntact ? " " : column.char;
895
+ }
896
+ if (!sameSgr(active, sgr)) {
897
+ if (!sameSgr(active, SGR_NONE)) out += "\x1B[0m";
898
+ out += openSgr(sgr);
899
+ }
900
+ return { text: out, sgr };
901
+ }
902
+ function applyCursorMovements(text) {
903
+ const replayed = [];
904
+ let sgr = SGR_NONE;
905
+ for (const raw of text.split("\n")) {
906
+ const line = raw.replace(/\r+$/, "");
907
+ if (NEEDS_REPLAY.test(line)) {
908
+ const result = replayLine(line, sgr);
909
+ replayed.push(result.text);
910
+ sgr = result.sgr;
911
+ continue;
912
+ }
913
+ replayed.push(line);
914
+ for (const match of line.matchAll(SGR_SEQUENCE)) sgr = foldSgr(sgr, String(match[1]));
915
+ }
916
+ return replayed.join("\n");
917
+ }
918
+ function sanitize(text) {
919
+ const escaped = text.replace(OSC_SEQUENCE, "").replace(NON_CSI_ESCAPE, "");
920
+ return applyCursorMovements(escaped).replace(INERT_CONTROL, "");
921
+ }
922
+ function resolveStyle(chunk) {
923
+ const style = {};
924
+ const background = chunk.bg === null ? void 0 : `rgb(${chunk.bg})`;
925
+ if (background !== void 0) style.backgroundColor = background;
926
+ if (chunk.fg !== null) {
927
+ const literal = `rgb(${chunk.fg})`;
928
+ style.color = background === void 0 ? TOKEN_BY_BASIC_RGB[chunk.fg.replace(/\s+/g, "")] ?? literal : literal;
929
+ }
930
+ for (const decoration of chunk.decorations) Object.assign(style, STYLE_BY_DECORATION[decoration]);
931
+ return Object.keys(style).length === 0 ? void 0 : style;
932
+ }
933
+ function parseAnsiLines(text) {
934
+ let current = [];
935
+ const lines = [current];
936
+ for (const chunk of Anser.ansiToJson(sanitize(text), { json: true, remove_empty: true })) {
937
+ const style = resolveStyle(chunk);
938
+ for (const [index, part] of chunk.content.split("\n").entries()) {
939
+ if (index > 0) {
940
+ current = [];
941
+ lines.push(current);
942
+ }
943
+ if (part !== "") current.push({ text: part, style });
944
+ }
945
+ }
946
+ return lines;
947
+ }
948
+
949
+ // src/head-tail-cap.ts
950
+ function headTailCap(total, maxLines, expanded) {
951
+ const hidden = total - maxLines;
952
+ const headLines = Math.ceil(maxLines / 2);
953
+ return { hidden, capped: hidden > 0 && !expanded, headLines, tailLines: maxLines - headLines };
954
+ }
955
+
956
+ // .build/css/TerminalBlock.module.mjs
957
+ var id2 = "@seekbuddy/dsh-ui/TerminalBlock.module.css";
958
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id2 + '"]')) {
959
+ const element = document.createElement("style");
960
+ element.setAttribute("data-dsh-ui-primitives", id2);
961
+ element.textContent = ".OBf4Nq_block{--dsl-terminal-radius:var(--dsw-radius-lg);--dsl-terminal-line-height:22px;--dsl-terminal-font:var(--dsw-font-markdown-code-block);--dsl-terminal-gutter:30px;padding-left:var(--dsl-terminal-gutter);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-markdown-code-block);border-radius:var(--dsl-terminal-radius);margin:16px 0;position:relative;overflow:hidden}.OBf4Nq_header{margin-left:calc(-1 * var(--dsl-terminal-gutter));padding:9px 14px 9px var(--dsl-terminal-gutter);border-top-left-radius:var(--dsl-terminal-radius);border-top-right-radius:var(--dsl-terminal-radius);align-items:flex-start;gap:12px;max-height:150px;display:flex;overflow-y:auto}.OBf4Nq_header::-webkit-scrollbar-thumb{border-radius:var(--dsw-radius-sm);background-clip:padding-box;border:2px solid #0000}.OBf4Nq_header::-webkit-scrollbar-track{margin:6px}.OBf4Nq_block[data-body] .OBf4Nq_header{border-bottom:.5px solid var(--dsw-alias-border-l2)}.OBf4Nq_prompt{min-width:0;font:var(--dsl-terminal-font);flex-direction:column;flex:1;display:flex}.OBf4Nq_promptLine{min-width:0;line-height:var(--dsl-terminal-line-height);align-items:baseline;gap:8px;display:flex;position:relative}.OBf4Nq_runState{left:calc(-1 * var(--dsl-terminal-gutter) + 8px);top:calc(var(--dsl-terminal-line-height) / 2);position:absolute;transform:translateY(-50%)}.OBf4Nq_runStateLabel{clip-path:inset(50%);white-space:nowrap;width:1px;height:1px;position:absolute;overflow:hidden}.OBf4Nq_cwd{color:var(--dsw-alias-label-tertiary);flex:none}.OBf4Nq_command{--dsl-command-whitespace:var(--dsl-terminal-command-whitespace,pre);color:var(--dsw-alias-label-primary)}.OBf4Nq_status{height:var(--dsl-terminal-line-height);color:var(--dsw-alias-state-error-primary);flex:none;position:sticky;top:0}.OBf4Nq_copyButton{background-color:var(--dsw-alias-markdown-code-block);color:var(--dsw-alias-label-secondary);cursor:pointer;font:var(--dsw-font-xs-13);line-height:var(--dsl-terminal-line-height);border:none;flex:none;margin:0;padding:0;position:sticky;top:0}.OBf4Nq_output{max-height:var(--dsl-terminal-output-max-height,none);font:var(--dsl-terminal-font);padding:12px 14px 12px 0;overflow:auto}.OBf4Nq_output::-webkit-scrollbar-thumb{border-radius:var(--dsw-radius-sm);background-clip:padding-box;border:2px solid #0000}.OBf4Nq_output::-webkit-scrollbar-track{margin:6px}.OBf4Nq_line{min-height:var(--dsl-terminal-line-height);white-space:var(--dsl-terminal-line-whitespace,pre);overflow-wrap:anywhere}.OBf4Nq_expand{width:100%;color:var(--dsw-alias-label-tertiary);cursor:pointer;font:inherit;text-align:left;background-color:#0000;border:none;padding:0;display:block}@media (hover:hover){.OBf4Nq_expand:hover{color:var(--dsw-alias-label-secondary)}}.OBf4Nq_empty{font:var(--dsl-terminal-font);color:var(--dsw-alias-label-tertiary);padding:12px 14px 12px 0}";
962
+ document.head.appendChild(element);
963
+ }
964
+ var TerminalBlock_module_default = { "prompt": "OBf4Nq_prompt", "promptLine": "OBf4Nq_promptLine", "runState": "OBf4Nq_runState", "command": "OBf4Nq_command", "status": "OBf4Nq_status", "cwd": "OBf4Nq_cwd", "runStateLabel": "OBf4Nq_runStateLabel", "output": "OBf4Nq_output", "expand": "OBf4Nq_expand", "copyButton": "OBf4Nq_copyButton", "empty": "OBf4Nq_empty", "line": "OBf4Nq_line", "block": "OBf4Nq_block", "header": "OBf4Nq_header" };
965
+
966
+ // src/CommandText.tsx
967
+ import { useLayoutEffect as useLayoutEffect2, useRef as useRef2, useState as useState2 } from "react";
968
+ import clsx2 from "clsx";
969
+
970
+ // .build/css/CommandText.module.mjs
971
+ var id3 = "@seekbuddy/dsh-ui/CommandText.module.css";
972
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id3 + '"]')) {
973
+ const element = document.createElement("style");
974
+ element.setAttribute("data-dsh-ui-primitives", id3);
975
+ element.textContent = "._7k6xxG_text{min-width:0;white-space:var(--dsl-command-whitespace,pre);overflow-wrap:anywhere;display:block;overflow-x:auto}._7k6xxG_text:focus-visible{outline:var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:-2px}";
976
+ document.head.appendChild(element);
977
+ }
978
+ var CommandText_module_default = { "text": "_7k6xxG_text" };
979
+
980
+ // src/CommandText.tsx
981
+ import { jsx as jsx2 } from "react/jsx-runtime";
982
+ function CommandText({ text, label, className }) {
983
+ const ref = useRef2(null);
984
+ const [overflow, setOverflow] = useState2(false);
985
+ useLayoutEffect2(() => {
986
+ const element = ref.current;
987
+ if (element === null) return void 0;
988
+ const measure = () => {
989
+ setOverflow(element.scrollWidth > element.clientWidth);
990
+ };
991
+ measure();
992
+ const observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(measure);
993
+ observer?.observe(element);
994
+ const fonts = "fonts" in element.ownerDocument ? element.ownerDocument.fonts : void 0;
995
+ fonts?.addEventListener("loadingdone", measure);
996
+ return () => {
997
+ observer?.disconnect();
998
+ fonts?.removeEventListener("loadingdone", measure);
999
+ };
1000
+ }, [text]);
1001
+ return /* @__PURE__ */ jsx2(
1002
+ "span",
1003
+ {
1004
+ ref,
1005
+ className: clsx2(CommandText_module_default.text, className),
1006
+ "data-command-text": true,
1007
+ tabIndex: overflow ? 0 : void 0,
1008
+ role: overflow ? "group" : void 0,
1009
+ "aria-label": overflow ? label : void 0,
1010
+ children: text
1011
+ }
1012
+ );
1013
+ }
1014
+
1015
+ // src/TerminalBlock.tsx
1016
+ import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1017
+ var DEFAULT_TERMINAL_MAX_LINES = 16;
1018
+ function promptLabel(cwd, home) {
1019
+ const trimmed = cwd.replace(/[/\\]+$/, "");
1020
+ if (home !== void 0 && trimmed === home.replace(/[/\\]+$/, "")) return "~";
1021
+ const segment = trimmed.split(/[/\\]/).pop();
1022
+ return segment === void 0 || segment === "" ? cwd : segment;
1023
+ }
1024
+ function statusText(exitCode, signal, labels) {
1025
+ if (signal !== void 0) return labels.signal(signal);
1026
+ if (exitCode === null) return labels.noExitCode;
1027
+ if (exitCode !== void 0 && exitCode !== 0) return labels.exitCode(exitCode);
1028
+ return void 0;
1029
+ }
1030
+ function runState(running, exitCode, signal, labels) {
1031
+ if (running) return { state: "ongoing", label: labels.running };
1032
+ if (statusText(exitCode, signal, labels) !== void 0) return { state: "error", label: labels.failed };
1033
+ return { state: "done", label: labels.done };
1034
+ }
1035
+ function renderLine(line) {
1036
+ return line.map(
1037
+ (span, index) => span.style === void 0 ? span.text : /* @__PURE__ */ jsx3("span", { style: span.style, children: span.text }, index)
1038
+ );
1039
+ }
1040
+ function TerminalBlock({
1041
+ command,
1042
+ cwd,
1043
+ home,
1044
+ output,
1045
+ exitCode,
1046
+ signal,
1047
+ running = false,
1048
+ background = false,
1049
+ maxLines = DEFAULT_TERMINAL_MAX_LINES,
1050
+ copyText: copyText4,
1051
+ runStateDot = true,
1052
+ className,
1053
+ labels
1054
+ }) {
1055
+ const copy = labels;
1056
+ const text = output ?? "";
1057
+ const lines = useMemo(() => {
1058
+ const parsed = parseAnsiLines(text);
1059
+ const last = parsed[parsed.length - 1];
1060
+ const terminated = parsed.length > 1 && last !== void 0 && last.every((span) => span.text === "");
1061
+ return terminated ? parsed.slice(0, -1) : parsed;
1062
+ }, [text]);
1063
+ const [expanded, setExpanded] = useState3(false);
1064
+ const { copied, onCopy } = useClipboardCopy(copyText4 ?? text);
1065
+ const onToggle = useCallback2(() => {
1066
+ setExpanded((value) => !value);
1067
+ }, []);
1068
+ const status = background ? void 0 : statusText(exitCode, signal, copy);
1069
+ const state = runState(running, exitCode, signal, copy);
1070
+ const showState = runStateDot && (!background || running);
1071
+ const commandLines = useMemo(() => {
1072
+ const body2 = command.endsWith("\n") ? command.slice(0, -1) : command;
1073
+ return body2.split("\n");
1074
+ }, [command]);
1075
+ const empty = lines.every((line) => line.every((span) => span.text.trim() === ""));
1076
+ const { hidden, capped, headLines, tailLines } = headTailCap(lines.length, maxLines, expanded);
1077
+ const body = !background && (!running || !empty);
1078
+ return /* @__PURE__ */ jsxs2(
1079
+ "div",
1080
+ {
1081
+ className: clsx3(TerminalBlock_module_default.block, className),
1082
+ "data-terminal": "",
1083
+ "data-running": running ? "" : void 0,
1084
+ "data-body": body ? "" : void 0,
1085
+ children: [
1086
+ /* @__PURE__ */ jsxs2("div", { className: TerminalBlock_module_default.header, children: [
1087
+ /* @__PURE__ */ jsxs2("div", { className: TerminalBlock_module_default.prompt, children: [
1088
+ showState && /* @__PURE__ */ jsx3("span", { className: TerminalBlock_module_default.runStateLabel, children: state.label }),
1089
+ commandLines.map((line, index) => /* @__PURE__ */ jsxs2("div", { className: TerminalBlock_module_default.promptLine, children: [
1090
+ index === 0 && showState && /* @__PURE__ */ jsx3(StateDot, { state: state.state, className: TerminalBlock_module_default.runState }),
1091
+ /* @__PURE__ */ jsx3("span", { className: TerminalBlock_module_default.cwd, children: index > 0 || cwd === void 0 ? "$" : promptLabel(cwd, home) }),
1092
+ /* @__PURE__ */ jsx3(CommandText, { className: TerminalBlock_module_default.command, text: line, label: copy.commandLine(index + 1) })
1093
+ ] }, index))
1094
+ ] }),
1095
+ status !== void 0 && /* @__PURE__ */ jsx3(Pill, { className: TerminalBlock_module_default.status, children: status }),
1096
+ (copyText4 !== void 0 || !background && !running && !empty) && /* @__PURE__ */ jsx3("button", { type: "button", className: TerminalBlock_module_default.copyButton, onClick: onCopy, children: copied ? copy.copied : copy.copy })
1097
+ ] }),
1098
+ body && (empty ? /* @__PURE__ */ jsx3("div", { className: TerminalBlock_module_default.empty, children: copy.noOutput }) : /* @__PURE__ */ jsxs2("div", { className: TerminalBlock_module_default.output, children: [
1099
+ (capped ? lines.slice(0, headLines) : lines).map((line, index) => /* @__PURE__ */ jsx3("div", { className: TerminalBlock_module_default.line, children: renderLine(line) }, index)),
1100
+ hidden > 0 && /* @__PURE__ */ jsx3(
1101
+ "button",
1102
+ {
1103
+ type: "button",
1104
+ className: TerminalBlock_module_default.expand,
1105
+ "aria-expanded": expanded,
1106
+ "aria-label": expanded ? copy.collapseAria : copy.expandAria(hidden),
1107
+ onClick: onToggle,
1108
+ children: expanded ? copy.collapse : copy.expand(hidden)
1109
+ }
1110
+ ),
1111
+ capped && lines.slice(lines.length - tailLines).map((line, index) => /* @__PURE__ */ jsx3("div", { className: TerminalBlock_module_default.line, children: renderLine(line) }, index))
1112
+ ] }))
1113
+ ]
1114
+ }
1115
+ );
1116
+ }
1117
+
1118
+ // src/ReadBlock.tsx
1119
+ import { useCallback as useCallback3, useMemo as useMemo2, useRef as useRef3, useState as useState4, useSyncExternalStore as useSyncExternalStore2 } from "react";
1120
+ import clsx4 from "clsx";
1121
+
1122
+ // src/FoldToggle.tsx
1123
+ import { jsx as jsx4 } from "react/jsx-runtime";
1124
+ function FoldToggle({ className, expanded, hidden, labels, onToggle }) {
1125
+ return /* @__PURE__ */ jsx4(
1126
+ "button",
1127
+ {
1128
+ type: "button",
1129
+ className,
1130
+ "aria-expanded": expanded,
1131
+ "aria-label": expanded ? labels.collapseAria : labels.expandAria(hidden),
1132
+ onClick: onToggle,
1133
+ children: expanded ? labels.collapse : labels.expand(hidden)
1134
+ }
1135
+ );
1136
+ }
1137
+
1138
+ // .build/css/ReadBlock.module.mjs
1139
+ var id4 = "@seekbuddy/dsh-ui/ReadBlock.module.css";
1140
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id4 + '"]')) {
1141
+ const element = document.createElement("style");
1142
+ element.setAttribute("data-dsh-ui-primitives", id4);
1143
+ element.textContent = ".Lq5Aja_line{white-space:pre;min-height:1lh;display:flex}.Lq5Aja_gutter{width:var(--dsl-read-gutter);text-align:right;color:var(--dsw-alias-label-tertiary);user-select:none;flex:none;margin-right:12px}.Lq5Aja_content{min-width:0;color:var(--dsw-alias-label-primary)}.Lq5Aja_block[data-code-wrap=true] .Lq5Aja_line{white-space:pre-wrap}.Lq5Aja_block[data-code-wrap=true] .Lq5Aja_content{overflow-wrap:anywhere}.Lq5Aja_expand{width:100%;padding:0 0 0 calc(var(--dsl-read-gutter) + 12px);color:var(--dsw-alias-label-tertiary);cursor:pointer;font:inherit;text-align:left;background:0 0;border:none;display:block}@media (hover:hover){.Lq5Aja_expand:hover{color:var(--dsw-alias-label-secondary)}}";
1144
+ document.head.appendChild(element);
1145
+ }
1146
+ var ReadBlock_module_default = { "block": "Lq5Aja_block", "line": "Lq5Aja_line", "expand": "Lq5Aja_expand", "content": "Lq5Aja_content", "gutter": "Lq5Aja_gutter" };
1147
+
1148
+ // src/ReadBlock.tsx
1149
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1150
+ var DEFAULT_READ_MAX_LINES = 16;
1151
+ function renderSpans(spans) {
1152
+ return spans.map((span, index) => /* @__PURE__ */ jsx5("span", { style: span.style, children: span.text }, index));
1153
+ }
1154
+ function ReadBlock({
1155
+ label,
1156
+ labels,
1157
+ lines,
1158
+ totalLines,
1159
+ lang,
1160
+ maxLines = DEFAULT_READ_MAX_LINES,
1161
+ className
1162
+ }) {
1163
+ const rootRef = useRef3(null);
1164
+ const highlighting = useViewportHighlighting(rootRef, lang);
1165
+ const raw = useMemo2(() => lines.map((line) => line.text).join("\n"), [lines]);
1166
+ const loaded = useSyncExternalStore2(subscribeGrammarLoaded, grammarLoadCount, grammarLoadCount);
1167
+ const highlighted = useMemo2(
1168
+ () => highlighting ? highlightLines(raw, lang) : void 0,
1169
+ [highlighting, raw, lang, loaded]
1170
+ );
1171
+ const [expanded, setExpanded] = useState4(false);
1172
+ const [copied, setCopied] = useState4(false);
1173
+ const [wrapped, setWrapped] = useState4(false);
1174
+ const onCopy = useCallback3(() => {
1175
+ if (copied) return;
1176
+ void writeClipboard(raw).then((ok) => {
1177
+ if (!ok) return;
1178
+ setCopied(true);
1179
+ window.setTimeout(() => {
1180
+ setCopied(false);
1181
+ }, 1e3);
1182
+ });
1183
+ }, [copied, raw]);
1184
+ const onToggle = useCallback3(() => {
1185
+ setExpanded((value) => !value);
1186
+ }, []);
1187
+ const hidden = lines.length - maxLines;
1188
+ const capped = hidden > 0 && !expanded;
1189
+ const headLines = Math.ceil(maxLines / 2);
1190
+ const tailLines = maxLines - headLines;
1191
+ const windowed = lines.length < totalLines;
1192
+ const rows = (slice) => slice.map(([line, spans]) => /* @__PURE__ */ jsxs3("div", { className: ReadBlock_module_default.line, children: [
1193
+ /* @__PURE__ */ jsx5("span", { className: ReadBlock_module_default.gutter, "aria-hidden": true, children: line.number }),
1194
+ /* @__PURE__ */ jsx5("span", { className: ReadBlock_module_default.content, children: spans === void 0 ? line.text : renderSpans(spans) })
1195
+ ] }, line.number));
1196
+ const gutterDigits = lines.reduce((digits, line) => Math.max(digits, String(line.number).length), 3);
1197
+ const gutterStyle = { "--dsl-read-gutter": `${gutterDigits}ch` };
1198
+ const paired = lines.map((line, index) => [
1199
+ line,
1200
+ highlighted?.[index]
1201
+ ]);
1202
+ return /* @__PURE__ */ jsxs3(
1203
+ "div",
1204
+ {
1205
+ ref: rootRef,
1206
+ className: clsx4(CodeCard_module_default.card, ReadBlock_module_default.block, className),
1207
+ "data-read": "",
1208
+ "data-code-wrap": wrapped,
1209
+ style: gutterStyle,
1210
+ children: [
1211
+ /* @__PURE__ */ jsx5(
1212
+ CodeToolbar,
1213
+ {
1214
+ lang,
1215
+ title: label,
1216
+ status: windowed ? labels.window(lines.length, totalLines) : void 0,
1217
+ labels,
1218
+ copyLabel: labels.copy,
1219
+ copiedLabel: labels.copied,
1220
+ copied,
1221
+ wrapped,
1222
+ onCopy: lines.length > 0 ? onCopy : void 0,
1223
+ onWrap: () => {
1224
+ setWrapped((value) => !value);
1225
+ }
1226
+ }
1227
+ ),
1228
+ /* @__PURE__ */ jsxs3("div", { className: CodeCard_module_default.body, children: [
1229
+ rows(capped ? paired.slice(0, headLines) : paired),
1230
+ hidden > 0 && /* @__PURE__ */ jsx5(FoldToggle, { className: ReadBlock_module_default.expand, expanded, hidden, labels, onToggle }),
1231
+ capped && rows(paired.slice(paired.length - tailLines))
1232
+ ] })
1233
+ ]
1234
+ }
1235
+ );
1236
+ }
1237
+
1238
+ // src/DiffBlock.tsx
1239
+ import { useCallback as useCallback5, useMemo as useMemo3, useState as useState5 } from "react";
1240
+ import clsx5 from "clsx";
1241
+ import { structuredPatch } from "diff";
1242
+
1243
+ // src/code-highlighting.ts
1244
+ import { useCallback as useCallback4, useSyncExternalStore as useSyncExternalStore3 } from "react";
1245
+ import { CODE_HIGHLIGHT_EXTENSIONS, languageForPath } from "@deepseek-ai/dsh-util-code-language";
1246
+ function useCodeHighlighter(language) {
1247
+ const loaded = useSyncExternalStore3(subscribeGrammarLoaded, grammarLoadCount, grammarLoadCount);
1248
+ return useCallback4((code) => highlightLines(code, language), [language, loaded]);
1249
+ }
1250
+
1251
+ // .build/css/DiffBlock.module.mjs
1252
+ var id5 = "@seekbuddy/dsh-ui/DiffBlock.module.css";
1253
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id5 + '"]')) {
1254
+ const element = document.createElement("style");
1255
+ element.setAttribute("data-dsh-ui-primitives", id5);
1256
+ element.textContent = '.tEQPFa_block{overflow:hidden}.tEQPFa_body{font:var(--dsw-font-markdown-code-block);grid-template-columns:minmax(max-content,1fr);padding:6px 0 20px;display:grid;overflow-x:auto}.tEQPFa_line{box-sizing:border-box;white-space:pre;min-height:1lh;padding:0 22px}.tEQPFa_block[data-code-wrap=true] .tEQPFa_body{grid-template-columns:minmax(0,1fr)}.tEQPFa_block[data-code-wrap=true] .tEQPFa_line{white-space:pre-wrap;overflow-wrap:anywhere}.tEQPFa_path{color:var(--dsw-alias-label-secondary);font-weight:500}.tEQPFa_gap{color:var(--dsw-alias-label-tertiary)}.tEQPFa_del:before{content:"- "}.tEQPFa_del{color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-code-diff-deleted);box-shadow:inset 3px 0 0 var(--dsw-alias-state-error-primary)}.tEQPFa_add:before{content:"+ "}.tEQPFa_add{color:var(--dsw-alias-state-success-primary);background:var(--dsw-alias-code-diff-added);box-shadow:inset 3px 0 0 var(--dsw-alias-state-success-primary)}.tEQPFa_context{color:var(--dsw-alias-label-secondary)}.tEQPFa_context:before{content:" "}.tEQPFa_expand{width:100%;color:var(--dsw-alias-label-tertiary);cursor:pointer;font:inherit;text-align:left;background:0 0;border:none;padding:0 22px;display:block}@media (hover:hover){.tEQPFa_expand:hover{color:var(--dsw-alias-label-secondary)}}';
1257
+ document.head.appendChild(element);
1258
+ }
1259
+ var DiffBlock_module_default = { "add": "tEQPFa_add", "expand": "tEQPFa_expand", "block": "tEQPFa_block", "gap": "tEQPFa_gap", "line": "tEQPFa_line", "del": "tEQPFa_del", "context": "tEQPFa_context", "path": "tEQPFa_path", "body": "tEQPFa_body" };
1260
+
1261
+ // src/DiffBlock.tsx
1262
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1263
+ var DEFAULT_DIFF_MAX_LINES = 16;
1264
+ function assertNever(value) {
1265
+ throw new Error(`unreachable diff row kind: ${String(value)}`);
1266
+ }
1267
+ var ROW_CLASS = {
1268
+ path: DiffBlock_module_default.path,
1269
+ del: DiffBlock_module_default.del,
1270
+ add: DiffBlock_module_default.add,
1271
+ context: DiffBlock_module_default.context,
1272
+ gap: DiffBlock_module_default.gap
1273
+ };
1274
+ var MAX_DIFF_EDIT_LENGTH = 256;
1275
+ function localHunks(diff) {
1276
+ const oldLines = contentLines(diff.oldText ?? "");
1277
+ const newLines = contentLines(diff.newText);
1278
+ const normalize = (lines) => lines.map((line) => `${line}
1279
+ `).join("");
1280
+ return structuredPatch("", "", normalize(oldLines), normalize(newLines), void 0, void 0, {
1281
+ context: 3,
1282
+ maxEditLength: MAX_DIFF_EDIT_LENGTH
1283
+ })?.hunks ?? [{ lines: [...oldLines.map((line) => `-${line}`), ...newLines.map((line) => `+${line}`)] }];
1284
+ }
1285
+ function diffTotals(diffs) {
1286
+ let added = 0;
1287
+ let removed = 0;
1288
+ for (const diff of diffs) {
1289
+ for (const hunk of localHunks(diff)) {
1290
+ for (const line of hunk.lines) {
1291
+ if (line.startsWith("+")) added++;
1292
+ if (line.startsWith("-")) removed++;
1293
+ }
1294
+ }
1295
+ }
1296
+ return { added, removed };
1297
+ }
1298
+ function buildRows(diffs) {
1299
+ const rows = [];
1300
+ let prevPath;
1301
+ for (const diff of diffs) {
1302
+ if (diff.path !== prevPath) rows.push({ kind: "path", text: diff.path });
1303
+ else rows.push({ kind: "gap", text: "\u22EF" });
1304
+ prevPath = diff.path;
1305
+ for (const [index, hunk] of localHunks(diff).entries()) {
1306
+ if (index > 0) rows.push({ kind: "gap", text: "\u22EF" });
1307
+ for (const line of hunk.lines) {
1308
+ const kind = line.startsWith("-") ? "del" : line.startsWith("+") ? "add" : "context";
1309
+ rows.push({ kind, text: line.slice(1) });
1310
+ }
1311
+ }
1312
+ }
1313
+ return rows;
1314
+ }
1315
+ function contentLines(text) {
1316
+ if (text === "") return [];
1317
+ const body = text.endsWith("\n") ? text.slice(0, -1) : text;
1318
+ return body.split("\n");
1319
+ }
1320
+ function copyText2(rows) {
1321
+ return rows.map((row) => {
1322
+ switch (row.kind) {
1323
+ case "del":
1324
+ return `- ${row.text}`;
1325
+ case "add":
1326
+ return `+ ${row.text}`;
1327
+ case "context":
1328
+ return ` ${row.text}`;
1329
+ case "path":
1330
+ return row.text;
1331
+ case "gap":
1332
+ return row.text;
1333
+ /* v8 ignore next -- closed-union backstop; only reached if a row kind is forged */
1334
+ default:
1335
+ return assertNever(row.kind);
1336
+ }
1337
+ }).join("\n");
1338
+ }
1339
+ function DiffBlock({ diffs, labels, maxLines = DEFAULT_DIFF_MAX_LINES, className }) {
1340
+ const rows = useMemo3(() => buildRows(diffs), [diffs]);
1341
+ const [expanded, setExpanded] = useState5(false);
1342
+ const [copied, setCopied] = useState5(false);
1343
+ const [wrapped, setWrapped] = useState5(false);
1344
+ const firstLanguage = diffs[0] === void 0 ? void 0 : languageForPath(diffs[0].path);
1345
+ const language = diffs.every((diff) => languageForPath(diff.path) === firstLanguage) ? firstLanguage : void 0;
1346
+ const onCopy = useCallback5(() => {
1347
+ if (copied) return;
1348
+ void writeClipboard(copyText2(rows)).then((ok) => {
1349
+ if (!ok) return;
1350
+ setCopied(true);
1351
+ window.setTimeout(() => {
1352
+ setCopied(false);
1353
+ }, 1e3);
1354
+ });
1355
+ }, [copied, rows]);
1356
+ const onToggle = useCallback5(() => {
1357
+ setExpanded((value) => !value);
1358
+ }, []);
1359
+ if (rows.length === 0) return null;
1360
+ const hidden = rows.length - maxLines;
1361
+ const capped = hidden > 0 && !expanded;
1362
+ const headLines = Math.ceil(maxLines / 2);
1363
+ const tailLines = maxLines - headLines;
1364
+ const head = capped ? rows.slice(0, headLines) : rows;
1365
+ const tail = capped ? rows.slice(rows.length - tailLines) : [];
1366
+ return /* @__PURE__ */ jsxs4("div", { className: clsx5(CodeCard_module_default.card, DiffBlock_module_default.block, className), "data-diff": "", "data-code-wrap": wrapped, children: [
1367
+ /* @__PURE__ */ jsx6(
1368
+ CodeToolbar,
1369
+ {
1370
+ lang: language,
1371
+ labels,
1372
+ copyLabel: labels.copy,
1373
+ copiedLabel: labels.copied,
1374
+ copied,
1375
+ wrapped,
1376
+ onCopy,
1377
+ onWrap: () => {
1378
+ setWrapped((value) => !value);
1379
+ }
1380
+ }
1381
+ ),
1382
+ /* @__PURE__ */ jsxs4("div", { className: DiffBlock_module_default.body, children: [
1383
+ head.map((row, index) => /* @__PURE__ */ jsx6("div", { className: clsx5(DiffBlock_module_default.line, ROW_CLASS[row.kind]), children: row.text }, index)),
1384
+ hidden > 0 && /* @__PURE__ */ jsx6(FoldToggle, { className: DiffBlock_module_default.expand, expanded, hidden, labels, onToggle }),
1385
+ tail.map((row, index) => /* @__PURE__ */ jsx6("div", { className: clsx5(DiffBlock_module_default.line, ROW_CLASS[row.kind]), children: row.text }, index))
1386
+ ] })
1387
+ ] });
1388
+ }
1389
+
1390
+ // src/SearchBlock.tsx
1391
+ import { useCallback as useCallback6, useState as useState6 } from "react";
1392
+ import clsx6 from "clsx";
1393
+
1394
+ // .build/css/SearchBlock.module.mjs
1395
+ var id6 = "@seekbuddy/dsh-ui/SearchBlock.module.css";
1396
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id6 + '"]')) {
1397
+ const element = document.createElement("style");
1398
+ element.setAttribute("data-dsh-ui-primitives", id6);
1399
+ element.textContent = "._-soDW_block{--dsl-search-radius:var(--dsw-radius-lg);--dsl-search-line-height:22px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-markdown-code-block);border-radius:var(--dsl-search-radius);margin:16px 0;position:relative}._-soDW_header{background:var(--dsw-alias-markdown-code-block-banner);border-top-left-radius:var(--dsl-search-radius);border-top-right-radius:var(--dsl-search-radius);align-items:center;gap:12px;padding:9px 14px;display:flex}._-soDW_summary{text-overflow:ellipsis;white-space:nowrap;min-width:0;font:var(--dsw-font-xs-13);color:var(--dsw-alias-label-secondary);flex:1;overflow:hidden}._-soDW_copyButton{color:var(--dsw-alias-label-secondary);cursor:pointer;font:var(--dsw-font-xs-13);background-color:#0000;border:none;flex:none;margin:0;padding:0}._-soDW_body{font:var(--dsw-font-markdown-code-block);padding:8px 14px 12px 0;overflow:auto hidden}._-soDW_line{min-height:var(--dsl-search-line-height);white-space:pre;padding-left:14px}._-soDW_lineNumber{color:var(--dsw-alias-label-tertiary)}._-soDW_fileHeader{width:100%;min-height:var(--dsl-search-line-height);cursor:pointer;font:inherit;text-align:left;background-color:#0000;border:none;align-items:baseline;gap:8px;padding:0 14px;display:flex}._-soDW_filePath{min-width:0;color:var(--dsw-alias-label-primary);white-space:pre;font-weight:600}._-soDW_fileCount{color:var(--dsw-alias-label-tertiary);flex:none}._-soDW_expand{width:100%;color:var(--dsw-alias-label-tertiary);cursor:pointer;font:inherit;text-align:left;background-color:#0000;border:none;padding:0 14px;display:block}@media (hover:hover){._-soDW_expand:hover{color:var(--dsw-alias-label-secondary)}}._-soDW_empty{font:var(--dsw-font-markdown-code-block);color:var(--dsw-alias-label-tertiary);padding:12px 14px}";
1400
+ document.head.appendChild(element);
1401
+ }
1402
+ var SearchBlock_module_default = { "copyButton": "_-soDW_copyButton", "fileCount": "_-soDW_fileCount", "line": "_-soDW_line", "body": "_-soDW_body", "empty": "_-soDW_empty", "header": "_-soDW_header", "filePath": "_-soDW_filePath", "expand": "_-soDW_expand", "block": "_-soDW_block", "summary": "_-soDW_summary", "fileHeader": "_-soDW_fileHeader", "lineNumber": "_-soDW_lineNumber" };
1403
+
1404
+ // src/SearchBlock.tsx
1405
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1406
+ var DEFAULT_SEARCH_MAX_LINES = 16;
1407
+ function copyText3(props) {
1408
+ if (props.kind === "paths") return props.paths.join("\n");
1409
+ return props.files.map((file) => [file.path, ...file.matches.map((m) => `${m.lineNumber}: ${m.line}`)].join("\n")).join("\n\n");
1410
+ }
1411
+ function shownCount(props) {
1412
+ return props.kind === "paths" ? props.paths.length : props.files.reduce((sum, file) => sum + file.matches.length, 0);
1413
+ }
1414
+ function summaryText(props, shown, truncated, total) {
1415
+ return props.kind === "paths" ? props.labels.pathsSummary(shown, total, truncated) : props.labels.matchesSummary(shown, total, props.files.length, truncated);
1416
+ }
1417
+ function toRows(props, collapsed) {
1418
+ if (props.kind === "paths") return props.paths.map((path) => ({ type: "path", path }));
1419
+ const rows = [];
1420
+ props.files.forEach((file, index) => {
1421
+ const isCollapsed = collapsed.has(index);
1422
+ rows.push({ type: "file", path: file.path, count: file.matches.length, index, collapsed: isCollapsed });
1423
+ if (isCollapsed) return;
1424
+ for (const match of file.matches) {
1425
+ rows.push({
1426
+ type: "match",
1427
+ lineNumber: match.lineNumber,
1428
+ line: match.line,
1429
+ key: `${index}:${match.lineNumber}`,
1430
+ fileIndex: index
1431
+ });
1432
+ }
1433
+ });
1434
+ return rows;
1435
+ }
1436
+ function rowKey(row) {
1437
+ switch (row.type) {
1438
+ case "match":
1439
+ return `match:${row.key}`;
1440
+ case "file":
1441
+ return `file:${row.index}`;
1442
+ case "path":
1443
+ return `path:${row.path}`;
1444
+ }
1445
+ }
1446
+ function SearchBlock(props) {
1447
+ const { truncated, total, maxLines = DEFAULT_SEARCH_MAX_LINES, className } = props;
1448
+ const [expanded, setExpanded] = useState6(false);
1449
+ const [collapsed, setCollapsed] = useState6(() => /* @__PURE__ */ new Set());
1450
+ const rows = toRows(props, collapsed);
1451
+ const shown = shownCount(props);
1452
+ const empty = rows.length === 0;
1453
+ const { copied, onCopy } = useClipboardCopy(copyText3(props));
1454
+ const onToggle = useCallback6(() => {
1455
+ setExpanded((value) => !value);
1456
+ }, []);
1457
+ const toggleFile = useCallback6((index) => {
1458
+ setCollapsed((prev) => {
1459
+ const next = new Set(prev);
1460
+ if (next.has(index)) next.delete(index);
1461
+ else next.add(index);
1462
+ return next;
1463
+ });
1464
+ }, []);
1465
+ const { hidden, capped, headLines, tailLines } = headTailCap(rows.length, maxLines, expanded);
1466
+ const head = capped ? rows.slice(0, headLines) : rows;
1467
+ const naturalTail = capped ? rows.slice(rows.length - tailLines) : [];
1468
+ const tailLead = naturalTail[0];
1469
+ const tailHeader = tailLead?.type === "match" && !head.some((row) => row.type === "file" && row.index === tailLead.fileIndex) ? rows.find(
1470
+ (row) => row.type === "file" && row.index === tailLead.fileIndex
1471
+ ) : void 0;
1472
+ const tail = tailHeader === void 0 ? naturalTail : naturalTail.slice(1);
1473
+ const renderRow = (row) => {
1474
+ if (row.type === "path") return /* @__PURE__ */ jsx7("div", { className: SearchBlock_module_default.line, children: row.path });
1475
+ if (row.type === "match") {
1476
+ return /* @__PURE__ */ jsxs5("div", { className: SearchBlock_module_default.line, children: [
1477
+ /* @__PURE__ */ jsxs5("span", { className: SearchBlock_module_default.lineNumber, children: [
1478
+ row.lineNumber,
1479
+ ": "
1480
+ ] }),
1481
+ row.line
1482
+ ] });
1483
+ }
1484
+ return /* @__PURE__ */ jsxs5(
1485
+ "button",
1486
+ {
1487
+ type: "button",
1488
+ className: SearchBlock_module_default.fileHeader,
1489
+ "aria-expanded": !row.collapsed,
1490
+ onClick: () => {
1491
+ toggleFile(row.index);
1492
+ },
1493
+ children: [
1494
+ /* @__PURE__ */ jsx7("span", { className: SearchBlock_module_default.filePath, children: row.path }),
1495
+ /* @__PURE__ */ jsx7("span", { className: SearchBlock_module_default.fileCount, children: row.count })
1496
+ ]
1497
+ }
1498
+ );
1499
+ };
1500
+ return /* @__PURE__ */ jsxs5("div", { className: clsx6(SearchBlock_module_default.block, className), "data-search": props.kind, children: [
1501
+ /* @__PURE__ */ jsxs5("div", { className: SearchBlock_module_default.header, children: [
1502
+ /* @__PURE__ */ jsx7("span", { className: SearchBlock_module_default.summary, children: summaryText(props, shown, truncated, total) }),
1503
+ !empty && /* @__PURE__ */ jsx7("button", { type: "button", className: SearchBlock_module_default.copyButton, onClick: onCopy, children: copied ? props.labels.copied : props.labels.copy })
1504
+ ] }),
1505
+ empty ? /* @__PURE__ */ jsx7("div", { className: SearchBlock_module_default.empty, children: props.labels.noResults }) : /* @__PURE__ */ jsxs5("div", { className: SearchBlock_module_default.body, children: [
1506
+ head.map((row) => /* @__PURE__ */ jsx7("div", { children: renderRow(row) }, rowKey(row))),
1507
+ hidden > 0 && /* @__PURE__ */ jsx7(
1508
+ "button",
1509
+ {
1510
+ type: "button",
1511
+ className: SearchBlock_module_default.expand,
1512
+ "aria-expanded": expanded,
1513
+ "aria-label": expanded ? props.labels.collapseAria : props.labels.expandAria(hidden),
1514
+ onClick: onToggle,
1515
+ children: expanded ? props.labels.collapse : props.labels.expand(hidden)
1516
+ }
1517
+ ),
1518
+ tailHeader !== void 0 && /* @__PURE__ */ jsx7("div", { children: renderRow(tailHeader) }, `tailHeader:${rowKey(tailHeader)}`),
1519
+ tail.map((row) => /* @__PURE__ */ jsx7("div", { children: renderRow(row) }, rowKey(row)))
1520
+ ] })
1521
+ ] });
1522
+ }
1523
+
1524
+ // src/WebBlock.tsx
1525
+ import clsx7 from "clsx";
1526
+
1527
+ // .build/css/WebBlock.module.mjs
1528
+ var id7 = "@seekbuddy/dsh-ui/WebBlock.module.css";
1529
+ if (typeof document !== "undefined" && !document.querySelector('style[data-dsh-ui-primitives="' + id7 + '"]')) {
1530
+ const element = document.createElement("style");
1531
+ element.setAttribute("data-dsh-ui-primitives", id7);
1532
+ element.textContent = ".MTeYQa_block{--dsl-web-radius:var(--dsw-radius-lg);color:var(--dsw-alias-label-primary);background:var(--dsw-alias-markdown-code-block);border-radius:var(--dsl-web-radius);margin:16px 0;padding:12px 14px}.MTeYQa_answer{margin-bottom:8px}.MTeYQa_answer>div>:first-child{margin-top:0}.MTeYQa_answer>div>:last-child{margin-bottom:0}.MTeYQa_sources{flex-direction:column;gap:10px;max-height:320px;margin:0;padding-left:2.5em;display:flex;overflow-y:auto}.MTeYQa_source{min-width:0}.MTeYQa_sourceLink{color:var(--dsw-alias-link);word-break:break-word;font-size:14px;font-weight:500;line-height:20px;text-decoration:none}.MTeYQa_linkIcon{vertical-align:-.25em;width:1.1em;height:1.1em;margin-right:5px}.MTeYQa_sourceLink:focus-visible{text-underline-offset:3px;text-decoration:underline dotted}@media (hover:hover){.MTeYQa_sourceLink:hover{text-underline-offset:3px;text-decoration:underline dotted}}.MTeYQa_snippet{color:var(--dsw-alias-label-secondary);word-break:break-word;margin-top:2px;font-size:13px;line-height:19px}.MTeYQa_published{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);margin-top:2px}.MTeYQa_truncated{color:var(--dsw-alias-label-tertiary);font:var(--dsw-font-xs-13);margin-top:8px}.MTeYQa_empty{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-13)}.MTeYQa_fetch{flex-direction:column;gap:6px;display:flex}.MTeYQa_fetchUrl{color:var(--dsw-alias-link);font-family:var(--ds-font-family-code);word-break:break-all;font-size:13px;font-weight:500;line-height:19px;text-decoration:none}.MTeYQa_fetchUrl:focus-visible{text-underline-offset:3px;text-decoration:underline dotted}@media (hover:hover){.MTeYQa_fetchUrl:hover{text-underline-offset:3px;text-decoration:underline dotted}}.MTeYQa_fetchMeta{align-items:baseline;gap:12px;display:flex}.MTeYQa_status{color:var(--dsw-alias-label-secondary);font:var(--dsw-font-xs-13)}.MTeYQa_fetch .MTeYQa_truncated{margin-top:0}";
1533
+ document.head.appendChild(element);
1534
+ }
1535
+ var WebBlock_module_default = { "answer": "MTeYQa_answer", "sources": "MTeYQa_sources", "source": "MTeYQa_source", "empty": "MTeYQa_empty", "fetch": "MTeYQa_fetch", "fetchUrl": "MTeYQa_fetchUrl", "fetchMeta": "MTeYQa_fetchMeta", "status": "MTeYQa_status", "linkIcon": "MTeYQa_linkIcon", "truncated": "MTeYQa_truncated", "block": "MTeYQa_block", "published": "MTeYQa_published", "snippet": "MTeYQa_snippet", "sourceLink": "MTeYQa_sourceLink" };
1536
+
1537
+ // src/WebBlock.tsx
1538
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1539
+ function safeHref(url) {
1540
+ try {
1541
+ const { protocol } = new URL(url);
1542
+ return protocol === "http:" || protocol === "https:" ? url : void 0;
1543
+ } catch {
1544
+ return void 0;
1545
+ }
1546
+ }
1547
+ function linkLabel(url, title) {
1548
+ if (title !== void 0 && title !== "") return title;
1549
+ try {
1550
+ const { hostname } = new URL(url);
1551
+ return hostname === "" ? url : hostname;
1552
+ } catch {
1553
+ return url;
1554
+ }
1555
+ }
1556
+ function SafeLink({ url, label, className }) {
1557
+ const href = safeHref(url);
1558
+ if (href === void 0) return /* @__PURE__ */ jsx8("span", { className, children: label });
1559
+ return /* @__PURE__ */ jsxs6("a", { className, href, target: "_blank", rel: "noopener noreferrer", children: [
1560
+ /* @__PURE__ */ jsx8(LinkIconMedium, { kind: "url", href, className: WebBlock_module_default.linkIcon }),
1561
+ label
1562
+ ] });
1563
+ }
1564
+ function SourceItem({ source, ordinal }) {
1565
+ return /* @__PURE__ */ jsxs6("li", { className: WebBlock_module_default.source, value: ordinal, children: [
1566
+ /* @__PURE__ */ jsx8(SafeLink, { url: source.url, label: linkLabel(source.url, source.title), className: WebBlock_module_default.sourceLink }),
1567
+ source.snippet !== void 0 && source.snippet !== "" && /* @__PURE__ */ jsx8("div", { className: WebBlock_module_default.snippet, children: source.snippet }),
1568
+ source.publishedAt !== void 0 && source.publishedAt !== "" && /* @__PURE__ */ jsx8("div", { className: WebBlock_module_default.published, children: source.publishedAt })
1569
+ ] });
1570
+ }
1571
+ function WebSearchBlock({ answer, sources, truncated, labels, className }) {
1572
+ const empty = (answer === void 0 || answer === "") && sources.length === 0;
1573
+ return /* @__PURE__ */ jsxs6("div", { className: clsx7(WebBlock_module_default.block, className), "data-web": "search", children: [
1574
+ answer !== void 0 && answer !== "" && /* @__PURE__ */ jsx8("div", { className: WebBlock_module_default.answer, children: /* @__PURE__ */ jsx8(MarkdownText, { text: answer, labels: labels.markdown }) }),
1575
+ empty ? /* @__PURE__ */ jsx8("div", { className: WebBlock_module_default.empty, children: labels.noResults }) : /* @__PURE__ */ jsx8("ol", { className: WebBlock_module_default.sources, children: sources.map((source, index) => /* @__PURE__ */ jsx8(SourceItem, { source, ordinal: index + 1 }, index)) }),
1576
+ truncated && /* @__PURE__ */ jsx8("div", { className: WebBlock_module_default.truncated, children: labels.sourcesTruncated })
1577
+ ] });
1578
+ }
1579
+ function WebFetchBlock({ url, statusCode, truncated, labels, className }) {
1580
+ return /* @__PURE__ */ jsxs6("div", { className: clsx7(WebBlock_module_default.block, WebBlock_module_default.fetch, className), "data-web": "fetch", children: [
1581
+ /* @__PURE__ */ jsx8(SafeLink, { url, label: url, className: WebBlock_module_default.fetchUrl }),
1582
+ /* @__PURE__ */ jsxs6("div", { className: WebBlock_module_default.fetchMeta, children: [
1583
+ /* @__PURE__ */ jsxs6("span", { className: WebBlock_module_default.status, children: [
1584
+ labels.http,
1585
+ " ",
1586
+ statusCode
1587
+ ] }),
1588
+ truncated && /* @__PURE__ */ jsx8("span", { className: WebBlock_module_default.truncated, children: labels.contentTruncated })
1589
+ ] })
1590
+ ] });
1591
+ }
1592
+ function WebBlock(props) {
1593
+ return props.kind === "search" ? /* @__PURE__ */ jsx8(WebSearchBlock, { ...props }) : /* @__PURE__ */ jsx8(WebFetchBlock, { ...props });
1594
+ }
1595
+ export {
1596
+ CODE_HIGHLIGHT_EXTENSIONS,
1597
+ CommandText,
1598
+ DEFAULT_DIFF_MAX_LINES,
1599
+ DEFAULT_READ_MAX_LINES,
1600
+ DEFAULT_SEARCH_MAX_LINES,
1601
+ DEFAULT_TERMINAL_MAX_LINES,
1602
+ DiffBlock,
1603
+ FileTypeIcon,
1604
+ JsonTree,
1605
+ LinkIconMedium,
1606
+ LinkIconRegular,
1607
+ ReadBlock,
1608
+ SearchBlock,
1609
+ TerminalBlock,
1610
+ WebBlock,
1611
+ classifyFileType,
1612
+ classifyLinkPath,
1613
+ diffTotals,
1614
+ fileExtension,
1615
+ languageForPath,
1616
+ useCodeHighlighter
1617
+ };