doc-detective 4.6.1 → 4.7.0-runtime-dependency-detection.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/dist/cli.js +57 -6
- package/dist/cli.js.map +1 -1
- package/dist/common/src/schemas/schemas.json +6 -18
- package/dist/common/src/types/generated/config_v3.d.ts +2 -1
- package/dist/common/src/types/generated/config_v3.d.ts.map +1 -1
- package/dist/common/src/types/generated/resolvedTests_v3.d.ts +2 -1
- package/dist/common/src/types/generated/resolvedTests_v3.d.ts.map +1 -1
- package/dist/core/config.d.ts +17 -1
- package/dist/core/config.d.ts.map +1 -1
- package/dist/core/config.js +218 -63
- package/dist/core/config.js.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +7 -10
- package/dist/core/index.js.map +1 -1
- package/dist/core/tests.d.ts +41 -1
- package/dist/core/tests.d.ts.map +1 -1
- package/dist/core/tests.js +166 -7
- package/dist/core/tests.js.map +1 -1
- package/dist/debug/command.d.ts +10 -0
- package/dist/debug/command.d.ts.map +1 -0
- package/dist/debug/command.js +72 -0
- package/dist/debug/command.js.map +1 -0
- package/dist/debug/envvars.d.ts +9 -0
- package/dist/debug/envvars.d.ts.map +1 -0
- package/dist/debug/envvars.js +231 -0
- package/dist/debug/envvars.js.map +1 -0
- package/dist/debug/index.d.ts +85 -0
- package/dist/debug/index.d.ts.map +1 -0
- package/dist/debug/index.js +465 -0
- package/dist/debug/index.js.map +1 -0
- package/dist/debug/redact.d.ts +7 -0
- package/dist/debug/redact.d.ts.map +1 -0
- package/dist/debug/redact.js +190 -0
- package/dist/debug/redact.js.map +1 -0
- package/dist/debug/render.d.ts +8 -0
- package/dist/debug/render.d.ts.map +1 -0
- package/dist/debug/render.js +42 -0
- package/dist/debug/render.js.map +1 -0
- package/dist/debug/system.d.ts +24 -0
- package/dist/debug/system.d.ts.map +1 -0
- package/dist/debug/system.js +59 -0
- package/dist/debug/system.js.map +1 -0
- package/dist/debug/tools.d.ts +11 -0
- package/dist/debug/tools.d.ts.map +1 -0
- package/dist/debug/tools.js +170 -0
- package/dist/debug/tools.js.map +1 -0
- package/dist/hints/hints.d.ts.map +1 -1
- package/dist/hints/hints.js +17 -0
- package/dist/hints/hints.js.map +1 -1
- package/dist/index.cjs +374 -147
- package/dist/runtime/browsers.d.ts +14 -0
- package/dist/runtime/browsers.d.ts.map +1 -1
- package/dist/runtime/browsers.js +23 -0
- package/dist/runtime/browsers.js.map +1 -1
- package/dist/runtime/installer.d.ts.map +1 -1
- package/dist/runtime/installer.js +44 -9
- package/dist/runtime/installer.js.map +1 -1
- package/dist/runtime/loader.d.ts +20 -0
- package/dist/runtime/loader.d.ts.map +1 -1
- package/dist/runtime/loader.js +50 -0
- package/dist/runtime/loader.js.map +1 -1
- package/dist/utils.d.ts +2 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -11
- package/dist/utils.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
// Env-var enumeration for the debug dump.
|
|
2
|
+
//
|
|
3
|
+
// Two collection paths:
|
|
4
|
+
// 1. `findReferencedEnvVars` walks raw text (config file source,
|
|
5
|
+
// DOC_DETECTIVE_CONFIG env value, input file contents) for
|
|
6
|
+
// `$VAR` style references — the same shape `replaceEnvs` in
|
|
7
|
+
// `src/core/utils.ts` substitutes at runtime.
|
|
8
|
+
// 2. `detectContainer` returns a small struct describing whether
|
|
9
|
+
// Doc Detective is running inside a container (IN_CONTAINER
|
|
10
|
+
// canary, /.dockerenv probe, or /proc/1/cgroup substring).
|
|
11
|
+
//
|
|
12
|
+
// Both helpers are pure / cheap and safe to call in any order. File
|
|
13
|
+
// I/O lives in the orchestrator, not here.
|
|
14
|
+
import fs from "node:fs";
|
|
15
|
+
import path from "node:path";
|
|
16
|
+
// Env-var references, scoped to POSIX-valid variable names: a leading
|
|
17
|
+
// letter or underscore followed by letters / digits / underscores.
|
|
18
|
+
//
|
|
19
|
+
// `replaceEnvs` (in src/core/utils.ts) uses the looser `\$[a-zA-Z0-9_]+`
|
|
20
|
+
// shape, but that's harmless there — it only ever resolves names that
|
|
21
|
+
// actually exist in `process.env`, and env var names can't start with a
|
|
22
|
+
// digit. The debug dump GREPS raw source, so the loose shape matched
|
|
23
|
+
// shell positionals (`$0`, `$1`), regex backreferences (`$2`), and
|
|
24
|
+
// numeric tokens (`$86`) that can never be env vars — pure noise in a
|
|
25
|
+
// pasted report. Anchoring on a non-digit first char drops all of it
|
|
26
|
+
// without hiding anything `replaceEnvs` would ever substitute.
|
|
27
|
+
const ENV_REF_REGEX = /\$[a-zA-Z_][a-zA-Z0-9_]*/g;
|
|
28
|
+
export function findReferencedEnvVars(value) {
|
|
29
|
+
const found = new Set();
|
|
30
|
+
collect(value, found, new WeakSet());
|
|
31
|
+
return found;
|
|
32
|
+
}
|
|
33
|
+
function collect(value, out, seen) {
|
|
34
|
+
if (value == null)
|
|
35
|
+
return;
|
|
36
|
+
if (typeof value === "string") {
|
|
37
|
+
const matches = value.match(ENV_REF_REGEX);
|
|
38
|
+
if (matches) {
|
|
39
|
+
for (const m of matches)
|
|
40
|
+
out.add(m.slice(1));
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (typeof value !== "object")
|
|
45
|
+
return;
|
|
46
|
+
if (seen.has(value))
|
|
47
|
+
return;
|
|
48
|
+
seen.add(value);
|
|
49
|
+
if (Array.isArray(value)) {
|
|
50
|
+
for (const item of value)
|
|
51
|
+
collect(item, out, seen);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
for (const k of Object.keys(value)) {
|
|
55
|
+
if (k === "__proto__" || k === "constructor" || k === "prototype")
|
|
56
|
+
continue;
|
|
57
|
+
collect(value[k], out, seen);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
export function detectContainer() {
|
|
61
|
+
const signals = [];
|
|
62
|
+
if (process.env.IN_CONTAINER === "true") {
|
|
63
|
+
signals.push("IN_CONTAINER=true");
|
|
64
|
+
}
|
|
65
|
+
// /.dockerenv exists in Docker containers on Linux. Safe to stat on
|
|
66
|
+
// Windows too — it just returns false.
|
|
67
|
+
try {
|
|
68
|
+
if (fs.existsSync("/.dockerenv"))
|
|
69
|
+
signals.push("/.dockerenv exists");
|
|
70
|
+
}
|
|
71
|
+
catch {
|
|
72
|
+
// Stat errors are non-fatal — diagnostics should never crash.
|
|
73
|
+
}
|
|
74
|
+
// /proc/1/cgroup substring check (Linux only). Skip on win32 / darwin
|
|
75
|
+
// where /proc doesn't exist.
|
|
76
|
+
if (process.platform === "linux") {
|
|
77
|
+
try {
|
|
78
|
+
const cgroup = fs.readFileSync("/proc/1/cgroup", "utf8");
|
|
79
|
+
if (/docker|containerd|kubepods/.test(cgroup)) {
|
|
80
|
+
signals.push("/proc/1/cgroup matches container runtime");
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Non-fatal — /proc/1/cgroup may not be readable.
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return { inContainer: signals.length > 0, signals };
|
|
88
|
+
}
|
|
89
|
+
// Default file-type → extension map, mirroring core's `defaultFileTypes`
|
|
90
|
+
// (src/core/config.ts). Used to scope the referenced-env-var scan to the
|
|
91
|
+
// files doc-detective actually parses, instead of every file in the tree
|
|
92
|
+
// (where the `$VAR` grep matched shell/code/CI syntax — see the dump's
|
|
93
|
+
// noise before this was added).
|
|
94
|
+
const DOC_EXTENSIONS_BY_TYPE = {
|
|
95
|
+
markdown: ["md", "markdown", "mdx"],
|
|
96
|
+
asciidoc: ["adoc", "asciidoc", "asc"],
|
|
97
|
+
html: ["html", "htm"],
|
|
98
|
+
dita: ["dita", "ditamap", "xml"],
|
|
99
|
+
};
|
|
100
|
+
// Resolve `config.fileTypes` into the set of lowercase extensions (no
|
|
101
|
+
// leading dot) that doc-detective would treat as input. Handles both the
|
|
102
|
+
// post-setConfig string-name form (`["markdown", "dita"]`) and richer
|
|
103
|
+
// object entries that carry their own `extensions` / `name` / `extends`.
|
|
104
|
+
// Falls back to the union of all known doc extensions when fileTypes is
|
|
105
|
+
// absent or yields nothing, so the scan still targets something sensible.
|
|
106
|
+
export function resolveDocExtensions(fileTypes) {
|
|
107
|
+
const exts = new Set();
|
|
108
|
+
const add = (e) => {
|
|
109
|
+
if (typeof e === "string" && e.length > 0) {
|
|
110
|
+
exts.add(e.replace(/^\./, "").toLowerCase());
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
if (Array.isArray(fileTypes)) {
|
|
114
|
+
for (const ft of fileTypes) {
|
|
115
|
+
if (typeof ft === "string") {
|
|
116
|
+
for (const e of DOC_EXTENSIONS_BY_TYPE[ft] || [])
|
|
117
|
+
add(e);
|
|
118
|
+
}
|
|
119
|
+
else if (ft && typeof ft === "object") {
|
|
120
|
+
const obj = ft;
|
|
121
|
+
// The schema allows `extensions` as a string OR an array.
|
|
122
|
+
if (typeof obj.extensions === "string") {
|
|
123
|
+
add(obj.extensions);
|
|
124
|
+
}
|
|
125
|
+
else if (Array.isArray(obj.extensions)) {
|
|
126
|
+
for (const e of obj.extensions)
|
|
127
|
+
add(e);
|
|
128
|
+
}
|
|
129
|
+
for (const key of ["name", "extends"]) {
|
|
130
|
+
const named = obj[key];
|
|
131
|
+
if (typeof named === "string") {
|
|
132
|
+
for (const e of DOC_EXTENSIONS_BY_TYPE[named] || [])
|
|
133
|
+
add(e);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (exts.size === 0) {
|
|
140
|
+
for (const list of Object.values(DOC_EXTENSIONS_BY_TYPE)) {
|
|
141
|
+
for (const e of list)
|
|
142
|
+
add(e);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return exts;
|
|
146
|
+
}
|
|
147
|
+
// Hard cap on how many filesystem entries the walk will examine, separate
|
|
148
|
+
// from the matched-file `cap`. Without it, an input pointed at `/` or a
|
|
149
|
+
// huge repo with no doc-extension matches would traverse the whole tree
|
|
150
|
+
// (the matched-file cap never trips), making `doc-detective debug` look
|
|
151
|
+
// hung. 50k entries is plenty for any real docs tree.
|
|
152
|
+
const MAX_ENTRIES_EXAMINED = 50_000;
|
|
153
|
+
// Walk a list of input paths (files or directories) and return a list of
|
|
154
|
+
// readable file paths up to `cap` entries. Bounded so the debug dump can
|
|
155
|
+
// never hang on a giant tree. Skips node_modules and .git.
|
|
156
|
+
//
|
|
157
|
+
// When `allowedExtensions` is provided and non-empty, only files whose
|
|
158
|
+
// extension is in the set are returned — directories are always traversed.
|
|
159
|
+
// An explicitly-passed input file is returned regardless of extension
|
|
160
|
+
// (the user pointed at it directly); the filter only prunes files
|
|
161
|
+
// discovered by walking a directory.
|
|
162
|
+
export function enumerateInputFiles(inputs, cap = 200, allowedExtensions) {
|
|
163
|
+
const filter = allowedExtensions && allowedExtensions.size > 0 ? allowedExtensions : null;
|
|
164
|
+
const matches = (p) => {
|
|
165
|
+
if (!filter)
|
|
166
|
+
return true;
|
|
167
|
+
const ext = path.extname(p).replace(/^\./, "").toLowerCase();
|
|
168
|
+
return filter.has(ext);
|
|
169
|
+
};
|
|
170
|
+
const out = [];
|
|
171
|
+
const stack = [];
|
|
172
|
+
const explicit = new Set();
|
|
173
|
+
// Canonical paths of directories already walked. Guards against cyclic
|
|
174
|
+
// symlinked directory graphs (e.g. `a/link -> ..`) that would otherwise
|
|
175
|
+
// keep the stack non-empty forever — a real hang risk, especially when
|
|
176
|
+
// the extension filter means no files ever pass to bound the walk.
|
|
177
|
+
const visitedDirs = new Set();
|
|
178
|
+
let examined = 0;
|
|
179
|
+
for (const i of inputs) {
|
|
180
|
+
if (typeof i === "string" && i.length > 0) {
|
|
181
|
+
stack.push(i);
|
|
182
|
+
explicit.add(i);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
while (stack.length > 0 && out.length < cap && examined < MAX_ENTRIES_EXAMINED) {
|
|
186
|
+
examined++;
|
|
187
|
+
// pop() (LIFO) keeps the walk O(n); shift() reindexes the array on every
|
|
188
|
+
// iteration, degrading a large tree to O(n²). Order doesn't matter here.
|
|
189
|
+
const p = stack.pop();
|
|
190
|
+
let stat;
|
|
191
|
+
try {
|
|
192
|
+
stat = fs.statSync(p);
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (stat.isFile()) {
|
|
198
|
+
// Honor an explicitly-passed file path even if its extension isn't
|
|
199
|
+
// a recognized doc type; only filter files found by walking dirs.
|
|
200
|
+
if (explicit.has(p) || matches(p))
|
|
201
|
+
out.push(p);
|
|
202
|
+
continue;
|
|
203
|
+
}
|
|
204
|
+
if (stat.isDirectory()) {
|
|
205
|
+
let realDir;
|
|
206
|
+
try {
|
|
207
|
+
realDir = fs.realpathSync(p);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
realDir = p;
|
|
211
|
+
}
|
|
212
|
+
if (visitedDirs.has(realDir))
|
|
213
|
+
continue;
|
|
214
|
+
visitedDirs.add(realDir);
|
|
215
|
+
let entries;
|
|
216
|
+
try {
|
|
217
|
+
entries = fs.readdirSync(p);
|
|
218
|
+
}
|
|
219
|
+
catch {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
for (const e of entries) {
|
|
223
|
+
if (e === "node_modules" || e === ".git")
|
|
224
|
+
continue;
|
|
225
|
+
stack.push(path.join(p, e));
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
return out;
|
|
230
|
+
}
|
|
231
|
+
//# sourceMappingURL=envvars.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envvars.js","sourceRoot":"","sources":["../../src/debug/envvars.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,EAAE;AACF,wBAAwB;AACxB,mEAAmE;AACnE,gEAAgE;AAChE,iEAAiE;AACjE,mDAAmD;AACnD,mEAAmE;AACnE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AAE,EAAE,CAAC;YAClB,mEAAmE;YACnE,kEAAkE;YAClE,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAC/C,SAAS;QACX,CAAC;QACD,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;YACvB,IAAI,OAAe,CAAC;YACpB,IAAI,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAC/B,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,GAAG,CAAC,CAAC;YACd,CAAC;YACD,IAAI,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,SAAS;YACvC,WAAW,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACzB,IAAI,OAAiB,CAAC;YACtB,IAAI,CAAC;gBACH,OAAO,GAAG,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;YACD,KAAK,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;gBACxB,IAAI,CAAC,KAAK,cAAc,IAAI,CAAC,KAAK,MAAM;oBAAE,SAAS;gBACnD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YAC9B,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type SystemInfo } from "./system.js";
|
|
2
|
+
import { type ToolResult } from "./tools.js";
|
|
3
|
+
import { type ContainerInfo } from "./envvars.js";
|
|
4
|
+
export interface PrintDebugOptions {
|
|
5
|
+
config: any;
|
|
6
|
+
configPath?: string | null;
|
|
7
|
+
configError?: Error | null;
|
|
8
|
+
/**
|
|
9
|
+
* When `true`, dump every `process.env` entry (redacted by name and
|
|
10
|
+
* by value-shape). When falsy (the default), only env vars actually
|
|
11
|
+
* referenced via `$VAR` in config / input files are listed.
|
|
12
|
+
*
|
|
13
|
+
* Wired from the `--include-env` flag on the `debug` subcommand.
|
|
14
|
+
* Intentionally separate from container detection so users in
|
|
15
|
+
* containers (the common case for env-leak risk) do NOT get an
|
|
16
|
+
* implicit full env dump unless they explicitly ask for it.
|
|
17
|
+
*/
|
|
18
|
+
includeEnv?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* When set, the dump is written into this directory as two timestamped
|
|
21
|
+
* files — `debug-<timestamp>.txt` and `debug-<timestamp>.json` — using
|
|
22
|
+
* the same timestamp printed at the top of the dump. Parent directories
|
|
23
|
+
* are created. Production callers pass `defaultDebugDir()`; unit tests
|
|
24
|
+
* omit it so calling `printDebug` never writes a file as a side effect.
|
|
25
|
+
*/
|
|
26
|
+
outDir?: string;
|
|
27
|
+
print?: (line: string) => void;
|
|
28
|
+
}
|
|
29
|
+
export declare function defaultDebugDir(): string;
|
|
30
|
+
interface BrowserComponent {
|
|
31
|
+
label: string;
|
|
32
|
+
installed: boolean;
|
|
33
|
+
detail?: string;
|
|
34
|
+
}
|
|
35
|
+
interface BrowserDiagnostic {
|
|
36
|
+
name: string;
|
|
37
|
+
supported: boolean;
|
|
38
|
+
available: boolean;
|
|
39
|
+
components: BrowserComponent[];
|
|
40
|
+
note?: string;
|
|
41
|
+
}
|
|
42
|
+
interface BrowsersData {
|
|
43
|
+
timedOut?: boolean;
|
|
44
|
+
error?: string;
|
|
45
|
+
detectionFailed?: boolean;
|
|
46
|
+
browsers?: BrowserDiagnostic[];
|
|
47
|
+
}
|
|
48
|
+
interface DocDetectiveData {
|
|
49
|
+
version: string;
|
|
50
|
+
executionMethod?: string;
|
|
51
|
+
loadedFrom: string;
|
|
52
|
+
entryPoint: string;
|
|
53
|
+
nodeVersion?: string;
|
|
54
|
+
platform?: string;
|
|
55
|
+
timestamp?: string;
|
|
56
|
+
dependencies: Record<string, string>;
|
|
57
|
+
lockstepWarning?: string;
|
|
58
|
+
error?: string;
|
|
59
|
+
}
|
|
60
|
+
interface EnvData {
|
|
61
|
+
mode: "referenced" | "full";
|
|
62
|
+
scannedFileCount?: number;
|
|
63
|
+
variables: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
value: string;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
interface ConfigData {
|
|
69
|
+
configPath: string | null;
|
|
70
|
+
configError?: string;
|
|
71
|
+
redacted: unknown;
|
|
72
|
+
}
|
|
73
|
+
export interface DebugData {
|
|
74
|
+
generatedAt: string;
|
|
75
|
+
system: SystemInfo;
|
|
76
|
+
docDetective: DocDetectiveData;
|
|
77
|
+
tools: ToolResult[];
|
|
78
|
+
browsers: BrowsersData;
|
|
79
|
+
container: ContainerInfo;
|
|
80
|
+
environment: EnvData;
|
|
81
|
+
config: ConfigData;
|
|
82
|
+
}
|
|
83
|
+
export declare function printDebug(opts: PrintDebugOptions): Promise<void>;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/debug/index.ts"],"names":[],"mappings":"AAsBA,OAAO,EAAqB,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,cAAc,CAAC;AAStB,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,GAAG,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IAC3B;;;;;;;;;OASG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EA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