@mdxui/terminal 2.0.0

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 (191) hide show
  1. package/README.md +571 -0
  2. package/dist/ansi-css-Sk5mWtdK.d.ts +119 -0
  3. package/dist/ansi-css-V6JIHGsM.d.ts +119 -0
  4. package/dist/ansi-css-_3eSEU9d.d.ts +119 -0
  5. package/dist/chunk-3EFDH7PK.js +5235 -0
  6. package/dist/chunk-3RG5ZIWI.js +10 -0
  7. package/dist/chunk-3X5IR6WE.js +884 -0
  8. package/dist/chunk-4FV5ZDCE.js +5236 -0
  9. package/dist/chunk-4OVMSF2J.js +243 -0
  10. package/dist/chunk-63FEETIS.js +4048 -0
  11. package/dist/chunk-B43KP7XJ.js +884 -0
  12. package/dist/chunk-BMTJXWUV.js +655 -0
  13. package/dist/chunk-C3SVH4N7.js +882 -0
  14. package/dist/chunk-EVWR7Y47.js +874 -0
  15. package/dist/chunk-F6A5VWUC.js +1285 -0
  16. package/dist/chunk-FD7KW7GE.js +882 -0
  17. package/dist/chunk-GBQ6UD6I.js +655 -0
  18. package/dist/chunk-GMDD3M6U.js +5227 -0
  19. package/dist/chunk-JBHRXOXM.js +1058 -0
  20. package/dist/chunk-JFOO3EYO.js +1182 -0
  21. package/dist/chunk-JQ5H3WXL.js +1291 -0
  22. package/dist/chunk-JQD5NASE.js +234 -0
  23. package/dist/chunk-KRHJP5R7.js +592 -0
  24. package/dist/chunk-KWF6WVJE.js +962 -0
  25. package/dist/chunk-LHYQVN3H.js +1038 -0
  26. package/dist/chunk-M3TLQLGC.js +1032 -0
  27. package/dist/chunk-MVW4Q5OP.js +240 -0
  28. package/dist/chunk-NXCZSWLU.js +1294 -0
  29. package/dist/chunk-O25TNRO6.js +607 -0
  30. package/dist/chunk-PNECDA2I.js +884 -0
  31. package/dist/chunk-QIHWRLJR.js +962 -0
  32. package/dist/chunk-QW5YMQ7K.js +882 -0
  33. package/dist/chunk-R5U7XKVJ.js +16 -0
  34. package/dist/chunk-RP2MVQLR.js +962 -0
  35. package/dist/chunk-TP6RXGXA.js +1087 -0
  36. package/dist/chunk-TQQSTITZ.js +655 -0
  37. package/dist/chunk-X24GWXQV.js +1281 -0
  38. package/dist/components/index.d.ts +802 -0
  39. package/dist/components/index.js +149 -0
  40. package/dist/data/index.d.ts +2554 -0
  41. package/dist/data/index.js +51 -0
  42. package/dist/forms/index.d.ts +1596 -0
  43. package/dist/forms/index.js +464 -0
  44. package/dist/index-CQRFZntR.d.ts +867 -0
  45. package/dist/index.d.ts +579 -0
  46. package/dist/index.js +786 -0
  47. package/dist/interactive-D0JkWosD.d.ts +217 -0
  48. package/dist/keyboard/index.d.ts +2 -0
  49. package/dist/keyboard/index.js +43 -0
  50. package/dist/renderers/index.d.ts +546 -0
  51. package/dist/renderers/index.js +2157 -0
  52. package/dist/storybook/index.d.ts +396 -0
  53. package/dist/storybook/index.js +641 -0
  54. package/dist/theme/index.d.ts +1339 -0
  55. package/dist/theme/index.js +123 -0
  56. package/dist/types-Bxu5PAgA.d.ts +710 -0
  57. package/dist/types-CIlop5Ji.d.ts +701 -0
  58. package/dist/types-Ca8p_p5X.d.ts +710 -0
  59. package/package.json +90 -0
  60. package/src/__tests__/components/data/card.test.ts +458 -0
  61. package/src/__tests__/components/data/list.test.ts +473 -0
  62. package/src/__tests__/components/data/metrics.test.ts +541 -0
  63. package/src/__tests__/components/data/table.test.ts +448 -0
  64. package/src/__tests__/components/input/field.test.ts +555 -0
  65. package/src/__tests__/components/input/form.test.ts +870 -0
  66. package/src/__tests__/components/input/search.test.ts +1238 -0
  67. package/src/__tests__/components/input/select.test.ts +658 -0
  68. package/src/__tests__/components/navigation/breadcrumb.test.ts +923 -0
  69. package/src/__tests__/components/navigation/command-palette.test.ts +1095 -0
  70. package/src/__tests__/components/navigation/sidebar.test.ts +1018 -0
  71. package/src/__tests__/components/navigation/tabs.test.ts +995 -0
  72. package/src/__tests__/components.test.tsx +1197 -0
  73. package/src/__tests__/core/compiler.test.ts +986 -0
  74. package/src/__tests__/core/parser.test.ts +785 -0
  75. package/src/__tests__/core/tier-switcher.test.ts +1103 -0
  76. package/src/__tests__/core/types.test.ts +1398 -0
  77. package/src/__tests__/data/collections.test.ts +1337 -0
  78. package/src/__tests__/data/db.test.ts +1265 -0
  79. package/src/__tests__/data/reactive.test.ts +1010 -0
  80. package/src/__tests__/data/sync.test.ts +1614 -0
  81. package/src/__tests__/errors.test.ts +660 -0
  82. package/src/__tests__/forms/integration.test.ts +444 -0
  83. package/src/__tests__/integration.test.ts +905 -0
  84. package/src/__tests__/keyboard.test.ts +1791 -0
  85. package/src/__tests__/renderer.test.ts +489 -0
  86. package/src/__tests__/renderers/ansi-css.test.ts +948 -0
  87. package/src/__tests__/renderers/ansi.test.ts +1366 -0
  88. package/src/__tests__/renderers/ascii.test.ts +1360 -0
  89. package/src/__tests__/renderers/interactive.test.ts +2353 -0
  90. package/src/__tests__/renderers/markdown.test.ts +1483 -0
  91. package/src/__tests__/renderers/text.test.ts +1369 -0
  92. package/src/__tests__/renderers/unicode.test.ts +1307 -0
  93. package/src/__tests__/theme.test.ts +639 -0
  94. package/src/__tests__/utils/assertions.ts +685 -0
  95. package/src/__tests__/utils/index.ts +115 -0
  96. package/src/__tests__/utils/test-renderer.ts +381 -0
  97. package/src/__tests__/utils/utils.test.ts +560 -0
  98. package/src/components/containers/card.ts +56 -0
  99. package/src/components/containers/dialog.ts +53 -0
  100. package/src/components/containers/index.ts +9 -0
  101. package/src/components/containers/panel.ts +59 -0
  102. package/src/components/feedback/badge.ts +40 -0
  103. package/src/components/feedback/index.ts +8 -0
  104. package/src/components/feedback/spinner.ts +23 -0
  105. package/src/components/helpers.ts +81 -0
  106. package/src/components/index.ts +153 -0
  107. package/src/components/layout/breadcrumb.ts +31 -0
  108. package/src/components/layout/index.ts +10 -0
  109. package/src/components/layout/list.ts +29 -0
  110. package/src/components/layout/sidebar.ts +79 -0
  111. package/src/components/layout/table.ts +62 -0
  112. package/src/components/primitives/box.ts +95 -0
  113. package/src/components/primitives/button.ts +54 -0
  114. package/src/components/primitives/index.ts +11 -0
  115. package/src/components/primitives/input.ts +88 -0
  116. package/src/components/primitives/select.ts +97 -0
  117. package/src/components/primitives/text.ts +60 -0
  118. package/src/components/render.ts +155 -0
  119. package/src/components/templates/app.ts +43 -0
  120. package/src/components/templates/index.ts +8 -0
  121. package/src/components/templates/site.ts +54 -0
  122. package/src/components/types.ts +777 -0
  123. package/src/core/compiler.ts +718 -0
  124. package/src/core/parser.ts +127 -0
  125. package/src/core/tier-switcher.ts +607 -0
  126. package/src/core/types.ts +672 -0
  127. package/src/data/collection.ts +316 -0
  128. package/src/data/collections.ts +50 -0
  129. package/src/data/context.tsx +174 -0
  130. package/src/data/db.ts +127 -0
  131. package/src/data/hooks.ts +532 -0
  132. package/src/data/index.ts +138 -0
  133. package/src/data/reactive.ts +1225 -0
  134. package/src/data/saas-collections.ts +375 -0
  135. package/src/data/sync.ts +1213 -0
  136. package/src/data/types.ts +660 -0
  137. package/src/forms/converters.ts +512 -0
  138. package/src/forms/index.ts +133 -0
  139. package/src/forms/schemas.ts +403 -0
  140. package/src/forms/types.ts +476 -0
  141. package/src/index.ts +542 -0
  142. package/src/keyboard/focus.ts +748 -0
  143. package/src/keyboard/index.ts +96 -0
  144. package/src/keyboard/integration.ts +371 -0
  145. package/src/keyboard/manager.ts +377 -0
  146. package/src/keyboard/presets.ts +90 -0
  147. package/src/renderers/ansi-css.ts +576 -0
  148. package/src/renderers/ansi.ts +802 -0
  149. package/src/renderers/ascii.ts +680 -0
  150. package/src/renderers/breadcrumb.ts +480 -0
  151. package/src/renderers/command-palette.ts +802 -0
  152. package/src/renderers/components/field.ts +210 -0
  153. package/src/renderers/components/form.ts +327 -0
  154. package/src/renderers/components/index.ts +21 -0
  155. package/src/renderers/components/search.ts +449 -0
  156. package/src/renderers/components/select.ts +222 -0
  157. package/src/renderers/index.ts +101 -0
  158. package/src/renderers/interactive/component-handlers.ts +622 -0
  159. package/src/renderers/interactive/cursor-manager.ts +147 -0
  160. package/src/renderers/interactive/focus-manager.ts +279 -0
  161. package/src/renderers/interactive/index.ts +661 -0
  162. package/src/renderers/interactive/input-handler.ts +164 -0
  163. package/src/renderers/interactive/keyboard-handler.ts +212 -0
  164. package/src/renderers/interactive/mouse-handler.ts +167 -0
  165. package/src/renderers/interactive/state-manager.ts +109 -0
  166. package/src/renderers/interactive/types.ts +338 -0
  167. package/src/renderers/interactive-string.ts +299 -0
  168. package/src/renderers/interactive.ts +59 -0
  169. package/src/renderers/markdown.ts +950 -0
  170. package/src/renderers/sidebar.ts +549 -0
  171. package/src/renderers/tabs.ts +682 -0
  172. package/src/renderers/text.ts +791 -0
  173. package/src/renderers/unicode.ts +917 -0
  174. package/src/renderers/utils.ts +942 -0
  175. package/src/router/adapters.ts +383 -0
  176. package/src/router/types.ts +140 -0
  177. package/src/router/utils.ts +452 -0
  178. package/src/schemas.ts +205 -0
  179. package/src/storybook/index.ts +91 -0
  180. package/src/storybook/interactive-decorator.tsx +659 -0
  181. package/src/storybook/keyboard-simulator.ts +501 -0
  182. package/src/theme/ansi-codes.ts +80 -0
  183. package/src/theme/box-drawing.ts +132 -0
  184. package/src/theme/color-convert.ts +254 -0
  185. package/src/theme/color-support.ts +321 -0
  186. package/src/theme/index.ts +134 -0
  187. package/src/theme/strip-ansi.ts +50 -0
  188. package/src/theme/tailwind-map.ts +469 -0
  189. package/src/theme/text-styles.ts +206 -0
  190. package/src/theme/theme-system.ts +568 -0
  191. package/src/types.ts +103 -0
