@cqse/commons 1.0.4 → 1.0.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cqse/commons",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "A collection of generic functionality for TypeScript projects.",
5
5
  "author": "CQSE GmbH",
6
6
  "main": "lib/index.cjs",
@@ -21,7 +21,8 @@
21
21
  "license": "Apache-2.0",
22
22
  "homepage": "https://docs.teamscale.com/howto/setting-up-profiler-tga/javascript/",
23
23
  "files": [
24
- "lib/**/*"
24
+ "lib/*.mjs",
25
+ "lib/*.cjs"
25
26
  ],
26
27
  "publishConfig": {
27
28
  "access": "public"
package/lib/index.d.cts DELETED
@@ -1,142 +0,0 @@
1
- //#region src/Contract.d.ts
2
- type Nullable<Type> = Type | null;
3
- declare class Contract {
4
- static require(condition: boolean, message?: string): void;
5
- static requireDefined<E>(obj: Nullable<E>, message?: string): E;
6
- static requireNonEmpty(text: string, message?: string): string;
7
- static requireStringPattern(text: string, regexp: string | RegExp, message?: string): string;
8
- }
9
- //#endregion
10
- //#region src/Exceptions.d.ts
11
- declare class ImplementMeException extends Error {
12
- private readonly _implementMeFor?;
13
- constructor(implementMeFor?: string);
14
- get message(): string;
15
- }
16
- declare class IllegalStateException extends Error {}
17
- declare class IllegalArgumentException extends Error {}
18
- declare class InvalidConfigurationException extends Error {}
19
- //#endregion
20
- //#region src/Strings.d.ts
21
- declare function removePrefix(prefix: string, removeFrom: string): string;
22
- //#endregion
23
- //#region src/ConfigParser.d.ts
24
- type ConfigParameterType = 'string' | 'int' | 'bool' | 'string[]';
25
- type ConfigValueType = string | number | boolean | string[];
26
- type Options = Record<string, ConfigValueType>;
27
- type VersionAndHelpOptions = {
28
- version: boolean;
29
- help: boolean;
30
- };
31
- type ConfigParsingResult = {
32
- options: Options;
33
- unnamedArguments: string[];
34
- };
35
- type AppInfos = {
36
- name: string;
37
- version: string;
38
- about: string;
39
- };
40
- type ParameterGroup = {
41
- order: number;
42
- title: string;
43
- hints?: string;
44
- };
45
- declare const CONFIG_GROUP_APP: ParameterGroup;
46
- type ParameterDescriptor = {
47
- parameterId: string;
48
- shortParameter?: string;
49
- longParameter: string;
50
- environmentVariableName: string;
51
- disableEnvironmentVariableOverride?: boolean;
52
- type: ConfigParameterType;
53
- default?: ConfigValueType;
54
- help: string;
55
- internal: boolean;
56
- group?: ParameterGroup;
57
- };
58
- type ParameterDefinitionOptions = Partial<ParameterDescriptor>;
59
- declare function parameterNameToParameterId(parameterName: string): string;
60
- declare function longParameterToEnvironmentVariableName(longParameter: string): string;
61
- declare class ConfigurationParameters {
62
- private readonly parameters;
63
- private readonly shortToLongParameterMap;
64
- private readonly sequentialParameters;
65
- private readonly argumentChecks;
66
- constructor();
67
- addParameter(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType, options?: ParameterDefinitionOptions): void;
68
- addArgumentCheck(check: (options: Record<string, unknown>) => string | undefined): void;
69
- addRequiredArgumentFor(parameterId: string): void;
70
- describeParameter(parameterId: string, descriptor: ParameterDescriptor): void;
71
- lookupParameter(parameterId: string): ParameterDescriptor | undefined;
72
- getParameters(): ParameterDescriptor[];
73
- getArgumentChecks(): Array<(options: Record<string, unknown>) => string | undefined>;
74
- getSequentialParameters(): string[];
75
- clone(): ConfigurationParameters;
76
- addAllOf(toAdd: ConfigurationParameters): void;
77
- }
78
- declare function parseArguments<OptionsType extends Record<string, unknown>>(args: string[], parameters: ConfigurationParameters): Partial<OptionsType>;
79
- declare function parseConfigFile(fileContent: string, parameters: ConfigurationParameters): ConfigParsingResult;
80
- declare function printHelp(parameters: ConfigurationParameters, aboutText?: string, printParamterId?: boolean): void;
81
- declare function checkArguments(configParameters: ConfigurationParameters, options: Options, errorReceiver?: (error: string) => void): boolean;
82
- declare function processCommandLine<O>(parameters: ConfigurationParameters, appInfos: AppInfos, args?: string[], beforeCheckCallback?: (options: O) => void): O;
83
- declare function parameterUnion(parameters1: ConfigurationParameters, parameters2: ConfigurationParameters): ConfigurationParameters;
84
- //#endregion
85
- //#region src/ConfigWithOverwrites.d.ts
86
- declare class ConfigurationWithOverwrites<BaseConfigType extends Options> {
87
- private readonly baseConfiguration;
88
- private readonly redefinableParameters;
89
- private readonly allParameters;
90
- private overwrites;
91
- private hash?;
92
- constructor(allParameters: ConfigurationParameters, redefinableParameters: ConfigurationParameters, baseConfiguration: Record<string, ConfigValueType>, overwrites?: Record<string, ConfigValueType>);
93
- get(parameterId: string): ConfigValueType;
94
- set(parameterId: string, value: ConfigValueType): void;
95
- overwriteConfig(parameter: string, value: ConfigValueType | undefined): void;
96
- private castConfigArgument;
97
- private assertParameterExists;
98
- private getParameter;
99
- getHash(): string;
100
- copy(): ConfigurationWithOverwrites<BaseConfigType>;
101
- }
102
- declare function makeConfigProxy<BaseConfigType extends Options>(configuration: ConfigurationWithOverwrites<BaseConfigType>): BaseConfigType;
103
- //#endregion
104
- //#region src/CollectorConfig.d.ts
105
- type PredefinableOptions = {
106
- keepCoverageFiles: boolean;
107
- dumpAfterMins: number;
108
- artifactoryServerUrl?: string;
109
- artifactoryUser?: string;
110
- artifactoryPassword?: string;
111
- artifactoryAccessToken?: string;
112
- artifactoryPathSuffix?: string;
113
- };
114
- type StaticCollectorOptions = PredefinableOptions & {
115
- port: number;
116
- dumpFolder: string;
117
- httpProxy?: string;
118
- logLevel: string;
119
- logToFile: string;
120
- jsonLog: boolean;
121
- enableControlPort?: number;
122
- teamscaleServerUrl?: string;
123
- teamscaleUser?: string;
124
- teamscaleAccessToken?: string;
125
- };
126
- type ReconfigurableCollectorOptions = PredefinableOptions & {
127
- teamscaleProject?: string;
128
- teamscalePartition?: string;
129
- teamscaleRepository?: string;
130
- teamscaleMessage?: string;
131
- dumpToFolder?: string;
132
- };
133
- type CollectorOptions = StaticCollectorOptions & ReconfigurableCollectorOptions;
134
- declare function buildPredefinableParameters(): ConfigurationParameters;
135
- declare function buildStaticCollectorParameters(): ConfigurationParameters;
136
- declare function buildReconfigurableCollectorParameters(): ConfigurationParameters;
137
- //#endregion
138
- //#region src/Validation.d.ts
139
- declare function isValidCommitInfo(commit?: unknown): boolean;
140
- //#endregion
141
- export { AppInfos, CONFIG_GROUP_APP, CollectorOptions, ConfigParameterType, ConfigParsingResult, ConfigValueType, ConfigurationParameters, ConfigurationWithOverwrites, Contract, IllegalArgumentException, IllegalStateException, ImplementMeException, InvalidConfigurationException, Nullable, Options, ParameterDefinitionOptions, ParameterDescriptor, ParameterGroup, PredefinableOptions, ReconfigurableCollectorOptions, StaticCollectorOptions, VersionAndHelpOptions, buildPredefinableParameters, buildReconfigurableCollectorParameters, buildStaticCollectorParameters, checkArguments, isValidCommitInfo, longParameterToEnvironmentVariableName, makeConfigProxy, parameterNameToParameterId, parameterUnion, parseArguments, parseConfigFile, printHelp, processCommandLine, removePrefix };
142
- //# sourceMappingURL=index.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/Contract.ts","../src/Exceptions.ts","../src/Strings.ts","../src/ConfigParser.ts","../src/ConfigWithOverwrites.ts","../src/CollectorConfig.ts","../src/Validation.ts"],"mappings":";KAKY,QAAA,SAAiB,IAAA;AAAA,cAKhB,QAAA;EAAA,OAAA,QAAA,SAAA,WAAA,OAAA;EAAA,OAAA,cAAA,GAAA,CAAA,GAAA,EAmByB,QAAA,CAAS,CAAA,GAAA,OAAA,YAAuB,CAAA;EAAA,OAAA,gBAAA,IAAA,UAAA,OAAA;EAAA,OAAA,qBAAA,IAAA,UAAA,MAAA,WA2CH,MAAA,EAAA,OAAA;AAAA;;;cClEtD,oBAAA,SAA6B,KAAA;EAAA,iBAAA,eAAA;EAAA,YAAA,cAAA;EAAA,IAAA,QAAA;AAAA;AAAA,cAoB7B,qBAAA,SAA8B,KAAA;AAAA,cAK9B,wBAAA,SAAiC,KAAA;AAAA,cAKjC,6BAAA,SAAsC,KAAA;;;iBC5BnC,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AcA,sBAAA,GAAyB,mBAAA;EAAA,IAAA;EAAA,UAAA;EAAA,SAAA;EAAA,QAAA;EAAA,SAAA;EAAA,OAAA;EAAA,iBAAA;EAAA,kBAAA;EAAA,aAAA;EAAA,oBAAA;AAAA;AAAA,KAoBzB,8BAAA,GAAiC,mBAAA;EAAA,gBAAA;EAAA,kBAAA;EAAA,mBAAA;EAAA,gBAAA;EAAA,YAAA;AAAA;AAAA,KAYjC,gBAAA,GAAmB,sBAAA,GAAyB,8BAAA;AAAA,iBA8CxC,2BAAA,CAAA,GAA+B,uBAAA;AAAA,iBAqE/B,8BAAA,CAAA,GAAkC,uBAAA;AAAA,iBAuDlC,sCAAA,CAAA,GAA0C,uBAAA;;;iBC1N1C,iBAAA,CAAA,MAAA"}
package/lib/index.d.mts DELETED
@@ -1,142 +0,0 @@
1
- //#region src/Contract.d.ts
2
- type Nullable<Type> = Type | null;
3
- declare class Contract {
4
- static require(condition: boolean, message?: string): void;
5
- static requireDefined<E>(obj: Nullable<E>, message?: string): E;
6
- static requireNonEmpty(text: string, message?: string): string;
7
- static requireStringPattern(text: string, regexp: string | RegExp, message?: string): string;
8
- }
9
- //#endregion
10
- //#region src/Exceptions.d.ts
11
- declare class ImplementMeException extends Error {
12
- private readonly _implementMeFor?;
13
- constructor(implementMeFor?: string);
14
- get message(): string;
15
- }
16
- declare class IllegalStateException extends Error {}
17
- declare class IllegalArgumentException extends Error {}
18
- declare class InvalidConfigurationException extends Error {}
19
- //#endregion
20
- //#region src/Strings.d.ts
21
- declare function removePrefix(prefix: string, removeFrom: string): string;
22
- //#endregion
23
- //#region src/ConfigParser.d.ts
24
- type ConfigParameterType = 'string' | 'int' | 'bool' | 'string[]';
25
- type ConfigValueType = string | number | boolean | string[];
26
- type Options = Record<string, ConfigValueType>;
27
- type VersionAndHelpOptions = {
28
- version: boolean;
29
- help: boolean;
30
- };
31
- type ConfigParsingResult = {
32
- options: Options;
33
- unnamedArguments: string[];
34
- };
35
- type AppInfos = {
36
- name: string;
37
- version: string;
38
- about: string;
39
- };
40
- type ParameterGroup = {
41
- order: number;
42
- title: string;
43
- hints?: string;
44
- };
45
- declare const CONFIG_GROUP_APP: ParameterGroup;
46
- type ParameterDescriptor = {
47
- parameterId: string;
48
- shortParameter?: string;
49
- longParameter: string;
50
- environmentVariableName: string;
51
- disableEnvironmentVariableOverride?: boolean;
52
- type: ConfigParameterType;
53
- default?: ConfigValueType;
54
- help: string;
55
- internal: boolean;
56
- group?: ParameterGroup;
57
- };
58
- type ParameterDefinitionOptions = Partial<ParameterDescriptor>;
59
- declare function parameterNameToParameterId(parameterName: string): string;
60
- declare function longParameterToEnvironmentVariableName(longParameter: string): string;
61
- declare class ConfigurationParameters {
62
- private readonly parameters;
63
- private readonly shortToLongParameterMap;
64
- private readonly sequentialParameters;
65
- private readonly argumentChecks;
66
- constructor();
67
- addParameter(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType, options?: ParameterDefinitionOptions): void;
68
- addArgumentCheck(check: (options: Record<string, unknown>) => string | undefined): void;
69
- addRequiredArgumentFor(parameterId: string): void;
70
- describeParameter(parameterId: string, descriptor: ParameterDescriptor): void;
71
- lookupParameter(parameterId: string): ParameterDescriptor | undefined;
72
- getParameters(): ParameterDescriptor[];
73
- getArgumentChecks(): Array<(options: Record<string, unknown>) => string | undefined>;
74
- getSequentialParameters(): string[];
75
- clone(): ConfigurationParameters;
76
- addAllOf(toAdd: ConfigurationParameters): void;
77
- }
78
- declare function parseArguments<OptionsType extends Record<string, unknown>>(args: string[], parameters: ConfigurationParameters): Partial<OptionsType>;
79
- declare function parseConfigFile(fileContent: string, parameters: ConfigurationParameters): ConfigParsingResult;
80
- declare function printHelp(parameters: ConfigurationParameters, aboutText?: string, printParamterId?: boolean): void;
81
- declare function checkArguments(configParameters: ConfigurationParameters, options: Options, errorReceiver?: (error: string) => void): boolean;
82
- declare function processCommandLine<O>(parameters: ConfigurationParameters, appInfos: AppInfos, args?: string[], beforeCheckCallback?: (options: O) => void): O;
83
- declare function parameterUnion(parameters1: ConfigurationParameters, parameters2: ConfigurationParameters): ConfigurationParameters;
84
- //#endregion
85
- //#region src/ConfigWithOverwrites.d.ts
86
- declare class ConfigurationWithOverwrites<BaseConfigType extends Options> {
87
- private readonly baseConfiguration;
88
- private readonly redefinableParameters;
89
- private readonly allParameters;
90
- private overwrites;
91
- private hash?;
92
- constructor(allParameters: ConfigurationParameters, redefinableParameters: ConfigurationParameters, baseConfiguration: Record<string, ConfigValueType>, overwrites?: Record<string, ConfigValueType>);
93
- get(parameterId: string): ConfigValueType;
94
- set(parameterId: string, value: ConfigValueType): void;
95
- overwriteConfig(parameter: string, value: ConfigValueType | undefined): void;
96
- private castConfigArgument;
97
- private assertParameterExists;
98
- private getParameter;
99
- getHash(): string;
100
- copy(): ConfigurationWithOverwrites<BaseConfigType>;
101
- }
102
- declare function makeConfigProxy<BaseConfigType extends Options>(configuration: ConfigurationWithOverwrites<BaseConfigType>): BaseConfigType;
103
- //#endregion
104
- //#region src/CollectorConfig.d.ts
105
- type PredefinableOptions = {
106
- keepCoverageFiles: boolean;
107
- dumpAfterMins: number;
108
- artifactoryServerUrl?: string;
109
- artifactoryUser?: string;
110
- artifactoryPassword?: string;
111
- artifactoryAccessToken?: string;
112
- artifactoryPathSuffix?: string;
113
- };
114
- type StaticCollectorOptions = PredefinableOptions & {
115
- port: number;
116
- dumpFolder: string;
117
- httpProxy?: string;
118
- logLevel: string;
119
- logToFile: string;
120
- jsonLog: boolean;
121
- enableControlPort?: number;
122
- teamscaleServerUrl?: string;
123
- teamscaleUser?: string;
124
- teamscaleAccessToken?: string;
125
- };
126
- type ReconfigurableCollectorOptions = PredefinableOptions & {
127
- teamscaleProject?: string;
128
- teamscalePartition?: string;
129
- teamscaleRepository?: string;
130
- teamscaleMessage?: string;
131
- dumpToFolder?: string;
132
- };
133
- type CollectorOptions = StaticCollectorOptions & ReconfigurableCollectorOptions;
134
- declare function buildPredefinableParameters(): ConfigurationParameters;
135
- declare function buildStaticCollectorParameters(): ConfigurationParameters;
136
- declare function buildReconfigurableCollectorParameters(): ConfigurationParameters;
137
- //#endregion
138
- //#region src/Validation.d.ts
139
- declare function isValidCommitInfo(commit?: unknown): boolean;
140
- //#endregion
141
- export { AppInfos, CONFIG_GROUP_APP, CollectorOptions, ConfigParameterType, ConfigParsingResult, ConfigValueType, ConfigurationParameters, ConfigurationWithOverwrites, Contract, IllegalArgumentException, IllegalStateException, ImplementMeException, InvalidConfigurationException, Nullable, Options, ParameterDefinitionOptions, ParameterDescriptor, ParameterGroup, PredefinableOptions, ReconfigurableCollectorOptions, StaticCollectorOptions, VersionAndHelpOptions, buildPredefinableParameters, buildReconfigurableCollectorParameters, buildStaticCollectorParameters, checkArguments, isValidCommitInfo, longParameterToEnvironmentVariableName, makeConfigProxy, parameterNameToParameterId, parameterUnion, parseArguments, parseConfigFile, printHelp, processCommandLine, removePrefix };
142
- //# sourceMappingURL=index.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/Contract.ts","../src/Exceptions.ts","../src/Strings.ts","../src/ConfigParser.ts","../src/ConfigWithOverwrites.ts","../src/CollectorConfig.ts","../src/Validation.ts"],"mappings":";KAKY,QAAA,SAAiB,IAAA;AAAA,cAKhB,QAAA;EAAA,OAAA,QAAA,SAAA,WAAA,OAAA;EAAA,OAAA,cAAA,GAAA,CAAA,GAAA,EAmByB,QAAA,CAAS,CAAA,GAAA,OAAA,YAAuB,CAAA;EAAA,OAAA,gBAAA,IAAA,UAAA,OAAA;EAAA,OAAA,qBAAA,IAAA,UAAA,MAAA,WA2CH,MAAA,EAAA,OAAA;AAAA;;;cClEtD,oBAAA,SAA6B,KAAA;EAAA,iBAAA,eAAA;EAAA,YAAA,cAAA;EAAA,IAAA,QAAA;AAAA;AAAA,cAoB7B,qBAAA,SAA8B,KAAA;AAAA,cAK9B,wBAAA,SAAiC,KAAA;AAAA,cAKjC,6BAAA,SAAsC,KAAA;;;iBC5BnC,YAAA,CA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AA,GAAyB,mBAAA;EAAA,IAAA;EAAA,UAAA;EAAA,SAAA;EAAA,QAAA;EAAA,SAAA;EAAA,OAAA;EAAA,iBAAA;EAAA,kBAAA;EAAA,aAAA;EAAA,oBAAA;AAAA;AAAA,KAoBzB,8BAAA,GAAiC,mBAAA;EAAA,gBAAA;EAAA,kBAAA;EAAA,mBAAA;EAAA,gBAAA;EAAA,YAAA;AAAA;AAAA,KAYjC,gBAAA,GAAmB,sBAAA,GAAyB,8BAAA;AAAA,iBA8CxC,2BAAA,CAAA,GAA+B,uBAAA;AAAA,iBAqE/B,8BAAA,CAAA,GAAkC,uBAAA;AAAA,iBAuDlC,sCAAA,CAAA,GAA0C,uBAAA;;;iBC1N1C,iBAAA,CAAA,MAAA"}
package/lib/index.mjs.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["parameters"],"sources":["../src/Exceptions.ts","../src/Contract.ts","../src/Strings.ts","../src/ConfigParser.ts","../src/ConfigWithOverwrites.ts","../src/CollectorConfig.ts","../src/Validation.ts"],"sourcesContent":["/**\n * Excepting signaling that there is functionality that is supposed\n * to be implemented in case the exception is thrown.\n *\n * This is helpful for writing prototypes and not yet handling all possible cases.\n */\nexport class ImplementMeException extends Error {\n\tprivate readonly _implementMeFor?: string;\n\n\tconstructor(implementMeFor?: string) {\n\t\tsuper('Implement me!');\n\t\tthis._implementMeFor = implementMeFor;\n\t}\n\n\tget message(): string {\n\t\tif (this._implementMeFor) {\n\t\t\treturn `Implement me for: ${this._implementMeFor}`;\n\t\t} else {\n\t\t\treturn 'Implement me!';\n\t\t}\n\t}\n}\n\n/**\n * Exception signaling that the application is in an invalid state.\n */\nexport class IllegalStateException extends Error {}\n\n/**\n * Exception signaling that an invalid argument has been passed for a parameter.\n */\nexport class IllegalArgumentException extends Error {}\n\n/**\n * Exception signaling that a component is mis-configured.\n */\nexport class InvalidConfigurationException extends Error {}\n\n","import { IllegalArgumentException } from './Exceptions';\n\n/**\n * Nullable type.\n */\nexport type Nullable<Type> = Type | null;\n\n/**\n * Methods to express and check code contracts.\n */\nexport class Contract {\n\t/**\n\t * The given predicate `condition` has to be satisfied.\n\t *\n\t * @param condition Condition predicate (boolean value)\n\t * @param message Message describing the condition.\n\t */\n\tpublic static require(condition: boolean, message?: string): void {\n\t\tif (!condition) {\n\t\t\tthrow new IllegalArgumentException(message);\n\t\t}\n\t}\n\n\t/**\n\t * Require that the given argument `obj` is defined.\n\t *\n\t * @param obj The object that has to be defined.\n\t * @param message The message describing this requirement.\n\t */\n\tpublic static requireDefined<E>(obj: Nullable<E>, message?: string): E {\n\t\tif (obj) {\n\t\t\treturn obj;\n\t\t}\n\n\t\tif (typeof obj === 'number' || typeof obj === 'boolean') {\n\t\t\treturn obj;\n\t\t}\n\n\t\tif (typeof obj === 'string' || obj instanceof String) {\n\t\t\t// Deal with the case `obj === \"\"`\n\t\t\treturn obj;\n\t\t}\n\n\t\tif (message) {\n\t\t\tthrow new IllegalArgumentException(message);\n\t\t} else {\n\t\t\tthrow new IllegalArgumentException('Reference must be defined.');\n\t\t}\n\t}\n\n\t/**\n\t * Require that the given string is not empty.\n\t *\n\t * @param text The string to check.\n\t * @param message The message that describes the requirement.\n\t */\n\tpublic static requireNonEmpty(text: string, message?: string): string {\n\t\tthis.requireDefined(text);\n\t\tif (text.length === 0) {\n\t\t\tthrow new IllegalArgumentException(message);\n\t\t}\n\n\t\treturn text;\n\t}\n\n\t/**\n\t * Require that the string adheres to a particular pattern.\n\t *\n\t * @param text The string to check.\n\t * @param regexp The regular expression to satisfy.\n\t * @param message The message describing the requirement.\n\t */\n\tpublic static requireStringPattern(text: string, regexp: string | RegExp, message?: string): string {\n\t\tthis.requireDefined(text);\n\t\tthis.requireDefined(regexp);\n\n\t\tif (!text.match(regexp)) {\n\t\t\tthrow new IllegalArgumentException(message);\n\t\t}\n\n\t\treturn text;\n\t}\n}\n","/**\n * Remove the given prefix, if present, from the given string.\n *\n * @param prefix - The prefix to remove.\n * @param removeFrom - The string to remove the prefix from.\n *\n * @returns a new string where the prefix is removed.\n */\nexport function removePrefix(prefix: string, removeFrom: string): string {\n\tif (removeFrom.startsWith(prefix)) {\n\t\treturn removeFrom.substring(prefix.length);\n\t}\n\treturn removeFrom;\n}\n","/**\n * Configuration parser module that handles command-line arguments, environment variables,\n * and configuration files for TypeScript/JavaScript applications.\n *\n * @module ConfigParser\n */\n\nimport process from 'node:process';\nimport { InvalidConfigurationException } from './Exceptions';\n\n/** Supported parameter types for configuration options */\nexport type ConfigParameterType = 'string' | 'int' | 'bool' | 'string[]';\n\n/** Possible value types for configuration parameters */\nexport type ConfigValueType = string | number | boolean | string[];\n\n/** Record of parameter names to their values */\nexport type Options = Record<string, ConfigValueType>;\n\n/** Options for printing the version and help information */\nexport type VersionAndHelpOptions = { version: boolean, help: boolean };\n\n/** Result of parsing the configuration containing options and unnamed arguments */\nexport type ConfigParsingResult = {\n\toptions: Options;\n\tunnamedArguments: string[];\n};\n\n/** Describes the application that is going to be configured and run. */\nexport type AppInfos = {\n\tname: string;\n\tversion: string;\n\tabout: string;\n}\n\n/** Defines a group of configuration parameters. */\nexport type ParameterGroup = {\n\t/** Number used as the primary criterion for ordering */\n\torder: number;\n\n\t/** Title of the group */\n\ttitle: string;\n\n\t/** Hints on the intended use of the parameters */\n\thints?: string;\n}\n\n/** Parameter group for --version and --help */\nexport const CONFIG_GROUP_APP: ParameterGroup = {\n\torder: 999,\n\ttitle: 'Application'\n};\n\n/** Describes a configuration parameter with its properties */\nexport type ParameterDescriptor = {\n\t/** Internal identifier for the parameter */\n\tparameterId: string;\n\n\t/** Short form of the parameter (e.g., -p) */\n\tshortParameter?: string;\n\n\t/** Long form of the parameter (e.g., --port) */\n\tlongParameter: string;\n\n\t/** Environment variable name for this parameter */\n\tenvironmentVariableName: string;\n\n\t/** Disable overwriting the parameter value via an environment variable? */\n\tdisableEnvironmentVariableOverride?: boolean;\n\n\t/** Parameter's data type */\n\ttype: ConfigParameterType;\n\n\t/** Default value if parameter is not specified */\n\tdefault?: ConfigValueType;\n\n\t/** Help text describing the parameter */\n\thelp: string;\n\n\t/**\n\t * Is it an internal parameter, not to be visible in the command line by default?\n\t * An example is a parameter that is configured via a different mechanism but still\n\t * shall be present in the configuration mechanism at hand.\n\t */\n\tinternal: boolean;\n\n\t/** Parameter group it belongs to. */\n\tgroup?: ParameterGroup;\n};\n\n/**\n * See `ParameterDescriptor`.\n */\nexport type ParameterDefinitionOptions = Partial<ParameterDescriptor>;\n\nfunction expectedArgumentCount(parameterDescriptor: ParameterDescriptor): number {\n\tif (parameterDescriptor.type === 'int' || parameterDescriptor.type === 'string') {\n\t\treturn 1;\n\t} else if (parameterDescriptor.type === 'bool') {\n\t\treturn 0;\n\t} else if (parameterDescriptor.type === 'string[]') {\n\t\treturn Number.POSITIVE_INFINITY;\n\t} else {\n\t\tthrow new InvalidConfigurationException(`Unsupported parameter type \"${parameterDescriptor.type}\" for parameter \"${parameterDescriptor.longParameter}\".`);\n\t}\n}\n\n/**\n * Converts a parameter name (with dashes) to a camelCase parameter ID.\n *\n * @param parameterName - The parameter name to convert (e.g., --my-param)\n * @returns The camelCase parameter ID (e.g., myParam)\n */\nexport function parameterNameToParameterId(parameterName: string): string {\n\tconst withoutLeadingDashes = parameterName.replace(/^-+/, '');\n\treturn withoutLeadingDashes.replace(/-([a-z])/g, (_, char: string) => char.toUpperCase());\n}\n\n/**\n * Converts a long parameter name to an environment variable name.\n *\n * @param longParameter - The long parameter name (e.g., --my-param)\n * @returns The environment variable name (e.g., MY_PARAM)\n */\nexport function longParameterToEnvironmentVariableName(longParameter: string): string {\n\tconst withoutLeadingDashes = longParameter.replace(/^--/, '');\n\treturn withoutLeadingDashes.toUpperCase().replace(/-/g, '_');\n}\n\n/**\n * Manages configuration parameters and their properties.\n * Provides functionality to add, describe, and parse parameters.\n */\nexport class ConfigurationParameters {\n\n\tprivate readonly parameters: Map<string, ParameterDescriptor>;\n\n\tprivate readonly shortToLongParameterMap: Map<string, string>;\n\n\tprivate readonly sequentialParameters: string[];\n\n\tprivate readonly argumentChecks: Array<(options: Record<string, unknown>) => string | undefined>;\n\n\tconstructor() {\n\t\tthis.parameters = new Map();\n\t\tthis.shortToLongParameterMap = new Map();\n\t\tthis.sequentialParameters = [];\n\t\tthis.argumentChecks = [];\n\t}\n\n\t/**\n\t * Adds a new parameter to the configuration.\n\t *\n\t * @param shortParameter - Optional short form of the parameter (e.g., -p)\n\t * @param longParameter - Long form of the parameter (e.g., --port)\n\t * @param type - Parameter's data type\n\t * @param options - Additional parameter options including a help text and default value\n\t */\n\tpublic addParameter(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType,\n\t\t\t\t\t\toptions: ParameterDefinitionOptions = {}): void {\n\t\tconst parameterId = parameterNameToParameterId(longParameter);\n\t\tconst environmentVariableName = longParameterToEnvironmentVariableName(longParameter);\n\t\tthis.describeParameter(parameterId, { parameterId, longParameter, type, shortParameter,\n\t\t\thelp: options.help ?? \"\",\n\t\t\tdefault: options.default,\n\t\t\tinternal: options.internal ?? false,\n\t\t\tgroup: options.group,\n\t\t\tenvironmentVariableName });\n\t}\n\n\t/**\n\t * Adds a new argument check function to the list of checks.\n\t *\n\t * @param check - A function that takes an options object as input and returns a string containing an\n\t * error message if a validation fails, or undefined if the validation passes.\n\t */\n\tpublic addArgumentCheck(check: (options: Record<string, unknown>) => string | undefined): void {\n\t\tthis.argumentChecks.push(check);\n\t}\n\n\t/**\n\t * Makes the given parameter mandatory.\n\t */\n\tpublic addRequiredArgumentFor(parameterId: string): void {\n\t\tconst parameter = this.lookupParameter(parameterId);\n\t\tif (parameter === undefined) {\n\t\t\tthrow new InvalidConfigurationException(`Unknown parameter \"${parameterId}\".`);\n\t\t}\n\t\tif (parameter.default !== undefined) {\n\t\t\tthrow new InvalidConfigurationException(`Parameter \"${parameterId}\" is required, but has a default value.`);\n\t\t}\n\n\t\tthis.argumentChecks.push((parsedArguments: Record<string, unknown>) => {\n\t\t\tconst argument = parsedArguments[parameterId];\n\t\t\tif (argument === undefined) {\n\t\t\t\treturn `Missing required argument for parameter \"${parameter.longParameter}\"\\n` +\n\t\t\t\t\t`\\tParameter description: ${parameter.help}`;\n\t\t\t}\n\t\t\treturn undefined;\n\t\t});\n\t}\n\n\t/**\n\t * Describes a parameter with its complete set of properties.\n\t *\n\t * @param parameterId - Internal identifier for the parameter\n\t * @param descriptor - Complete parameter descriptor\n\t * @throws Error if short parameter is invalid or already mapped\n\t */\n\tpublic describeParameter(parameterId: string, descriptor: ParameterDescriptor): void {\n\t\tthis.parameters.set(parameterId, descriptor);\n\n\t\t// Store a mapping for short parameters to their expanded (long) counterpart.\n\t\tif (descriptor.shortParameter) {\n\t\t\tconst shortParameterId = descriptor.shortParameter.replace(/^-/, '').trim().toLowerCase();\n\t\t\tif (shortParameterId.length < 1 || shortParameterId.length > 3) {\n\t\t\t\tthrow new InvalidConfigurationException(`Short parameter \"${shortParameterId}\" is invalid.`);\n\t\t\t}\n\t\t\tconst existingMapping = this.shortToLongParameterMap.get(shortParameterId)\n\t\t\tif (existingMapping !== undefined && existingMapping !== parameterId) {\n\t\t\t\tthrow new InvalidConfigurationException(`Short parameter \"${shortParameterId}\" is already mapped to parameter \"${existingMapping}\".`);\n\t\t\t}\n\t\t\tthis.shortToLongParameterMap.set(shortParameterId, descriptor.parameterId);\n\t\t}\n\n\t\t// Maybe it describes a sequential parameter.\n\t\tif (!descriptor.longParameter.startsWith('--')) {\n\t\t\tthis.sequentialParameters.push(parameterId);\n\t\t}\n\t}\n\n\t/**\n\t * Looks up a parameter descriptor by its ID.\n\t *\n\t * @param parameterId - Parameter identifier to look up\n\t * @returns Parameter descriptor if found, undefined otherwise\n\t */\n\tpublic lookupParameter(parameterId: string): ParameterDescriptor | undefined {\n\t\tlet result = this.parameters.get(parameterId);\n\t\tif (result === undefined) {\n\t\t\tconst longParameterId = this.shortToLongParameterMap.get(parameterId);\n\t\t\tif (longParameterId !== undefined) {\n\t\t\t\tresult = this.parameters.get(longParameterId);\n\t\t\t}\n\t\t}\n\t\treturn result;\n\t}\n\n\t/**\n\t * Returns all registered parameter descriptors.\n\t *\n\t * @returns Array of all parameter descriptors\n\t */\n\tpublic getParameters(): ParameterDescriptor[] {\n\t\treturn Array.from(this.parameters.values());\n\t}\n\n\t/**\n\t * Retrieves the collection of functions used for argument validation.\n\t */\n\tpublic getArgumentChecks(): Array<(options: Record<string, unknown>) => string | undefined> {\n\t\treturn this.argumentChecks;\n\t}\n\n\t/**\n\t * Returns an array of parameter IDs that are configured as sequential parameters.\n\t * That is, parameters that are given without a name but where their mapping\n\t * to concrete parameters is defined by their position in the command line.\n\t */\n\tpublic getSequentialParameters(): string[] {\n\t\treturn this.sequentialParameters;\n\t}\n\n\t/**\n\t * @returns A new configuration object with the same parameters as this one.\n\t */\n\tpublic clone(): ConfigurationParameters {\n\t\tconst clone = new ConfigurationParameters();\n\t\tfor (const parameter of this.parameters.values()) {\n\t\t\tclone.describeParameter(parameter.parameterId, parameter);\n\t\t}\n\t\tfor (const check of this.argumentChecks) {\n\t\t\tclone.addArgumentCheck(check);\n\t\t}\n\t\treturn clone;\n\t}\n\n\t/**\n\t * Adds all parameters and checks from the given configuration to this one.\n\t */\n\tpublic addAllOf(toAdd: ConfigurationParameters) {\n\t\tfor (const parameter of toAdd.getParameters()) {\n\t\t\tthis.describeParameter(parameter.parameterId, parameter);\n\t\t}\n\t\tfor (const check of toAdd.getArgumentChecks()) {\n\t\t\tthis.addArgumentCheck(check);\n\t\t}\n\t}\n}\n\n/**\n * Parses command line arguments according to parameter definitions.\n *\n * @param args - Array of command line arguments to parse\n * @param parameters - Configuration parameters defining valid options\n * @returns Parsed options object with parameter values\n * @throws Error if parameter values are invalid or missing\n */\nexport function parseArguments<OptionsType extends Record<string, unknown>>(\n\targs: string[], parameters: ConfigurationParameters): Partial<OptionsType> {\n\n\tconst result: Record<string, unknown> = {};\n\tlet activeParameter: ParameterDescriptor | undefined;\n\tlet activeArguments: string[] = [];\n\tlet awaitingArguments = 0;\n\n\tfunction finishParameter(): void {\n\t\tif (!activeParameter) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (awaitingArguments < Number.POSITIVE_INFINITY && awaitingArguments > 0) {\n\t\t\tthrow new InvalidConfigurationException(`Missing value for parameter \"${activeParameter.longParameter}\".`);\n\t\t}\n\n\t\tif (activeParameter.type === 'bool') {\n\t\t\tresult[activeParameter.parameterId] = true;\n\t\t\tactiveParameter = undefined;\n\t\t} else if (activeParameter.type === 'string[]') {\n\t\t\tconst targetList = result[activeParameter.parameterId];\n\t\t\t// A list argument can be either provided by separating a string with commas\n\t\t\t// or by pasing multiple string arguments (separated by space) in a sequence.\n\t\t\tconst argumentsNormalizedAsList = parseStringListArgument(activeArguments.join(\",\"));\n\t\t\tif (isDefinedStringList(targetList)) {\n\t\t\t\tresult[activeParameter.parameterId] = targetList.concat(argumentsNormalizedAsList);\n\t\t\t} else {\n\t\t\t\tresult[activeParameter.parameterId] = argumentsNormalizedAsList;\n\t\t\t}\n\t\t} else {\n\t\t\tif (activeArguments.length !== 1) {\n\t\t\t\tthrow new InvalidConfigurationException(`Invalid value for parameter \"${activeParameter.longParameter}\": Expected a single value, got ${activeArguments.length}.`);\n\t\t\t}\n\t\t\tresult[activeParameter.parameterId] = parseWithProperType(activeArguments[0], activeParameter);\n\t\t}\n\n\t\tactiveParameter = undefined;\n\t\tactiveArguments = [];\n\t}\n\n\tfor (const argument of args) {\n\t\tif (argument.startsWith('-')) {\n\t\t\tfinishParameter();\n\n\t\t\tconst parameterId = parameterNameToParameterId(argument);\n\t\t\tactiveParameter = parameters.lookupParameter(parameterId);\n\t\t\tif (!activeParameter) {\n\t\t\t\tthrow new InvalidConfigurationException(`Unknown configuration parameter: ${argument}`);\n\t\t\t}\n\n\t\t\tawaitingArguments = expectedArgumentCount(activeParameter);\n\t\t} else {\n\t\t\tif (!activeParameter) {\n\t\t\t\tthrow new InvalidConfigurationException(`Unexpected or unnamed argument, or unknown parameter '${argument}' supplied. Please specify a parameter name (for example, --input) for each argument.`);\n\t\t\t}\n\t\t\tactiveArguments.push(argument);\n\t\t\tawaitingArguments--;\n\t\t}\n\n\t\tif (awaitingArguments === 0) {\n\t\t\tfinishParameter();\n\t\t}\n\t}\n\n\tfinishParameter()\n\n\t// Set default values for parameters for which we did not receive an argument.\n\t// Or read the value from an ENVIRONMENT_VARIABLE.\n\tfor (const parameter of parameters.getParameters()) {\n\t\tif (result[parameter.parameterId] === undefined) {\n\t\t\tresult[parameter.parameterId] = parameter.default;\n\t\t\tconst environmentValue = process.env[parameter.environmentVariableName];\n\t\t\tif (environmentValue && !parameter.disableEnvironmentVariableOverride) {\n\t\t\t\tresult[parameter.parameterId] = parseWithProperType(environmentValue, parameter);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result as Partial<OptionsType>;\n}\n\nfunction unquoteString(text: string): string {\n\ttext = text.trim();\n\tif ((text.startsWith('\"') && text.endsWith('\"')) ||\n\t\t(text.startsWith('\\'') && text.endsWith('\\'')) ||\n\t\t(text.startsWith('`') && text.endsWith('`'))) {\n\t\treturn text.substring(1, text.length - 1);\n\t} else {\n\t\treturn text;\n\t}\n}\n\nfunction parseStringListArgument(value: string | undefined) {\n\tif (!value) {\n\t\treturn [];\n\t}\n\treturn value.split(',').map(item => unquoteString(item));\n}\n\nfunction parseWithProperType(value: string, parameterDescriptor: ParameterDescriptor) {\n\tif (parameterDescriptor.type === 'int') {\n\t\tconst parsedValue = parseInt(value, 10);\n\t\tif (isNaN(parsedValue)) {\n\t\t\tthrow new InvalidConfigurationException(`Invalid value for parameter \"${parameterDescriptor.longParameter}\": Expected an integer, got \"${value}\".`);\n\t\t}\n\t\treturn parsedValue;\n\t} else if (parameterDescriptor.type === 'bool') {\n\t\tconst lowerValue = value.toLowerCase();\n\t\tif (lowerValue === 'true' || lowerValue === '1') {\n\t\t\treturn true;\n\t\t} else if (lowerValue === 'false' || lowerValue === '0') {\n\t\t\treturn false;\n\t\t} else {\n\t\t\tthrow new InvalidConfigurationException(`Invalid value for parameter \"${parameterDescriptor.longParameter}\": Expected a boolean, got \"${value}\".`);\n\t\t}\n\t} else if (parameterDescriptor.type === 'string') {\n\t\treturn unquoteString(value);\n\t} else if (parameterDescriptor.type === 'string[]') {\n\t\treturn parseStringListArgument(value);\n\t} else {\n\t\tthrow new InvalidConfigurationException(`Unsupported parameter type \"${parameterDescriptor.type}\" for parameter \"${parameterDescriptor.longParameter}\".`);\n\t}\n}\n\nfunction isDefinedStringList(option: unknown): option is string[] {\n\treturn Array.isArray(option) && option.every(item => typeof item === 'string');\n}\n\n/**\n * Parses a configuration file content into options and unnamed arguments.\n *\n * @param fileContent - Content of the configuration file to parse\n * @param parameters - Configuration parameters defining valid options\n * @returns Object containing parsed options and unnamed arguments\n * @throws Error if the configuration file contains invalid parameters or values\n */\nexport function parseConfigFile(fileContent: string, parameters: ConfigurationParameters): ConfigParsingResult {\n\tconst options: Record<string, string | number | boolean | string[]> = {};\n\tconst unnamedArguments: string[] = [];\n\n\tfor (const line of fileContent.split('\\n')) {\n\t\tconst trimmedLine = line.trim();\n\t\tif (trimmedLine.startsWith('#') || trimmedLine.length === 0) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (!trimmedLine.includes('=') && parameters.getSequentialParameters().length > 0) {\n\t\t\tunnamedArguments.push(trimmedLine);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst [key, value] = trimmedLine.split('=');\n\t\tconst parameterId = parameterNameToParameterId(key);\n\t\tconst parameterDescriptor = parameters.lookupParameter(parameterId);\n\t\tif (parameterDescriptor) {\n\t\t\tif (isDefinedStringList(options[parameterId]) && parameterDescriptor.type === 'string[]') {\n\t\t\t\tconst newListValue = parseWithProperType(value, parameterDescriptor);\n\t\t\t\tif (isDefinedStringList(newListValue)) {\n\t\t\t\t\toptions[parameterId] = options[parameterId].concat(newListValue);\n\t\t\t\t} else {\n\t\t\t\t\tthrow new InvalidConfigurationException(`Invalid value for parameter \"${parameterDescriptor.longParameter}\": Expected a list of strings, got \"${value}\".`);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\toptions[parameterId] = parseWithProperType(value, parameterDescriptor);\n\t\t\t}\n\t\t} else {\n\t\t\tthrow new InvalidConfigurationException(`Unknown configuration parameter: ${key}`);\n\t\t}\n\t}\n\n\treturn { options, unnamedArguments };\n}\n\n/**\n * Prints help information for all registered parameters.\n *\n * @param parameters - Configuration parameters to display help for\n * @param aboutText - Optional descriptive text to display before parameter help\n * @param printParamterId - Print the ID of the parameter instead of the command line parameter names?\n */\nexport function printHelp(parameters: ConfigurationParameters, aboutText?: string, printParamterId = false): void {\n\tconst lines: string[] = [];\n\n\tif (aboutText) {\n\t\tlines.push(aboutText);\n\t\tlines.push('');\n\t}\n\n\tif (!printParamterId) {\n\t\tlines.push('Usage:');\n\t}\n\n\tconst grouped = groupAndSortParameterDescriptors(parameters);\n\n\tfor (const group of grouped) {\n\t\tif (group.groupTitle) {\n\t\t\tlines.push('');\n\t\t\tlines.push(`# ${group.groupTitle}`);\n\t\t\tlines.push('');\n\t\t}\n\n\t\tif (group.groupHint) {\n\t\t\tlines.push(restrictLineLengthTo(group.groupHint, 80));\n\t\t\tlines.push('')\n\t\t}\n\n\t\tfor (const descriptor of group.parameters) {\n\t\t\tif (descriptor.internal) {\n\t\t\t\t// Do not print internal parameters.\n\t\t\t\t// Note that getting them via the command line would still not be a problem;\n\t\t\t\t// typically, it would only define a new default value.\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tfunction getArgumentPlaceholder(): string {\n\t\t\t\tconst singleArgumentName = descriptor.environmentVariableName;\n\t\t\t\tif (descriptor.type === \"bool\") {\n\t\t\t\t\treturn \"\";\n\t\t\t\t} else if (descriptor.type === \"string[]\") {\n\t\t\t\t\treturn ` ${singleArgumentName}, .., ${singleArgumentName}`\n\t\t\t\t} else {\n\t\t\t\t\treturn ` ${singleArgumentName}`;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tconst options = [];\n\t\t\tif (printParamterId) {\n\t\t\t\toptions.push(`Parameter \"${descriptor.parameterId}\" (${descriptor.type})`);\n\t\t\t} else {\n\t\t\t\tif (descriptor.shortParameter) {\n\t\t\t\t\toptions.push(`${descriptor.shortParameter}${getArgumentPlaceholder()}`);\n\t\t\t\t}\n\t\t\t\toptions.push(`${descriptor.longParameter}${getArgumentPlaceholder()}`);\n\t\t\t}\n\n\t\t\tconst help = ensureTabAfterNewline(restrictLineLengthTo(descriptor.help, 80));\n\t\t\tconst defaultValue = descriptor.default ? `Default: ${descriptor.default}` : undefined;\n\n\t\t\tlines.push(` ${options.join(', ')}`);\n\t\t\tif (help) {\n\t\t\t\tlines.push(`\\t${help}`);\n\t\t\t}\n\t\t\tif (defaultValue) {\n\t\t\t\tlines.push(`\\t${defaultValue}`);\n\t\t\t}\n\t\t}\n\t}\n\n\tlines.push('');\n\tconsole.log(lines.join('\\n'));\n}\n\n/**\n * Add breaks after words (replace space by newline) in case a sentence gets longer\n * on one line than the specified `maxLineLength`.\n */\nfunction restrictLineLengthTo(text: string, maxLineLength: number): string {\n\ttext = text.replace(/\\n/g, ' ');\n\tconst words = text.split(' ');\n\tconst lines: string[] = [];\n\tlet currentLine = '';\n\tfor (const word of words) {\n\t\tif (currentLine.length + word.length + 1 > maxLineLength) {\n\t\t\tlines.push(currentLine);\n\t\t\tcurrentLine = '';\n\t\t}\n\t\tif (currentLine.length > 0) {\n\t\t\tcurrentLine += ' ';\n\t\t}\n\t\tcurrentLine += word;\n\t}\n\tif (currentLine.length > 0) {\n\t\tlines.push(currentLine);\n\t}\n\treturn lines.join('\\n');\n}\n\nfunction ensureTabAfterNewline(text: string | undefined): string | undefined {\n\tif (!text) {\n\t\treturn undefined;\n\t}\n\treturn text.replace(/\\n/g, '\\n\\t');\n}\n\ntype ParameterGrouping = { groupTitle?: string, groupHint?: string, parameters: ParameterDescriptor[] };\n\nfunction groupAndSortParameterDescriptors(parameters: ConfigurationParameters): ParameterGrouping[] {\n\tconst parametersByGroup = new Map<string | undefined, ParameterDescriptor[]>();\n\tconst groupOrders = new Map<string | undefined, number>();\n\tconst groupHints = new Map<string | undefined, string>();\n\n\t// Group parameters and collect group orders\n\tfor (const parameter of parameters.getParameters()) {\n\t\tconst groupTitle = parameter.group?.title;\n\t\tif (parameter.group) {\n\t\t\tgroupOrders.set(groupTitle, parameter.group.order);\n\t\t}\n\t\tif (parameter.group?.hints) {\n\t\t\tgroupHints.set(groupTitle, parameter.group?.hints);\n\t\t}\n\n\t\tconst groupParameters = parametersByGroup.get(groupTitle) || [];\n\t\tgroupParameters.push(parameter);\n\t\tparametersByGroup.set(groupTitle, groupParameters);\n\t}\n\n\t// Convert to array and sort by group order\n\treturn Array.from(parametersByGroup.entries())\n\t\t.sort(([groupTitle1], [groupTitle2]) => {\n\t\t\tconst order1 = groupOrders.get(groupTitle1) ?? Number.MAX_VALUE;\n\t\t\tconst order2 = groupOrders.get(groupTitle2) ?? Number.MAX_VALUE;\n\t\t\treturn order1 - order2;\n\t\t})\n\t\t.map(([groupTitle, parameters]) => ({\n\t\t\tgroupTitle,\n\t\t\tgroupHint: groupHints.get(groupTitle),\n\t\t\tparameters: parameters.sort(\n\t\t\t\t(a, b) => a.longParameter.localeCompare(b.longParameter))\n\t\t}));\n}\n\n/**\n * Runs the config parameter checks for the given options.\n */\nexport function checkArguments(configParameters: ConfigurationParameters, options: Options,\n\t\t\t\t\t\t\t errorReceiver?: (error: string) => void): boolean {\n\tlet argumentsValid = true;\n\tif (!errorReceiver) {\n\t\terrorReceiver = (error: string) => {\n\t\t\tconsole.error(error);\n\t\t};\n\t}\n\n\tfor (const argumentCheck of configParameters.getArgumentChecks()) {\n\t\tconst checkError = argumentCheck(options);\n\t\tif (checkError) {\n\t\t\terrorReceiver('Invalid configuration: ' + checkError);\n\t\t\targumentsValid = false;\n\t\t}\n\t}\n\treturn argumentsValid;\n}\n\n/**\n * Parses the command-line arguments.\n */\nexport function processCommandLine<O>(parameters: ConfigurationParameters, appInfos: AppInfos, args?: string[],\n\t\t\t\t\t\t\t\t\t beforeCheckCallback?: (options: O) => void): O {\n\t// Fall back to the NodeJS process's arguments if no arguments are given.\n\targs = args ?? process.argv.slice(2);\n\n\tconst configParameters = parameters.clone();\n\tconfigParameters.addParameter('-h', '--help', 'bool', {\n\t\thelp: 'Show this help message and exit.',\n\t\tgroup: CONFIG_GROUP_APP, disableEnvironmentVariableOverride: true\n\t});\n\tconfigParameters.addParameter('-v', '--version', 'bool', {\n\t\thelp: 'Show the version number and exit.',\n\t\tgroup: CONFIG_GROUP_APP, disableEnvironmentVariableOverride: true\n\t});\n\n\tconst options = parseArguments(args, configParameters) as VersionAndHelpOptions;\n\tif (options.version) {\n\t\tconsole.log(`${appInfos.name} v${appInfos.version}`);\n\t\tprocess.exit(0);\n\t}\n\tif (options.help) {\n\t\tprintHelp(configParameters, appInfos.about);\n\t\tprocess.exit(0);\n\t}\n\n\tif (beforeCheckCallback) {\n\t\tbeforeCheckCallback(options as O);\n\t}\n\n\tif (!checkArguments(configParameters, options)) {\n\t\tconsole.error('\\nArguments were missing or invalid. Please check the --help for more information. Exiting with error code 1.');\n\t\tprocess.exit(1);\n\t}\n\n\treturn options as O;\n}\n\n/**\n * Creates a new configuration object by merging two configuration objects.\n */\nexport function parameterUnion(parameters1: ConfigurationParameters, parameters2: ConfigurationParameters): ConfigurationParameters {\n\tconst result = parameters1.clone();\n\tresult.addAllOf(parameters2);\n\treturn result;\n}","import { Contract } from './Contract';\nimport {\n\tConfigurationParameters,\n\tConfigValueType,\n\tOptions,\n\tParameterDescriptor,\n\tparameterNameToParameterId\n} from './ConfigParser';\nimport { createHash } from 'node:crypto';\n\n/**\n * Configuration with a possibility to overwrite configuration values for this app run,\n * delegating to the base configuration if no overwrite was performed.\n * For type-safe access, use `makeConfigProxy` to create a proxy object.\n */\nexport class ConfigurationWithOverwrites<BaseConfigType extends Options> {\n\n\tprivate readonly baseConfiguration: Record<string, ConfigValueType>;\n\n\tprivate readonly redefinableParameters: ConfigurationParameters;\n\n\tprivate readonly allParameters: ConfigurationParameters;\n\n\tprivate overwrites: Record<string, ConfigValueType>;\n\n\tprivate hash?: string;\n\n\tconstructor(allParameters: ConfigurationParameters, redefinableParameters: ConfigurationParameters,\n\t\t\t\tbaseConfiguration: Record<string, ConfigValueType>, overwrites?: Record<string, ConfigValueType>) {\n\t\tthis.baseConfiguration = Contract.requireDefined(baseConfiguration);\n\t\tthis.redefinableParameters = Contract.requireDefined(redefinableParameters);\n\t\tthis.allParameters = Contract.requireDefined(allParameters);\n\t\tthis.overwrites = overwrites ?? {} as Record<keyof BaseConfigType, ConfigValueType>;\n\t\tthis.hash = undefined;\n\t}\n\n\t/**\n\t * Retrieves the value of a configuration parameter based on the provided parameter ID.\n\t */\n\tpublic get(parameterId: string): ConfigValueType {\n\t\tthis.assertParameterExists(parameterId);\n\t\treturn this.overwrites[parameterId] ?? this.baseConfiguration[parameterId];\n\t}\n\n\t/**\n\t * Sets the specified parameter with a given value in the `overwrites` map.\n\t */\n\tpublic set(parameterId: string, value: ConfigValueType): void {\n\t\tif (this.redefinableParameters.lookupParameter(parameterId) === undefined) {\n\t\t\tthrow new Error(`Unknown configuration parameter: ${parameterId}`);\n\t\t}\n\n\t\tthis.overwriteConfig(parameterId, value);\n\t\tthis.hash = undefined;\n\t}\n\n\t/**\n\t * Updates or removes a configuration-overwrite for the given parameter.\n\t */\n\tpublic overwriteConfig(parameter: string, value: ConfigValueType | undefined): void {\n\t\tconst parameterId = parameterNameToParameterId(parameter);\n\t\tthis.assertParameterExists(parameterId);\n\t\tif (value === undefined) {\n\t\t\tdelete this.overwrites[parameterId];\n\t\t\treturn;\n\t\t}\n\t\tthis.overwrites[parameterId] = this.castConfigArgument(parameterId, value);\n\t\tthis.hash = undefined;\n\t}\n\n\tprivate castConfigArgument(parameterId: string, value: unknown): ConfigValueType {\n\t\tconst parameter = this.getParameter(parameterId);\n\t\tconst type = parameter.type;\n\t\tif (type === 'int') {\n\t\t\tif (typeof value === 'number') {\n\t\t\t\treturn Math.floor(value);\n\t\t\t}\n\t\t\tif (typeof value === 'string') {\n\t\t\t\treturn parseInt(value, 10);\n\t\t\t}\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\treturn value ? 1 : 0;\n\t\t\t}\n\t\t} else if (type === 'bool') {\n\t\t\tif (typeof value === 'boolean') {\n\t\t\t\treturn value;\n\t\t\t}\n\t\t\tif (typeof value === 'string') {\n\t\t\t\treturn value.toLowerCase() === 'true';\n\t\t\t}\n\t\t\tif (typeof value === 'number') {\n\t\t\t\treturn value !== 0;\n\t\t\t}\n\t\t} else if (type === 'string[]') {\n\t\t\tif (value === undefined || value == null) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\tif (Array.isArray(value)) {\n\t\t\t\treturn value.map(String);\n\t\t\t}\n\t\t\tif (typeof value === 'string') {\n\t\t\t\treturn value.split(',').map(s => s.trim());\n\t\t\t}\n\t\t} else {\n\t\t\t// string type\n\t\t\treturn String(value);\n\t\t}\n\n\t\tthrow new Error(`Cannot cast value of type ${typeof value} to ${type}`);\n\t}\n\n\tprivate assertParameterExists(parameterId: string): void {\n\t\tif (this.allParameters.lookupParameter(parameterId) === undefined) {\n\t\t\tthrow new Error(`Unknown configuration parameter: ${parameterId}`);\n\t\t}\n\t}\n\n\tprivate getParameter(parameterId: string): ParameterDescriptor {\n\t\tconst parameter = this.redefinableParameters.lookupParameter(parameterId);\n\t\tif (parameter === undefined) {\n\t\t\tthrow new Error(`Unknown configuration parameter: ${parameterId}`);\n\t\t}\n\t\treturn parameter;\n\t}\n\n\t/**\n\t * Computes a hash for the given (possibly overwritten) configuration.\n\t */\n\tpublic getHash(): string {\n\t\tif (this.hash === undefined) {\n\t\t\tconst hash = createHash('sha256');\n\t\t\tfor (const [key, value] of Object.entries(this.baseConfiguration)) {\n\t\t\t\thash.update(key);\n\t\t\t\thash.update(String(value));\n\t\t\t}\n\t\t\tfor (const [key, value] of Object.entries(this.overwrites)) {\n\t\t\t\thash.update(key);\n\t\t\t\thash.update(String(value));\n\t\t\t}\n\t\t\tthis.hash = hash.digest('hex');\n\t\t}\n\n\t\treturn this.hash;\n\t}\n\n\t/**\n\t * Copies the given configuration along with the overrides.\n\t */\n\tpublic copy(): ConfigurationWithOverwrites<BaseConfigType> {\n\t\tconst overwritesCopy = JSON.parse(JSON.stringify(this.overwrites));\n\t\treturn new ConfigurationWithOverwrites<BaseConfigType>(this.allParameters, this.redefinableParameters, this.baseConfiguration,\n\t\t\toverwritesCopy);\n\t}\n\n}\n\n/**\n * Creates a proxy object to retrieve and set config options via the attributes in the `BaseConfigType` interface.\n */\nexport function makeConfigProxy<BaseConfigType extends Options>(\n\tconfiguration: ConfigurationWithOverwrites<BaseConfigType>): BaseConfigType {\n\treturn new Proxy(configuration, {\n\t\tget(_, property: string | symbol) {\n\t\t\treturn configuration.get(property.toString());\n\t\t},\n\t\tset(target, property: string | symbol, value: ConfigValueType) {\n\t\t\tconfiguration.set(property.toString(), value);\n\t\t\treturn true;\n\t\t}\n\t}) as unknown as BaseConfigType;\n}\n\n","import {\n\tConfigParameterType,\n\tConfigurationParameters, ParameterDefinitionOptions, ParameterGroup\n} from './ConfigParser';\n\nexport type PredefinableOptions = {\n\tkeepCoverageFiles: boolean;\n\tdumpAfterMins: number;\n\tartifactoryServerUrl?: string;\n\tartifactoryUser?: string;\n\tartifactoryPassword?: string;\n\tartifactoryAccessToken?: string;\n\tartifactoryPathSuffix?: string;\n}\n\n/**\n * Options that cannot be reconfigured during runtime.\n * These settings are fixed after initial configuration.\n */\nexport type StaticCollectorOptions = PredefinableOptions & {\n\tport: number;\n\tdumpFolder: string;\n\thttpProxy?: string;\n\tlogLevel: string;\n\tlogToFile: string;\n\tjsonLog: boolean;\n\tenableControlPort?: number;\n\tteamscaleServerUrl?: string;\n\tteamscaleUser?: string;\n\tteamscaleAccessToken?: string;\n};\n\n/**\n * Options that can be modified during runtime.\n * These settings control various aspects of the collector's behavior.\n *\n * See the other code in the present file for a list of all available\n * options and their descriptions and default values.\n */\nexport type ReconfigurableCollectorOptions = PredefinableOptions & {\n\tteamscaleProject?: string;\n\tteamscalePartition?: string;\n\tteamscaleRepository?: string;\n\tteamscaleMessage?: string;\n\tdumpToFolder?: string;\n};\n\n/**\n * Complete collection of collector configuration options.\n * Combines both fixed and reconfigurable options into a single type.\n */\nexport type CollectorOptions = StaticCollectorOptions & ReconfigurableCollectorOptions;\n\ntype ArgumentOptions = {\n\thelp?: string;\n\tdefault?: string | number | boolean | string[];\n\tinternal?: boolean;\n};\n\nconst CONFIG_GROUP_COLLECTOR_CONNECTIVITY: ParameterGroup = {\n\torder: 1,\n\ttitle: 'Collector Connectivity'\n};\n\nconst CONFIG_GROUP_TEAMSCALE_SERVER: ParameterGroup = {\n\torder: 1,\n\ttitle: 'Teamscale Server'\n};\n\nconst CONFIG_GROUP_TEAMSCALE_UPLOAD: ParameterGroup = {\n\torder: 2,\n\ttitle: 'Upload to Teamscale',\n\thints: 'NOTE: We generally recommend to set these parameters per app during ' +\n\t\t'the instrumentation process, that is, on the instrumenter side, for example, ' +\n\t\t'by setting `--config-id` or specifying single options via `--collector-option`. ' +\n\t\t'The following parameters are supposed to take effect if the application ' +\n\t\t'is instrumented with the `--coverage-target-from-collector` flag.'\n};\n\nconst CONFIG_GROUP_COVERAGE_DUMP: ParameterGroup = {\n\torder: 3,\n\ttitle: 'Coverage Dumping'\n};\n\nconst CONFIG_GROUP_ARTIFACTORY_UPLOAD: ParameterGroup = {\n\torder: 4,\n\ttitle: 'Upload to Artifactory'\n};\n\nconst CONFIG_GROUP_LOGGING: ParameterGroup = {\n\torder: 5,\n\ttitle: 'Logging Behavior'\n};\n\n/**\n * Build the collector parameters that can be overwritten by instrumented apps.\n */\nexport function buildPredefinableParameters(): ConfigurationParameters {\n\tconst parameters = new ConfigurationParameters();\n\n\tfunction add(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType,\n\t\t\t\t\t options: ParameterDefinitionOptions): void {\n\t\tparameters.addParameter(shortParameter, longParameter, type, options)\n\t}\n\n\tadd('-k', '--keep-coverage-files', 'bool', {\n\t\thelp: 'Whether to keep the coverage files on disk after a successful upload to Teamscale.',\n\t\tdefault: false,\n\t\tgroup: CONFIG_GROUP_COVERAGE_DUMP\n\t});\n\tadd('-t', '--dump-after-mins', 'int', {\n\t\thelp: 'Dump the coverage information every N minutes.',\n\t\tdefault: 120,\n\t\tgroup: CONFIG_GROUP_COVERAGE_DUMP\n\t});\n\n\t// Artifactory upload\n\tadd(undefined, '--artifactory-server-url', 'string', {\n\t\thelp: 'Upload the coverage to the given Artifactory server URL. The URL may include a subpath on the artifactory server, e.g. https://artifactory.acme.com/my-repo/my/subpath',\n\t\tgroup: CONFIG_GROUP_ARTIFACTORY_UPLOAD\n\t});\n\tadd(undefined, '--artifactory-user', 'string', {\n\t\thelp: 'The user for uploading coverage to Artifactory. Only needed when not using the --artifactory-access-token option',\n\t\tgroup: CONFIG_GROUP_ARTIFACTORY_UPLOAD\n\t});\n\tadd(undefined, '--artifactory-password', 'string', {\n\t\thelp: 'The password for uploading coverage to Artifactory. Only needed when not using the --artifactory-access-token option',\n\t\tgroup: CONFIG_GROUP_ARTIFACTORY_UPLOAD\n\t});\n\tadd(undefined, '--artifactory-access-token', 'string', {\n\t\thelp: 'The access_token for uploading coverage to Artifactory.',\n\t\tgroup: CONFIG_GROUP_ARTIFACTORY_UPLOAD\n\t});\n\tadd(undefined, '--artifactory-path-suffix', 'string', {\n\t\thelp: '(optional): The path within the storage location between the default path and the uploaded artifact.',\n\t\tgroup: CONFIG_GROUP_ARTIFACTORY_UPLOAD\n\t});\n\n\t// Upload to Teamscale\n\tadd(undefined, '--teamscale-project', 'string', {\n\t\thelp: 'The project ID to upload coverage to.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_UPLOAD\n\t});\n\tadd(undefined, '--teamscale-partition', 'string', {\n\t\thelp: 'The partition to upload coverage to.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_UPLOAD\n\t});\n\tadd(undefined, '--teamscale-repository', 'string', {\n\t\thelp: 'The repository to upload coverage for. Optional: Only needed when uploading via revision to a project that has more than one connector.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_UPLOAD\n\t});\n\tadd(undefined, '--teamscale-message', 'string', {\n\t\thelp: 'The commit message shown within Teamscale for the coverage upload.',\n\t\tdefault: 'JavaScript coverage upload',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_UPLOAD\n\t});\n\n\treturn parameters;\n}\n\n/**\n * Builds and returns the configuration parameters for the collector.\n * This includes all available command line arguments and their default values.\n *\n * @returns {ConfigurationParameters} Configuration parameters instance with all defined options\n */\nexport function buildStaticCollectorParameters(): ConfigurationParameters {\n\tconst parameters = buildPredefinableParameters();\n\n\tfunction add(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType,\n\t\t\t\t options: ParameterDefinitionOptions): void {\n\t\tparameters.addParameter(shortParameter, longParameter, type, options)\n\t}\n\n\tadd('-p', '--port', 'int', { help: 'The port to receive coverage information on.',\n\t\tdefault: 54678, group: CONFIG_GROUP_COLLECTOR_CONNECTIVITY, disableEnvironmentVariableOverride: true });\n\tadd('-l', '--log-to-file', 'string', { help: 'Log file', default: 'logs/collector-combined.log', group: CONFIG_GROUP_LOGGING,\n\t\tdisableEnvironmentVariableOverride: true});\n\tadd('-e', '--log-level', 'string', { help: 'Log level',\n\t\tdefault: 'info', group: CONFIG_GROUP_LOGGING, disableEnvironmentVariableOverride: true });\n\tadd('-j', '--json-log', 'bool', { help: 'Additional JSON-like log file format.',\n\t\tgroup: CONFIG_GROUP_LOGGING, disableEnvironmentVariableOverride: true });\n\tadd('-c', '--enable-control-port', 'int', {\n\t\thelp: 'Enables the remote control API on the specified port (<=0 means \"disabled\").',\n\t\tdefault: 0, group: CONFIG_GROUP_COLLECTOR_CONNECTIVITY });\n\tadd('-s', '--teamscale-server-url', 'string', {\n\t\thelp: 'Upload the coverage to the given Teamscale server URL, for example, https://teamscale.dev.example.com:8080/production.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_SERVER\n\t});\n\tadd('-u', '--teamscale-user', 'string', {\n\t\thelp: 'The user for uploading coverage to Teamscale.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_SERVER\n\t});\n\tadd('-a', '--teamscale-access-token', 'string', {\n\t\thelp: 'The API key to use for uploading to Teamscale.',\n\t\tgroup: CONFIG_GROUP_TEAMSCALE_SERVER\n\t});\n\tadd(undefined, '--http-proxy', 'string', {\n\t\thelp: '(optional): The HTTP/HTTPS proxy address that should be used in the format: http://host:port/ or http://username:password@host:port/.',\n\t\tgroup: CONFIG_GROUP_COLLECTOR_CONNECTIVITY,\n\t});\n\tadd('-f', '--dump-folder', 'string', {\n\t\thelp: 'Target folder for coverage files.',\n\t\tdefault: './coverage',\n\t\tgroup: CONFIG_GROUP_COVERAGE_DUMP\n\t});\n\n\tparameters.addArgumentCheck((options: Partial<StaticCollectorOptions>) => {\n\t\tif (options.teamscaleServerUrl){\n\t\t\tif (!options.teamscaleUser || !options.teamscaleAccessToken) {\n\t\t\t\treturn 'The Teamscale user name and access token must be given if the Teamscale server URL is given.';\n\t\t\t}\n\t\t}\n\t});\n\n\treturn parameters;\n}\n\n/**\n * Builds and returns the during run-time reconfigurable configuration parameters for the collector.\n */\nexport function buildReconfigurableCollectorParameters(): ConfigurationParameters {\n\tconst parameters = buildPredefinableParameters();\n\n\tfunction addShort(shortParameter: string | undefined, longParameter: string, type: ConfigParameterType,\n\t\t\t\t\t options: ArgumentOptions): void {\n\t\tparameters.addParameter(shortParameter, longParameter, type, options)\n\t}\n\n\tfunction add(longArgument: string, type: ConfigParameterType, options: ParameterDefinitionOptions): void {\n\t\taddShort(undefined, longArgument, type, options);\n\t}\n\n\t// Coverage dumping\n\tadd('--dump-to-folder', 'string', {\n\t\thelp: 'Coverage should be dumped to a folder on the server that the collector is running on.\\n' +\n\t\t\t'Specifies the name of the subfolder within the collector\\'s dump folder (--dump-folder of the collector) where coverage files should be placed.',\n\t\tgroup: CONFIG_GROUP_COVERAGE_DUMP\n\t});\n\n\treturn parameters;\n}\n","/**\n * Checks if the given string describes a commit in a valid fashion.\n */\nexport function isValidCommitInfo(commit?: unknown): boolean {\n\tif (typeof commit === 'string') {\n\t\tif (/^[a-zA-Z0-9_-]+:([0-9]+|HEAD|head)$/.test(commit)) {\n\t\t\t// Branch name with a timestamp\n\t\t\treturn true;\n\t\t}\n\n\t\tif (/^[0-9]+$/.test(commit)) {\n\t\t\t// Timestamps must always be combined with a branch name;\n\t\t\t// Git hashes consisting of only digits are very very unlikely.\n\t\t\treturn false;\n\t\t}\n\n\t\tif (/^[a-zA-Z0-9]{7,40}$/.test(commit)) {\n\t\t\t// A Git commit hash\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false;\n}"],"mappings":";;;;;;;;;;AAMA,IAAa,uBAAb,cAA0C,MAAM;CAG/C,YAAY,gBAAyB;AACpC,QAAM,gBAAgB;AACtB,OAAK,kBAAkB;;CAGxB,IAAI,UAAkB;AACrB,MAAI,KAAK,gBACR,QAAO,qBAAqB,KAAK;MAEjC,QAAO;;;;;;AAQV,IAAa,wBAAb,cAA2C,MAAM;;;;AAKjD,IAAa,2BAAb,cAA8C,MAAM;;;;AAKpD,IAAa,gCAAb,cAAmD,MAAM;;;;;;;AC1BzD,IAAa,WAAb,MAAsB;;;;;;;CAOrB,OAAc,QAAQ,WAAoB,SAAwB;AACjE,MAAI,CAAC,UACJ,OAAM,IAAI,yBAAyB,QAAQ;;;;;;;;CAU7C,OAAc,eAAkB,KAAkB,SAAqB;AACtE,MAAI,IACH,QAAO;AAGR,MAAI,OAAO,QAAQ,YAAY,OAAO,QAAQ,UAC7C,QAAO;AAGR,MAAI,OAAO,QAAQ,YAAY,eAAe,OAE7C,QAAO;AAGR,MAAI,QACH,OAAM,IAAI,yBAAyB,QAAQ;MAE3C,OAAM,IAAI,yBAAyB,6BAA6B;;;;;;;;CAUlE,OAAc,gBAAgB,MAAc,SAA0B;AACrE,OAAK,eAAe,KAAK;AACzB,MAAI,KAAK,WAAW,EACnB,OAAM,IAAI,yBAAyB,Q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