@gridland/demo 0.2.18 → 0.2.20

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.
package/dist/landing.js CHANGED
@@ -1,6 +1,1250 @@
1
+ // ../docs/components/landing/landing-app.tsx
2
+ import { useState as useState10 } from "react";
3
+
4
+ // ../ui/components/theme/themes.ts
5
+ var darkTheme = {
6
+ primary: "#FF71CE",
7
+ accent: "#01CDFE",
8
+ secondary: "#B967FF",
9
+ muted: "#A69CBD",
10
+ placeholder: "#CEC7DE",
11
+ border: "#B967FF",
12
+ foreground: "#F0E6FF",
13
+ background: "#0D0B10",
14
+ success: "#05FFA1",
15
+ error: "#FF6B6B",
16
+ warning: "#FFC164"
17
+ };
18
+
19
+ // ../ui/components/theme/theme-context.tsx
20
+ import { createContext, useContext } from "react";
21
+ import { jsx } from "react/jsx-runtime";
22
+ var ThemeContext = createContext(darkTheme);
23
+ function useTheme() {
24
+ return useContext(ThemeContext);
25
+ }
26
+
27
+ // ../ui/components/link/link.tsx
28
+ import { jsx as jsx2 } from "react/jsx-runtime";
29
+ var UNDERLINE = 1 << 3;
30
+ var UNDERLINE_DASHED = 1 << 4;
31
+ var UNDERLINE_DOTTED = 1 << 6;
32
+
33
+ // ../ui/components/link/link-demo.tsx
34
+ import { useState } from "react";
35
+
36
+ // ../ui/components/text-style.ts
37
+ var BOLD = 1 << 0;
38
+ var DIM = 1 << 1;
39
+ var ITALIC = 1 << 2;
40
+ var UNDERLINE2 = 1 << 3;
41
+ var INVERSE = 1 << 5;
42
+ function textStyle(opts) {
43
+ let attributes = 0;
44
+ if (opts.bold) attributes |= BOLD;
45
+ if (opts.dim) attributes |= DIM;
46
+ if (opts.italic) attributes |= ITALIC;
47
+ if (opts.underline) attributes |= UNDERLINE2;
48
+ if (opts.inverse) attributes |= INVERSE;
49
+ const result = {};
50
+ if (opts.fg) result.fg = opts.fg;
51
+ if (opts.bg) result.bg = opts.bg;
52
+ if (attributes) result.attributes = attributes;
53
+ return result;
54
+ }
55
+
56
+ // ../ui/components/status-bar/status-bar.tsx
57
+ import { jsx as jsx3 } from "react/jsx-runtime";
58
+ function StatusBar({ items, extra }) {
59
+ const theme = useTheme();
60
+ const parts = [];
61
+ if (extra !== void 0) {
62
+ parts.push(
63
+ /* @__PURE__ */ jsx3("span", { children: extra }, "extra")
64
+ );
65
+ parts.push(
66
+ /* @__PURE__ */ jsx3("span", { style: textStyle({ dim: true, fg: theme.placeholder }), children: " \u2502 " }, "pipe")
67
+ );
68
+ }
69
+ items.forEach((item, i) => {
70
+ if (i > 0) {
71
+ parts.push(/* @__PURE__ */ jsx3("span", { children: " " }, `gap-${i}`));
72
+ }
73
+ parts.push(
74
+ /* @__PURE__ */ jsx3("span", { style: textStyle({ bold: true, fg: theme.background, bg: theme.muted }), children: ` ${item.key} ` }, `key-${i}`)
75
+ );
76
+ parts.push(
77
+ /* @__PURE__ */ jsx3("span", { style: textStyle({ dim: true, fg: theme.placeholder }), children: ` ${item.label}` }, `label-${i}`)
78
+ );
79
+ });
80
+ if (parts.length === 0) {
81
+ return null;
82
+ }
83
+ return /* @__PURE__ */ jsx3("text", { children: parts });
84
+ }
85
+
86
+ // ../ui/components/provider/provider.tsx
87
+ import { createContext as createContext2, useContext as useContext2 } from "react";
88
+ import { jsx as jsx4 } from "react/jsx-runtime";
89
+ var KeyboardContext = createContext2(null);
90
+ function useKeyboardContext(propOverride) {
91
+ const fromContext = useContext2(KeyboardContext);
92
+ return propOverride ?? fromContext ?? void 0;
93
+ }
94
+
95
+ // ../ui/components/link/link-demo.tsx
96
+ import { jsx as jsx5, jsxs } from "react/jsx-runtime";
97
+
98
+ // ../ui/components/ascii/ascii.tsx
99
+ import { jsx as jsx6 } from "react/jsx-runtime";
100
+
101
+ // ../ui/components/spinner/spinner.tsx
102
+ import { useEffect, useState as useState2 } from "react";
103
+ import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
104
+ var VARIANTS = {
105
+ dots: { frames: ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"], interval: 83 },
106
+ pulse: { frames: ["\xB7", "\u2219", "\u25CF", "\u2219", "\xB7", "\xB7", "\xB7"], interval: 180 },
107
+ meter: { frames: ["\u25B1\u25B1\u25B1", "\u25B0\u25B1\u25B1", "\u25B0\u25B0\u25B1", "\u25B0\u25B0\u25B0", "\u25B0\u25B0\u25B1", "\u25B0\u25B1\u25B1", "\u25B1\u25B1\u25B1"], interval: 143 },
108
+ bloom: { frames: ["\xB7", "\u2726", "\u2727", "\u2739", "\u273A", "\u274B", "\u2738", "\u2735", "\u2738", "\u274B", "\u273A", "\u2739", "\u2727", "\u2726", "\xB7", "\xB7"], interval: 100 },
109
+ ellipsis: { frames: [" ", ". ", ".. ", "..."], interval: 333 }
110
+ };
111
+ var VARIANT_NAMES = Object.keys(VARIANTS);
112
+
113
+ // ../ui/components/spinner/spinner-showcase.tsx
114
+ import { useState as useState3 } from "react";
115
+ import { jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
116
+
117
+ // ../ui/components/text-input/text-input.tsx
118
+ import { useCallback, useRef, useState as useState4 } from "react";
119
+ import { jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
120
+
121
+ // ../ui/components/select-input/select-input.tsx
122
+ import { useReducer, useMemo, useRef as useRef2 } from "react";
123
+ import { jsx as jsx10, jsxs as jsxs5 } from "react/jsx-runtime";
124
+
125
+ // ../ui/components/multi-select/multi-select.tsx
126
+ import { useReducer as useReducer2, useMemo as useMemo2, useRef as useRef3 } from "react";
127
+ import { jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
128
+
129
+ // ../ui/components/table/table.tsx
130
+ import { Fragment } from "react";
131
+ import { jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
132
+
133
+ // ../ui/components/gradient/gradient.tsx
134
+ import { Fragment as Fragment2, jsx as jsx13 } from "react/jsx-runtime";
135
+ var GRADIENTS = {
136
+ cristal: ["#bdfff3", "#4ac29a"],
137
+ teen: ["#77a1d3", "#79cbca", "#e684ae"],
138
+ mind: ["#473b7b", "#3584a7", "#30d2be"],
139
+ morning: ["#ff5f6d", "#ffc371"],
140
+ vice: ["#5ee7df", "#b490ca"],
141
+ passion: ["#f43b47", "#453a94"],
142
+ fruit: ["#ff4e50", "#f9d423"],
143
+ instagram: ["#833ab4", "#fd1d1d", "#fcb045"],
144
+ atlas: ["#feac5e", "#c779d0", "#4bc0c8"],
145
+ retro: ["#3f51b1", "#5a55ae", "#7b5fac", "#8f6aae", "#a86aa4", "#cc6b8e", "#f18271", "#f3a469", "#f7c978"],
146
+ summer: ["#fdbb2d", "#22c1c3"],
147
+ rainbow: ["#ff0000", "#ffff00", "#00ff00", "#00ffff", "#0000ff", "#ff00ff", "#ff0000"],
148
+ pastel: ["#74ebd5", "#ACB6E5"]
149
+ };
150
+ function hexToRgb(hex) {
151
+ const normalized = hex.replace("#", "");
152
+ return {
153
+ r: parseInt(normalized.substring(0, 2), 16),
154
+ g: parseInt(normalized.substring(2, 4), 16),
155
+ b: parseInt(normalized.substring(4, 6), 16)
156
+ };
157
+ }
158
+ function rgbToHex(rgb) {
159
+ const r = rgb.r.toString(16).padStart(2, "0");
160
+ const g = rgb.g.toString(16).padStart(2, "0");
161
+ const b = rgb.b.toString(16).padStart(2, "0");
162
+ return `#${r}${g}${b}`;
163
+ }
164
+ function lerp(a, b, t) {
165
+ return a + (b - a) * t;
166
+ }
167
+ function interpolateColor(color1, color2, t) {
168
+ return {
169
+ r: Math.round(lerp(color1.r, color2.r, t)),
170
+ g: Math.round(lerp(color1.g, color2.g, t)),
171
+ b: Math.round(lerp(color1.b, color2.b, t))
172
+ };
173
+ }
174
+ function generateGradient(colors, steps) {
175
+ if (colors.length === 0) throw new Error("At least one color is required");
176
+ if (colors.length === 1 || steps <= 1) return Array(steps).fill(colors[0]);
177
+ const rgbColors = colors.map(hexToRgb);
178
+ const result = [];
179
+ const segmentLength = (steps - 1) / (rgbColors.length - 1);
180
+ for (let i = 0; i < steps; i++) {
181
+ const segmentIndex = Math.min(Math.floor(i / segmentLength), rgbColors.length - 2);
182
+ const segmentProgress = segmentLength > 0 ? (i - segmentIndex * segmentLength) / segmentLength : 0;
183
+ const color = interpolateColor(rgbColors[segmentIndex], rgbColors[segmentIndex + 1], Math.min(segmentProgress, 1));
184
+ result.push(rgbToHex(color));
185
+ }
186
+ return result;
187
+ }
188
+ function Gradient({ children, name, colors }) {
189
+ if (name && colors) throw new Error("The `name` and `colors` props are mutually exclusive");
190
+ if (!name && !colors) throw new Error("Either `name` or `colors` prop must be provided");
191
+ const gradientColors = name ? GRADIENTS[name] : colors;
192
+ const lines = children.split("\n");
193
+ const maxLength = Math.max(...lines.map((l) => l.length));
194
+ if (maxLength === 0) return /* @__PURE__ */ jsx13("text", { children });
195
+ const hexColors = generateGradient(gradientColors, maxLength);
196
+ return /* @__PURE__ */ jsx13(Fragment2, { children: lines.map((line, lineIndex) => /* @__PURE__ */ jsx13("text", { children: line.split("").map((char, charIndex) => /* @__PURE__ */ jsx13("span", { style: { fg: hexColors[charIndex] }, children: char }, charIndex)) }, lineIndex)) });
197
+ }
198
+
199
+ // ../ui/components/tab-bar/tab-bar.tsx
200
+ import { createContext as createContext3, useContext as useContext3, useState as useState5, Children, isValidElement } from "react";
201
+ import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs8 } from "react/jsx-runtime";
202
+ var TabsContext = createContext3(null);
203
+
204
+ // ../ui/components/modal/modal.tsx
205
+ import { Fragment as Fragment4, jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
206
+ function Modal({
207
+ children,
208
+ title,
209
+ borderColor,
210
+ borderStyle = "rounded",
211
+ onClose,
212
+ useKeyboard: useKeyboardProp
213
+ }) {
214
+ const theme = useTheme();
215
+ const useKeyboard = useKeyboardContext(useKeyboardProp);
216
+ const resolvedBorderColor = borderColor ?? theme.muted;
217
+ useKeyboard?.((event) => {
218
+ if (event.name === "escape" && onClose) {
219
+ onClose();
220
+ }
221
+ });
222
+ return /* @__PURE__ */ jsx15("box", { flexDirection: "column", flexGrow: 1, children: /* @__PURE__ */ jsx15(
223
+ "box",
224
+ {
225
+ flexDirection: "column",
226
+ flexGrow: 1,
227
+ border: true,
228
+ borderStyle,
229
+ borderColor: resolvedBorderColor,
230
+ children: title ? /* @__PURE__ */ jsxs9(Fragment4, { children: [
231
+ /* @__PURE__ */ jsx15("box", { paddingX: 1, marginBottom: 1, children: /* @__PURE__ */ jsx15("text", { style: textStyle({ bold: true, fg: theme.primary }), children: title }) }),
232
+ children
233
+ ] }) : children
234
+ }
235
+ ) });
236
+ }
237
+
238
+ // ../ui/components/prompt-input/prompt-input.tsx
1
239
  import {
2
- LandingApp
3
- } from "./chunk-R3ENBVV6.js";
240
+ useState as useState6,
241
+ useRef as useRef4,
242
+ useCallback as useCallback2,
243
+ useMemo as useMemo3,
244
+ createContext as createContext4,
245
+ useContext as useContext4
246
+ } from "react";
247
+ import { Fragment as Fragment5, jsx as jsx16, jsxs as jsxs10 } from "react/jsx-runtime";
248
+ var PromptInputControllerCtx = createContext4(null);
249
+ var useOptionalController = () => useContext4(PromptInputControllerCtx);
250
+ var PromptInputContext = createContext4(null);
251
+ function usePromptInput() {
252
+ const ctx = useContext4(PromptInputContext);
253
+ if (!ctx) {
254
+ throw new Error("usePromptInput must be used within a <PromptInput> component");
255
+ }
256
+ return ctx;
257
+ }
258
+ function computeDefaultSuggestions(input, commands, files) {
259
+ if (input.startsWith("/") && commands.length > 0) {
260
+ return commands.filter((c) => c.cmd.startsWith(input)).map((c) => ({ text: c.cmd, desc: c.desc }));
261
+ }
262
+ if (input.includes("@") && files.length > 0) {
263
+ const query = input.split("@").pop() ?? "";
264
+ return files.filter((f) => f.toLowerCase().includes(query.toLowerCase())).map((f) => ({ text: "@" + f }));
265
+ }
266
+ return [];
267
+ }
268
+ function resolveStatusHintText(status, submittedText, streamingText, errorText, disabledText) {
269
+ if (status === "submitted") return submittedText;
270
+ if (status === "streaming") return streamingText;
271
+ if (status === "error") return errorText;
272
+ return disabledText;
273
+ }
274
+ function PromptInputDivider() {
275
+ const { theme } = usePromptInput();
276
+ return /* @__PURE__ */ jsx16("text", { wrapMode: "none", children: /* @__PURE__ */ jsx16("span", { style: textStyle({ dim: true, fg: theme.muted }), children: "\u2500".repeat(500) }) });
277
+ }
278
+ function PromptInputSuggestions() {
279
+ const { suggestions, sugIdx, maxSuggestions, theme } = usePromptInput();
280
+ const visible = suggestions.slice(0, maxSuggestions);
281
+ if (visible.length === 0) return null;
282
+ return /* @__PURE__ */ jsx16("box", { flexDirection: "column", marginLeft: 2, children: visible.map((sug, i) => {
283
+ const active = i === sugIdx;
284
+ return /* @__PURE__ */ jsxs10("text", { children: [
285
+ /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: active ? theme.primary : theme.muted }), children: active ? "\u25B8 " : " " }),
286
+ /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: active ? theme.primary : theme.muted, bold: active }), children: sug.text }),
287
+ sug.desc && /* @__PURE__ */ jsx16("span", { style: textStyle({ dim: true, fg: theme.placeholder }), children: " " + sug.desc })
288
+ ] }, sug.text);
289
+ }) });
290
+ }
291
+ var CURSOR_CHAR = "\u258D";
292
+ function PromptInputTextarea() {
293
+ const { value, disabled, statusHintText, placeholder, prompt, promptColor, theme } = usePromptInput();
294
+ return /* @__PURE__ */ jsxs10("text", { children: [
295
+ /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: promptColor }), children: prompt }),
296
+ value.length === 0 ? /* @__PURE__ */ jsxs10(Fragment5, { children: [
297
+ !disabled && /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: theme.muted }), children: CURSOR_CHAR }),
298
+ /* @__PURE__ */ jsx16("span", { style: textStyle({ dim: true, fg: theme.placeholder }), children: disabled ? statusHintText : " " + placeholder })
299
+ ] }) : /* @__PURE__ */ jsxs10(Fragment5, { children: [
300
+ /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: theme.foreground }), children: value }),
301
+ !disabled && /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: theme.muted }), children: CURSOR_CHAR })
302
+ ] })
303
+ ] });
304
+ }
305
+ function PromptInputSubmit(props) {
306
+ const ctx = usePromptInput();
307
+ const status = props.status ?? ctx.status;
308
+ const onStop = props.onStop ?? ctx.onStop;
309
+ const { disabled, theme } = ctx;
310
+ const isGenerating = status === "submitted" || status === "streaming";
311
+ const icon = status === "submitted" ? "\u25D0" : status === "streaming" ? onStop ? "\u25A0" : "\u25D0" : status === "error" ? "\u2715" : "\u23CE";
312
+ const color = status === "error" ? theme.error : isGenerating ? theme.muted : disabled ? theme.muted : theme.primary;
313
+ return /* @__PURE__ */ jsx16("text", { children: /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: color }), children: " " + icon }) });
314
+ }
315
+ function PromptInputStatusText() {
316
+ const { status, errorText, theme } = usePromptInput();
317
+ if (status !== "error") return null;
318
+ return /* @__PURE__ */ jsx16("text", { children: /* @__PURE__ */ jsx16("span", { style: textStyle({ fg: theme.error }), children: errorText }) });
319
+ }
320
+ function PromptInput({
321
+ value: controlledValue,
322
+ defaultValue = "",
323
+ onSubmit,
324
+ onChange,
325
+ placeholder = "Type a message...",
326
+ prompt = "\u276F ",
327
+ promptColor,
328
+ status,
329
+ onStop,
330
+ submittedText = "Thinking...",
331
+ streamingText: streamingLabel = "Generating...",
332
+ errorText = "An error occurred. Try again.",
333
+ disabled: disabledProp = false,
334
+ disabledText = "Generating...",
335
+ commands = [],
336
+ files = [],
337
+ getSuggestions: customGetSuggestions,
338
+ maxSuggestions = 5,
339
+ enableHistory = true,
340
+ showDividers = false,
341
+ useKeyboard: useKeyboardProp,
342
+ children
343
+ }) {
344
+ const theme = useTheme();
345
+ const useKeyboard = useKeyboardContext(useKeyboardProp);
346
+ const resolvedPromptColor = promptColor ?? theme.muted;
347
+ const disabled = status ? status === "submitted" || status === "streaming" : disabledProp;
348
+ const statusHintText = resolveStatusHintText(status, submittedText, streamingLabel, errorText, disabledText);
349
+ const controller = useOptionalController();
350
+ const usingProvider = !!controller;
351
+ const isControlled = controlledValue !== void 0;
352
+ const controlledRef = useRef4(isControlled);
353
+ if (controlledRef.current !== isControlled) {
354
+ console.warn("PromptInput: switching between controlled and uncontrolled is not supported.");
355
+ }
356
+ const [localValue, setLocalValue] = useState6(defaultValue);
357
+ const [localSuggestions, setLocalSuggestions] = useState6([]);
358
+ const [localSugIdx, setLocalSugIdx] = useState6(0);
359
+ const [history, setHistory] = useState6([]);
360
+ const [histIdx, setHistIdx] = useState6(-1);
361
+ const value = isControlled ? controlledValue : usingProvider ? controller.textInput.value : localValue;
362
+ const suggestions = usingProvider ? controller.suggestions.suggestions : localSuggestions;
363
+ const sugIdx = usingProvider ? controller.suggestions.selectedIndex : localSugIdx;
364
+ const valueRef = useRef4(defaultValue);
365
+ if (isControlled) valueRef.current = controlledValue;
366
+ else if (usingProvider) valueRef.current = controller.textInput.value;
367
+ else valueRef.current = localValue;
368
+ const suggestionsRef = useRef4([]);
369
+ suggestionsRef.current = suggestions;
370
+ const sugIdxRef = useRef4(0);
371
+ sugIdxRef.current = sugIdx;
372
+ const historyRef = useRef4([]);
373
+ historyRef.current = history;
374
+ const histIdxRef = useRef4(-1);
375
+ histIdxRef.current = histIdx;
376
+ const setSug = useCallback2((next) => {
377
+ suggestionsRef.current = next;
378
+ if (usingProvider) {
379
+ controller.suggestions.setSuggestions(next);
380
+ } else {
381
+ setLocalSuggestions(next);
382
+ }
383
+ }, [usingProvider, controller]);
384
+ const setSugI = useCallback2((next) => {
385
+ sugIdxRef.current = next;
386
+ if (usingProvider) {
387
+ controller.suggestions.setSelectedIndex(next);
388
+ } else {
389
+ setLocalSugIdx(next);
390
+ }
391
+ }, [usingProvider, controller]);
392
+ const setHist = useCallback2((next) => {
393
+ historyRef.current = next;
394
+ setHistory(next);
395
+ }, []);
396
+ const setHistI = useCallback2((next) => {
397
+ histIdxRef.current = next;
398
+ setHistIdx(next);
399
+ }, []);
400
+ const computeSuggestions = useCallback2((input) => {
401
+ if (customGetSuggestions) return customGetSuggestions(input);
402
+ return computeDefaultSuggestions(input, commands, files);
403
+ }, [customGetSuggestions, commands, files]);
404
+ const updateValue = useCallback2((next) => {
405
+ valueRef.current = next;
406
+ if (isControlled) {
407
+ } else if (usingProvider) {
408
+ controller.textInput.setValue(next);
409
+ } else {
410
+ setLocalValue(next);
411
+ }
412
+ onChange?.(next);
413
+ const sug = computeSuggestions(next);
414
+ setSug(sug);
415
+ setSugI(0);
416
+ }, [isControlled, usingProvider, controller, onChange, computeSuggestions, setSug, setSugI]);
417
+ const clearInput = useCallback2(() => {
418
+ if (usingProvider) {
419
+ controller.textInput.clear();
420
+ } else if (!isControlled) {
421
+ setLocalValue("");
422
+ }
423
+ onChange?.("");
424
+ }, [usingProvider, controller, isControlled, onChange]);
425
+ const handleSubmit = useCallback2((text) => {
426
+ if (!onSubmit) return;
427
+ const result = onSubmit({ text });
428
+ if (result instanceof Promise) {
429
+ result.then(
430
+ () => clearInput(),
431
+ () => {
432
+ }
433
+ );
434
+ } else {
435
+ clearInput();
436
+ }
437
+ }, [onSubmit, clearInput]);
438
+ useKeyboard?.((event) => {
439
+ if (event.name === "escape" && (status === "streaming" || status === "submitted") && onStop) {
440
+ onStop();
441
+ return;
442
+ }
443
+ if (disabled) return;
444
+ if (event.name === "return") {
445
+ if (suggestionsRef.current.length > 0) {
446
+ const sel = suggestionsRef.current[sugIdxRef.current];
447
+ if (sel) {
448
+ if (valueRef.current.startsWith("/")) {
449
+ setSug([]);
450
+ updateValue("");
451
+ if (enableHistory) {
452
+ setHist([sel.text, ...historyRef.current]);
453
+ }
454
+ setHistI(-1);
455
+ handleSubmit(sel.text);
456
+ } else {
457
+ const base = valueRef.current.slice(0, valueRef.current.lastIndexOf("@"));
458
+ updateValue(base + sel.text + " ");
459
+ setSug([]);
460
+ }
461
+ }
462
+ } else {
463
+ const trimmed = valueRef.current.trim();
464
+ if (!trimmed) return;
465
+ if (enableHistory) {
466
+ setHist([trimmed, ...historyRef.current]);
467
+ }
468
+ updateValue("");
469
+ setHistI(-1);
470
+ setSug([]);
471
+ handleSubmit(trimmed);
472
+ }
473
+ return;
474
+ }
475
+ if (event.name === "tab" && suggestionsRef.current.length > 0) {
476
+ setSugI((sugIdxRef.current + 1) % suggestionsRef.current.length);
477
+ return;
478
+ }
479
+ if (event.name === "up") {
480
+ if (suggestionsRef.current.length > 0) {
481
+ setSugI(Math.max(0, sugIdxRef.current - 1));
482
+ } else if (enableHistory && historyRef.current.length > 0) {
483
+ const idx = Math.min(historyRef.current.length - 1, histIdxRef.current + 1);
484
+ setHistI(idx);
485
+ updateValue(historyRef.current[idx]);
486
+ }
487
+ return;
488
+ }
489
+ if (event.name === "down") {
490
+ if (suggestionsRef.current.length > 0) {
491
+ setSugI(Math.min(suggestionsRef.current.length - 1, sugIdxRef.current + 1));
492
+ } else if (enableHistory && histIdxRef.current > 0) {
493
+ const nextIdx = histIdxRef.current - 1;
494
+ setHistI(nextIdx);
495
+ updateValue(historyRef.current[nextIdx]);
496
+ } else if (enableHistory && histIdxRef.current === 0) {
497
+ setHistI(-1);
498
+ updateValue("");
499
+ }
500
+ return;
501
+ }
502
+ if (event.name === "escape") {
503
+ if (suggestionsRef.current.length > 0) {
504
+ setSug([]);
505
+ }
506
+ return;
507
+ }
508
+ if (event.name === "backspace" || event.name === "delete") {
509
+ updateValue(valueRef.current.slice(0, -1));
510
+ return;
511
+ }
512
+ if (event.ctrl || event.meta) return;
513
+ if (event.name === "space") {
514
+ updateValue(valueRef.current + " ");
515
+ return;
516
+ }
517
+ if (event.name && event.name.length === 1) {
518
+ updateValue(valueRef.current + event.name);
519
+ }
520
+ });
521
+ const visibleSuggestions = suggestions.slice(0, maxSuggestions);
522
+ const ctxValue = {
523
+ value,
524
+ disabled,
525
+ status,
526
+ onStop,
527
+ statusHintText,
528
+ placeholder,
529
+ prompt,
530
+ promptColor: resolvedPromptColor,
531
+ suggestions: visibleSuggestions,
532
+ sugIdx,
533
+ maxSuggestions,
534
+ errorText,
535
+ theme
536
+ };
537
+ if (children) {
538
+ return /* @__PURE__ */ jsx16(PromptInputContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsx16("box", { flexDirection: "column", children }) });
539
+ }
540
+ return /* @__PURE__ */ jsx16(PromptInputContext.Provider, { value: ctxValue, children: /* @__PURE__ */ jsxs10("box", { flexDirection: "column", children: [
541
+ showDividers && /* @__PURE__ */ jsx16(PromptInputDivider, {}),
542
+ /* @__PURE__ */ jsx16(PromptInputSuggestions, {}),
543
+ /* @__PURE__ */ jsx16(PromptInputTextarea, {}),
544
+ /* @__PURE__ */ jsx16(PromptInputStatusText, {}),
545
+ showDividers && /* @__PURE__ */ jsx16(PromptInputDivider, {})
546
+ ] }) });
547
+ }
548
+ PromptInput.Textarea = PromptInputTextarea;
549
+ PromptInput.Suggestions = PromptInputSuggestions;
550
+ PromptInput.Submit = PromptInputSubmit;
551
+ PromptInput.Divider = PromptInputDivider;
552
+ PromptInput.StatusText = PromptInputStatusText;
553
+
554
+ // ../ui/components/chat/chat.tsx
555
+ import { jsx as jsx17, jsxs as jsxs11 } from "react/jsx-runtime";
556
+
557
+ // ../ui/components/timeline/timeline.tsx
558
+ import { useState as useState7, useEffect as useEffect2, useRef as useRef5 } from "react";
559
+ import { jsx as jsx18, jsxs as jsxs12 } from "react/jsx-runtime";
560
+ var DOTS = ["\u25CB", "\u25D4", "\u25D1", "\u25D5", "\u25CF"];
561
+ function getStepDot(status) {
562
+ return status === "pending" ? "\u25CB" : "\u25CF";
563
+ }
564
+ function getStepColor(status, theme) {
565
+ switch (status) {
566
+ case "done":
567
+ return theme.success;
568
+ case "running":
569
+ return theme.primary;
570
+ case "pending":
571
+ return theme.muted;
572
+ case "error":
573
+ return theme.error;
574
+ default:
575
+ return theme.muted;
576
+ }
577
+ }
578
+ function StepRow({ step, isLast, theme, frame }) {
579
+ const color = getStepColor(step.status, theme);
580
+ const isActive = step.status === "running";
581
+ const isPending = step.status === "pending";
582
+ const pipe = "\u2502";
583
+ const dot = isActive ? DOTS[frame % DOTS.length] : getStepDot(step.status);
584
+ const dashIdx = step.label.indexOf(" \u2014 ");
585
+ const mainLabel = dashIdx >= 0 ? step.label.slice(0, dashIdx) : step.label;
586
+ const detail = dashIdx >= 0 ? step.label.slice(dashIdx) : "";
587
+ return /* @__PURE__ */ jsxs12("box", { flexDirection: "column", marginLeft: 1, children: [
588
+ /* @__PURE__ */ jsxs12("text", { children: [
589
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: color }), children: dot }),
590
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: theme.foreground }), children: " " }),
591
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: isPending ? theme.muted : color, dim: isPending, bold: isActive }), children: mainLabel }),
592
+ detail && /* @__PURE__ */ jsx18("span", { style: textStyle({ dim: true, fg: theme.muted }), children: detail })
593
+ ] }),
594
+ step.output && /* @__PURE__ */ jsxs12("text", { children: [
595
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: color, dim: true }), children: pipe + " " }),
596
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: step.status === "error" ? theme.error : theme.accent }), children: step.output })
597
+ ] }),
598
+ !isLast && /* @__PURE__ */ jsx18("text", { children: /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: color, dim: true }), children: pipe }) })
599
+ ] });
600
+ }
601
+ function Timeline({
602
+ steps,
603
+ duration,
604
+ collapsed = true,
605
+ headerLabel = "Thought for"
606
+ }) {
607
+ const theme = useTheme();
608
+ const arrow = collapsed ? "\u25B6" : "\u25BC";
609
+ const durationStr = duration ?? "0ms";
610
+ const hasRunning = steps?.some((s) => s.status === "running") ?? false;
611
+ const [frame, setFrame] = useState7(0);
612
+ const alive = useRef5(true);
613
+ useEffect2(() => {
614
+ alive.current = true;
615
+ return () => {
616
+ alive.current = false;
617
+ };
618
+ }, []);
619
+ useEffect2(() => {
620
+ if (!hasRunning) return;
621
+ const id = setInterval(() => {
622
+ if (alive.current) setFrame((f) => f + 1);
623
+ }, 150);
624
+ return () => clearInterval(id);
625
+ }, [hasRunning]);
626
+ return /* @__PURE__ */ jsxs12("box", { flexDirection: "column", children: [
627
+ /* @__PURE__ */ jsxs12("text", { children: [
628
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ fg: theme.muted }), children: arrow }),
629
+ /* @__PURE__ */ jsx18("span", { style: textStyle({ dim: true, fg: theme.muted }), children: " " + headerLabel + " " + durationStr })
630
+ ] }),
631
+ !collapsed && steps && steps.map((step, i) => /* @__PURE__ */ jsx18(
632
+ StepRow,
633
+ {
634
+ step,
635
+ isLast: i === steps.length - 1,
636
+ theme,
637
+ frame
638
+ },
639
+ `step-${i}`
640
+ ))
641
+ ] });
642
+ }
643
+
644
+ // ../ui/components/message/message.tsx
645
+ import { createContext as createContext5, useContext as useContext5 } from "react";
646
+ import { jsx as jsx19, jsxs as jsxs13 } from "react/jsx-runtime";
647
+ var MessageContext = createContext5(null);
648
+ function useMessage() {
649
+ const ctx = useContext5(MessageContext);
650
+ if (!ctx) throw new Error("useMessage must be used within <Message>");
651
+ return ctx;
652
+ }
653
+ function getBubbleColors(theme) {
654
+ const isDark = theme.background !== "#FFFFFF";
655
+ return isDark ? { assistantBg: "#2a2a4a", userBg: "#2a3a3a" } : { assistantBg: "#F1F5F9", userBg: "#E2E8F0" };
656
+ }
657
+ var TOOL_STATE_ICONS = {
658
+ "partial-call": "\u2022",
659
+ // •
660
+ "call": "\u280B",
661
+ // ⠋
662
+ "result": "\u2713"
663
+ // ✓
664
+ };
665
+ function getToolStateColor(state, theme) {
666
+ switch (state) {
667
+ case "partial-call":
668
+ return theme.muted;
669
+ case "call":
670
+ return theme.warning;
671
+ case "result":
672
+ return theme.success;
673
+ default:
674
+ return theme.muted;
675
+ }
676
+ }
677
+ function MessageContent({ children }) {
678
+ const { role, backgroundColor } = useMessage();
679
+ const isUser = role === "user";
680
+ return /* @__PURE__ */ jsx19(
681
+ "box",
682
+ {
683
+ flexDirection: "column",
684
+ backgroundColor,
685
+ paddingX: 2,
686
+ paddingY: 1,
687
+ ...isUser ? { maxWidth: "85%" } : { width: "85%" },
688
+ children
689
+ }
690
+ );
691
+ }
692
+ function MessageText({ children, isLast = false }) {
693
+ const { isStreaming, streamingCursor, backgroundColor, textColor } = useMessage();
694
+ return /* @__PURE__ */ jsxs13("text", { wrapMode: "word", children: [
695
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, bg: backgroundColor }), children }),
696
+ isLast && isStreaming && /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: streamingCursor })
697
+ ] });
698
+ }
699
+ function MessageReasoning({ part }) {
700
+ return /* @__PURE__ */ jsx19(
701
+ Timeline,
702
+ {
703
+ steps: part.steps,
704
+ duration: part.duration,
705
+ collapsed: part.collapsed
706
+ }
707
+ );
708
+ }
709
+ function MessageToolInvocation({ part, toolColors }) {
710
+ const theme = useTheme();
711
+ const { backgroundColor, textColor } = useMessage();
712
+ const { toolName, state, result } = part.toolInvocation;
713
+ const icon = TOOL_STATE_ICONS[state] || "\u2022";
714
+ const stateColor = toolColors?.[toolName] ?? getToolStateColor(state, theme);
715
+ const isActive = state === "partial-call" || state === "call";
716
+ return /* @__PURE__ */ jsxs13("box", { flexDirection: "column", children: [
717
+ /* @__PURE__ */ jsxs13("text", { children: [
718
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: stateColor, bg: backgroundColor }), children: icon }),
719
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, bg: backgroundColor }), children: " " }),
720
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: stateColor, bold: isActive, bg: backgroundColor }), children: toolName }),
721
+ isActive && /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: " ..." })
722
+ ] }),
723
+ state === "result" && result !== void 0 && /* @__PURE__ */ jsxs13("text", { children: [
724
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: " \u2514\u2500 " }),
725
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: String(result).slice(0, 120) })
726
+ ] })
727
+ ] });
728
+ }
729
+ function MessageSource({ part, index }) {
730
+ const theme = useTheme();
731
+ const { backgroundColor, textColor } = useMessage();
732
+ const title = part.source.title || part.source.url || "source";
733
+ return /* @__PURE__ */ jsxs13("text", { children: [
734
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: "[" }),
735
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: theme.accent, bg: backgroundColor }), children: String(index + 1) }),
736
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: textColor, dim: true, bg: backgroundColor }), children: "] " }),
737
+ /* @__PURE__ */ jsx19("span", { style: textStyle({ fg: theme.accent, bg: backgroundColor }), children: title })
738
+ ] });
739
+ }
740
+ function MessageFooter({ model, timestamp }) {
741
+ const theme = useTheme();
742
+ if (!model && !timestamp) return null;
743
+ return /* @__PURE__ */ jsxs13("text", { children: [
744
+ model && /* @__PURE__ */ jsx19("span", { style: textStyle({ dim: true, fg: theme.muted }), children: model }),
745
+ model && timestamp && /* @__PURE__ */ jsx19("span", { style: textStyle({ dim: true, fg: theme.muted }), children: " \xB7 " }),
746
+ timestamp && /* @__PURE__ */ jsx19("span", { style: textStyle({ dim: true, fg: theme.muted }), children: timestamp })
747
+ ] });
748
+ }
749
+ function Message({
750
+ role,
751
+ isStreaming = false,
752
+ streamingCursor = "\u258E",
753
+ backgroundColor,
754
+ children
755
+ }) {
756
+ const theme = useTheme();
757
+ const { assistantBg, userBg } = getBubbleColors(theme);
758
+ const isUser = role === "user";
759
+ const bg = backgroundColor ?? (isUser ? userBg : assistantBg);
760
+ return /* @__PURE__ */ jsx19(MessageContext.Provider, { value: { role, isStreaming, streamingCursor, backgroundColor: bg, textColor: theme.foreground }, children: /* @__PURE__ */ jsx19(
761
+ "box",
762
+ {
763
+ flexDirection: "column",
764
+ flexShrink: 0,
765
+ alignItems: isUser ? "flex-end" : "flex-start",
766
+ children
767
+ }
768
+ ) });
769
+ }
770
+ Message.Content = MessageContent;
771
+ Message.Text = MessageText;
772
+ Message.Reasoning = MessageReasoning;
773
+ Message.ToolInvocation = MessageToolInvocation;
774
+ Message.Source = MessageSource;
775
+ Message.Footer = MessageFooter;
776
+
777
+ // ../ui/components/terminal-window/terminal-window.tsx
778
+ import { jsx as jsx20, jsxs as jsxs14 } from "react/jsx-runtime";
779
+
780
+ // ../ui/components/breakpoints/use-breakpoints.ts
781
+ import { useTerminalDimensions } from "@gridland/web";
782
+ var BREAKPOINTS = {
783
+ tiny: 40,
784
+ narrow: 60,
785
+ mobile: 70
786
+ };
787
+ function useBreakpoints() {
788
+ const { width, height } = useTerminalDimensions();
789
+ return {
790
+ isTiny: width < BREAKPOINTS.tiny,
791
+ isNarrow: width < BREAKPOINTS.narrow,
792
+ isMobile: width < BREAKPOINTS.mobile,
793
+ isDesktop: width >= BREAKPOINTS.mobile,
794
+ width,
795
+ height
796
+ };
797
+ }
798
+
799
+ // ../docs/components/landing/logo.tsx
800
+ import { useState as useState8, useEffect as useEffect3, useRef as useRef6, useMemo as useMemo4 } from "react";
801
+ import figlet from "figlet";
802
+ import ansiShadow from "figlet/importable-fonts/ANSI Shadow.js";
803
+ import { Fragment as Fragment6, jsx as jsx21, jsxs as jsxs15 } from "react/jsx-runtime";
804
+ figlet.parseFont("ANSI Shadow", ansiShadow);
805
+ function makeArt(text) {
806
+ return figlet.textSync(text, { font: "ANSI Shadow" }).split("\n").filter((l) => l.trimEnd().length > 0).join("\n");
807
+ }
808
+ var fullArt = makeArt("gridland");
809
+ var gridArt = makeArt("grid");
810
+ var landArt = makeArt("land");
811
+ var ART_HEIGHT = 6;
812
+ function useAnimation(duration = 1e3) {
813
+ const isBrowser = typeof document !== "undefined";
814
+ const [progress, setProgress] = useState8(isBrowser ? 0 : 1);
815
+ const startTime = useRef6(null);
816
+ useEffect3(() => {
817
+ if (!isBrowser) return;
818
+ let raf;
819
+ const tick = (time) => {
820
+ if (startTime.current === null) startTime.current = time;
821
+ const elapsed = time - startTime.current;
822
+ const t = Math.min(1, elapsed / duration);
823
+ const eased = 1 - Math.pow(1 - t, 3);
824
+ setProgress(eased);
825
+ if (t < 1) raf = requestAnimationFrame(tick);
826
+ };
827
+ raf = requestAnimationFrame(tick);
828
+ return () => cancelAnimationFrame(raf);
829
+ }, []);
830
+ return progress;
831
+ }
832
+ function RevealGradient({ children, revealCol }) {
833
+ const gradientColors = GRADIENTS.instagram;
834
+ const lines = children.split("\n");
835
+ const maxLength = Math.max(...lines.map((l) => l.length));
836
+ if (maxLength === 0) return /* @__PURE__ */ jsx21("text", { children });
837
+ const hexColors = useMemo4(() => generateGradient(gradientColors, maxLength), [maxLength]);
838
+ return /* @__PURE__ */ jsx21("box", { position: "relative", width: maxLength, height: lines.length, shouldFill: false, children: lines.map((line, lineIndex) => {
839
+ const runs = [];
840
+ let current = null;
841
+ for (let i = 0; i < line.length; i++) {
842
+ const revealed = i <= revealCol;
843
+ const char = line[i];
844
+ const isVisible = revealed && char !== " ";
845
+ if (isVisible) {
846
+ if (!current) {
847
+ current = { start: i, chars: [] };
848
+ }
849
+ current.chars.push(char);
850
+ } else {
851
+ if (current) {
852
+ runs.push(current);
853
+ current = null;
854
+ }
855
+ }
856
+ }
857
+ if (current) runs.push(current);
858
+ return runs.map((run, runIndex) => /* @__PURE__ */ jsx21(
859
+ "box",
860
+ {
861
+ position: "absolute",
862
+ top: lineIndex,
863
+ left: run.start,
864
+ shouldFill: false,
865
+ children: /* @__PURE__ */ jsx21("text", { shouldFill: false, children: run.chars.map((char, ci) => /* @__PURE__ */ jsx21(
866
+ "span",
867
+ {
868
+ style: { fg: hexColors[run.start + ci] },
869
+ children: char
870
+ },
871
+ ci
872
+ )) })
873
+ },
874
+ `${lineIndex}-${runIndex}`
875
+ ));
876
+ }) });
877
+ }
878
+ function Logo({ compact, narrow, mobile }) {
879
+ const isBrowser = typeof document !== "undefined";
880
+ const progress = useAnimation(900);
881
+ const artHeight = compact ? 1 : narrow ? ART_HEIGHT * 2 : ART_HEIGHT;
882
+ const dropOffset = Math.round((1 - progress) * -artHeight);
883
+ const revealProgress = Math.max(0, Math.min(1, (progress - 0.1) / 0.7));
884
+ const maxWidth = compact ? 8 : narrow ? 40 : 62;
885
+ const revealCol = Math.round(revealProgress * (maxWidth + 4)) - 2;
886
+ const taglineOpacity = Math.max(0, Math.min(1, (progress - 0.7) / 0.3));
887
+ const subtitle = /* @__PURE__ */ jsxs15(Fragment6, { children: [
888
+ /* @__PURE__ */ jsx21("text", { children: " " }),
889
+ /* @__PURE__ */ jsx21("box", { flexDirection: "column", alignItems: "center", width: "100%", shouldFill: false, children: /* @__PURE__ */ jsxs15("text", { style: textStyle({ fg: "#d4b0e8" }), opacity: taglineOpacity, wrapMode: "word", textAlign: "center", width: "100%", shouldFill: false, children: [
890
+ "A framework for building terminal apps, built on ",
891
+ /* @__PURE__ */ jsx21("a", { href: "https://opentui.com", style: { attributes: 72, fg: "#d4b0e8" }, children: "OpenTUI" }),
892
+ " + React." + (mobile ? " " : "\n") + "(Gridland apps, like this website, work in the browser and terminal.)"
893
+ ] }) })
894
+ ] });
895
+ if (!isBrowser) {
896
+ const art = compact ? "gridland" : narrow ? gridArt + "\n" + landArt : fullArt;
897
+ return /* @__PURE__ */ jsxs15("box", { flexDirection: "column", flexShrink: 0, width: "100%", alignItems: "center", children: [
898
+ /* @__PURE__ */ jsx21(Gradient, { name: "instagram", children: art }),
899
+ /* @__PURE__ */ jsx21("text", { children: " " }),
900
+ /* @__PURE__ */ jsx21("box", { flexDirection: "column", alignItems: "center", width: "100%", shouldFill: false, children: /* @__PURE__ */ jsxs15("text", { style: textStyle({ fg: "#d4b0e8" }), shouldFill: false, children: [
901
+ "A framework for building terminal apps, built on OpenTUI + React.",
902
+ "\n",
903
+ "(Gridland apps, like this website, work in the browser and terminal.)"
904
+ ] }) })
905
+ ] });
906
+ }
907
+ if (compact) {
908
+ return /* @__PURE__ */ jsxs15("box", { flexDirection: "column", flexShrink: 0, width: "100%", shouldFill: false, children: [
909
+ /* @__PURE__ */ jsx21("box", { height: artHeight, overflow: "hidden", position: "relative", width: "100%", flexShrink: 0, shouldFill: false, children: /* @__PURE__ */ jsx21("box", { position: "absolute", top: dropOffset, width: "100%", flexDirection: "column", alignItems: "center", shouldFill: false, children: /* @__PURE__ */ jsx21(RevealGradient, { revealCol, children: "gridland" }) }) }),
910
+ subtitle
911
+ ] });
912
+ }
913
+ if (narrow) {
914
+ return /* @__PURE__ */ jsxs15("box", { flexDirection: "column", flexShrink: 0, width: "100%", shouldFill: false, children: [
915
+ /* @__PURE__ */ jsx21("box", { height: artHeight, overflow: "hidden", position: "relative", width: "100%", flexShrink: 0, shouldFill: false, children: /* @__PURE__ */ jsxs15("box", { position: "absolute", top: dropOffset, width: "100%", flexDirection: "column", alignItems: "center", shouldFill: false, children: [
916
+ /* @__PURE__ */ jsx21(RevealGradient, { revealCol, children: gridArt }),
917
+ /* @__PURE__ */ jsx21(RevealGradient, { revealCol, children: landArt })
918
+ ] }) }),
919
+ subtitle
920
+ ] });
921
+ }
922
+ return /* @__PURE__ */ jsxs15("box", { flexDirection: "column", flexShrink: 0, width: "100%", shouldFill: false, children: [
923
+ /* @__PURE__ */ jsx21("box", { height: artHeight, overflow: "hidden", position: "relative", width: "100%", flexShrink: 0, shouldFill: false, children: /* @__PURE__ */ jsx21("box", { position: "absolute", top: dropOffset, width: "100%", flexDirection: "column", alignItems: "center", shouldFill: false, children: /* @__PURE__ */ jsx21(RevealGradient, { revealCol, children: fullArt }) }) }),
924
+ subtitle
925
+ ] });
926
+ }
927
+
928
+ // ../docs/components/landing/install-box.tsx
929
+ import { jsx as jsx22, jsxs as jsxs16 } from "react/jsx-runtime";
930
+ function InstallBox() {
931
+ const theme = useTheme();
932
+ return /* @__PURE__ */ jsx22(
933
+ "box",
934
+ {
935
+ border: true,
936
+ borderStyle: "rounded",
937
+ borderColor: theme.border,
938
+ paddingX: 1,
939
+ flexDirection: "column",
940
+ flexShrink: 0,
941
+ children: /* @__PURE__ */ jsxs16("text", { children: [
942
+ /* @__PURE__ */ jsx22("span", { style: textStyle({ dim: true }), children: "$ " }),
943
+ /* @__PURE__ */ jsx22("span", { style: textStyle({ bold: true }), children: "bun create " }),
944
+ /* @__PURE__ */ jsx22("span", { style: textStyle({ fg: theme.accent }), children: "gridland" })
945
+ ] })
946
+ }
947
+ );
948
+ }
949
+
950
+ // ../docs/components/landing/links-box.tsx
951
+ import { jsx as jsx23, jsxs as jsxs17 } from "react/jsx-runtime";
952
+ var UNDERLINE3 = 1 << 3;
953
+ function LinksBox() {
954
+ const theme = useTheme();
955
+ return /* @__PURE__ */ jsx23(
956
+ "box",
957
+ {
958
+ border: true,
959
+ borderStyle: "rounded",
960
+ borderColor: theme.border,
961
+ paddingX: 1,
962
+ flexDirection: "column",
963
+ flexShrink: 0,
964
+ children: /* @__PURE__ */ jsxs17("text", { children: [
965
+ /* @__PURE__ */ jsx23("span", { children: "\u{1F431}" }),
966
+ /* @__PURE__ */ jsx23("a", { href: "https://github.com/cjroth/gridland", style: { attributes: UNDERLINE3, fg: theme.accent }, children: " GitHub" }),
967
+ /* @__PURE__ */ jsx23("span", { children: " " }),
968
+ /* @__PURE__ */ jsx23("span", { children: "\u{1F4D6}" }),
969
+ /* @__PURE__ */ jsx23("a", { href: "/docs", style: { attributes: UNDERLINE3, fg: theme.accent }, children: " Docs" })
970
+ ] })
971
+ }
972
+ );
973
+ }
974
+
975
+ // ../docs/components/landing/matrix-background.tsx
976
+ import { useMemo as useMemo5 } from "react";
977
+
978
+ // ../docs/components/landing/use-matrix.ts
979
+ import { useState as useState9, useEffect as useEffect4, useRef as useRef7 } from "react";
980
+ var CHARS = "abcdefghijklmnopqrstuvwxyz0123456789@#$%^&*(){}[]|;:<>,.?/~`";
981
+ function randomChar() {
982
+ return CHARS[Math.floor(Math.random() * CHARS.length)];
983
+ }
984
+ function createDrop(height, seeded = false) {
985
+ const length = Math.floor(Math.random() * Math.floor(height * 0.6)) + 4;
986
+ return {
987
+ y: seeded ? Math.floor(Math.random() * (height + length)) : -Math.floor(Math.random() * height),
988
+ speed: 1,
989
+ length,
990
+ chars: Array.from({ length }, randomChar)
991
+ };
992
+ }
993
+ function buildGrid(columns, width, height) {
994
+ const grid = Array.from({ length: height }, () => Array(width).fill(" "));
995
+ const brightness = Array.from({ length: height }, () => Array(width).fill(0));
996
+ for (let x = 0; x < width; x++) {
997
+ const drop = columns[x];
998
+ if (!drop) continue;
999
+ for (let i = 0; i < drop.length; i++) {
1000
+ const row = Math.floor(drop.y) - i;
1001
+ if (row < 0 || row >= height) continue;
1002
+ grid[row][x] = drop.chars[i];
1003
+ if (i === 0) {
1004
+ brightness[row][x] = 1;
1005
+ } else {
1006
+ brightness[row][x] = Math.max(0.15, 1 - i / drop.length);
1007
+ }
1008
+ }
1009
+ }
1010
+ return { grid, brightness };
1011
+ }
1012
+ function useMatrix(width, height) {
1013
+ const columnsRef = useRef7([]);
1014
+ const [state, setState] = useState9(() => {
1015
+ const columns = Array.from(
1016
+ { length: width },
1017
+ () => Math.random() < 0.5 ? createDrop(height, true) : null
1018
+ );
1019
+ columnsRef.current = columns;
1020
+ return buildGrid(columns, width, height);
1021
+ });
1022
+ useEffect4(() => {
1023
+ if (width < 2 || height < 2) return;
1024
+ const id = setInterval(() => {
1025
+ const columns = columnsRef.current;
1026
+ for (let x = 0; x < width; x++) {
1027
+ if (columns[x] === null || columns[x] === void 0) {
1028
+ if (Math.random() < 0.03) {
1029
+ columns[x] = createDrop(height);
1030
+ }
1031
+ continue;
1032
+ }
1033
+ const drop = columns[x];
1034
+ drop.y += drop.speed;
1035
+ if (Math.random() < 0.1) {
1036
+ const idx = Math.floor(Math.random() * drop.chars.length);
1037
+ drop.chars[idx] = randomChar();
1038
+ }
1039
+ if (drop.y - drop.length > height) {
1040
+ columns[x] = null;
1041
+ }
1042
+ }
1043
+ setState(buildGrid(columns, width, height));
1044
+ }, 80);
1045
+ return () => clearInterval(id);
1046
+ }, [width, height]);
1047
+ useEffect4(() => {
1048
+ columnsRef.current = Array.from(
1049
+ { length: width },
1050
+ () => Math.random() < 0.5 ? createDrop(height, true) : null
1051
+ );
1052
+ setState(buildGrid(columnsRef.current, width, height));
1053
+ }, [width, height]);
1054
+ return state;
1055
+ }
1056
+
1057
+ // ../docs/components/landing/matrix-background.tsx
1058
+ import { jsx as jsx24 } from "react/jsx-runtime";
1059
+ var MUTE_LEVELS = [0.12, 0.18, 0.24, 0.3, 0.38];
1060
+ var BG = hexToRgb("#1a1a2e");
1061
+ function buildMutedColors(baseHex) {
1062
+ const fg = hexToRgb(baseHex);
1063
+ return MUTE_LEVELS.map((factor) => rgbToHex({
1064
+ r: Math.round(BG.r + (fg.r - BG.r) * factor),
1065
+ g: Math.round(BG.g + (fg.g - BG.g) * factor),
1066
+ b: Math.round(BG.b + (fg.b - BG.b) * factor)
1067
+ }));
1068
+ }
1069
+ function colorForCell(mutedColors, b) {
1070
+ if (b >= 1) return mutedColors[4];
1071
+ const idx = Math.min(Math.floor(b * (MUTE_LEVELS.length - 1)), MUTE_LEVELS.length - 2);
1072
+ return mutedColors[idx];
1073
+ }
1074
+ function MatrixBackground({ width, height, clearRect, clearRects }) {
1075
+ const { grid, brightness } = useMatrix(width, height);
1076
+ const theme = useTheme();
1077
+ const columnColors = useMemo5(
1078
+ () => width > 0 ? generateGradient([theme.accent, theme.secondary, theme.primary], width) : [],
1079
+ [width, theme.accent, theme.secondary, theme.primary]
1080
+ );
1081
+ const columnMutedColors = useMemo5(
1082
+ () => columnColors.map(buildMutedColors),
1083
+ [columnColors]
1084
+ );
1085
+ return /* @__PURE__ */ jsx24("box", { flexDirection: "column", children: grid.map((row, y) => /* @__PURE__ */ jsx24("text", { children: row.map((cell, x) => {
1086
+ const inClearRect = clearRect && y >= clearRect.top && y < clearRect.top + clearRect.height && x >= clearRect.left && x < clearRect.left + clearRect.width || clearRects && clearRects.some(
1087
+ (r) => y >= r.top && y < r.top + r.height && x >= r.left && x < r.left + r.width
1088
+ );
1089
+ const mutedColors = columnMutedColors[x];
1090
+ if (cell === " " || inClearRect || !mutedColors) {
1091
+ return /* @__PURE__ */ jsx24("span", { children: " " }, x);
1092
+ }
1093
+ return /* @__PURE__ */ jsx24(
1094
+ "span",
1095
+ {
1096
+ style: {
1097
+ fg: colorForCell(mutedColors, brightness[y][x])
1098
+ },
1099
+ children: cell
1100
+ },
1101
+ x
1102
+ );
1103
+ }) }, y)) });
1104
+ }
1105
+
1106
+ // ../docs/components/landing/about-modal.tsx
1107
+ import { jsx as jsx25, jsxs as jsxs18 } from "react/jsx-runtime";
1108
+ function AboutModal({ onClose, useKeyboard }) {
1109
+ const theme = useTheme();
1110
+ return /* @__PURE__ */ jsx25(Modal, { title: "About Gridland", useKeyboard, onClose, children: /* @__PURE__ */ jsxs18("box", { paddingX: 1, flexDirection: "column", gap: 1, children: [
1111
+ /* @__PURE__ */ jsx25("text", { style: textStyle({ bold: true, fg: theme.accent }), children: "What is Gridland?" }),
1112
+ /* @__PURE__ */ jsx25("text", { children: "Gridland renders terminal UIs to HTML5 Canvas with React." }),
1113
+ /* @__PURE__ */ jsx25("text", { children: "No xterm.js. No terminal emulator. Just pixels." }),
1114
+ /* @__PURE__ */ jsx25("text", { style: textStyle({ bold: true, fg: theme.accent }), children: "Features" }),
1115
+ /* @__PURE__ */ jsxs18("text", { children: [
1116
+ /* @__PURE__ */ jsxs18("span", { style: textStyle({ dim: true }), children: [
1117
+ "\u2022",
1118
+ " "
1119
+ ] }),
1120
+ "Canvas-rendered TUI components"
1121
+ ] }),
1122
+ /* @__PURE__ */ jsxs18("text", { children: [
1123
+ /* @__PURE__ */ jsxs18("span", { style: textStyle({ dim: true }), children: [
1124
+ "\u2022",
1125
+ " "
1126
+ ] }),
1127
+ "React reconciler with JSX"
1128
+ ] }),
1129
+ /* @__PURE__ */ jsxs18("text", { children: [
1130
+ /* @__PURE__ */ jsxs18("span", { style: textStyle({ dim: true }), children: [
1131
+ "\u2022",
1132
+ " "
1133
+ ] }),
1134
+ "Yoga flexbox layout engine"
1135
+ ] }),
1136
+ /* @__PURE__ */ jsxs18("text", { children: [
1137
+ /* @__PURE__ */ jsxs18("span", { style: textStyle({ dim: true }), children: [
1138
+ "\u2022",
1139
+ " "
1140
+ ] }),
1141
+ "Keyboard, mouse, and clipboard support"
1142
+ ] }),
1143
+ /* @__PURE__ */ jsxs18("text", { children: [
1144
+ /* @__PURE__ */ jsxs18("span", { style: textStyle({ dim: true }), children: [
1145
+ "\u2022",
1146
+ " "
1147
+ ] }),
1148
+ "Next.js and Vite plugins"
1149
+ ] }),
1150
+ /* @__PURE__ */ jsx25("text", { style: textStyle({ bold: true, fg: theme.accent }), children: "Tech Stack" }),
1151
+ /* @__PURE__ */ jsx25("text", { children: "React + opentui engine + yoga-layout + HTML5 Canvas" }),
1152
+ /* @__PURE__ */ jsx25("text", { style: textStyle({ dim: true }), children: "Press q to close" })
1153
+ ] }) });
1154
+ }
1155
+
1156
+ // ../docs/components/landing/landing-app.tsx
1157
+ import { jsx as jsx26, jsxs as jsxs19 } from "react/jsx-runtime";
1158
+ function LandingApp({ useKeyboard }) {
1159
+ const theme = useTheme();
1160
+ const { width, height, isNarrow, isTiny, isMobile } = useBreakpoints();
1161
+ const [showAbout, setShowAbout] = useState10(false);
1162
+ useKeyboard((event) => {
1163
+ if (event.name === "a" && !showAbout) {
1164
+ setShowAbout(true);
1165
+ }
1166
+ if (event.name === "q" && showAbout) {
1167
+ setShowAbout(false);
1168
+ }
1169
+ });
1170
+ if (showAbout) {
1171
+ return /* @__PURE__ */ jsxs19("box", { flexDirection: "column", width: "100%", height: "100%", children: [
1172
+ /* @__PURE__ */ jsx26("box", { flexGrow: 1, children: /* @__PURE__ */ jsx26(AboutModal, { onClose: () => setShowAbout(false), useKeyboard }) }),
1173
+ /* @__PURE__ */ jsx26(StatusBar, { items: [{ key: "q", label: "close" }] })
1174
+ ] });
1175
+ }
1176
+ const isBrowser = typeof document !== "undefined";
1177
+ const logoHeight = isTiny ? 2 : isNarrow ? 13 : 7;
1178
+ const logoExtra = isBrowser ? 1 : 0;
1179
+ const gap = isMobile ? 0 : 1;
1180
+ const installLinksTop = 3 + logoHeight + logoExtra + gap;
1181
+ const installLinksHeight = 3;
1182
+ const boxTop = installLinksTop + installLinksHeight + gap + 1;
1183
+ const boxHeight = height - boxTop - 1 - 1;
1184
+ const clearRect = { top: boxTop, left: 1, width: width - 2, height: boxHeight };
1185
+ const installLinksClearRect = { top: installLinksTop, left: 1, width: width - 2, height: installLinksHeight };
1186
+ return /* @__PURE__ */ jsxs19("box", { width: "100%", height: "100%", position: "relative", children: [
1187
+ /* @__PURE__ */ jsx26(MatrixBackground, { width, height, clearRect, clearRects: [installLinksClearRect] }),
1188
+ /* @__PURE__ */ jsxs19(
1189
+ "box",
1190
+ {
1191
+ position: "absolute",
1192
+ top: 0,
1193
+ left: 0,
1194
+ width,
1195
+ height,
1196
+ zIndex: 1,
1197
+ flexDirection: "column",
1198
+ shouldFill: false,
1199
+ children: [
1200
+ /* @__PURE__ */ jsxs19("box", { flexGrow: 1, flexDirection: "column", paddingTop: 3, paddingLeft: 1, paddingRight: 1, paddingBottom: 1, gap: isMobile ? 0 : 1, shouldFill: false, children: [
1201
+ /* @__PURE__ */ jsx26("box", { flexShrink: 0, shouldFill: false, children: /* @__PURE__ */ jsx26(Logo, { compact: isTiny, narrow: isNarrow, mobile: isMobile }) }),
1202
+ /* @__PURE__ */ jsxs19("box", { flexDirection: "row", flexWrap: "wrap", justifyContent: "center", gap: isMobile ? 0 : 1, flexShrink: 0, shouldFill: false, children: [
1203
+ /* @__PURE__ */ jsx26(
1204
+ "box",
1205
+ {
1206
+ border: true,
1207
+ borderStyle: "rounded",
1208
+ borderColor: theme.border,
1209
+ paddingX: 1,
1210
+ flexDirection: "column",
1211
+ flexShrink: 0,
1212
+ children: /* @__PURE__ */ jsxs19("text", { children: [
1213
+ /* @__PURE__ */ jsx26("span", { style: textStyle({ dim: true }), children: "$ " }),
1214
+ /* @__PURE__ */ jsx26("span", { style: textStyle({ bold: true }), children: "bunx " }),
1215
+ /* @__PURE__ */ jsx26("span", { style: textStyle({ fg: theme.accent }), children: "@gridland/demo landing" })
1216
+ ] })
1217
+ }
1218
+ ),
1219
+ /* @__PURE__ */ jsx26(InstallBox, {}),
1220
+ /* @__PURE__ */ jsx26(LinksBox, {})
1221
+ ] }),
1222
+ /* @__PURE__ */ jsx26(
1223
+ "box",
1224
+ {
1225
+ flexGrow: 1,
1226
+ border: true,
1227
+ borderStyle: "rounded",
1228
+ borderColor: theme.border
1229
+ }
1230
+ )
1231
+ ] }),
1232
+ /* @__PURE__ */ jsx26(
1233
+ StatusBar,
1234
+ {
1235
+ items: [
1236
+ { key: "a", label: "about" }
1237
+ ]
1238
+ }
1239
+ )
1240
+ ]
1241
+ }
1242
+ )
1243
+ ] });
1244
+ }
1245
+
1246
+ // ../docs/components/landing/matrix-rain.tsx
1247
+ import { jsx as jsx27 } from "react/jsx-runtime";
4
1248
  export {
5
1249
  LandingApp
6
1250
  };