@galaxy-stack/blackhole-cli 3.0.2 → 3.0.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.
Files changed (50) hide show
  1. package/README.md +96 -5
  2. package/dist/cli.js +24 -0
  3. package/dist/cli.js.map +1 -1
  4. package/dist/harness/command.d.ts +2 -0
  5. package/dist/harness/command.d.ts.map +1 -1
  6. package/dist/harness/command.js +11 -1
  7. package/dist/harness/command.js.map +1 -1
  8. package/dist/harness/ensure.d.ts +56 -0
  9. package/dist/harness/ensure.d.ts.map +1 -0
  10. package/dist/harness/ensure.js +100 -0
  11. package/dist/harness/ensure.js.map +1 -0
  12. package/dist/harness/install-command.d.ts +25 -0
  13. package/dist/harness/install-command.d.ts.map +1 -0
  14. package/dist/harness/install-command.js +224 -0
  15. package/dist/harness/install-command.js.map +1 -0
  16. package/dist/harness/install.d.ts +127 -0
  17. package/dist/harness/install.d.ts.map +1 -0
  18. package/dist/harness/install.js +329 -0
  19. package/dist/harness/install.js.map +1 -0
  20. package/dist/harness/locate.d.ts +77 -3
  21. package/dist/harness/locate.d.ts.map +1 -1
  22. package/dist/harness/locate.js +151 -17
  23. package/dist/harness/locate.js.map +1 -1
  24. package/dist/harness/process.d.ts.map +1 -1
  25. package/dist/harness/process.js +2 -2
  26. package/dist/harness/process.js.map +1 -1
  27. package/dist/harness/zip.d.ts +58 -0
  28. package/dist/harness/zip.d.ts.map +1 -0
  29. package/dist/harness/zip.js +190 -0
  30. package/dist/harness/zip.js.map +1 -0
  31. package/dist/options.d.ts +1 -1
  32. package/dist/options.d.ts.map +1 -1
  33. package/dist/options.js +3 -0
  34. package/dist/options.js.map +1 -1
  35. package/dist/web/command.d.ts.map +1 -1
  36. package/dist/web/command.js +3 -2
  37. package/dist/web/command.js.map +1 -1
  38. package/dist/web/doctor.d.ts.map +1 -1
  39. package/dist/web/doctor.js +9 -7
  40. package/dist/web/doctor.js.map +1 -1
  41. package/dist/web/open-browser.d.ts.map +1 -1
  42. package/dist/web/open-browser.js +2 -1
  43. package/dist/web/open-browser.js.map +1 -1
  44. package/dist/web/web.d.ts +2 -0
  45. package/dist/web/web.d.ts.map +1 -1
  46. package/dist/web/web.js +18 -8
  47. package/dist/web/web.js.map +1 -1
  48. package/package.json +1 -1
  49. package/web/brand/lib/client.js +4 -4
  50. package/web/brand/lib/journey-run.js +13 -1
