@hypercli/ui 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +11 -0
- package/dist/capabilities/index.d.ts +62 -0
- package/dist/capabilities/index.d.ts.map +1 -0
- package/dist/capabilities/index.js +182 -0
- package/dist/capabilities/index.js.map +1 -0
- package/dist/colors.d.ts +32 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/colors.js +40 -0
- package/dist/colors.js.map +1 -0
- package/dist/components/columns.d.ts +28 -0
- package/dist/components/columns.d.ts.map +1 -0
- package/dist/components/columns.js +70 -0
- package/dist/components/columns.js.map +1 -0
- package/dist/components/confirmPrompt.d.ts +38 -0
- package/dist/components/confirmPrompt.d.ts.map +1 -0
- package/dist/components/confirmPrompt.js +109 -0
- package/dist/components/confirmPrompt.js.map +1 -0
- package/dist/components/diff.d.ts +37 -0
- package/dist/components/diff.d.ts.map +1 -0
- package/dist/components/diff.js +36 -0
- package/dist/components/diff.js.map +1 -0
- package/dist/components/helpLayout.d.ts +59 -0
- package/dist/components/helpLayout.d.ts.map +1 -0
- package/dist/components/helpLayout.js +103 -0
- package/dist/components/helpLayout.js.map +1 -0
- package/dist/components/index.d.ts +38 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +23 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/keyValue.d.ts +31 -0
- package/dist/components/keyValue.d.ts.map +1 -0
- package/dist/components/keyValue.js +36 -0
- package/dist/components/keyValue.js.map +1 -0
- package/dist/components/list.d.ts +30 -0
- package/dist/components/list.d.ts.map +1 -0
- package/dist/components/list.js +80 -0
- package/dist/components/list.js.map +1 -0
- package/dist/components/message.d.ts +33 -0
- package/dist/components/message.d.ts.map +1 -0
- package/dist/components/message.js +86 -0
- package/dist/components/message.js.map +1 -0
- package/dist/components/panel.d.ts +28 -0
- package/dist/components/panel.d.ts.map +1 -0
- package/dist/components/panel.js +30 -0
- package/dist/components/panel.js.map +1 -0
- package/dist/components/progressBar.d.ts +44 -0
- package/dist/components/progressBar.d.ts.map +1 -0
- package/dist/components/progressBar.js +154 -0
- package/dist/components/progressBar.js.map +1 -0
- package/dist/components/section.d.ts +22 -0
- package/dist/components/section.d.ts.map +1 -0
- package/dist/components/section.js +48 -0
- package/dist/components/section.js.map +1 -0
- package/dist/components/selectPrompt.d.ts +58 -0
- package/dist/components/selectPrompt.d.ts.map +1 -0
- package/dist/components/selectPrompt.js +206 -0
- package/dist/components/selectPrompt.js.map +1 -0
- package/dist/components/spinner.d.ts +38 -0
- package/dist/components/spinner.d.ts.map +1 -0
- package/dist/components/spinner.js +125 -0
- package/dist/components/spinner.js.map +1 -0
- package/dist/components/statusList.d.ts +22 -0
- package/dist/components/statusList.d.ts.map +1 -0
- package/dist/components/statusList.js +43 -0
- package/dist/components/statusList.js.map +1 -0
- package/dist/components/table.d.ts +39 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +132 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/textPrompt.d.ts +43 -0
- package/dist/components/textPrompt.d.ts.map +1 -0
- package/dist/components/textPrompt.js +123 -0
- package/dist/components/textPrompt.js.map +1 -0
- package/dist/components/tree.d.ts +30 -0
- package/dist/components/tree.d.ts.map +1 -0
- package/dist/components/tree.js +49 -0
- package/dist/components/tree.js.map +1 -0
- package/dist/ds-index.d.ts +113 -0
- package/dist/ds-index.d.ts.map +1 -0
- package/dist/ds-index.js +112 -0
- package/dist/ds-index.js.map +1 -0
- package/dist/help.d.ts +32 -0
- package/dist/help.d.ts.map +1 -0
- package/dist/help.js +34 -0
- package/dist/help.js.map +1 -0
- package/dist/hyper-theme.d.ts +8 -0
- package/dist/hyper-theme.d.ts.map +1 -0
- package/dist/hyper-theme.js +30 -0
- package/dist/hyper-theme.js.map +1 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/md.d.ts +12 -0
- package/dist/md.d.ts.map +1 -0
- package/dist/md.js +19 -0
- package/dist/md.js.map +1 -0
- package/dist/messages.d.ts +20 -0
- package/dist/messages.d.ts.map +1 -0
- package/dist/messages.js +65 -0
- package/dist/messages.js.map +1 -0
- package/dist/palette.d.ts +20 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/palette.js +22 -0
- package/dist/palette.js.map +1 -0
- package/dist/primitives/align.d.ts +23 -0
- package/dist/primitives/align.d.ts.map +1 -0
- package/dist/primitives/align.js +40 -0
- package/dist/primitives/align.js.map +1 -0
- package/dist/primitives/badge.d.ts +24 -0
- package/dist/primitives/badge.d.ts.map +1 -0
- package/dist/primitives/badge.js +40 -0
- package/dist/primitives/badge.js.map +1 -0
- package/dist/primitives/border.d.ts +29 -0
- package/dist/primitives/border.d.ts.map +1 -0
- package/dist/primitives/border.js +100 -0
- package/dist/primitives/border.js.map +1 -0
- package/dist/primitives/context.d.ts +48 -0
- package/dist/primitives/context.d.ts.map +1 -0
- package/dist/primitives/context.js +64 -0
- package/dist/primitives/context.js.map +1 -0
- package/dist/primitives/divider.d.ts +25 -0
- package/dist/primitives/divider.d.ts.map +1 -0
- package/dist/primitives/divider.js +56 -0
- package/dist/primitives/divider.js.map +1 -0
- package/dist/primitives/indent.d.ts +16 -0
- package/dist/primitives/indent.d.ts.map +1 -0
- package/dist/primitives/indent.js +25 -0
- package/dist/primitives/indent.js.map +1 -0
- package/dist/primitives/index.d.ts +32 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/index.js +22 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/line.d.ts +21 -0
- package/dist/primitives/line.d.ts.map +1 -0
- package/dist/primitives/line.js +29 -0
- package/dist/primitives/line.js.map +1 -0
- package/dist/primitives/markdown.d.ts +91 -0
- package/dist/primitives/markdown.d.ts.map +1 -0
- package/dist/primitives/markdown.js +62 -0
- package/dist/primitives/markdown.js.map +1 -0
- package/dist/primitives/pad.d.ts +24 -0
- package/dist/primitives/pad.d.ts.map +1 -0
- package/dist/primitives/pad.js +20 -0
- package/dist/primitives/pad.js.map +1 -0
- package/dist/primitives/stack.d.ts +22 -0
- package/dist/primitives/stack.d.ts.map +1 -0
- package/dist/primitives/stack.js +21 -0
- package/dist/primitives/stack.js.map +1 -0
- package/dist/primitives/styledText.d.ts +36 -0
- package/dist/primitives/styledText.d.ts.map +1 -0
- package/dist/primitives/styledText.js +42 -0
- package/dist/primitives/styledText.js.map +1 -0
- package/dist/primitives/symbol.d.ts +15 -0
- package/dist/primitives/symbol.d.ts.map +1 -0
- package/dist/primitives/symbol.js +18 -0
- package/dist/primitives/symbol.js.map +1 -0
- package/dist/primitives/truncate.d.ts +23 -0
- package/dist/primitives/truncate.d.ts.map +1 -0
- package/dist/primitives/truncate.js +99 -0
- package/dist/primitives/truncate.js.map +1 -0
- package/dist/primitives/wrap.d.ts +23 -0
- package/dist/primitives/wrap.d.ts.map +1 -0
- package/dist/primitives/wrap.js +30 -0
- package/dist/primitives/wrap.js.map +1 -0
- package/dist/render/ansi-utils.d.ts +49 -0
- package/dist/render/ansi-utils.d.ts.map +1 -0
- package/dist/render/ansi-utils.js +405 -0
- package/dist/render/ansi-utils.js.map +1 -0
- package/dist/render/index.d.ts +11 -0
- package/dist/render/index.d.ts.map +1 -0
- package/dist/render/index.js +11 -0
- package/dist/render/index.js.map +1 -0
- package/dist/render/sgr.d.ts +60 -0
- package/dist/render/sgr.d.ts.map +1 -0
- package/dist/render/sgr.js +191 -0
- package/dist/render/sgr.js.map +1 -0
- package/dist/render/strip.d.ts +24 -0
- package/dist/render/strip.d.ts.map +1 -0
- package/dist/render/strip.js +81 -0
- package/dist/render/strip.js.map +1 -0
- package/dist/render/width.d.ts +30 -0
- package/dist/render/width.d.ts.map +1 -0
- package/dist/render/width.js +149 -0
- package/dist/render/width.js.map +1 -0
- package/dist/shortcuts.d.ts +76 -0
- package/dist/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts.js +117 -0
- package/dist/shortcuts.js.map +1 -0
- package/dist/styles.d.ts +43 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +44 -0
- package/dist/styles.js.map +1 -0
- package/dist/symbols.d.ts +19 -0
- package/dist/symbols.d.ts.map +1 -0
- package/dist/symbols.js +21 -0
- package/dist/symbols.js.map +1 -0
- package/dist/test/compare.d.ts +28 -0
- package/dist/test/compare.d.ts.map +1 -0
- package/dist/test/compare.js +37 -0
- package/dist/test/compare.js.map +1 -0
- package/dist/test/index.d.ts +16 -0
- package/dist/test/index.d.ts.map +1 -0
- package/dist/test/index.js +14 -0
- package/dist/test/index.js.map +1 -0
- package/dist/test/mock.d.ts +50 -0
- package/dist/test/mock.d.ts.map +1 -0
- package/dist/test/mock.js +135 -0
- package/dist/test/mock.js.map +1 -0
- package/dist/test/render.d.ts +29 -0
- package/dist/test/render.d.ts.map +1 -0
- package/dist/test/render.js +87 -0
- package/dist/test/render.js.map +1 -0
- package/dist/test/snapshot.d.ts +16 -0
- package/dist/test/snapshot.d.ts.map +1 -0
- package/dist/test/snapshot.js +216 -0
- package/dist/test/snapshot.js.map +1 -0
- package/dist/theme/builtins.d.ts +10 -0
- package/dist/theme/builtins.d.ts.map +1 -0
- package/dist/theme/builtins.js +102 -0
- package/dist/theme/builtins.js.map +1 -0
- package/dist/theme/engine.d.ts +51 -0
- package/dist/theme/engine.d.ts.map +1 -0
- package/dist/theme/engine.js +123 -0
- package/dist/theme/engine.js.map +1 -0
- package/dist/theme/index.d.ts +10 -0
- package/dist/theme/index.d.ts.map +1 -0
- package/dist/theme/index.js +12 -0
- package/dist/theme/index.js.map +1 -0
- package/dist/theme/merge.d.ts +24 -0
- package/dist/theme/merge.d.ts.map +1 -0
- package/dist/theme/merge.js +66 -0
- package/dist/theme/merge.js.map +1 -0
- package/dist/theme/types.d.ts +44 -0
- package/dist/theme/types.d.ts.map +1 -0
- package/dist/theme/types.js +8 -0
- package/dist/theme/types.js.map +1 -0
- package/dist/theme.d.ts +9 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +53 -0
- package/dist/theme.js.map +1 -0
- package/dist/tokens/defaults.d.ts +13 -0
- package/dist/tokens/defaults.d.ts.map +1 -0
- package/dist/tokens/defaults.js +248 -0
- package/dist/tokens/defaults.js.map +1 -0
- package/dist/tokens/index.d.ts +10 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +10 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/resolver.d.ts +100 -0
- package/dist/tokens/resolver.d.ts.map +1 -0
- package/dist/tokens/resolver.js +138 -0
- package/dist/tokens/resolver.js.map +1 -0
- package/dist/tokens/types.d.ts +265 -0
- package/dist/tokens/types.d.ts.map +1 -0
- package/dist/tokens/types.js +10 -0
- package/dist/tokens/types.js.map +1 -0
- package/dist/tokens.d.ts +26 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +30 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* message Component
|
|
3
|
+
*
|
|
4
|
+
* Renders a styled message with an icon, text, optional title, details/body,
|
|
5
|
+
* and hint. Supports error, warning, success, info, and tip levels.
|
|
6
|
+
*
|
|
7
|
+
* Produces rich output matching HyperDev's visual language:
|
|
8
|
+
* - Title line with prefix label
|
|
9
|
+
* - Icon + summary with gap
|
|
10
|
+
* - Vertical bar connectors for body content
|
|
11
|
+
* - Trailing blank line
|
|
12
|
+
*/
|
|
13
|
+
import { getContext, indent, stack, styledText, symbol } from "../primitives/index.js";
|
|
14
|
+
/** Prefix labels for each message level. */
|
|
15
|
+
const LEVEL_PREFIX = {
|
|
16
|
+
error: "Error:",
|
|
17
|
+
warning: "Warning:",
|
|
18
|
+
success: "Success:",
|
|
19
|
+
info: "Info:",
|
|
20
|
+
tip: "Tip:",
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Renders a styled message with an icon, text, optional title, body, and hint.
|
|
24
|
+
*
|
|
25
|
+
* @param options - Message configuration.
|
|
26
|
+
* @returns The formatted message as a multi-line string.
|
|
27
|
+
*/
|
|
28
|
+
export function message(options) {
|
|
29
|
+
const ctx = getContext();
|
|
30
|
+
const iconGap = " ".repeat(ctx.tokens.space.iconGap);
|
|
31
|
+
// Resolve the color token name — tip uses 'info' color since there's no 'tip' color token
|
|
32
|
+
const colorName = options.level === "tip" ? "info" : options.level;
|
|
33
|
+
const icon = symbol(options.level === "tip" ? "tip" : options.level);
|
|
34
|
+
const styledSummary = styledText(options.text, { color: colorName, bold: true });
|
|
35
|
+
// Indentation: tip messages have no leading indent, others get 2 spaces
|
|
36
|
+
const INDENT = " ";
|
|
37
|
+
const leadingIndent = options.level === "tip" ? "" : INDENT;
|
|
38
|
+
const contentIndent = options.level === "tip" ? INDENT : INDENT + INDENT;
|
|
39
|
+
const parts = [];
|
|
40
|
+
if (!options.title && !options.details) {
|
|
41
|
+
// Summary-only: just icon + summary
|
|
42
|
+
parts.push(`${leadingIndent}${icon}${iconGap}${styledSummary}`);
|
|
43
|
+
}
|
|
44
|
+
else if (!options.title && options.details) {
|
|
45
|
+
// No title, but has details: icon + summary, then indented details
|
|
46
|
+
parts.push(`${leadingIndent}${icon}${iconGap}${styledSummary}`);
|
|
47
|
+
const detailLines = Array.isArray(options.details)
|
|
48
|
+
? options.details
|
|
49
|
+
: options.details.split("\n");
|
|
50
|
+
for (const detail of detailLines) {
|
|
51
|
+
parts.push(indent(detail, 1));
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
else if (options.title && !options.details) {
|
|
55
|
+
// Title + summary (no body)
|
|
56
|
+
const prefix = styledText(LEVEL_PREFIX[options.level] ?? "", { color: colorName });
|
|
57
|
+
parts.push(`${leadingIndent}${prefix} ${options.title}`);
|
|
58
|
+
parts.push("");
|
|
59
|
+
parts.push(`${contentIndent}${icon}${iconGap}${styledSummary}`);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// Title + summary + body with bar connectors
|
|
63
|
+
const prefix = styledText(LEVEL_PREFIX[options.level] ?? "", { color: colorName });
|
|
64
|
+
const barChar = symbol("bar");
|
|
65
|
+
const styledBar = styledText(barChar, { color: colorName });
|
|
66
|
+
const bodyLines = Array.isArray(options.details)
|
|
67
|
+
? options.details
|
|
68
|
+
: options.details.split("\n");
|
|
69
|
+
parts.push(`${leadingIndent}${prefix} ${options.title}`);
|
|
70
|
+
parts.push("");
|
|
71
|
+
parts.push(`${contentIndent}${icon}${iconGap}${styledSummary}`);
|
|
72
|
+
parts.push(`${contentIndent}${styledBar}`);
|
|
73
|
+
for (const bodyLine of bodyLines) {
|
|
74
|
+
const dimLine = styledText(bodyLine, { dim: true });
|
|
75
|
+
parts.push(`${contentIndent}${styledBar}${iconGap}${dimLine}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (options.hint) {
|
|
79
|
+
const hintText = styledText(options.hint, { dim: true });
|
|
80
|
+
parts.push(indent(hintText, 1));
|
|
81
|
+
}
|
|
82
|
+
// Trailing blank line
|
|
83
|
+
parts.push("");
|
|
84
|
+
return parts.join("\n");
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=message.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../src/components/message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAgBvF,4CAA4C;AAC5C,MAAM,YAAY,GAA2B;IAC5C,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,UAAU;IACnB,OAAO,EAAE,UAAU;IACnB,IAAI,EAAE,OAAO;IACb,GAAG,EAAE,MAAM;CACX,CAAC;AA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"../tokens/index.ts";
|
|
7
|
+
/** Options for rendering a panel box. */
|
|
8
|
+
export type PanelOptions = {
|
|
9
|
+
/** Title displayed in the top border. */
|
|
10
|
+
title?: string;
|
|
11
|
+
/** Title alignment within the top border. Defaults to `'left'`. */
|
|
12
|
+
titleAlign?: "left" | "center" | "right";
|
|
13
|
+
/** Border character style. Defaults to the theme's default. */
|
|
14
|
+
borderStyle?: BorderStyleName;
|
|
15
|
+
/** Vertical padding (blank lines) inside the box. Defaults to `0`. */
|
|
16
|
+
padding?: number;
|
|
17
|
+
/** Total box width, or `'auto'` to fit content. */
|
|
18
|
+
width?: number | "auto";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Renders content inside a bordered panel box with optional vertical padding.
|
|
22
|
+
*
|
|
23
|
+
* @param content - A string or array of lines to enclose.
|
|
24
|
+
* @param options - Panel configuration.
|
|
25
|
+
* @returns The bordered panel as a multi-line string.
|
|
26
|
+
*/
|
|
27
|
+
export declare function panel(content: string | string[], options?: PanelOptions): string;
|
|
28
|
+
//# sourceMappingURL=panel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.d.ts","sourceRoot":"","sources":["../../src/components/panel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D,yCAAyC;AACzC,MAAM,MAAM,YAAY,GAAG;IAC1B,yCAAyC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mEAAmE;IACnE,UAAU,CAAC,EAAE,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;IACzC,+DAA+D;IAC/D,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,MAAM,CAiBhF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* panel Component
|
|
3
|
+
*
|
|
4
|
+
* Thin wrapper around the border primitive that adds vertical padding support.
|
|
5
|
+
*/
|
|
6
|
+
import { border } from "../primitives/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Renders content inside a bordered panel box with optional vertical padding.
|
|
9
|
+
*
|
|
10
|
+
* @param content - A string or array of lines to enclose.
|
|
11
|
+
* @param options - Panel configuration.
|
|
12
|
+
* @returns The bordered panel as a multi-line string.
|
|
13
|
+
*/
|
|
14
|
+
export function panel(content, options) {
|
|
15
|
+
const padding = options?.padding ?? 0;
|
|
16
|
+
let lines = Array.isArray(content) ? [...content] : content.split("\n");
|
|
17
|
+
// Add vertical padding (blank lines) inside the box
|
|
18
|
+
if (padding > 0) {
|
|
19
|
+
const blankLines = Array.from({ length: padding }, () => "");
|
|
20
|
+
lines = [...blankLines, ...lines, ...blankLines];
|
|
21
|
+
}
|
|
22
|
+
return border(lines, {
|
|
23
|
+
style: options?.borderStyle,
|
|
24
|
+
title: options?.title,
|
|
25
|
+
titleAlign: options?.titleAlign,
|
|
26
|
+
padding: options?.padding ?? 1,
|
|
27
|
+
width: options?.width,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"panel.js","sourceRoot":"","sources":["../../src/components/panel.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiBhD;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,OAA0B,EAAE,OAAsB;IACvE,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,CAAC,CAAC;IACtC,IAAI,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAExE,oDAAoD;IACpD,IAAI,OAAO,GAAG,CAAC,EAAE,CAAC;QACjB,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;QAC7D,KAAK,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,OAAO,EAAE,WAAW;QAC3B,KAAK,EAAE,OAAO,EAAE,KAAK;QACrB,UAAU,EAAE,OAAO,EAAE,UAAU;QAC/B,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,CAAC;QAC9B,KAAK,EAAE,OAAO,EAAE,KAAK;KACrB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProgressBar Component
|
|
3
|
+
*
|
|
4
|
+
* A progress bar for determinate or indeterminate operations.
|
|
5
|
+
* Renders an animated bar with percentage, using spinner frames for the leading indicator.
|
|
6
|
+
* Gracefully degrades in non-TTY/CI environments to periodic percentage updates.
|
|
7
|
+
*/
|
|
8
|
+
/** Options for creating a progress bar. */
|
|
9
|
+
export type ProgressBarOptions = {
|
|
10
|
+
/** Total number of units for determinate progress. Omit for indeterminate mode. */
|
|
11
|
+
total?: number;
|
|
12
|
+
/** Width of the progress bar in characters. Defaults to `30`. */
|
|
13
|
+
width?: number;
|
|
14
|
+
/** Label text displayed alongside the bar. */
|
|
15
|
+
label?: string;
|
|
16
|
+
/** Whether to show a percentage indicator. Defaults to `true`. */
|
|
17
|
+
showPercentage?: boolean;
|
|
18
|
+
/** Output stream for progress bar rendering. Defaults to `process.stderr`. */
|
|
19
|
+
stream?: NodeJS.WriteStream;
|
|
20
|
+
};
|
|
21
|
+
/** Handle for controlling a running progress bar. */
|
|
22
|
+
export type ProgressBarHandle = {
|
|
23
|
+
/** Start the progress bar, optionally setting the label. */
|
|
24
|
+
start(label?: string): void;
|
|
25
|
+
/** Set the current progress value, optionally updating the label. */
|
|
26
|
+
update(current: number, label?: string): void;
|
|
27
|
+
/** Increment progress by an amount. Defaults to `1`. */
|
|
28
|
+
increment(amount?: number): void;
|
|
29
|
+
/** Stop the progress bar, optionally showing a final message. */
|
|
30
|
+
stop(finalText?: string): void;
|
|
31
|
+
/** Stop with a success icon and optional message. */
|
|
32
|
+
succeed(text?: string): void;
|
|
33
|
+
/** Stop with a failure icon and optional message. */
|
|
34
|
+
fail(text?: string): void;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Creates a progress bar for determinate or indeterminate operations.
|
|
38
|
+
* Gracefully degrades to periodic percentage updates in non-TTY environments.
|
|
39
|
+
*
|
|
40
|
+
* @param options - Progress bar configuration.
|
|
41
|
+
* @returns A handle to control the progress bar lifecycle.
|
|
42
|
+
*/
|
|
43
|
+
export declare function progressBar(options?: ProgressBarOptions): ProgressBarHandle;
|
|
44
|
+
//# sourceMappingURL=progressBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressBar.d.ts","sourceRoot":"","sources":["../../src/components/progressBar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,2CAA2C;AAC3C,MAAM,MAAM,kBAAkB,GAAG;IAChC,mFAAmF;IACnF,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8CAA8C;IAC9C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kEAAkE;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,8EAA8E;IAC9E,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW,CAAC;CAC5B,CAAC;AAEF,qDAAqD;AACrD,MAAM,MAAM,iBAAiB,GAAG;IAC/B,4DAA4D;IAC5D,KAAK,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,qEAAqE;IACrE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9C,wDAAwD;IACxD,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,iEAAiE;IACjE,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,qDAAqD;IACrD,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,qDAAqD;IACrD,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CAiK3E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ProgressBar Component
|
|
3
|
+
*
|
|
4
|
+
* A progress bar for determinate or indeterminate operations.
|
|
5
|
+
* Renders an animated bar with percentage, using spinner frames for the leading indicator.
|
|
6
|
+
* Gracefully degrades in non-TTY/CI environments to periodic percentage updates.
|
|
7
|
+
*/
|
|
8
|
+
import { getContext, styledText, symbol } from "../primitives/index.js";
|
|
9
|
+
/**
|
|
10
|
+
* Creates a progress bar for determinate or indeterminate operations.
|
|
11
|
+
* Gracefully degrades to periodic percentage updates in non-TTY environments.
|
|
12
|
+
*
|
|
13
|
+
* @param options - Progress bar configuration.
|
|
14
|
+
* @returns A handle to control the progress bar lifecycle.
|
|
15
|
+
*/
|
|
16
|
+
export function progressBar(options) {
|
|
17
|
+
const ctx = getContext();
|
|
18
|
+
const stream = options?.stream ?? process.stderr;
|
|
19
|
+
const total = options?.total;
|
|
20
|
+
const barWidth = options?.width ?? 30;
|
|
21
|
+
const showPercentage = options?.showPercentage ?? true;
|
|
22
|
+
let label = options?.label ?? "";
|
|
23
|
+
let current = 0;
|
|
24
|
+
let running = false;
|
|
25
|
+
let timer = null;
|
|
26
|
+
let spinnerFrame = 0;
|
|
27
|
+
let lastReportedDecile = -1;
|
|
28
|
+
const spinnerFrames = ctx.tokens.motion.spinnerDots;
|
|
29
|
+
const filledChar = ctx.tokens.motion.progressFilled;
|
|
30
|
+
const partialChar = ctx.tokens.motion.progressPartial;
|
|
31
|
+
const interval = ctx.tokens.motion.progressInterval;
|
|
32
|
+
const isTTY = !!stream.isTTY;
|
|
33
|
+
const isInteractive = isTTY && !ctx.capabilities.isCI;
|
|
34
|
+
function clearLine() {
|
|
35
|
+
stream.write("\r\x1b[K");
|
|
36
|
+
}
|
|
37
|
+
function renderBar() {
|
|
38
|
+
if (total === undefined) {
|
|
39
|
+
// Indeterminate mode
|
|
40
|
+
const frame = spinnerFrames[spinnerFrame % spinnerFrames.length];
|
|
41
|
+
spinnerFrame++;
|
|
42
|
+
const frameStyled = styledText(frame, { color: "accent" });
|
|
43
|
+
clearLine();
|
|
44
|
+
stream.write(`${frameStyled} ${label}`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const pct = Math.min(current / total, 1);
|
|
48
|
+
const filled = Math.round(pct * barWidth);
|
|
49
|
+
const empty = barWidth - filled;
|
|
50
|
+
const frame = spinnerFrames[spinnerFrame % spinnerFrames.length];
|
|
51
|
+
spinnerFrame++;
|
|
52
|
+
const frameStyled = styledText(frame, { color: "accent" });
|
|
53
|
+
const barFilled = styledText(filledChar.repeat(filled), { color: "accent" });
|
|
54
|
+
const barEmpty = styledText(partialChar.repeat(empty), { dim: true });
|
|
55
|
+
const bar = barFilled + barEmpty;
|
|
56
|
+
const pctStr = showPercentage ? ` ${Math.round(pct * 100)}%` : "";
|
|
57
|
+
const labelStr = label ? ` ${label}` : "";
|
|
58
|
+
clearLine();
|
|
59
|
+
stream.write(`${frameStyled}${labelStr} ${bar}${pctStr}`);
|
|
60
|
+
}
|
|
61
|
+
function checkComplete() {
|
|
62
|
+
if (total !== undefined && current >= total) {
|
|
63
|
+
handle.succeed();
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const handle = {
|
|
67
|
+
start(startLabel) {
|
|
68
|
+
if (running)
|
|
69
|
+
return;
|
|
70
|
+
running = true;
|
|
71
|
+
if (startLabel !== undefined)
|
|
72
|
+
label = startLabel;
|
|
73
|
+
current = 0;
|
|
74
|
+
lastReportedDecile = -1;
|
|
75
|
+
if (!isInteractive) {
|
|
76
|
+
const pctStr = total !== undefined ? " 0%" : "";
|
|
77
|
+
stream.write(`${label}...${pctStr}\n`);
|
|
78
|
+
lastReportedDecile = 0;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
stream.write("\x1b[?25l");
|
|
82
|
+
spinnerFrame = 0;
|
|
83
|
+
renderBar();
|
|
84
|
+
timer = setInterval(renderBar, interval);
|
|
85
|
+
},
|
|
86
|
+
update(value, updateLabel) {
|
|
87
|
+
current = value;
|
|
88
|
+
if (updateLabel !== undefined)
|
|
89
|
+
label = updateLabel;
|
|
90
|
+
if (!isInteractive) {
|
|
91
|
+
if (total !== undefined) {
|
|
92
|
+
const pct = Math.min(current / total, 1);
|
|
93
|
+
const decile = Math.floor(pct * 10);
|
|
94
|
+
if (decile > lastReportedDecile) {
|
|
95
|
+
lastReportedDecile = decile;
|
|
96
|
+
stream.write(`${label}... ${Math.round(pct * 100)}%\n`);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (total !== undefined && current >= total) {
|
|
100
|
+
handle.succeed();
|
|
101
|
+
}
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
checkComplete();
|
|
105
|
+
},
|
|
106
|
+
increment(amount) {
|
|
107
|
+
handle.update(current + (amount ?? 1));
|
|
108
|
+
},
|
|
109
|
+
stop(finalText) {
|
|
110
|
+
if (!running)
|
|
111
|
+
return;
|
|
112
|
+
running = false;
|
|
113
|
+
if (timer) {
|
|
114
|
+
clearInterval(timer);
|
|
115
|
+
timer = null;
|
|
116
|
+
}
|
|
117
|
+
if (!isInteractive) {
|
|
118
|
+
if (finalText) {
|
|
119
|
+
stream.write(`${finalText}\n`);
|
|
120
|
+
}
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
clearLine();
|
|
124
|
+
if (finalText) {
|
|
125
|
+
stream.write(`${finalText}\n`);
|
|
126
|
+
}
|
|
127
|
+
stream.write("\x1b[?25h");
|
|
128
|
+
},
|
|
129
|
+
succeed(text) {
|
|
130
|
+
const finalText = text ?? label;
|
|
131
|
+
const icon = styledText(symbol("success"), { color: "success" });
|
|
132
|
+
if (!isInteractive) {
|
|
133
|
+
const prefix = ctx.capabilities.unicode ? symbol("success") : "[OK]";
|
|
134
|
+
stream.write(`${prefix} ${finalText}\n`);
|
|
135
|
+
running = false;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
handle.stop(`${icon} ${finalText}`);
|
|
139
|
+
},
|
|
140
|
+
fail(text) {
|
|
141
|
+
const finalText = text ?? label;
|
|
142
|
+
const icon = styledText(symbol("error"), { color: "error" });
|
|
143
|
+
if (!isInteractive) {
|
|
144
|
+
const prefix = ctx.capabilities.unicode ? symbol("error") : "[FAIL]";
|
|
145
|
+
stream.write(`${prefix} ${finalText}\n`);
|
|
146
|
+
running = false;
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
handle.stop(`${icon} ${finalText}`);
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
return handle;
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=progressBar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progressBar.js","sourceRoot":"","sources":["../../src/components/progressBar.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,UAA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
|
+
*/
|
|
6
|
+
/** Options for rendering a titled section. */
|
|
7
|
+
export type SectionOptions = {
|
|
8
|
+
/** The section heading text. */
|
|
9
|
+
title: string;
|
|
10
|
+
/** Heading level: `1` (divider + spacing), `2` (spacing only), `3` (compact). Defaults to `1`. */
|
|
11
|
+
level?: 1 | 2 | 3;
|
|
12
|
+
/** Body content below the heading. */
|
|
13
|
+
content: string | string[];
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Renders a titled section with heading level styling and content layout.
|
|
17
|
+
*
|
|
18
|
+
* @param options - Section configuration.
|
|
19
|
+
* @returns The formatted section as a multi-line string.
|
|
20
|
+
*/
|
|
21
|
+
export declare function section(options: SectionOptions): string;
|
|
22
|
+
//# sourceMappingURL=section.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section.d.ts","sourceRoot":"","sources":["../../src/components/section.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,8CAA8C;AAC9C,MAAM,MAAM,cAAc,GAAG;IAC5B,gCAAgC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,kGAAkG;IAClG,KAAK,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAClB,sCAAsC;IACtC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CAC3B,CAAC;AAEF;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,MAAM,CAqCvD"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* section Component
|
|
3
|
+
*
|
|
4
|
+
* Renders a titled section with heading level styling and content layout.
|
|
5
|
+
*/
|
|
6
|
+
import { divider, getContext, stack, styledText } from "../primitives/index.js";
|
|
7
|
+
/**
|
|
8
|
+
* Renders a titled section with heading level styling and content layout.
|
|
9
|
+
*
|
|
10
|
+
* @param options - Section configuration.
|
|
11
|
+
* @returns The formatted section as a multi-line string.
|
|
12
|
+
*/
|
|
13
|
+
export function section(options) {
|
|
14
|
+
const ctx = getContext();
|
|
15
|
+
const level = options.level ?? 1;
|
|
16
|
+
const content = Array.isArray(options.content) ? options.content.join("\n") : options.content;
|
|
17
|
+
// Get typography style for the heading level
|
|
18
|
+
const typoKey = `heading${level}`;
|
|
19
|
+
const typoStyle = ctx.tokens.type[typoKey];
|
|
20
|
+
const title = styledText(options.title, {
|
|
21
|
+
bold: typoStyle.bold,
|
|
22
|
+
dim: typoStyle.dim,
|
|
23
|
+
italic: typoStyle.italic,
|
|
24
|
+
underline: typoStyle.underline,
|
|
25
|
+
color: typoStyle.color,
|
|
26
|
+
});
|
|
27
|
+
const parts = [];
|
|
28
|
+
if (level === 1) {
|
|
29
|
+
// Title + divider + blank line + content
|
|
30
|
+
parts.push(title);
|
|
31
|
+
parts.push(divider());
|
|
32
|
+
parts.push("");
|
|
33
|
+
parts.push(content);
|
|
34
|
+
}
|
|
35
|
+
else if (level === 2) {
|
|
36
|
+
// Title + blank line + content
|
|
37
|
+
parts.push(title);
|
|
38
|
+
parts.push("");
|
|
39
|
+
parts.push(content);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
// Title + content (no blank line)
|
|
43
|
+
parts.push(title);
|
|
44
|
+
parts.push(content);
|
|
45
|
+
}
|
|
46
|
+
return parts.join("\n");
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=section.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"section.js","sourceRoot":"","sources":["../../src/components/section.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAahF;;;;;GAKG;AACH,MAAM,UAAU,OAAO,CAAC,OAAuB;IAC9C,MAAM,GAAG,GAAG,UAAU,EAAE,CAAC;IACzB,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;IACjC,MAAM,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AAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SelectPrompt Component
|
|
3
|
+
*
|
|
4
|
+
* Prompts the user to select a single option from a list.
|
|
5
|
+
* Uses raw mode to capture keystrokes for arrow navigation.
|
|
6
|
+
* Falls back to numbered list input in non-TTY environments.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* A single option in a select prompt.
|
|
10
|
+
* @typeParam T - The value type returned when this option is selected.
|
|
11
|
+
*/
|
|
12
|
+
export type SelectOption<T> = {
|
|
13
|
+
/** Display label shown to the user. */
|
|
14
|
+
label: string;
|
|
15
|
+
/** Value returned when this option is selected. */
|
|
16
|
+
value: T;
|
|
17
|
+
/** Hint text shown next to the label when active. */
|
|
18
|
+
hint?: string;
|
|
19
|
+
/** Whether this option is disabled and cannot be selected. */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Options for creating a select prompt.
|
|
24
|
+
* @typeParam T - The value type of the selectable options.
|
|
25
|
+
*/
|
|
26
|
+
export type SelectPromptOptions<T> = {
|
|
27
|
+
/** The question displayed above the option list. */
|
|
28
|
+
message: string;
|
|
29
|
+
/** Available options to choose from. */
|
|
30
|
+
options: SelectOption<T>[];
|
|
31
|
+
/** Maximum number of options visible at once before scrolling. Defaults to `10`. */
|
|
32
|
+
maxVisible?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Formats the select question line.
|
|
36
|
+
* Returns: `? message` with `?` in accent color.
|
|
37
|
+
*/
|
|
38
|
+
export declare function formatSelectQuestion(message: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Formats the submitted answer line.
|
|
41
|
+
* Returns: `checkmark message selected-label`.
|
|
42
|
+
*/
|
|
43
|
+
export declare function formatSelectAnswer(message: string, selectedLabel: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Renders the option list for display.
|
|
46
|
+
* Returns an array of formatted option lines.
|
|
47
|
+
*/
|
|
48
|
+
export declare function renderOptions<T>(options: SelectOption<T>[], activeIndex: number, scrollOffset: number, maxVisible: number): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Prompts the user to select a single option from a list using arrow-key navigation.
|
|
51
|
+
* Falls back to numbered list input in non-TTY environments.
|
|
52
|
+
*
|
|
53
|
+
* @typeParam T - The value type of the selectable options.
|
|
54
|
+
* @param options - Select prompt configuration.
|
|
55
|
+
* @returns The value of the selected option.
|
|
56
|
+
*/
|
|
57
|
+
export declare function selectPrompt<T>(options: SelectPromptOptions<T>): Promise<T>;
|
|
58
|
+
//# sourceMappingURL=selectPrompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selectPrompt.d.ts","sourceRoot":"","sources":["../../src/components/selectPrompt.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAKH;;;GAGG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC7B,uCAAuC;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,mDAAmD;IACnD,KAAK,EAAE,CAAC,CAAC;IACT,qDAAqD;IACrD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI;IACpC,oDAAoD;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,wCAAwC;IACxC,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC;IAC3B,oFAAoF;IACpF,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5D;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAIjF;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC9B,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,EAC1B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE,MAAM,GAChB,MAAM,EAAE,CAqCV;AAeD;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAsI3E"}
|