@mnmal-ai/surface-core 0.0.0 → 0.14.5
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 +202 -0
- package/README.md +10 -1
- package/dist/app.d.ts +135 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/apply-input.d.ts +6 -0
- package/dist/apply-input.d.ts.map +1 -0
- package/dist/complete.d.ts +15 -0
- package/dist/complete.d.ts.map +1 -0
- package/dist/compose.d.ts +55 -0
- package/dist/compose.d.ts.map +1 -0
- package/dist/editor.d.ts +58 -0
- package/dist/editor.d.ts.map +1 -0
- package/dist/exit-chord.d.ts +4 -0
- package/dist/exit-chord.d.ts.map +1 -0
- package/dist/history.d.ts +41 -0
- package/dist/history.d.ts.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1103 -0
- package/dist/key-spec.d.ts +3 -0
- package/dist/key-spec.d.ts.map +1 -0
- package/dist/keys.d.ts +57 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/module.d.ts +266 -0
- package/dist/module.d.ts.map +1 -0
- package/dist/overlay-DIAFXlMT.js +1011 -0
- package/dist/overlay.d.ts +27 -0
- package/dist/overlay.d.ts.map +1 -0
- package/dist/palette.d.ts +38 -0
- package/dist/palette.d.ts.map +1 -0
- package/dist/pure.d.ts +16 -0
- package/dist/pure.d.ts.map +1 -0
- package/dist/pure.js +3 -0
- package/dist/route-input.d.ts +28 -0
- package/dist/route-input.d.ts.map +1 -0
- package/dist/sanitise.d.ts +3 -0
- package/dist/sanitise.d.ts.map +1 -0
- package/dist/terminal.d.ts +70 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/transcript.d.ts +63 -0
- package/dist/transcript.d.ts.map +1 -0
- package/package.json +54 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key-spec.d.ts","sourceRoot":"","sources":["../src/key-spec.ts"],"names":[],"mappings":"AAyBA,iHAAiH;AACjH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAarD"}
|
package/dist/keys.d.ts
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Registry } from './compose.js';
|
|
2
|
+
import type { Key, KeySpec } from './module.js';
|
|
3
|
+
export declare function keySpecOf(k: Key): KeySpec | null;
|
|
4
|
+
export interface KeyState {
|
|
5
|
+
readonly overlay: {
|
|
6
|
+
readonly module: string;
|
|
7
|
+
readonly panel: string;
|
|
8
|
+
} | null;
|
|
9
|
+
readonly menu: 'palette' | 'completion' | null;
|
|
10
|
+
readonly draftEmpty: boolean;
|
|
11
|
+
/** The focused panel's armed confirm key, set only while the draft is exactly it. */
|
|
12
|
+
readonly armed?: string | null;
|
|
13
|
+
}
|
|
14
|
+
export type Route = {
|
|
15
|
+
readonly kind: 'exit-chord';
|
|
16
|
+
} | {
|
|
17
|
+
readonly kind: 'menu';
|
|
18
|
+
readonly act: 'move';
|
|
19
|
+
readonly delta: -1 | 1;
|
|
20
|
+
} | {
|
|
21
|
+
readonly kind: 'menu';
|
|
22
|
+
readonly act: 'accept' | 'run' | 'close';
|
|
23
|
+
} | {
|
|
24
|
+
readonly kind: 'panel';
|
|
25
|
+
readonly module: string;
|
|
26
|
+
readonly panel: string;
|
|
27
|
+
readonly act: string;
|
|
28
|
+
} | {
|
|
29
|
+
readonly kind: 'panel-close';
|
|
30
|
+
}
|
|
31
|
+
/** Enter on an armed confirm key: run the act and clear the draft. */
|
|
32
|
+
| {
|
|
33
|
+
readonly kind: 'confirm';
|
|
34
|
+
readonly module: string;
|
|
35
|
+
readonly panel: string;
|
|
36
|
+
readonly act: string;
|
|
37
|
+
} | {
|
|
38
|
+
readonly kind: 'global';
|
|
39
|
+
readonly module: string;
|
|
40
|
+
readonly key: KeySpec;
|
|
41
|
+
} | {
|
|
42
|
+
readonly kind: 'cancel-turn';
|
|
43
|
+
} | {
|
|
44
|
+
readonly kind: 'history';
|
|
45
|
+
readonly dir: 'up' | 'down';
|
|
46
|
+
} | {
|
|
47
|
+
readonly kind: 'submit';
|
|
48
|
+
} | {
|
|
49
|
+
readonly kind: 'complete';
|
|
50
|
+
} | {
|
|
51
|
+
readonly kind: 'edit';
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: 'ignore';
|
|
54
|
+
};
|
|
55
|
+
/** Pure: a key resolves to data, and only then does a handler run. Precedence per spec §3. */
|
|
56
|
+
export declare function resolveKey(state: KeyState, key: Key, registry: Registry): Route;
|
|
57
|
+
//# sourceMappingURL=keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.d.ts","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEhD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,CAiBhD;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAC7E,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,IAAI,CAAC;IAC/C,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,qFAAqF;IACrF,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAED,MAAM,MAAM,KAAK,GACb;IAAE,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAA;CAAE,GAC/B;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC,GA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AQ,GAAG,KAAK,CA8D/E"}
|
package/dist/module.d.ts
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
import type { Theme, Tone } from '@mnmal-ai/surface-theme';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { Transcript } from './transcript.js';
|
|
4
|
+
/** Ink's key flags plus the raw input, as the core routes them. */
|
|
5
|
+
export interface Key {
|
|
6
|
+
readonly input: string;
|
|
7
|
+
readonly ctrl?: boolean;
|
|
8
|
+
readonly meta?: boolean;
|
|
9
|
+
readonly shift?: boolean;
|
|
10
|
+
readonly escape?: boolean;
|
|
11
|
+
readonly return?: boolean;
|
|
12
|
+
readonly tab?: boolean;
|
|
13
|
+
readonly upArrow?: boolean;
|
|
14
|
+
readonly downArrow?: boolean;
|
|
15
|
+
readonly leftArrow?: boolean;
|
|
16
|
+
readonly rightArrow?: boolean;
|
|
17
|
+
readonly backspace?: boolean;
|
|
18
|
+
readonly delete?: boolean;
|
|
19
|
+
readonly home?: boolean;
|
|
20
|
+
readonly end?: boolean;
|
|
21
|
+
readonly pageUp?: boolean;
|
|
22
|
+
readonly pageDown?: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** 'a', 'ctrl+p', 'meta+x', 'escape', 'enter', 'tab', 'up', 'down', 'left', 'right', 'pageup', 'pagedown'. */
|
|
25
|
+
export type KeySpec = string;
|
|
26
|
+
/** Room on screen, in terminal cells. */
|
|
27
|
+
export interface Size {
|
|
28
|
+
readonly rows: number;
|
|
29
|
+
readonly columns: number;
|
|
30
|
+
}
|
|
31
|
+
export interface Chip {
|
|
32
|
+
readonly label: string;
|
|
33
|
+
readonly tone?: Tone;
|
|
34
|
+
}
|
|
35
|
+
/** What a turn renders: a renderer is chosen by `kind`. */
|
|
36
|
+
export interface Reply {
|
|
37
|
+
readonly kind: string;
|
|
38
|
+
readonly data: unknown;
|
|
39
|
+
readonly chips?: readonly Chip[];
|
|
40
|
+
}
|
|
41
|
+
export type TurnPhase = 'pending' | 'partial' | 'final' | 'failed';
|
|
42
|
+
export interface TurnUpdate {
|
|
43
|
+
readonly phase: TurnPhase;
|
|
44
|
+
readonly reply: Reply;
|
|
45
|
+
}
|
|
46
|
+
export interface ArgSpec {
|
|
47
|
+
readonly name: string;
|
|
48
|
+
readonly optional?: boolean;
|
|
49
|
+
/** Id of a completer (`<module>:<completer>`) that completes this argument. */
|
|
50
|
+
readonly completer?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface Suggestion {
|
|
53
|
+
readonly label: string;
|
|
54
|
+
/** Replaces the token under the cursor, or the `replace` span when one is given. */
|
|
55
|
+
readonly insert: string;
|
|
56
|
+
/**
|
|
57
|
+
* The draft span `insert` replaces, as `[start, end)` character offsets, for a completer
|
|
58
|
+
* that knows its span, which may end after the cursor. Absent, the whitespace token ending at
|
|
59
|
+
* the cursor is replaced, as a shell completes. An invalid span is ignored.
|
|
60
|
+
*/
|
|
61
|
+
readonly replace?: readonly [start: number, end: number];
|
|
62
|
+
readonly detail?: string;
|
|
63
|
+
/** Higher ranks first; default 0. */
|
|
64
|
+
readonly score?: number;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Cross-module events: event name to payload type. Apps extend it by declaration merging:
|
|
68
|
+
* `declare module '@mnmal-ai/surface-core' { interface TuiEvents { 'x/changed': { id: string } } }`.
|
|
69
|
+
*/
|
|
70
|
+
export interface TuiEvents {
|
|
71
|
+
}
|
|
72
|
+
/** What a module may say about a line it submits, beyond its text. */
|
|
73
|
+
export interface SubmitOptions {
|
|
74
|
+
/** What the transcript prints as the ask, when it is not the text sent. */
|
|
75
|
+
readonly shown?: string;
|
|
76
|
+
/** A part of the printed ask to set apart; the app's ask view decides how. */
|
|
77
|
+
readonly emphasis?: string;
|
|
78
|
+
/** Whatever the app's turn handler needs; the core never reads it. */
|
|
79
|
+
readonly context?: unknown;
|
|
80
|
+
}
|
|
81
|
+
/** A turn as its handler receives it. */
|
|
82
|
+
export interface TurnContext {
|
|
83
|
+
/** The shell's id for this turn: unique for the session, the same from send to land. */
|
|
84
|
+
readonly id: number;
|
|
85
|
+
/** What the transcript prints as the ask: the text, unless the submitter said otherwise. */
|
|
86
|
+
readonly shown: string;
|
|
87
|
+
readonly emphasis?: string;
|
|
88
|
+
readonly context?: unknown;
|
|
89
|
+
}
|
|
90
|
+
export interface ModuleCtx<P> {
|
|
91
|
+
readonly theme: Theme;
|
|
92
|
+
/** Aborted when the app exits. */
|
|
93
|
+
readonly signal: AbortSignal;
|
|
94
|
+
/** Opens one of this module's panels, replacing whatever is open. With `ifNoneOpen`, only when no
|
|
95
|
+
* panel is open: one a module opens on its own, never over one the operator has open. */
|
|
96
|
+
open<K extends keyof P & string>(panel: K, state: P[K], opts?: {
|
|
97
|
+
readonly ifNoneOpen?: boolean;
|
|
98
|
+
}): void;
|
|
99
|
+
update<K extends keyof P & string>(panel: K, fn: (state: P[K]) => P[K]): void;
|
|
100
|
+
close(): void;
|
|
101
|
+
print(text: string, tone?: Tone): void;
|
|
102
|
+
/**
|
|
103
|
+
* A line the far side started — a greeting, an offer: an answer entry marked
|
|
104
|
+
* `unprompted` and stamped `at`, drawn by its reply's renderer. It answers no question and
|
|
105
|
+
* takes no mark.
|
|
106
|
+
*/
|
|
107
|
+
say(reply: Reply): void;
|
|
108
|
+
/**
|
|
109
|
+
* The conversation so far, read-only: committed entries, the turns in flight in send
|
|
110
|
+
* order, and the next mark. Current as of the last commit, not the last render, so a command
|
|
111
|
+
* that prints and then reads sees its own line. The transcript helpers apply to it:
|
|
112
|
+
* `answerEntry(ctx.transcript(), mark)`.
|
|
113
|
+
*/
|
|
114
|
+
transcript(): Transcript<Reply>;
|
|
115
|
+
/**
|
|
116
|
+
* A line sent as if typed, and routed as one: a /command runs, anything else is a turn. It stays
|
|
117
|
+
* out of the history, which holds only what the operator typed. `opts` reach the turn as its
|
|
118
|
+
* `TurnContext`.
|
|
119
|
+
*/
|
|
120
|
+
submit(text: string, opts?: SubmitOptions): void;
|
|
121
|
+
/** The panel budget now, as a panel's view is given it: for acts that page, and for commands
|
|
122
|
+
* that open a panel at a page boundary. */
|
|
123
|
+
size(): Size;
|
|
124
|
+
/** Replace the input line, cursor at its end ('' clears it): a rename's prefill. */
|
|
125
|
+
setDraft(text: string): void;
|
|
126
|
+
status(id: string, text: string | null, tone?: Tone): void;
|
|
127
|
+
toast(text: string, tone?: Tone): void;
|
|
128
|
+
emit<K extends keyof TuiEvents>(event: K, payload: TuiEvents[K]): void;
|
|
129
|
+
on<K extends keyof TuiEvents>(event: K, fn: (payload: TuiEvents[K]) => void): () => void;
|
|
130
|
+
}
|
|
131
|
+
export interface CommandSpec<P = unknown> {
|
|
132
|
+
readonly name: string;
|
|
133
|
+
readonly summary: string;
|
|
134
|
+
readonly args: readonly ArgSpec[];
|
|
135
|
+
/**
|
|
136
|
+
* Why the command cannot run now, or null when it can. Read each time the palette draws and
|
|
137
|
+
* when the command is typed: an unavailable command is left out of the palette, and typed in
|
|
138
|
+
* full it prints `/<name>: <reason>` instead of running. A thunk that throws, or returns an
|
|
139
|
+
* empty reason, counts as unavailable, with the reason `unavailable`.
|
|
140
|
+
*/
|
|
141
|
+
readonly unavailable?: () => string | null;
|
|
142
|
+
run(args: readonly string[], ctx: ModuleCtx<P>): void | Promise<void>;
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Letter, then Enter: a verdict that must not ride on a keystroke meant as text. On an
|
|
146
|
+
* empty draft the key is typed as usual and arms the act; Enter runs it only while the draft is
|
|
147
|
+
* still exactly that key, and any other edit disarms it.
|
|
148
|
+
*/
|
|
149
|
+
export interface ConfirmBinding {
|
|
150
|
+
/** One printable character. */
|
|
151
|
+
readonly key: string;
|
|
152
|
+
readonly act: string;
|
|
153
|
+
/** What Enter will do, for the view to say: 'approves this proposal'. */
|
|
154
|
+
readonly label: string;
|
|
155
|
+
}
|
|
156
|
+
/** The confirm binding Enter would run now, as a panel's view is told it. */
|
|
157
|
+
export interface Armed {
|
|
158
|
+
readonly key: string;
|
|
159
|
+
readonly label: string;
|
|
160
|
+
}
|
|
161
|
+
export interface PanelDef<S, P = unknown> {
|
|
162
|
+
readonly view: (props: {
|
|
163
|
+
readonly state: S;
|
|
164
|
+
readonly theme: Theme;
|
|
165
|
+
/** Present while a confirm key is armed on this panel. */
|
|
166
|
+
readonly armed?: Armed;
|
|
167
|
+
/** The room the panel has: the columns left beside the rail, and `AppOptions.panelRows`. */
|
|
168
|
+
readonly size: Size;
|
|
169
|
+
}) => ReactNode;
|
|
170
|
+
readonly keymap?: readonly {
|
|
171
|
+
readonly key: KeySpec;
|
|
172
|
+
readonly act: string;
|
|
173
|
+
}[];
|
|
174
|
+
/**
|
|
175
|
+
* Letter, then Enter (`ConfirmBinding`). A panel that declares any keeps the draft live under
|
|
176
|
+
* it: a key its keymap does not bind edits the line, and Enter runs the armed act or sends
|
|
177
|
+
* the line as typed. A panel without `confirm` takes every key, as before.
|
|
178
|
+
*/
|
|
179
|
+
readonly confirm?: readonly ConfirmBinding[];
|
|
180
|
+
/**
|
|
181
|
+
* The panel owns the input line. While it is focused, a submitted line that is not a
|
|
182
|
+
* `/command` (or every typed line, `/command` included, when `mask` is set) comes here, the
|
|
183
|
+
* empty line included, instead of going to the turn handlers. It is
|
|
184
|
+
* an entry in the panel, not a turn, so it stays out of the history. The draft stays live
|
|
185
|
+
* under the panel, as for `confirm`. Return the next state, or undefined to keep it.
|
|
186
|
+
*/
|
|
187
|
+
readonly submit?: (state: S, line: string, ctx: ModuleCtx<P>) => S | undefined;
|
|
188
|
+
/**
|
|
189
|
+
* Escape on a panel with `submit`: return a state to stay open with it (abandoning an edit in
|
|
190
|
+
* progress), or undefined to close as usual. A different panel opened here with `ctx.open`
|
|
191
|
+
* replaces this one rather than being closed with it. Only for a panel with `submit`.
|
|
192
|
+
*/
|
|
193
|
+
readonly escape?: (state: S, ctx: ModuleCtx<P>) => S | undefined;
|
|
194
|
+
/**
|
|
195
|
+
* The input line is a secret while this panel is focused, e.g. a passphrase. The draft draws
|
|
196
|
+
* as `•`, every typed line goes to `submit` (a `/command` too; a module's `ctx.submit` still
|
|
197
|
+
* routes as usual), and nothing typed reaches the history, the palette, the completers or the
|
|
198
|
+
* transcript. The draft is cleared when the panel gains or loses focus, however that happens.
|
|
199
|
+
* `submit` must never echo the line in a thrown error or a print: a throw's message is printed
|
|
200
|
+
* to the transcript. Only for a panel with `submit`, and refused with `confirm` or with a
|
|
201
|
+
* printable single-character key in `keymap`.
|
|
202
|
+
*/
|
|
203
|
+
readonly mask?: boolean;
|
|
204
|
+
/** act -> handler. Returning a state replaces the panel's state. */
|
|
205
|
+
readonly on?: Readonly<Record<string, (state: S, ctx: ModuleCtx<P>) => S | undefined>>;
|
|
206
|
+
}
|
|
207
|
+
export interface GlobalBinding<P = unknown> {
|
|
208
|
+
readonly key: KeySpec;
|
|
209
|
+
run(ctx: ModuleCtx<P>): void;
|
|
210
|
+
}
|
|
211
|
+
export interface Completer {
|
|
212
|
+
readonly id: string;
|
|
213
|
+
complete(draft: string, cursor: number): readonly Suggestion[] | Promise<readonly Suggestion[]>;
|
|
214
|
+
}
|
|
215
|
+
export interface TurnHandler<P = unknown> {
|
|
216
|
+
readonly id: string;
|
|
217
|
+
/** A priority if this handler wants the text, else false. */
|
|
218
|
+
claims(text: string): number | false;
|
|
219
|
+
answer(text: string, ctx: ModuleCtx<P>, signal: AbortSignal, turn: TurnContext): AsyncIterable<TurnUpdate>;
|
|
220
|
+
}
|
|
221
|
+
/** A reply's view. `size.columns` is the width it prints at; a final reply goes to `<Static>`,
|
|
222
|
+
* where height means nothing, so it gets no rows. */
|
|
223
|
+
export type Renderer = (props: {
|
|
224
|
+
readonly data: unknown;
|
|
225
|
+
readonly theme: Theme;
|
|
226
|
+
readonly size: {
|
|
227
|
+
readonly columns: number;
|
|
228
|
+
};
|
|
229
|
+
}) => ReactNode;
|
|
230
|
+
export interface RailItem {
|
|
231
|
+
readonly id: string;
|
|
232
|
+
readonly view: (props: {
|
|
233
|
+
readonly theme: Theme;
|
|
234
|
+
}) => ReactNode;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* A module's identity in the input band's presence row: its name, then a dim, truncating view.
|
|
238
|
+
* Only drawn when the app sets `band`; otherwise ignored. At most one module may declare it.
|
|
239
|
+
*/
|
|
240
|
+
export interface PresenceSpec {
|
|
241
|
+
/** Rendered by the core, in bold, after sanitising. */
|
|
242
|
+
readonly name: string;
|
|
243
|
+
/** Rendered inside a truncating `<Text>`: return inline text, never a Box. */
|
|
244
|
+
readonly view?: (props: {
|
|
245
|
+
readonly theme: Theme;
|
|
246
|
+
}) => ReactNode;
|
|
247
|
+
}
|
|
248
|
+
export interface ModuleSpec<P> {
|
|
249
|
+
readonly presence?: PresenceSpec;
|
|
250
|
+
readonly commands?: readonly CommandSpec<P>[];
|
|
251
|
+
readonly panels?: {
|
|
252
|
+
readonly [K in keyof P]: PanelDef<P[K], P>;
|
|
253
|
+
};
|
|
254
|
+
readonly keymap?: readonly GlobalBinding<P>[];
|
|
255
|
+
readonly completers?: readonly Completer[];
|
|
256
|
+
readonly turns?: readonly TurnHandler<P>[];
|
|
257
|
+
readonly renderers?: Readonly<Record<string, Renderer>>;
|
|
258
|
+
readonly rail?: readonly RailItem[];
|
|
259
|
+
readonly status?: readonly RailItem[];
|
|
260
|
+
init?(ctx: ModuleCtx<P>): undefined | (() => void);
|
|
261
|
+
}
|
|
262
|
+
export interface TuiModule<P = Record<string, never>> extends ModuleSpec<P> {
|
|
263
|
+
readonly id: string;
|
|
264
|
+
}
|
|
265
|
+
export declare function defineModule<P extends Record<string, unknown> = Record<string, never>>(id: string, spec: ModuleSpec<P>): TuiModule<P>;
|
|
266
|
+
//# sourceMappingURL=module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.d.ts","sourceRoot":"","sources":["../src/module.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,K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