@@ -0,0 +1,962 @@
1
+ import {
2
+ ANSI,
3
+ CreateTerminalThemeOptionsSchema,
4
+ CreateThemeInputSchema,
5
+ hexToAnsi,
6
+ rgbToAnsi256
7
+ } from "./chunk-MVW4Q5OP.js";
8
+
9
+ // src/theme/tailwind-map.ts
10
+ var TAILWIND_COLORS = {
11
+ gray: {
12
+ "50": "#f9fafb",
13
+ "100": "#f3f4f6",
14
+ "200": "#e5e7eb",
15
+ "300": "#d1d5db",
16
+ "400": "#9ca3af",
17
+ "500": "#6b7280",
18
+ "600": "#4b5563",
19
+ "700": "#374151",
20
+ "800": "#1f2937",
21
+ "900": "#111827",
22
+ "950": "#030712"
23
+ },
24
+ slate: {
25
+ "50": "#f8fafc",
26
+ "100": "#f1f5f9",
27
+ "200": "#e2e8f0",
28
+ "300": "#cbd5e1",
29
+ "400": "#94a3b8",
30
+ "500": "#64748b",
31
+ "600": "#475569",
32
+ "700": "#334155",
33
+ "800": "#1e293b",
34
+ "900": "#0f172a",
35
+ "950": "#020617"
36
+ },
37
+ zinc: {
38
+ "50": "#fafafa",
39
+ "100": "#f4f4f5",
40
+ "200": "#e4e4e7",
41
+ "300": "#d4d4d8",
42
+ "400": "#a1a1aa",
43
+ "500": "#71717a",
44
+ "600": "#52525b",
45
+ "700": "#3f3f46",
46
+ "800": "#27272a",
47
+ "900": "#18181b",
48
+ "950": "#09090b"
49
+ },
50
+ neutral: {
51
+ "50": "#fafafa",
52
+ "100": "#f5f5f5",
53
+ "200": "#e5e5e5",
54
+ "300": "#d4d4d4",
55
+ "400": "#a3a3a3",
56
+ "500": "#737373",
57
+ "600": "#525252",
58
+ "700": "#404040",
59
+ "800": "#262626",
60
+ "900": "#171717",
61
+ "950": "#0a0a0a"
62
+ },
63
+ stone: {
64
+ "50": "#fafaf9",
65
+ "100": "#f5f5f4",
66
+ "200": "#e7e5e4",
67
+ "300": "#d6d3d1",
68
+ "400": "#a8a29e",
69
+ "500": "#78716c",
70
+ "600": "#57534e",
71
+ "700": "#44403c",
72
+ "800": "#292524",
73
+ "900": "#1c1917",
74
+ "950": "#0c0a09"
75
+ },
76
+ red: {
77
+ "50": "#fef2f2",
78
+ "100": "#fee2e2",
79
+ "200": "#fecaca",
80
+ "300": "#fca5a5",
81
+ "400": "#f87171",
82
+ "500": "#ef4444",
83
+ "600": "#dc2626",
84
+ "700": "#b91c1c",
85
+ "800": "#991b1b",
86
+ "900": "#7f1d1d",
87
+ "950": "#450a0a"
88
+ },
89
+ orange: {
90
+ "50": "#fff7ed",
91
+ "100": "#ffedd5",
92
+ "200": "#fed7aa",
93
+ "300": "#fdba74",
94
+ "400": "#fb923c",
95
+ "500": "#f97316",
96
+ "600": "#ea580c",
97
+ "700": "#c2410c",
98
+ "800": "#9a3412",
99
+ "900": "#7c2d12",
100
+ "950": "#431407"
101
+ },
102
+ amber: {
103
+ "50": "#fffbeb",
104
+ "100": "#fef3c7",
105
+ "200": "#fde68a",
106
+ "300": "#fcd34d",
107
+ "400": "#fbbf24",
108
+ "500": "#f59e0b",
109
+ "600": "#d97706",
110
+ "700": "#b45309",
111
+ "800": "#92400e",
112
+ "900": "#78350f",
113
+ "950": "#451a03"
114
+ },
115
+ yellow: {
116
+ "50": "#fefce8",
117
+ "100": "#fef9c3",
118
+ "200": "#fef08a",
119
+ "300": "#fde047",
120
+ "400": "#facc15",
121
+ "500": "#eab308",
122
+ "600": "#ca8a04",
123
+ "700": "#a16207",
124
+ "800": "#854d0e",
125
+ "900": "#713f12",
126
+ "950": "#422006"
127
+ },
128
+ lime: {
129
+ "50": "#f7fee7",
130
+ "100": "#ecfccb",
131
+ "200": "#d9f99d",
132
+ "300": "#bef264",
133
+ "400": "#a3e635",
134
+ "500": "#84cc16",
135
+ "600": "#65a30d",
136
+ "700": "#4d7c0f",
137
+ "800": "#3f6212",
138
+ "900": "#365314",
139
+ "950": "#1a2e05"
140
+ },
141
+ green: {
142
+ "50": "#f0fdf4",
143
+ "100": "#dcfce7",
144
+ "200": "#bbf7d0",
145
+ "300": "#86efac",
146
+ "400": "#4ade80",
147
+ "500": "#22c55e",
148
+ "600": "#16a34a",
149
+ "700": "#15803d",
150
+ "800": "#166534",
151
+ "900": "#14532d",
152
+ "950": "#052e16"
153
+ },
154
+ emerald: {
155
+ "50": "#ecfdf5",
156
+ "100": "#d1fae5",
157
+ "200": "#a7f3d0",
158
+ "300": "#6ee7b7",
159
+ "400": "#34d399",
160
+ "500": "#10b981",
161
+ "600": "#059669",
162
+ "700": "#047857",
163
+ "800": "#065f46",
164
+ "900": "#064e3b",
165
+ "950": "#022c22"
166
+ },
167
+ teal: {
168
+ "50": "#f0fdfa",
169
+ "100": "#ccfbf1",
170
+ "200": "#99f6e4",
171
+ "300": "#5eead4",
172
+ "400": "#2dd4bf",
173
+ "500": "#14b8a6",
174
+ "600": "#0d9488",
175
+ "700": "#0f766e",
176
+ "800": "#115e59",
177
+ "900": "#134e4a",
178
+ "950": "#042f2e"
179
+ },
180
+ cyan: {
181
+ "50": "#ecfeff",
182
+ "100": "#cffafe",
183
+ "200": "#a5f3fc",
184
+ "300": "#67e8f9",
185
+ "400": "#22d3ee",
186
+ "500": "#06b6d4",
187
+ "600": "#0891b2",
188
+ "700": "#0e7490",
189
+ "800": "#155e75",
190
+ "900": "#164e63",
191
+ "950": "#083344"
192
+ },
193
+ sky: {
194
+ "50": "#f0f9ff",
195
+ "100": "#e0f2fe",
196
+ "200": "#bae6fd",
197
+ "300": "#7dd3fc",
198
+ "400": "#38bdf8",
199
+ "500": "#0ea5e9",
200
+ "600": "#0284c7",
201
+ "700": "#0369a1",
202
+ "800": "#075985",
203
+ "900": "#0c4a6e",
204
+ "950": "#082f49"
205
+ },
206
+ blue: {
207
+ "50": "#eff6ff",
208
+ "100": "#dbeafe",
209
+ "200": "#bfdbfe",
210
+ "300": "#93c5fd",
211
+ "400": "#60a5fa",
212
+ "500": "#3b82f6",
213
+ "600": "#2563eb",
214
+ "700": "#1d4ed8",
215
+ "800": "#1e40af",
216
+ "900": "#1e3a8a",
217
+ "950": "#172554"
218
+ },
219
+ indigo: {
220
+ "50": "#eef2ff",
221
+ "100": "#e0e7ff",
222
+ "200": "#c7d2fe",
223
+ "300": "#a5b4fc",
224
+ "400": "#818cf8",
225
+ "500": "#6366f1",
226
+ "600": "#4f46e5",
227
+ "700": "#4338ca",
228
+ "800": "#3730a3",
229
+ "900": "#312e81",
230
+ "950": "#1e1b4b"
231
+ },
232
+ violet: {
233
+ "50": "#f5f3ff",
234
+ "100": "#ede9fe",
235
+ "200": "#ddd6fe",
236
+ "300": "#c4b5fd",
237
+ "400": "#a78bfa",
238
+ "500": "#8b5cf6",
239
+ "600": "#7c3aed",
240
+ "700": "#6d28d9",
241
+ "800": "#5b21b6",
242
+ "900": "#4c1d95",
243
+ "950": "#2e1065"
244
+ },
245
+ purple: {
246
+ "50": "#faf5ff",
247
+ "100": "#f3e8ff",
248
+ "200": "#e9d5ff",
249
+ "300": "#d8b4fe",
250
+ "400": "#c084fc",
251
+ "500": "#a855f7",
252
+ "600": "#9333ea",
253
+ "700": "#7e22ce",
254
+ "800": "#6b21a8",
255
+ "900": "#581c87",
256
+ "950": "#3b0764"
257
+ },
258
+ fuchsia: {
259
+ "50": "#fdf4ff",
260
+ "100": "#fae8ff",
261
+ "200": "#f5d0fe",
262
+ "300": "#f0abfc",
263
+ "400": "#e879f9",
264
+ "500": "#d946ef",
265
+ "600": "#c026d3",
266
+ "700": "#a21caf",
267
+ "800": "#86198f",
268
+ "900": "#701a75",
269
+ "950": "#4a044e"
270
+ },
271
+ pink: {
272
+ "50": "#fdf2f8",
273
+ "100": "#fce7f3",
274
+ "200": "#fbcfe8",
275
+ "300": "#f9a8d4",
276
+ "400": "#f472b6",
277
+ "500": "#ec4899",
278
+ "600": "#db2777",
279
+ "700": "#be185d",
280
+ "800": "#9d174d",
281
+ "900": "#831843",
282
+ "950": "#500724"
283
+ },
284
+ rose: {
285
+ "50": "#fff1f2",
286
+ "100": "#ffe4e6",
287
+ "200": "#fecdd3",
288
+ "300": "#fda4af",
289
+ "400": "#fb7185",
290
+ "500": "#f43f5e",
291
+ "600": "#e11d48",
292
+ "700": "#be123c",
293
+ "800": "#9f1239",
294
+ "900": "#881337",
295
+ "950": "#4c0519"
296
+ }
297
+ };
298
+ var TAILWIND_TO_ANSI_256 = {
299
+ "blue-500": 33,
300
+ // #3b82f6 - bright blue
301
+ "red-600": 160,
302
+ // #dc2626 - dark red
303
+ "green-400": 71,
304
+ // #4ade80 - light green
305
+ "yellow-500": 220,
306
+ // #eab308 - golden yellow
307
+ "purple-600": 128,
308
+ // #9333ea - purple
309
+ "gray-800": 238
310
+ // #1f2937 - dark gray (grayscale)
311
+ };
312
+ function tailwindToAnsi(className) {
313
+ if (className === "font-bold") return ANSI.bold;
314
+ if (className === "italic") return ANSI.italic;
315
+ if (className === "underline") return ANSI.underline;
316
+ if (className === "line-through") return ANSI.strikethrough;
317
+ if (className === "text-white") return "\x1B[38;5;15m";
318
+ if (className === "text-black") return "\x1B[38;5;0m";
319
+ const textMatch = className.match(/^text-(\w+)-(\d+)$/);
320
+ const bgMatch = className.match(/^bg-(\w+)-(\d+)$/);
321
+ if (textMatch) {
322
+ const [, color, shade] = textMatch;
323
+ const colorKey = `${color}-${shade}`;
324
+ if (TAILWIND_TO_ANSI_256[colorKey]) {
325
+ return `\x1B[38;5;${TAILWIND_TO_ANSI_256[colorKey]}m`;
326
+ }
327
+ if (TAILWIND_COLORS[color]?.[shade]) {
328
+ return hexToAnsi(TAILWIND_COLORS[color][shade]);
329
+ }
330
+ }
331
+ if (bgMatch) {
332
+ const [, color, shade] = bgMatch;
333
+ const colorKey = `${color}-${shade}`;
334
+ if (TAILWIND_TO_ANSI_256[colorKey]) {
335
+ return `\x1B[48;5;${TAILWIND_TO_ANSI_256[colorKey]}m`;
336
+ }
337
+ if (TAILWIND_COLORS[color]?.[shade]) {
338
+ return hexToAnsi(TAILWIND_COLORS[color][shade], { background: true });
339
+ }
340
+ }
341
+ return "";
342
+ }
343
+ var legacyTailwindToAnsi = {
344
+ // Text colors
345
+ "text-primary": ANSI.cyan,
346
+ "text-secondary": ANSI.blue,
347
+ "text-muted": ANSI.brightBlack,
348
+ "text-success": ANSI.green,
349
+ "text-warning": ANSI.yellow,
350
+ "text-error": ANSI.red,
351
+ "text-destructive": ANSI.red,
352
+ // Font styles
353
+ "font-bold": ANSI.bold,
354
+ "font-medium": ANSI.bold,
355
+ italic: ANSI.italic,
356
+ underline: ANSI.underline,
357
+ // Background colors
358
+ "bg-primary": ANSI.bgCyan,
359
+ "bg-secondary": ANSI.bgBlue,
360
+ "bg-muted": ANSI.bgBlack,
361
+ "bg-destructive": ANSI.bgRed
362
+ };
363
+ function tailwindToTerminal(classes) {
364
+ if (!classes || typeof classes !== "string") {
365
+ return "";
366
+ }
367
+ const parts = classes.split(" ").filter(Boolean);
368
+ const ansiCodes = [];
369
+ for (const cls of parts) {
370
+ if (legacyTailwindToAnsi[cls]) {
371
+ ansiCodes.push(legacyTailwindToAnsi[cls]);
372
+ }
373
+ }
374
+ return ansiCodes.join("");
375
+ }
376
+
377
+ // src/theme/theme-system.ts
378
+ var darkThemeColors = {
379
+ primary: "\x1B[38;5;33m",
380
+ // Blue
381
+ secondary: "\x1B[38;5;39m",
382
+ // Lighter blue
383
+ accent: "\x1B[38;5;200m",
384
+ // Magenta/Pink
385
+ muted: "\x1B[38;5;243m",
386
+ // Gray
387
+ success: "\x1B[38;5;71m",
388
+ // Green
389
+ warning: "\x1B[38;5;220m",
390
+ // Yellow
391
+ error: "\x1B[38;5;160m",
392
+ // Red
393
+ info: "\x1B[38;5;33m",
394
+ // Blue
395
+ border: "\x1B[38;5;240m",
396
+ // Dark gray
397
+ background: "\x1B[48;5;234m",
398
+ // Very dark gray
399
+ foreground: "\x1B[38;5;252m",
400
+ // Light gray
401
+ selection: "\x1B[48;5;24m",
402
+ // Dark blue background
403
+ focus: "\x1B[48;5;33m"
404
+ // Blue background
405
+ };
406
+ var lightThemeColors = {
407
+ primary: "\x1B[38;5;25m",
408
+ // Darker blue for light mode
409
+ secondary: "\x1B[38;5;31m",
410
+ // Darker cyan
411
+ accent: "\x1B[38;5;127m",
412
+ // Darker magenta
413
+ muted: "\x1B[38;5;245m",
414
+ // Medium gray
415
+ success: "\x1B[38;5;28m",
416
+ // Darker green
417
+ warning: "\x1B[38;5;172m",
418
+ // Darker yellow/orange
419
+ error: "\x1B[38;5;124m",
420
+ // Darker red
421
+ info: "\x1B[38;5;25m",
422
+ // Darker blue
423
+ border: "\x1B[38;5;250m",
424
+ // Light gray
425
+ background: "\x1B[48;5;255m",
426
+ // White
427
+ foreground: "\x1B[38;5;235m",
428
+ // Dark gray
429
+ selection: "\x1B[48;5;153m",
430
+ // Light blue background
431
+ focus: "\x1B[48;5;33m"
432
+ // Blue background
433
+ };
434
+ function createTerminalTheme(options) {
435
+ CreateTerminalThemeOptionsSchema.parse(options);
436
+ const mode = options.mode || "dark";
437
+ const baseColors = mode === "dark" ? darkThemeColors : lightThemeColors;
438
+ return {
439
+ mode,
440
+ colors: {
441
+ ...baseColors,
442
+ ...options.colors
443
+ }
444
+ };
445
+ }
446
+ function getThemeColor(theme, key, fallback) {
447
+ const color = theme.colors[key];
448
+ if (color !== void 0) {
449
+ return color;
450
+ }
451
+ if (fallback !== void 0) {
452
+ return fallback;
453
+ }
454
+ throw new Error(`Unknown theme color key: ${key}`);
455
+ }
456
+ var CSS_VAR_TO_THEME_KEY = {
457
+ "--primary": "primary",
458
+ "--secondary": "secondary",
459
+ "--accent": "accent",
460
+ "--muted": "muted",
461
+ "--muted-foreground": "muted",
462
+ "--success": "success",
463
+ "--warning": "warning",
464
+ "--error": "error",
465
+ "--destructive": "error",
466
+ "--info": "info",
467
+ "--border": "border",
468
+ "--background": "background",
469
+ "--foreground": "foreground",
470
+ "--selection": "selection",
471
+ "--focus": "focus"
472
+ };
473
+ function cssVarToAnsi(cssVar, theme) {
474
+ const key = CSS_VAR_TO_THEME_KEY[cssVar];
475
+ if (key && theme.colors[key]) {
476
+ return theme.colors[key];
477
+ }
478
+ return "";
479
+ }
480
+ function applyThemeStyles(text, theme, styleKey) {
481
+ const color = theme.colors[styleKey];
482
+ if (!color) {
483
+ return text;
484
+ }
485
+ return `${color}${text}${ANSI.reset}`;
486
+ }
487
+ var defaultTheme = {
488
+ primary: ANSI.cyan,
489
+ secondary: ANSI.blue,
490
+ accent: ANSI.magenta,
491
+ muted: ANSI.brightBlack,
492
+ success: ANSI.green,
493
+ warning: ANSI.yellow,
494
+ error: ANSI.red,
495
+ info: ANSI.blue,
496
+ border: ANSI.brightBlack,
497
+ background: "",
498
+ foreground: ANSI.white,
499
+ selection: ANSI.bgBlue,
500
+ focus: ANSI.bgCyan,
501
+ typography: {
502
+ headingWeight: "bold",
503
+ bodyWeight: "normal",
504
+ codeFont: "monospace"
505
+ },
506
+ spacing: {
507
+ xs: 1,
508
+ sm: 2,
509
+ md: 4,
510
+ lg: 8,
511
+ xl: 16
512
+ }
513
+ };
514
+ var colors = {
515
+ primary: ANSI.cyan,
516
+ secondary: ANSI.blue,
517
+ accent: ANSI.magenta,
518
+ muted: ANSI.brightBlack,
519
+ success: ANSI.green,
520
+ warning: ANSI.yellow,
521
+ error: ANSI.red,
522
+ info: ANSI.blue
523
+ };
524
+ var themeTokens = {
525
+ primary: "primary",
526
+ secondary: "secondary",
527
+ accent: "accent",
528
+ muted: "muted",
529
+ success: "success",
530
+ warning: "warning",
531
+ error: "error",
532
+ info: "info"
533
+ };
534
+ var darkTheme = {
535
+ ...defaultTheme,
536
+ background: ANSI.bgBlack,
537
+ foreground: ANSI.brightWhite
538
+ };
539
+ var lightTheme = {
540
+ ...defaultTheme,
541
+ background: ANSI.bgWhite,
542
+ foreground: ANSI.black
543
+ };
544
+ var highContrastTheme = {
545
+ ...defaultTheme,
546
+ foreground: ANSI.brightWhite,
547
+ background: ANSI.bgBlack,
548
+ primary: ANSI.brightCyan,
549
+ secondary: ANSI.brightBlue
550
+ };
551
+ var themePresets = {
552
+ default: defaultTheme,
553
+ dark: darkTheme,
554
+ light: lightTheme,
555
+ highContrast: highContrastTheme
556
+ };
557
+ function deepMerge(target, source) {
558
+ const result = { ...target };
559
+ for (const key of Object.keys(source)) {
560
+ const sourceValue = source[key];
561
+ const targetValue = target[key];
562
+ if (sourceValue !== void 0) {
563
+ if (typeof sourceValue === "object" && sourceValue !== null && !Array.isArray(sourceValue) && typeof targetValue === "object" && targetValue !== null && !Array.isArray(targetValue)) {
564
+ result[key] = deepMerge(
565
+ targetValue,
566
+ sourceValue
567
+ );
568
+ } else {
569
+ result[key] = sourceValue;
570
+ }
571
+ }
572
+ }
573
+ return result;
574
+ }
575
+ function createTheme(partial) {
576
+ CreateThemeInputSchema.parse(partial);
577
+ return deepMerge(defaultTheme, partial);
578
+ }
579
+ function extendTheme(base, overrides) {
580
+ return deepMerge(base, overrides);
581
+ }
582
+ function composeThemes(...themes) {
583
+ return themes.reduce((acc, theme) => deepMerge(acc, theme), {});
584
+ }
585
+ function createThemeVariant(base, _name, overrides) {
586
+ return extendTheme(base, overrides);
587
+ }
588
+ function detectColorScheme() {
589
+ if (typeof process !== "undefined") {
590
+ const colorBg = process.env?.COLORFGBG;
591
+ if (colorBg) {
592
+ const parts = colorBg.split(";");
593
+ if (parts.length >= 2) {
594
+ const bg2 = parseInt(parts[1], 10);
595
+ if (bg2 > 7 && bg2 < 16) {
596
+ return "light";
597
+ }
598
+ }
599
+ }
600
+ }
601
+ return "dark";
602
+ }
603
+
604
+ // src/theme/text-styles.ts
605
+ function fg(colorName, text) {
606
+ const colorCode = colors[colorName] || defaultTheme[colorName] || colorName;
607
+ return `${colorCode}${text}${ANSI.reset}`;
608
+ }
609
+ function bg(colorName, text) {
610
+ const bgMap = {
611
+ primary: ANSI.bgCyan,
612
+ secondary: ANSI.bgBlue,
613
+ accent: ANSI.bgMagenta,
614
+ muted: ANSI.bgBlack,
615
+ success: ANSI.bgGreen,
616
+ warning: ANSI.bgYellow,
617
+ error: ANSI.bgRed,
618
+ info: ANSI.bgBlue
619
+ };
620
+ const colorCode = bgMap[colorName] || colorName;
621
+ return `${colorCode}${text}${ANSI.reset}`;
622
+ }
623
+ function bold(text) {
624
+ return `${ANSI.bold}${text}${ANSI.reset}`;
625
+ }
626
+ function dim(text) {
627
+ return `${ANSI.dim}${text}${ANSI.reset}`;
628
+ }
629
+ function italic(text) {
630
+ return `${ANSI.italic}${text}${ANSI.reset}`;
631
+ }
632
+ function underline(text) {
633
+ return `${ANSI.underline}${text}${ANSI.reset}`;
634
+ }
635
+ function strikethrough(text) {
636
+ return `${ANSI.strikethrough}${text}${ANSI.reset}`;
637
+ }
638
+ function style(text, modifiers) {
639
+ const modifierMap = {
640
+ bold: ANSI.bold,
641
+ dim: ANSI.dim,
642
+ italic: ANSI.italic,
643
+ underline: ANSI.underline,
644
+ strikethrough: ANSI.strikethrough,
645
+ black: ANSI.black,
646
+ red: ANSI.red,
647
+ green: ANSI.green,
648
+ yellow: ANSI.yellow,
649
+ blue: ANSI.blue,
650
+ magenta: ANSI.magenta,
651
+ cyan: ANSI.cyan,
652
+ white: ANSI.white,
653
+ brightBlack: ANSI.brightBlack,
654
+ brightRed: ANSI.brightRed,
655
+ brightGreen: ANSI.brightGreen,
656
+ brightYellow: ANSI.brightYellow,
657
+ brightBlue: ANSI.brightBlue,
658
+ brightMagenta: ANSI.brightMagenta,
659
+ brightCyan: ANSI.brightCyan,
660
+ brightWhite: ANSI.brightWhite
661
+ };
662
+ const codes = modifiers.map((m) => modifierMap[m] || "").filter(Boolean);
663
+ if (codes.length === 0) return text;
664
+ return `${codes.join("")}${text}${ANSI.reset}`;
665
+ }
666
+ function styled(text, ...codes) {
667
+ if (text == null) return "";
668
+ if (codes.length === 0) return String(text);
669
+ const validCodes = codes.filter((c) => c && typeof c === "string");
670
+ if (validCodes.length === 0) return String(text);
671
+ return `${validCodes.join("")}${text}${ANSI.reset}`;
672
+ }
673
+
674
+ // src/theme/color-support.ts
675
+ function detectColorSupport() {
676
+ if (process.env.NO_COLOR) {
677
+ return "none";
678
+ }
679
+ if (process.env.FORCE_COLOR) {
680
+ const level = parseInt(process.env.FORCE_COLOR, 10);
681
+ if (level === 0) return "none";
682
+ if (level === 1) return "16";
683
+ if (level === 2) return "256";
684
+ if (level >= 3) return "truecolor";
685
+ }
686
+ const colorTerm = process.env.COLORTERM;
687
+ if (colorTerm === "truecolor" || colorTerm === "24bit") {
688
+ return "truecolor";
689
+ }
690
+ const term = process.env.TERM || "";
691
+ if (term === "dumb") {
692
+ return "none";
693
+ }
694
+ if (term.includes("256color")) {
695
+ return "256";
696
+ }
697
+ if (term.includes("color") || term.includes("xterm") || term.includes("vt100")) {
698
+ return "16";
699
+ }
700
+ return "256";
701
+ }
702
+ function ansi256To16(code) {
703
+ if (code < 8) {
704
+ return 30 + code;
705
+ }
706
+ if (code < 16) {
707
+ return 90 + (code - 8);
708
+ }
709
+ let r, g, b;
710
+ if (code >= 232) {
711
+ const gray = (code - 232) * 10 + 8;
712
+ r = g = b = gray;
713
+ } else {
714
+ const cubeIndex = code - 16;
715
+ r = Math.floor(cubeIndex / 36) * 51;
716
+ g = Math.floor(cubeIndex % 36 / 6) * 51;
717
+ b = cubeIndex % 6 * 51;
718
+ }
719
+ const basicColors = [
720
+ { r: 0, g: 0, b: 0, code: 30 },
721
+ // black
722
+ { r: 170, g: 0, b: 0, code: 31 },
723
+ // red
724
+ { r: 0, g: 170, b: 0, code: 32 },
725
+ // green
726
+ { r: 170, g: 170, b: 0, code: 33 },
727
+ // yellow
728
+ { r: 0, g: 0, b: 170, code: 34 },
729
+ // blue
730
+ { r: 170, g: 0, b: 170, code: 35 },
731
+ // magenta
732
+ { r: 0, g: 170, b: 170, code: 36 },
733
+ // cyan
734
+ { r: 170, g: 170, b: 170, code: 37 },
735
+ // white
736
+ { r: 85, g: 85, b: 85, code: 90 },
737
+ // bright black
738
+ { r: 255, g: 85, b: 85, code: 91 },
739
+ // bright red
740
+ { r: 85, g: 255, b: 85, code: 92 },
741
+ // bright green
742
+ { r: 255, g: 255, b: 85, code: 93 },
743
+ // bright yellow
744
+ { r: 85, g: 85, b: 255, code: 94 },
745
+ // bright blue
746
+ { r: 255, g: 85, b: 255, code: 95 },
747
+ // bright magenta
748
+ { r: 85, g: 255, b: 255, code: 96 },
749
+ // bright cyan
750
+ { r: 255, g: 255, b: 255, code: 97 }
751
+ // bright white
752
+ ];
753
+ let minDist = Infinity;
754
+ let closestCode = 37;
755
+ for (const bc of basicColors) {
756
+ const dist = Math.sqrt(
757
+ Math.pow(r - bc.r, 2) + Math.pow(g - bc.g, 2) + Math.pow(b - bc.b, 2)
758
+ );
759
+ if (dist < minDist) {
760
+ minDist = dist;
761
+ closestCode = bc.code;
762
+ }
763
+ }
764
+ return closestCode;
765
+ }
766
+ function parseAnsiCode(ansi) {
767
+ const fg256Match = ansi.match(/\x1b\[38;5;(\d+)m/);
768
+ if (fg256Match) {
769
+ return { type: "fg", format: "256", code: parseInt(fg256Match[1], 10) };
770
+ }
771
+ const bg256Match = ansi.match(/\x1b\[48;5;(\d+)m/);
772
+ if (bg256Match) {
773
+ return { type: "bg", format: "256", code: parseInt(bg256Match[1], 10) };
774
+ }
775
+ const fgTrueMatch = ansi.match(/\x1b\[38;2;(\d+);(\d+);(\d+)m/);
776
+ if (fgTrueMatch) {
777
+ return {
778
+ type: "fg",
779
+ format: "truecolor",
780
+ rgb: {
781
+ r: parseInt(fgTrueMatch[1], 10),
782
+ g: parseInt(fgTrueMatch[2], 10),
783
+ b: parseInt(fgTrueMatch[3], 10)
784
+ }
785
+ };
786
+ }
787
+ const bgTrueMatch = ansi.match(/\x1b\[48;2;(\d+);(\d+);(\d+)m/);
788
+ if (bgTrueMatch) {
789
+ return {
790
+ type: "bg",
791
+ format: "truecolor",
792
+ rgb: {
793
+ r: parseInt(bgTrueMatch[1], 10),
794
+ g: parseInt(bgTrueMatch[2], 10),
795
+ b: parseInt(bgTrueMatch[3], 10)
796
+ }
797
+ };
798
+ }
799
+ const basicMatch = ansi.match(/\x1b\[(\d+)m/);
800
+ if (basicMatch) {
801
+ const code = parseInt(basicMatch[1], 10);
802
+ if (code >= 30 && code <= 37) {
803
+ return { type: "fg", format: "16", code };
804
+ }
805
+ if (code >= 90 && code <= 97) {
806
+ return { type: "fg", format: "16", code };
807
+ }
808
+ if (code >= 40 && code <= 47) {
809
+ return { type: "bg", format: "16", code };
810
+ }
811
+ if (code >= 100 && code <= 107) {
812
+ return { type: "bg", format: "16", code };
813
+ }
814
+ return { type: "style", format: "16", code };
815
+ }
816
+ return null;
817
+ }
818
+ function degradeColor(ansi, support) {
819
+ if (support === "none") {
820
+ return "";
821
+ }
822
+ if (support === "truecolor") {
823
+ return ansi;
824
+ }
825
+ const parsed = parseAnsiCode(ansi);
826
+ if (!parsed) {
827
+ return ansi;
828
+ }
829
+ if (support === "256") {
830
+ if (parsed.format === "truecolor" && parsed.rgb) {
831
+ const code = rgbToAnsi256(parsed.rgb.r, parsed.rgb.g, parsed.rgb.b);
832
+ const prefix = parsed.type === "bg" ? "48" : "38";
833
+ return `\x1B[${prefix};5;${code}m`;
834
+ }
835
+ return ansi;
836
+ }
837
+ if (support === "16") {
838
+ if (parsed.format === "16") {
839
+ return ansi;
840
+ }
841
+ let code256;
842
+ if (parsed.format === "truecolor" && parsed.rgb) {
843
+ code256 = rgbToAnsi256(parsed.rgb.r, parsed.rgb.g, parsed.rgb.b);
844
+ } else if (parsed.code !== void 0) {
845
+ code256 = parsed.code;
846
+ } else {
847
+ return ansi;
848
+ }
849
+ const code16 = ansi256To16(code256);
850
+ return `\x1B[${code16}m`;
851
+ }
852
+ return ansi;
853
+ }
854
+ function adaptColor(color, level) {
855
+ return degradeColor(color, level);
856
+ }
857
+
858
+ // src/theme/strip-ansi.ts
859
+ function stripAnsi(text) {
860
+ if (!text || typeof text !== "string") {
861
+ return "";
862
+ }
863
+ return text.replace(/\x1b\[[0-9;]*m/g, "");
864
+ }
865
+ function visibleLength(text) {
866
+ return stripAnsi(text).length;
867
+ }
868
+
869
+ // src/theme/box-drawing.ts
870
+ var boxChars = {
871
+ single: {
872
+ topLeft: "\u250C",
873
+ topRight: "\u2510",
874
+ bottomLeft: "\u2514",
875
+ bottomRight: "\u2518",
876
+ horizontal: "\u2500",
877
+ vertical: "\u2502",
878
+ teeLeft: "\u251C",
879
+ teeRight: "\u2524",
880
+ teeTop: "\u252C",
881
+ teeBottom: "\u2534",
882
+ cross: "\u253C"
883
+ },
884
+ double: {
885
+ topLeft: "\u2554",
886
+ topRight: "\u2557",
887
+ bottomLeft: "\u255A",
888
+ bottomRight: "\u255D",
889
+ horizontal: "\u2550",
890
+ vertical: "\u2551",
891
+ teeLeft: "\u2560",
892
+ teeRight: "\u2563",
893
+ teeTop: "\u2566",
894
+ teeBottom: "\u2569",
895
+ cross: "\u256C"
896
+ },
897
+ rounded: {
898
+ topLeft: "\u256D",
899
+ topRight: "\u256E",
900
+ bottomLeft: "\u2570",
901
+ bottomRight: "\u256F",
902
+ horizontal: "\u2500",
903
+ vertical: "\u2502",
904
+ teeLeft: "\u251C",
905
+ teeRight: "\u2524",
906
+ teeTop: "\u252C",
907
+ teeBottom: "\u2534",
908
+ cross: "\u253C"
909
+ }
910
+ };
911
+ function drawBox(width, height, style2 = "single") {
912
+ if (width < 2) width = 2;
913
+ if (height < 2) height = 2;
914
+ width = Math.floor(width);
915
+ height = Math.floor(height);
916
+ const chars = boxChars[style2];
917
+ const lines = [];
918
+ lines.push(chars.topLeft + chars.horizontal.repeat(Math.max(0, width - 2)) + chars.topRight);
919
+ for (let i = 0; i < height - 2; i++) {
920
+ lines.push(chars.vertical + " ".repeat(Math.max(0, width - 2)) + chars.vertical);
921
+ }
922
+ lines.push(chars.bottomLeft + chars.horizontal.repeat(Math.max(0, width - 2)) + chars.bottomRight);
923
+ return lines;
924
+ }
925
+
926
+ export {
927
+ TAILWIND_COLORS,
928
+ tailwindToAnsi,
929
+ tailwindToTerminal,
930
+ createTerminalTheme,
931
+ getThemeColor,
932
+ cssVarToAnsi,
933
+ applyThemeStyles,
934
+ defaultTheme,
935
+ colors,
936
+ themeTokens,
937
+ darkTheme,
938
+ lightTheme,
939
+ highContrastTheme,
940
+ themePresets,
941
+ createTheme,
942
+ extendTheme,
943
+ composeThemes,
944
+ createThemeVariant,
945
+ detectColorScheme,
946
+ fg,
947
+ bg,
948
+ bold,
949
+ dim,
950
+ italic,
951
+ underline,
952
+ strikethrough,
953
+ style,
954
+ styled,
955
+ detectColorSupport,
956
+ degradeColor,
957
+ adaptColor,
958
+ stripAnsi,
959
+ visibleLength,
960
+ boxChars,
961
+ drawBox
962
+ };