@@ -0,0 +1,224 @@
1
+ /**
2
+ * `blackhole harness` — install, inspect and remove the blackhole-tauri checkout that
3
+ * `blackhole chat` and `blackhole web` boot.
4
+ *
5
+ * The CLI ships without the harness, so a fresh global install has nothing to launch. This command
6
+ * is the missing half of that distribution: it fetches a launcher, says where it went, reports what
7
+ * the resolver would pick right now, and removes what it installed.
8
+ */
9
+ import { existsSync, rmSync, rmdirSync } from "node:fs";
10
+ import { basename, dirname, resolve, sep } from "node:path";
11
+ import { harnessMissingMessage, defaultHarnessParent, installRecordPaths, systemLocateEnvironment } from "./locate.js";
12
+ import { harnessStatusFacts, installHarness } from "./install.js";
13
+ import { askConfirm } from "./ensure.js";
14
+ /** The help `blackhole harness --help` prints. */
15
+ export const HARNESS_HELP = [
16
+ "blackhole harness — bản harness blackhole-tauri mà chat/web cần",
17
+ "",
18
+ "Usage:",
19
+ " blackhole harness install [--force] [--dir <thư mục>] [--from <url>] [--no-deps]",
20
+ " blackhole harness status [--json]",
21
+ " blackhole harness remove [--yes]",
22
+ "",
23
+ " install Tải harness về ~/.galaxy/harness/blackhole-tauri: git clone --depth 1 nếu có git,",
24
+ " không thì tải ZIP của GitHub (không cần git), rồi cài phụ thuộc — bun install",
25
+ " (gốc + apps/host), hoặc npm install --omit=dev trong apps/host khi không có bun.",
26
+ " --force Tải lại dù đã có.",
27
+ " --dir Đặt harness ở chỗ khác (mặc định ~/.galaxy/harness). Đường dẫn kết thúc bằng",
28
+ " blackhole-tauri thì dùng luôn làm gốc. Vị trí được ghi lại để chat/web tìm thấy.",
29
+ " --from Tải từ URL .zip hoặc repo git khác (mặc định " + "https://github.com/galaxy-blackhole/blackhole-tauri" + ").",
30
+ " --no-deps Bỏ bước cài phụ thuộc.",
31
+ "",
32
+ " status In harness đang dùng + nguồn (GBH_TAURI_ROOT / $GBH_HOME / ~/.galaxy / sibling /",
33
+ " dev), version, node, bun và tình trạng apps/host/node_modules.",
34
+ " remove Xoá ~/.galaxy/harness (hỏi xác nhận; --yes để bỏ qua).",
35
+ "",
36
+ "Biến môi trường: GBH_TAURI_ROOT (checkout có sẵn), GBH_HOME (home dữ liệu harness),",
37
+ " GBH_TAURI_REPO / GBH_TAURI_ARCHIVE / GBH_TAURI_BRANCH (nguồn tải).",
38
+ "",
39
+ ].join("\n");
40
+ /** `blackhole harness status` output, shared with the tests. */
41
+ export function harnessStatusReport(facts, environment = systemLocateEnvironment()) {
42
+ if (facts.location === undefined)
43
+ return ["harness: (chưa cài)", ...harnessMissingMessage(environment).split("\n")];
44
+ const lines = [
45
+ "harness: " + facts.location.root,
46
+ "nguồn: " + facts.location.label,
47
+ "version: " + (facts.version ?? "?"),
48
+ ];
49
+ if (facts.hostVersion !== undefined)
50
+ lines.push("host: " + facts.hostVersion + " (apps/host)");
51
+ lines.push("node: " + (facts.node === undefined
52
+ ? "KHÔNG có — " + (facts.nodeError ?? "không tìm thấy Node")
53
+ : facts.node.version + " (" + facts.node.bin + ", " + facts.node.source + ")"));
54
+ lines.push("bun: " + (facts.bun ?? "không có (không bắt buộc để chạy; cần cho bun install)"));
55
+ lines.push("apps/host/node_modules: " + (facts.hostModules.present
56
+ ? "đã cài (" + String(facts.hostModules.packages) + " mục)"
57
+ : 'chưa có — chạy "blackhole harness install"'));
58
+ lines.push("GBH_HOME: " + facts.home);
59
+ lines.push("mặc định: " + facts.defaultDir);
60
+ return lines;
61
+ }
62
+ /**
63
+ * What `harness remove` deletes: the default slot, plus any checkout the installer recorded
64
+ * elsewhere. Paths inside a directory already scheduled for removal are left to the recursive delete.
65
+ * @param environment - locate facts.
66
+ * @returns directories and files to delete, absolute.
67
+ */
68
+ export function planHarnessRemove(environment) {
69
+ const dirs = new Set();
70
+ const files = new Set();
71
+ const parent = defaultHarnessParent(environment);
72
+ if (existsSync(parent))
73
+ dirs.add(resolve(parent));
74
+ const inside = (target) => [...dirs].some(dir => target === dir || target.startsWith(dir + sep));
75
+ for (const record of installRecordPaths(environment)) {
76
+ if (inside(resolve(record)))
77
+ continue;
78
+ const parsed = environment.readRecord?.(record);
79
+ if (parsed !== undefined) {
80
+ const root = resolve(parsed.root);
81
+ if (!inside(root) && basename(root) === "blackhole-tauri" && environment.exists(root))
82
+ dirs.add(root);
83
+ }
84
+ if (existsSync(record))
85
+ files.add(resolve(record));
86
+ }
87
+ return { dirs: [...dirs], files: [...files] };
88
+ }
89
+ /** Parse the flags after `install`. */
90
+ function parseInstallArgs(args) {
91
+ let dir;
92
+ let from;
93
+ let force = false;
94
+ let noDeps = false;
95
+ for (let index = 0; index < args.length; index += 1) {
96
+ const arg = args[index];
97
+ if (arg === "--force") {
98
+ force = true;
99
+ continue;
100
+ }
101
+ if (arg === "--no-deps") {
102
+ noDeps = true;
103
+ continue;
104
+ }
105
+ if (arg === "--dir" || arg === "--from") {
106
+ const value = args[index + 1];
107
+ if (value === undefined || value.startsWith("--"))
108
+ throw new Error(arg + " cần một giá trị.");
109
+ if (arg === "--dir")
110
+ dir = value;
111
+ else
112
+ from = value;
113
+ index += 1;
114
+ continue;
115
+ }
116
+ throw new Error('install: không hiểu "' + String(arg) + '". Dùng --force, --dir <thư mục>, --from <url>, --no-deps.');
117
+ }
118
+ return { ...(dir === undefined ? {} : { dir }), ...(from === undefined ? {} : { from }), force, noDeps };
119
+ }
120
+ /** Print one install result and decide the exit code. */
121
+ function reportInstall(result, write, noDeps) {
122
+ write("xong: " + result.root + " · nguồn " + result.via + " · phụ thuộc " + result.deps);
123
+ if (result.ready) {
124
+ if (result.note !== undefined)
125
+ write("lưu ý: " + result.note);
126
+ write("tiếp: blackhole chat (hoặc blackhole web)");
127
+ return 0;
128
+ }
129
+ if (noDeps) {
130
+ write('phụ thuộc: chưa cài (--no-deps) — chạy lại "blackhole harness install" khi cần');
131
+ return 0;
132
+ }
133
+ write("lỗi: harness đã tải nhưng chưa sẵn sàng — " + (result.note ?? "thiếu apps/host/node_modules"));
134
+ return 1;
135
+ }
136
+ /**
137
+ * Run `blackhole harness <action>`.
138
+ * @param argv - arguments after `harness`.
139
+ * @returns 0 ok, 1 the harness is missing or incomplete, 2 usage error.
140
+ */
141
+ export async function runHarnessCommand(argv) {
142
+ const [action = "status", ...rest] = argv;
143
+ const write = line => { process.stdout.write(line + "\n"); };
144
+ if (action === "help" || action === "--help" || action === "-h") {
145
+ process.stdout.write(HARNESS_HELP);
146
+ return 0;
147
+ }
148
+ try {
149
+ if (action === "install") {
150
+ const parsed = parseInstallArgs(rest);
151
+ if (parsed.dir !== undefined && resolve(parsed.dir) === resolve(parsed.dir, ".."))
152
+ throw new Error("--dir không hợp lệ: " + parsed.dir);
153
+ const result = await installHarness({
154
+ ...(parsed.dir === undefined ? {} : { dir: parsed.dir }),
155
+ ...(parsed.from === undefined ? {} : { from: parsed.from }),
156
+ force: parsed.force,
157
+ noDeps: parsed.noDeps,
158
+ write,
159
+ });
160
+ return reportInstall(result, write, parsed.noDeps);
161
+ }
162
+ if (action === "status") {
163
+ const environment = systemLocateEnvironment();
164
+ const facts = harnessStatusFacts(environment);
165
+ if (rest.includes("--json")) {
166
+ process.stdout.write(JSON.stringify(facts, null, 2) + "\n");
167
+ }
168
+ else {
169
+ for (const line of harnessStatusReport(facts, environment))
170
+ write(line);
171
+ }
172
+ if (facts.location === undefined)
173
+ return 1;
174
+ return facts.hostModules.present ? 0 : 1;
175
+ }
176
+ if (action === "remove") {
177
+ const environment = systemLocateEnvironment();
178
+ const plan = planHarnessRemove(environment);
179
+ if (plan.dirs.length === 0 && plan.files.length === 0) {
180
+ write("không có harness nào để xoá");
181
+ return 0;
182
+ }
183
+ write("blackhole harness remove sẽ xoá:");
184
+ for (const dir of plan.dirs)
185
+ write(" - " + dir);
186
+ for (const file of plan.files)
187
+ write(" - " + file);
188
+ if (!rest.includes("--yes")) {
189
+ const interactive = process.stdin.isTTY === true && process.stdout.isTTY === true;
190
+ if (!interactive) {
191
+ process.stderr.write("không phải terminal: thêm --yes để xoá thật.\n");
192
+ return 2;
193
+ }
194
+ const confirmed = await askConfirm("Xoá? [y/N] ", false);
195
+ if (!confirmed) {
196
+ write("đã huỷ — không xoá gì.");
197
+ return 0;
198
+ }
199
+ }
200
+ for (const dir of plan.dirs) {
201
+ if (basename(dir) === "blackhole-tauri" && !existsSync(dir))
202
+ continue;
203
+ rmSync(dir, { recursive: true, force: true });
204
+ write("đã xoá: " + dir);
205
+ }
206
+ for (const file of plan.files) {
207
+ rmSync(file, { force: true });
208
+ try {
209
+ rmdirSync(dirname(file));
210
+ }
211
+ catch { /* còn tệp khác trong thư mục: giữ lại */ }
212
+ write("đã xoá: " + file);
213
+ }
214
+ return 0;
215
+ }
216
+ }
217
+ catch (error) {
218
+ process.stderr.write("blackhole harness " + action + ": " + (error instanceof Error ? error.message : String(error)) + "\n");
219
+ return action === "install" ? 1 : 2;
220
+ }
221
+ process.stderr.write("blackhole harness: lệnh \"" + action + "\" không tồn tại. Dùng: install, status, remove.\n");
222
+ return 2;
223
+ }
224
+ //# sourceMappingURL=install-command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-command.js","sourceRoot":"","sources":["../../src/harness/install-command.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,uBAAuB,EAA0B,MAAM,aAAa,CAAC;AAC/I,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAsE,MAA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E,CAAC,CAAC;gBAC9B,IAAI,CAAC;oBAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;gBAAC,CAAC;gBAAC,MAAM,CAAC,CAAC,yCAAyC,CAAC,CAAC;gBACrF,KAAK,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC;YAC9B,CAAC;YACD,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,oBAAoB,GAAG,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;QAC7H,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,GAAG,MAAM,GAAG,oDAAoD,CAAC,CAAC;IACnH,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { type HarnessLocation, type LocateEnvironment } from "./locate.js";
2
+ import { type NodeRuntime } from "./node-runtime.js";
3
+ /** The repository the harness is published from. */
4
+ export declare const HARNESS_REPO = "https://github.com/galaxy-blackhole/blackhole-harness";
5
+ /** The branch a shallow clone and the archive URL both read. */
6
+ export declare const HARNESS_BRANCH = "main";
7
+ /** The checkout directory name every install ends with. */
8
+ export declare const HARNESS_DIR_NAME = "blackhole-harness";
9
+ /** One line of user-visible progress. */
10
+ export type WriteLine = (line: string) => void;
11
+ /**
12
+ * The archive URL for a repository: GitHub serves the branch head as a zip, which needs no git.
13
+ * @param repo - repository URL (an `.git` suffix is dropped).
14
+ * @param branch - branch to download.
15
+ * @returns the `archive/refs/heads/<branch>.zip` URL.
16
+ */
17
+ export declare function archiveUrl(repo?: string, branch?: string): string;
18
+ /** How one install was asked for. */
19
+ export interface HarnessInstallOptions {
20
+ /** Directory that holds the checkout (or the checkout itself when it ends with blackhole-tauri). */
21
+ readonly dir?: string;
22
+ /** Download again even when a checkout is already there. */
23
+ readonly force?: boolean;
24
+ /** `--from <url>`: a `.zip` URL or a git URL, instead of the default repository. */
25
+ readonly from?: string;
26
+ /** Skip the dependency step (`--no-deps`). */
27
+ readonly noDeps?: boolean;
28
+ /** Progress sink; stdout in production. */
29
+ readonly write?: WriteLine;
30
+ /** Locate facts (env, filesystem, PATH); this machine by default. */
31
+ readonly environment?: LocateEnvironment;
32
+ /** Runs one child to completion; inherits stdio in production. */
33
+ readonly run?: (command: string, args: readonly string[], cwd: string) => Promise<number>;
34
+ /** Downloads one URL into a file; injected by tests. */
35
+ readonly download?: (url: string, dest: string) => Promise<void>;
36
+ /** Node binary used to run npm's JS entry on Windows; this process by default. */
37
+ readonly node?: string;
38
+ }
39
+ /** What one install produced. */
40
+ export interface HarnessInstallResult {
41
+ /** Absolute checkout root. */
42
+ readonly root: string;
43
+ /** How the tree arrived; `existing` when nothing was downloaded. */
44
+ readonly via: "git" | "zip" | "existing";
45
+ /** Whether a download happened in this run. */
46
+ readonly downloaded: boolean;
47
+ /** Which package manager ran, or why none did. */
48
+ readonly deps: "bun" | "npm" | "skipped" | "failed";
49
+ /** Whether `apps/host/node_modules` exists afterwards — the launcher cannot boot without it. */
50
+ readonly ready: boolean;
51
+ /** What to do next, when the result is not ready. */
52
+ readonly note?: string;
53
+ }
54
+ /** The packages under `apps/host/node_modules`, when they are installed. */
55
+ export interface HostModulesState {
56
+ readonly present: boolean;
57
+ readonly packages: number;
58
+ }
59
+ /** Everything `harness status` reports. */
60
+ export interface HarnessStatusFacts {
61
+ readonly location?: HarnessLocation;
62
+ readonly version?: string;
63
+ readonly hostVersion?: string;
64
+ readonly node?: NodeRuntime;
65
+ readonly nodeError?: string;
66
+ readonly bun?: string;
67
+ readonly hostModules: HostModulesState;
68
+ readonly home: string;
69
+ readonly defaultDir: string;
70
+ }
71
+ /**
72
+ * Where a `--dir` install lands: the directory holding the checkout, or the checkout itself when
73
+ * the path already ends with `blackhole-tauri`.
74
+ * @param options - the parsed `--dir`, when one was given.
75
+ * @param environment - environment and home facts.
76
+ * @returns the absolute checkout root.
77
+ */
78
+ export declare function resolveInstallRoot(options: {
79
+ readonly dir?: string;
80
+ }, environment: LocateEnvironment): string;
81
+ /**
82
+ * Refuse to delete anything that is not a harness checkout directory.
83
+ * @param target - the directory an install would replace.
84
+ * @throws when the path is a filesystem root, a home directory, or not named blackhole-tauri.
85
+ */
86
+ export declare function assertReplaceable(target: string): void;
87
+ /** The `version` a checkout's package.json declares, when it has one. */
88
+ export declare function readHarnessVersion(root: string): string | undefined;
89
+ /**
90
+ * Whether `apps/host/node_modules` is populated.
91
+ * @param root - checkout root.
92
+ * @returns presence and the number of top-level entries.
93
+ */
94
+ export declare function hostModulesState(root: string): HostModulesState;
95
+ /** One package-manager invocation. */
96
+ export interface DependencyStep {
97
+ readonly command: string;
98
+ readonly args: readonly string[];
99
+ readonly cwd: string;
100
+ readonly label: string;
101
+ }
102
+ /**
103
+ * The dependency steps a checkout needs, in order.
104
+ *
105
+ * Bun is the repository's own tool (`bun install`, then `bun install` in `apps/host`, which is not
106
+ * a workspace member). Without Bun the host's pinned `@deepseek-ai/*` runtime is installed with
107
+ * npm instead, which is enough for the host process but not for the CLI's own tooling.
108
+ * @param root - checkout root.
109
+ * @param environment - PATH and filesystem facts.
110
+ * @param node - node binary for npm's JS entry.
111
+ * @returns the steps to run; empty when no package manager is installed.
112
+ */
113
+ export declare function planDependencies(root: string, environment: LocateEnvironment, node?: string): DependencyStep[];
114
+ /**
115
+ * Download (or reuse) the harness checkout and install its dependencies.
116
+ * @param options - destination, force, source override, progress sink and injected process facts.
117
+ * @returns the checkout root, how it arrived and whether it is ready to boot.
118
+ * @throws when the download fails, the archive has no launcher, or the destination is unsafe.
119
+ */
120
+ export declare function installHarness(options?: HarnessInstallOptions): Promise<HarnessInstallResult>;
121
+ /**
122
+ * Everything `harness status` prints, gathered without side effects.
123
+ * @param environment - locate facts; this machine by default.
124
+ * @returns the checkout (when found), its versions, the runtimes and the host dependency state.
125
+ */
126
+ export declare function harnessStatusFacts(environment?: LocateEnvironment): HarnessStatusFacts;
127
+ //# sourceMappingURL=install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../src/harness/install.ts"],"names":[],"mappings":"AAiBA,OAAO,EASL,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAwC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAE3F,oDAAoD;AACpD,eAAO,MAAM,YAAY,0DAA0D,CAAC;AAEpF,gEAAgE;AAChE,eAAO,MAAM,cAAc,SAAS,CAAC;AAErC,2DAA2D;AAC3D,eAAO,MAAM,gBAAgB,sBAAsB,CAAC;AAEpD,yCAAyC;AACzC,MAAM,MAAM,SAAS,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAE/C;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,GAAE,MAAqB,EAAE,MAAM,GAAE,MAAuB,GAAG,MAAM,CAE/F;AAED,qCAAqC;AACrC,MAAM,WAAW,qBAAqB;IACpC,oGAAoG;IACpG,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,oFAAoF;IACpF,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAC1B,2CAA2C;IAC3C,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,qEAAqE;IACrE,QAAQ,CAAC,WAAW,CAAC,EAAE,iBAAiB,CAAC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