@prosopo/datasets-fs 2.1.8 → 2.1.9
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/cli.d.ts +9 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +58 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/cliCommand.d.ts +17 -0
- package/dist/cli/cliCommand.d.ts.map +1 -0
- package/dist/cli/cliCommand.js +28 -0
- package/dist/cli/cliCommand.js.map +1 -0
- package/dist/cli/cliCommandComposite.d.ts +14 -0
- package/dist/cli/cliCommandComposite.d.ts.map +1 -0
- package/dist/cli/cliCommandComposite.js +32 -0
- package/dist/cli/cliCommandComposite.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +34 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/flatten.d.ts +59 -0
- package/dist/commands/flatten.d.ts.map +1 -0
- package/dist/commands/flatten.js +96 -0
- package/dist/commands/flatten.js.map +1 -0
- package/dist/commands/generate.d.ts +115 -0
- package/dist/commands/generate.d.ts.map +1 -0
- package/dist/commands/generate.js +150 -0
- package/dist/commands/generate.js.map +1 -0
- package/dist/commands/generateV1.d.ts +179 -0
- package/dist/commands/generateV1.d.ts.map +1 -0
- package/dist/commands/generateV1.js +169 -0
- package/dist/commands/generateV1.js.map +1 -0
- package/dist/commands/generateV2.d.ts +189 -0
- package/dist/commands/generateV2.d.ts.map +1 -0
- package/dist/commands/generateV2.js +200 -0
- package/dist/commands/generateV2.js.map +1 -0
- package/dist/commands/get.d.ts +35 -0
- package/dist/commands/get.d.ts.map +1 -0
- package/dist/commands/get.js +79 -0
- package/dist/commands/get.js.map +1 -0
- package/dist/commands/labels.d.ts +47 -0
- package/dist/commands/labels.d.ts.map +1 -0
- package/dist/commands/labels.js +48 -0
- package/dist/commands/labels.js.map +1 -0
- package/dist/commands/relocate.d.ts +71 -0
- package/dist/commands/relocate.d.ts.map +1 -0
- package/dist/commands/relocate.js +75 -0
- package/dist/commands/relocate.js.map +1 -0
- package/dist/commands/resize.d.ts +69 -0
- package/dist/commands/resize.d.ts.map +1 -0
- package/dist/commands/resize.js +112 -0
- package/dist/commands/resize.js.map +1 -0
- package/dist/dummy.d.ts +2 -0
- package/dist/dummy.d.ts.map +1 -0
- package/dist/dummy.js +28 -0
- package/dist/dummy.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/tests/data/flat_resized/labels.json +13 -0
- package/dist/tests/data/flat_resized/relocated_data.json +364 -0
- package/dist/tests/lodash.unit.test.d.ts +2 -0
- package/dist/tests/lodash.unit.test.d.ts.map +1 -0
- package/dist/tests/lodash.unit.test.js +29 -0
- package/dist/tests/lodash.unit.test.js.map +1 -0
- package/dist/tests/mocked.unit.test.d.ts +2 -0
- package/dist/tests/mocked.unit.test.d.ts.map +1 -0
- package/dist/tests/mocked.unit.test.js +253 -0
- package/dist/tests/mocked.unit.test.js.map +1 -0
- package/dist/tests/utils.d.ts +35 -0
- package/dist/tests/utils.d.ts.map +1 -0
- package/dist/tests/utils.js +101 -0
- package/dist/tests/utils.js.map +1 -0
- package/dist/utils/input.d.ts +24 -0
- package/dist/utils/input.d.ts.map +1 -0
- package/dist/utils/input.js +35 -0
- package/dist/utils/input.js.map +1 -0
- package/dist/utils/inputOutput.d.ts +21 -0
- package/dist/utils/inputOutput.d.ts.map +1 -0
- package/dist/utils/inputOutput.js +10 -0
- package/dist/utils/inputOutput.js.map +1 -0
- package/dist/utils/output.d.ts +36 -0
- package/dist/utils/output.d.ts.map +1 -0
- package/dist/utils/output.js +62 -0
- package/dist/utils/output.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Loggable } from "@prosopo/common";
|
|
2
|
+
import type { CliCommandAny } from "./cliCommand.js";
|
|
3
|
+
export declare class Cli extends Loggable {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(commands: CliCommandAny[]);
|
|
6
|
+
private config;
|
|
7
|
+
exec(args?: string[]): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAEN,QAAQ,EAGR,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAKrD,qBAAa,GAAI,SAAQ,QAAQ;;gBAGpB,QAAQ,EAAE,aAAa,EAAE;IAMrC,OAAO,CAAC,MAAM;IA+CD,IAAI,CAAC,IAAI,GAAE,MAAM,EAA0B;CAKxD"}
|
package/dist/cli/cli.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var _Cli_commands;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import { LogLevel, Loggable, ProsopoCliError, getLogger, } from "@prosopo/common";
|
|
4
|
+
import yargs from "yargs";
|
|
5
|
+
import { hideBin } from "yargs/helpers";
|
|
6
|
+
const dirname = process.cwd();
|
|
7
|
+
const logger = getLogger(LogLevel.enum.info, `${dirname}`);
|
|
8
|
+
export class Cli extends Loggable {
|
|
9
|
+
constructor(commands) {
|
|
10
|
+
super();
|
|
11
|
+
_Cli_commands.set(this, void 0);
|
|
12
|
+
__classPrivateFieldSet(this, _Cli_commands, commands, "f");
|
|
13
|
+
this.logger = logger;
|
|
14
|
+
}
|
|
15
|
+
config() {
|
|
16
|
+
let y = yargs(hideBin(process.argv))
|
|
17
|
+
.option("log-level", {
|
|
18
|
+
type: "string",
|
|
19
|
+
choices: Object.values(LogLevel.options),
|
|
20
|
+
default: LogLevel.enum.info,
|
|
21
|
+
description: "The log level",
|
|
22
|
+
})
|
|
23
|
+
.middleware((argv) => {
|
|
24
|
+
this.logger.setLogLevel(argv.logLevel);
|
|
25
|
+
}, true);
|
|
26
|
+
for (const command of __classPrivateFieldGet(this, _Cli_commands, "f")) {
|
|
27
|
+
y = y.command({
|
|
28
|
+
command: command.getCommandName(),
|
|
29
|
+
describe: command.getDescription(),
|
|
30
|
+
builder: command.getOptions(),
|
|
31
|
+
handler: async (argv) => {
|
|
32
|
+
this.logger.debug(`running ${command.getCommandName()}}`);
|
|
33
|
+
const args = await command.parse(argv);
|
|
34
|
+
await command.exec(args);
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (!__classPrivateFieldGet(this, _Cli_commands, "f").find((c) => c.getCommandName() === "$0")) {
|
|
39
|
+
y = y.command("$0", "default command", (y) => y, () => {
|
|
40
|
+
throw new ProsopoCliError("CLI.PARAMETER_ERROR", {
|
|
41
|
+
context: { error: "no command specified" },
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
y = y
|
|
46
|
+
.demandCommand()
|
|
47
|
+
.strict()
|
|
48
|
+
.showHelpOnFail(false, "Specify --help for available options");
|
|
49
|
+
return y;
|
|
50
|
+
}
|
|
51
|
+
async exec(args = process.argv.slice(2)) {
|
|
52
|
+
const config = this.config();
|
|
53
|
+
this.logger.debug("parsing", args);
|
|
54
|
+
await config.parse(args);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
_Cli_commands = new WeakMap();
|
|
58
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli/cli.ts"],"names":[],"mappings":";;AAAA,OAAO,EACN,QAAQ,EACR,QAAQ,EACR,eAAe,EACf,SAAS,GACT,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAoB,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAgBxC,MAAM,OAA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,CAAC,CAAC;oBACvC,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC1B,CAAC;aACD,CAAC,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,uBAAA,IAAI,qBAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC,EAAE,CAAC;YAE9D,CAAC,GAAG,CAAC,CAAC,OAAO,CACZ,IAAI,EACJ,iBAAiB,EACjB,CAAC,CAAO,EAAE,EAAE,CAAC,CAAC,EACd,GAAG,EAAE;gBACJ,MAAM,IAAI,eAAe,CAAC,qBAAqB,EAAE;oBAChD,OAAO,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE;iBAC1C,CAAC,CAAC;YACJ,CAAC,CACD,CAAC;QACH,CAAC;QACD,CAAC,GAAG,CAAC;aACH,aAAa,EAAE;aACf,MAAM,EAAE;aACR,cAAc,CAAC,KAAK,EAAE,sCAAsC,CAAC,CAAC;QAChE,OAAO,CAAC,CAAC;IACV,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,OAAiB,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;QAC7B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;QACnC,MAAM,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CACD"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Loggable } from "@prosopo/common";
|
|
2
|
+
import type { Options } from "yargs";
|
|
3
|
+
import type * as z from "zod";
|
|
4
|
+
export declare abstract class CliCommand<T extends z.ZodTypeAny> extends Loggable {
|
|
5
|
+
getOptions(): {
|
|
6
|
+
[key: string]: Options;
|
|
7
|
+
};
|
|
8
|
+
abstract getArgSchema(): T;
|
|
9
|
+
parse(args: unknown): Promise<z.infer<T>>;
|
|
10
|
+
_check(args: z.infer<T>): Promise<void>;
|
|
11
|
+
_run(args: z.infer<T>): Promise<void>;
|
|
12
|
+
exec(args: z.infer<T>): Promise<void>;
|
|
13
|
+
getCommandName(): string;
|
|
14
|
+
abstract getDescription(): string;
|
|
15
|
+
}
|
|
16
|
+
export type CliCommandAny = CliCommand<z.ZodTypeAny>;
|
|
17
|
+
//# sourceMappingURL=cliCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliCommand.d.ts","sourceRoot":"","sources":["../../src/cli/cliCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAcrC,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAE9B,8BAAsB,UAAU,CAAC,CAAC,SAAS,CAAC,CAAC,UAAU,CAAE,SAAQ,QAAQ;IAEjE,UAAU,IAAI;QACpB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;KACvB;aAKe,YAAY,IAAI,CAAC;IAIpB,KAAK,CAAC,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAQzC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAKvB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAKrB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IAQ3B,cAAc;aAIL,cAAc,IAAI,MAAM;CACxC;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Loggable } from "@prosopo/common";
|
|
2
|
+
import { kebabCase } from "@prosopo/util";
|
|
3
|
+
export class CliCommand extends Loggable {
|
|
4
|
+
getOptions() {
|
|
5
|
+
return {};
|
|
6
|
+
}
|
|
7
|
+
async parse(args) {
|
|
8
|
+
const argsSchema = this.getArgSchema();
|
|
9
|
+
const parsed = await argsSchema.parse(args);
|
|
10
|
+
this.logger.debug("parsed args:", parsed);
|
|
11
|
+
return parsed;
|
|
12
|
+
}
|
|
13
|
+
async _check(args) {
|
|
14
|
+
this.logger.debug("runChecks");
|
|
15
|
+
}
|
|
16
|
+
async _run(args) {
|
|
17
|
+
this.logger.debug("run");
|
|
18
|
+
}
|
|
19
|
+
async exec(args) {
|
|
20
|
+
this.logger.debug("exec");
|
|
21
|
+
await this._check(args);
|
|
22
|
+
await this._run(args);
|
|
23
|
+
}
|
|
24
|
+
getCommandName() {
|
|
25
|
+
return kebabCase(this.constructor.name);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=cliCommand.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliCommand.js","sourceRoot":"","sources":["../../src/cli/cliCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAiB1C,MAAM,OAAgB,UAAmC,SAAQ,QAAQ;IAEjE,UAAU;QAGhB,OAAO,EAAE,CAAC;IACX,CAAC;IAOM,KAAK,CAAC,KAAK,CAAC,IAAa;QAC/B,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;QAC1C,OAAO,MAAM,CAAC;IACf,CAAC;IAGM,KAAK,CAAC,MAAM,CAAC,IAAgB;QACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAChC,CAAC;IAGM,KAAK,CAAC,IAAI,CAAC,IAAgB;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAGM,KAAK,CAAC,IAAI,CAAC,IAAgB;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE1B,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAExB,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC;IAEM,cAAc;QACpB,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;CAGD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Options } from "yargs";
|
|
2
|
+
import type * as z from "zod";
|
|
3
|
+
import { CliCommand, type CliCommandAny } from "./cliCommand.js";
|
|
4
|
+
export declare abstract class CliCommandComposite<T extends z.ZodTypeAny> extends CliCommand<T> {
|
|
5
|
+
#private;
|
|
6
|
+
getCommands(): CliCommandAny[];
|
|
7
|
+
constructor(commands: CliCommandAny[]);
|
|
8
|
+
getOptions(): {
|
|
9
|
+
[key: string]: Options;
|
|
10
|
+
};
|
|
11
|
+
_run(args: z.TypeOf<T>): Promise<void>;
|
|
12
|
+
_check(args: z.TypeOf<T>): Promise<void>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cliCommandComposite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliCommandComposite.d.ts","sourceRoot":"","sources":["../../src/cli/cliCommandComposite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAcrC,OAAO,KAAK,KAAK,CAAC,MAAM,KAAK,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEjE,8BAAsB,mBAAmB,CACxC,CAAC,SAAS,CAAC,CAAC,UAAU,CACrB,SAAQ,UAAU,CAAC,CAAC,CAAC;;IAGf,WAAW;gBAIN,QAAQ,EAAE,aAAa,EAAE;IAMrB,UAAU,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE;IAQxC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAOtC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAMxD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var _CliCommandComposite_commands;
|
|
2
|
+
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
+
import { CliCommand } from "./cliCommand.js";
|
|
4
|
+
export class CliCommandComposite extends CliCommand {
|
|
5
|
+
getCommands() {
|
|
6
|
+
return __classPrivateFieldGet(this, _CliCommandComposite_commands, "f");
|
|
7
|
+
}
|
|
8
|
+
constructor(commands) {
|
|
9
|
+
super();
|
|
10
|
+
_CliCommandComposite_commands.set(this, []);
|
|
11
|
+
__classPrivateFieldSet(this, _CliCommandComposite_commands, [...commands], "f");
|
|
12
|
+
}
|
|
13
|
+
getOptions() {
|
|
14
|
+
return __classPrivateFieldGet(this, _CliCommandComposite_commands, "f").reduce((prev, command) => {
|
|
15
|
+
return { ...prev, ...command.getOptions() };
|
|
16
|
+
}, {});
|
|
17
|
+
}
|
|
18
|
+
_run(args) {
|
|
19
|
+
return __classPrivateFieldGet(this, _CliCommandComposite_commands, "f").reduce(async (prev, command) => {
|
|
20
|
+
await prev;
|
|
21
|
+
await command._run(args);
|
|
22
|
+
}, Promise.resolve());
|
|
23
|
+
}
|
|
24
|
+
_check(args) {
|
|
25
|
+
return __classPrivateFieldGet(this, _CliCommandComposite_commands, "f").reduce(async (prev, command) => {
|
|
26
|
+
await prev;
|
|
27
|
+
await command._check(args);
|
|
28
|
+
}, Promise.resolve());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
_CliCommandComposite_commands = new WeakMap();
|
|
32
|
+
//# sourceMappingURL=cliCommandComposite.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cliCommandComposite.js","sourceRoot":"","sources":["../../src/cli/cliCommandComposite.ts"],"names":[],"mappings":";;AAeA,OAAO,EAAE,UAAU,EAAsB,MAAM,iBAAiB,CAAC;AAEjE,MAAM,OAAgB,mBAEpB,SAAQ,UAAa;IAGf,WAAW;QACjB,OAAO,uBAAA,IAAI,qCAAU,CAAC;IACvB,CAAC;IAED,YAAY,QAAyB;QACpC,KAAK,EAAE,CAAC;QAPT,wCAA6B,EAAE,EAAC;QAS/B,uBAAA,IAAI,iCAAa,CAAC,GAAG,QAAQ,CAAC,MAAA,CAAC;IAChC,CAAC;IAEe,UAAU;QAEzB,OAAO,uBAAA,IAAI,qCAAU,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YAE9C,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC;QAC7C,CAAC,EAAE,EAAE,CAAC,CAAC;IACR,CAAC;IAEe,IAAI,CAAC,IAAiB;QACrC,OAAO,uBAAA,IAAI,qCAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;YACpD,MAAM,IAAI,CAAC;YACX,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACvB,CAAC;IAEe,MAAM,CAAC,IAAiB;QACvC,OAAO,uBAAA,IAAI,qCAAU,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE;YACpD,MAAM,IAAI,CAAC;YACX,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IACvB,CAAC;CACD"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isMain } from "@prosopo/util";
|
|
2
|
+
import { Flatten } from "./commands/flatten.js";
|
|
3
|
+
import { GenerateV1 } from "./commands/generateV1.js";
|
|
4
|
+
import { GenerateV2 } from "./commands/generateV2.js";
|
|
5
|
+
import { Get } from "./commands/get.js";
|
|
6
|
+
import { Labels } from "./commands/labels.js";
|
|
7
|
+
import { Relocate } from "./commands/relocate.js";
|
|
8
|
+
import { Resize } from "./commands/resize.js";
|
|
9
|
+
import { Cli } from "./index.js";
|
|
10
|
+
const main = async () => {
|
|
11
|
+
const commands = [
|
|
12
|
+
new Flatten(),
|
|
13
|
+
new GenerateV1(),
|
|
14
|
+
new GenerateV2(),
|
|
15
|
+
new Get(),
|
|
16
|
+
new Labels(),
|
|
17
|
+
new Relocate(),
|
|
18
|
+
new Resize(),
|
|
19
|
+
];
|
|
20
|
+
const cli = new Cli(commands);
|
|
21
|
+
cli.logger.setLogLevel("debug");
|
|
22
|
+
await cli.exec();
|
|
23
|
+
};
|
|
24
|
+
if (isMain(import.meta.url)) {
|
|
25
|
+
main()
|
|
26
|
+
.then(() => {
|
|
27
|
+
process.exit(0);
|
|
28
|
+
})
|
|
29
|
+
.catch((err) => {
|
|
30
|
+
console.log("error", err);
|
|
31
|
+
process.exit(1);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["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,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import { InputOutputCliCommand } from "../utils/inputOutput.js";
|
|
3
|
+
export declare const ArgsSchema: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
4
|
+
input: z.ZodString;
|
|
5
|
+
}, {
|
|
6
|
+
output: z.ZodString;
|
|
7
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
8
|
+
}>, {
|
|
9
|
+
allowDuplicates: z.ZodOptional<z.ZodBoolean>;
|
|
10
|
+
}>, "strip", z.ZodTypeAny, {
|
|
11
|
+
input: string;
|
|
12
|
+
output: string;
|
|
13
|
+
overwrite?: boolean | undefined;
|
|
14
|
+
allowDuplicates?: boolean | undefined;
|
|
15
|
+
}, {
|
|
16
|
+
input: string;
|
|
17
|
+
output: string;
|
|
18
|
+
overwrite?: boolean | undefined;
|
|
19
|
+
allowDuplicates?: boolean | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
export type ArgsSchemaType = typeof ArgsSchema;
|
|
22
|
+
export type Args = z.infer<ArgsSchemaType>;
|
|
23
|
+
export declare class Flatten extends InputOutputCliCommand<ArgsSchemaType> {
|
|
24
|
+
getArgSchema(): z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
25
|
+
input: z.ZodString;
|
|
26
|
+
}, {
|
|
27
|
+
output: z.ZodString;
|
|
28
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
+
}>, {
|
|
30
|
+
allowDuplicates: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
}>, "strip", z.ZodTypeAny, {
|
|
32
|
+
input: string;
|
|
33
|
+
output: string;
|
|
34
|
+
overwrite?: boolean | undefined;
|
|
35
|
+
allowDuplicates?: boolean | undefined;
|
|
36
|
+
}, {
|
|
37
|
+
input: string;
|
|
38
|
+
output: string;
|
|
39
|
+
overwrite?: boolean | undefined;
|
|
40
|
+
allowDuplicates?: boolean | undefined;
|
|
41
|
+
}>;
|
|
42
|
+
getDescription(): string;
|
|
43
|
+
getOptions(): {
|
|
44
|
+
[key: string]: import("yargs").Options;
|
|
45
|
+
} & {
|
|
46
|
+
input: {
|
|
47
|
+
description: string;
|
|
48
|
+
};
|
|
49
|
+
output: {
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
allowDuplicates: {
|
|
53
|
+
boolean: boolean;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
_run(args: Args): Promise<void>;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=flatten.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.d.ts","sourceRoot":"","sources":["../../src/commands/flatten.ts"],"names":[],"mappings":"AA0BA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAEN,qBAAqB,EACrB,MAAM,yBAAyB,CAAC;AAEjC,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;EAErB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,UAAU,CAAC;AAC/C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAE3C,qBAAa,OAAQ,SAAQ,qBAAqB,CAAC,cAAc,CAAC;IACjD,YAAY;;;;;;;;;;;;;;;;;;IAIZ,cAAc,IAAI,MAAM;IAIxB,UAAU;;;;;;;;;;;;;;IAiBJ,IAAI,CAAC,IAAI,EAAE,IAAI;CAuFrC"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import { blake2b } from "@noble/hashes/blake2b";
|
|
3
|
+
import { u8aToHex } from "@polkadot/util/u8a";
|
|
4
|
+
import { ProsopoDatasetError } from "@prosopo/common";
|
|
5
|
+
import { CaptchaItemTypes, DataSchema, } from "@prosopo/types";
|
|
6
|
+
import { at } from "@prosopo/util";
|
|
7
|
+
import { lodash } from "@prosopo/util/lodash";
|
|
8
|
+
import cliProgress from "cli-progress";
|
|
9
|
+
import * as z from "zod";
|
|
10
|
+
import { InputOutputArgsSchema, InputOutputCliCommand, } from "../utils/inputOutput.js";
|
|
11
|
+
export const ArgsSchema = InputOutputArgsSchema.extend({
|
|
12
|
+
allowDuplicates: z.boolean().optional(),
|
|
13
|
+
});
|
|
14
|
+
export class Flatten extends InputOutputCliCommand {
|
|
15
|
+
getArgSchema() {
|
|
16
|
+
return ArgsSchema;
|
|
17
|
+
}
|
|
18
|
+
getDescription() {
|
|
19
|
+
return "Restructure a directory containing directories for each image classification into a single directory with a file containing the labels";
|
|
20
|
+
}
|
|
21
|
+
getOptions() {
|
|
22
|
+
return lodash().merge(super.getOptions(), {
|
|
23
|
+
input: {
|
|
24
|
+
description: "Path to the data directory containing subdirectories for each image classification",
|
|
25
|
+
},
|
|
26
|
+
output: {
|
|
27
|
+
description: "Where to put the output file containing the labels and single directory of images",
|
|
28
|
+
},
|
|
29
|
+
allowDuplicates: {
|
|
30
|
+
boolean: true,
|
|
31
|
+
description: "If true, allow duplicates in the data",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async _run(args) {
|
|
36
|
+
this.logger.debug("flatten run");
|
|
37
|
+
await super._run(args);
|
|
38
|
+
const dataDir = args.input;
|
|
39
|
+
const outDir = args.output;
|
|
40
|
+
this.logger.info("reading data");
|
|
41
|
+
const labels = fs
|
|
42
|
+
.readdirSync(dataDir, { withFileTypes: true })
|
|
43
|
+
.filter((dirent) => dirent.isDirectory())
|
|
44
|
+
.map((dirent) => dirent.name)
|
|
45
|
+
.sort();
|
|
46
|
+
const imagesByLabel = labels.map((label) => fs.readdirSync(`${dataDir}/${label}`));
|
|
47
|
+
const imageDir = `${outDir}/images`;
|
|
48
|
+
fs.mkdirSync(imageDir, { recursive: true });
|
|
49
|
+
const bar = new cliProgress.SingleBar({}, cliProgress.Presets.shades_classic);
|
|
50
|
+
const items = [];
|
|
51
|
+
bar.start(imagesByLabel.reduce((acc, images) => acc + images.length, 0), 0);
|
|
52
|
+
labels.forEach((label, i) => {
|
|
53
|
+
const images = at(imagesByLabel, i);
|
|
54
|
+
for (const image of images) {
|
|
55
|
+
bar.increment();
|
|
56
|
+
const extension = image.split(".").pop();
|
|
57
|
+
const content = fs.readFileSync(`${dataDir}/${label}/${image}`);
|
|
58
|
+
const hash = blake2b(content);
|
|
59
|
+
const hex = u8aToHex(hash);
|
|
60
|
+
const name = `${hex}.${extension}`;
|
|
61
|
+
if (fs.existsSync(`${imageDir}/${name}`)) {
|
|
62
|
+
for (const item of items) {
|
|
63
|
+
if (item.hash === hex) {
|
|
64
|
+
this.logger.log(`\ndupe: ${label}/${image}`);
|
|
65
|
+
this.logger.log("item hash", item.hash);
|
|
66
|
+
this.logger.log("item label", item.label);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (!args.allowDuplicates) {
|
|
70
|
+
throw new ProsopoDatasetError("DATASET.DUPLICATE_IMAGE", {
|
|
71
|
+
context: { image: `${label}/${image}` },
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
fs.copyFileSync(`${dataDir}/${label}/${image}`, `${imageDir}/${name}`);
|
|
76
|
+
const filePath = fs.realpathSync(`${imageDir}/${name}`);
|
|
77
|
+
const entry = {
|
|
78
|
+
data: filePath,
|
|
79
|
+
type: CaptchaItemTypes.Image,
|
|
80
|
+
label,
|
|
81
|
+
hash: hex,
|
|
82
|
+
};
|
|
83
|
+
items.push(entry);
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
bar.stop();
|
|
87
|
+
const data = {
|
|
88
|
+
items,
|
|
89
|
+
};
|
|
90
|
+
this.logger.info("verifying data");
|
|
91
|
+
DataSchema.parse(data);
|
|
92
|
+
this.logger.info("writing data");
|
|
93
|
+
fs.writeFileSync(`${outDir}/data.json`, JSON.stringify(data, null, 4));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=flatten.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flatten.js","sourceRoot":"","sources":["../../src/commands/flatten.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EACN,gBAAgB,EAEhB,UAAU,GAEV,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,WAAW,MAAM,cAAc,CAAC;AAcvC,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EACN,qBAAqB,EACrB,qBAAqB,GACrB,MAAM,yBAAyB,CAAC;AAEjC,MAAM,CAAC,MAAM,UAAU,GAAG,qBAAqB,CAAC,MAAM,CAAC;IACtD,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACvC,CAAC,CAAC;AAIH,MAAM,OAAO,OAAQ,SAAQ,qBAAqC;IACjD,YAAY;QAC3B,OAAO,UAAU,CAAC;IACnB,CAAC;IAEe,cAAc;QAC7B,OAAO,wIAAwI,CAAC;IACjJ,CAAC;IAEe,UAAU;QACzB,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE;YACzC,KAAK,EAAE;gBACN,WAAW,EACV,oFAAoF;aACrF;YACD,MAAM,EAAE;gBACP,WAAW,EACV,mFAAmF;aACpF;YACD,eAAe,EAAE;gBAChB,OAAO,EAAE,IAAI;gBACb,WAAW,EAAE,uCAAuC;aACpD;SACD,CAAC,CAA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gBACF,CAAC;gBACD,EAAE,CAAC,YAAY,CAAC,GAAG,OAAO,IAAI,KAAK,IAAI,KAAK,EAAE,EAAE,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;gBACvE,MAAM,QAAQ,GAAG,EAAE,CAAC,YAAY,CAAC,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,CAAC;gBAExD,MAAM,KAAK,GAAiB;oBAC3B,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,gBAAgB,CAAC,KAAK;oBAC5B,KAAK;oBACL,IAAI,EAAE,GAAG;iBACT,CAAC;gBACF,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;QACF,CAAC,CAAC,CAAC;QACH,GAAG,CAAC,IAAI,EAAE,CAAC;QAEX,MAAM,IAAI,GAAS;YAClB,KAAK;SACL,CAAC;QAGF,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;QACnC,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAGvB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACjC,EAAE,CAAC,aAAa,CAAC,GAAG,MAAM,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;IACxE,CAAC;CACD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { type Item, type LabelledItem } from "@prosopo/types";
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import { OutputCliCommand } from "../utils/output.js";
|
|
4
|
+
export declare const ArgsSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
5
|
+
output: z.ZodString;
|
|
6
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
}, {
|
|
8
|
+
labels: z.ZodOptional<z.ZodString>;
|
|
9
|
+
labelled: z.ZodOptional<z.ZodString>;
|
|
10
|
+
unlabelled: z.ZodOptional<z.ZodString>;
|
|
11
|
+
seed: z.ZodNumber;
|
|
12
|
+
size: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
overwrite: z.ZodOptional<z.ZodBoolean>;
|
|
14
|
+
allowDuplicates: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
+
allowDuplicatesLabelled: z.ZodOptional<z.ZodBoolean>;
|
|
16
|
+
allowDuplicatesUnlabelled: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
}>, "strip", z.ZodTypeAny, {
|
|
18
|
+
output: string;
|
|
19
|
+
seed: number;
|
|
20
|
+
overwrite?: boolean | undefined;
|
|
21
|
+
allowDuplicates?: boolean | undefined;
|
|
22
|
+
labels?: string | undefined;
|
|
23
|
+
labelled?: string | undefined;
|
|
24
|
+
unlabelled?: string | undefined;
|
|
25
|
+
size?: number | undefined;
|
|
26
|
+
allowDuplicatesLabelled?: boolean | undefined;
|
|
27
|
+
allowDuplicatesUnlabelled?: boolean | undefined;
|
|
28
|
+
}, {
|
|
29
|
+
output: string;
|
|
30
|
+
seed: number;
|
|
31
|
+
overwrite?: boolean | undefined;
|
|
32
|
+
allowDuplicates?: boolean | undefined;
|
|
33
|
+
labels?: string | undefined;
|
|
34
|
+
labelled?: string | undefined;
|
|
35
|
+
unlabelled?: string | undefined;
|
|
36
|
+
size?: number | undefined;
|
|
37
|
+
allowDuplicatesLabelled?: boolean | undefined;
|
|
38
|
+
allowDuplicatesUnlabelled?: boolean | undefined;
|
|
39
|
+
}>;
|
|
40
|
+
export type ArgsSchemaType = typeof ArgsSchema;
|
|
41
|
+
export type Args = z.infer<ArgsSchemaType>;
|
|
42
|
+
export declare abstract class Generate<T extends ArgsSchemaType> extends OutputCliCommand<T> {
|
|
43
|
+
getOptions(): {
|
|
44
|
+
[key: string]: import("yargs").Options;
|
|
45
|
+
} & {
|
|
46
|
+
output: {
|
|
47
|
+
alias: string;
|
|
48
|
+
string: boolean;
|
|
49
|
+
demand: boolean;
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
overwrite: {
|
|
53
|
+
boolean: boolean;
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
} & {
|
|
57
|
+
output: {
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
labelled: {
|
|
61
|
+
string: boolean;
|
|
62
|
+
demand: boolean;
|
|
63
|
+
description: string;
|
|
64
|
+
};
|
|
65
|
+
unlabelled: {
|
|
66
|
+
string: boolean;
|
|
67
|
+
demand: boolean;
|
|
68
|
+
description: string;
|
|
69
|
+
};
|
|
70
|
+
seed: {
|
|
71
|
+
number: boolean;
|
|
72
|
+
demand: boolean;
|
|
73
|
+
description: string;
|
|
74
|
+
};
|
|
75
|
+
size: {
|
|
76
|
+
number: boolean;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
labels: {
|
|
80
|
+
string: boolean;
|
|
81
|
+
description: string;
|
|
82
|
+
};
|
|
83
|
+
allowDuplicates: {
|
|
84
|
+
boolean: boolean;
|
|
85
|
+
description: string;
|
|
86
|
+
};
|
|
87
|
+
allowDuplicatesLabelled: {
|
|
88
|
+
boolean: boolean;
|
|
89
|
+
description: string;
|
|
90
|
+
};
|
|
91
|
+
allowDuplicatesUnlabelled: {
|
|
92
|
+
boolean: boolean;
|
|
93
|
+
description: string;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
_check(args: Args): Promise<void>;
|
|
97
|
+
labelled: LabelledItem[];
|
|
98
|
+
unlabelled: Item[];
|
|
99
|
+
labels: string[];
|
|
100
|
+
labelledMapFile: string;
|
|
101
|
+
unlabelledMapFile: string;
|
|
102
|
+
labelToImages: {
|
|
103
|
+
[label: string]: Item[];
|
|
104
|
+
};
|
|
105
|
+
targets: string[];
|
|
106
|
+
saltRounds: number;
|
|
107
|
+
private loadData;
|
|
108
|
+
private loadLabels;
|
|
109
|
+
_run(args: Args): Promise<void>;
|
|
110
|
+
}
|
|
111
|
+
export declare const checkDuplicates: (labelled: LabelledItem[], unlabelled: Item[], options: {
|
|
112
|
+
allowDuplicatesLabelled?: boolean;
|
|
113
|
+
allowDuplicatesUnlabelled?: boolean;
|
|
114
|
+
}) => void;
|
|
115
|
+
//# sourceMappingURL=generate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../src/commands/generate.ts"],"names":[],"mappings":"AAEA,OAAO,EAEN,KAAK,IAAI,EAET,KAAK,YAAY,EAEjB,MAAM,gBAAgB,CAAC;AAexB,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAoB,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAExE,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAUrB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,UAAU,CAAC;AAC/C,MAAM,MAAM,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;AAE3C,8BAAsB,QAAQ,CAC7B,CAAC,SAAS,cAAc,CACvB,SAAQ,gBAAgB,CAAC,CAAC,CAAC;IACZ,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IA6CJ,MAAM,CAAC,IAAI,EAAE,IAAI;IAwBvC,QAAQ,EAAE,YAAY,EAAE,CAAM;IAC9B,UAAU,EAAE,IAAI,EAAE,CAAM;IACxB,MAAM,EAAE,MAAM,EAAE,CAAM;IACtB,eAAe,SAAM;IACrB,iBAAiB,SAAM;IACvB,aAAa,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,EAAE,CAAA;KAAE,CAAM;IAChD,OAAO,EAAE,MAAM,EAAE,CAAM;IACvB,UAAU,SAAM;IAEhB,OAAO,CAAC,QAAQ;IAkChB,OAAO,CAAC,UAAU;IAmBI,IAAI,CAAC,IAAI,EAAE,IAAI;CAWrC;AAED,eAAO,MAAM,eAAe,aACjB,YA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