@shware/http 0.2.25 → 0.2.26
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/index.cjs +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -1
- package/dist/utils/timing.cjs +74 -0
- package/dist/utils/timing.cjs.map +1 -0
- package/dist/utils/timing.d.cts +13 -0
- package/dist/utils/timing.d.ts +13 -0
- package/dist/utils/timing.mjs +49 -0
- package/dist/utils/timing.mjs.map +1 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22,6 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
24
|
hasText: () => import_string.hasText,
|
|
25
|
+
timing: () => import_timing.timing,
|
|
25
26
|
verifyStandardWebhook: () => import_webhook.verifyStandardWebhook
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(index_exports);
|
|
@@ -31,10 +32,12 @@ __reExport(index_exports, require("./vaild.cjs"), module.exports);
|
|
|
31
32
|
__reExport(index_exports, require("./snowflake.cjs"), module.exports);
|
|
32
33
|
__reExport(index_exports, require("./response.cjs"), module.exports);
|
|
33
34
|
var import_string = require("./utils/string.cjs");
|
|
35
|
+
var import_timing = require("./utils/timing.cjs");
|
|
34
36
|
var import_webhook = require("./webhook.cjs");
|
|
35
37
|
// Annotate the CommonJS export names for ESM import in node:
|
|
36
38
|
0 && (module.exports = {
|
|
37
39
|
hasText,
|
|
40
|
+
timing,
|
|
38
41
|
verifyStandardWebhook,
|
|
39
42
|
...require("./detail.cjs"),
|
|
40
43
|
...require("./status.cjs"),
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { verifyStandardWebhook } from './webhook';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,0BAAc,yBAvBd;AAwBA,0BAAc,yBAxBd;AAyBA,0BAAc,wBAzBd;AA0BA,0BAAc,4BA1Bd;AA2BA,0BAAc,2BA3Bd;AA4BA,oBAAwB;AACxB,qBAAsC;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBA,0BAAc,yBAvBd;AAwBA,0BAAc,yBAxBd;AAyBA,0BAAc,wBAzBd;AA0BA,0BAAc,4BA1Bd;AA2BA,0BAAc,2BA3Bd;AA4BA,oBAAwB;AACxB,oBAAuB;AACvB,qBAAsC;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -5,5 +5,6 @@ export { Result, valid } from './vaild.cjs';
|
|
|
5
5
|
export { UidGenerator, uid } from './snowflake.cjs';
|
|
6
6
|
export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, PageParams, PagedResponse, ParentPageParams, PrevParams, Response, pageParamsSchema } from './response.cjs';
|
|
7
7
|
export { hasText } from './utils/string.cjs';
|
|
8
|
+
export { timing } from './utils/timing.cjs';
|
|
8
9
|
export { verifyStandardWebhook } from './webhook.cjs';
|
|
9
10
|
import 'zod';
|
package/dist/index.d.ts
CHANGED
|
@@ -5,5 +5,6 @@ export { Result, valid } from './vaild.js';
|
|
|
5
5
|
export { UidGenerator, uid } from './snowflake.js';
|
|
6
6
|
export { Cursor, Empty, Entity, EntityId, InitParams, NextParams, PageParams, PagedResponse, ParentPageParams, PrevParams, Response, pageParamsSchema } from './response.js';
|
|
7
7
|
export { hasText } from './utils/string.js';
|
|
8
|
+
export { timing } from './utils/timing.js';
|
|
8
9
|
export { verifyStandardWebhook } from './webhook.js';
|
|
9
10
|
import 'zod';
|
package/dist/index.mjs
CHANGED
|
@@ -5,9 +5,11 @@ export * from "./vaild.mjs";
|
|
|
5
5
|
export * from "./snowflake.mjs";
|
|
6
6
|
export * from "./response.mjs";
|
|
7
7
|
import { hasText } from "./utils/string.mjs";
|
|
8
|
+
import { timing } from "./utils/timing.mjs";
|
|
8
9
|
import { verifyStandardWebhook } from "./webhook.mjs";
|
|
9
10
|
export {
|
|
10
11
|
hasText,
|
|
12
|
+
timing,
|
|
11
13
|
verifyStandardWebhook
|
|
12
14
|
};
|
|
13
15
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { verifyStandardWebhook } from './webhook';\n"],"mappings":";AAuBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe;AACxB,SAAS,6BAA6B;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * @example\n * import { Details, Status } from '@repo/error';\n *\n * Status.adapter = () => new Error('Error');\n *\n * const details = Details.new()\n * .requestInfo({ requestId: '1234567890', servingData: '/v1/tests' })\n * .errorInfo({ reason: 'ACCOUNT_LOCKED' });\n *\n * throw Status.alreadyExists('xxx').error(details);\n */\n\nexport type {\n NetworkErrorReason,\n StatusErrorReason,\n AuthenticationErrorReason,\n ModerationErrorReason,\n MultipartErrorReason,\n AppErrorReason,\n ErrorReason,\n} from './reason';\n\nexport * from './detail';\nexport * from './status';\nexport * from './vaild';\nexport * from './snowflake';\nexport * from './response';\nexport { hasText } from './utils/string';\nexport { timing } from './utils/timing';\nexport { verifyStandardWebhook } from './webhook';\n"],"mappings":";AAuBA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,SAAS,eAAe;AACxB,SAAS,cAAc;AACvB,SAAS,6BAA6B;","names":[]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/utils/timing.ts
|
|
21
|
+
var timing_exports = {};
|
|
22
|
+
__export(timing_exports, {
|
|
23
|
+
timing: () => timing
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(timing_exports);
|
|
26
|
+
function timing(options = { enabled: true }) {
|
|
27
|
+
const { enabled = true, crossOrigin } = options;
|
|
28
|
+
let start = performance.now();
|
|
29
|
+
const headers = [];
|
|
30
|
+
const timers = /* @__PURE__ */ new Map();
|
|
31
|
+
return {
|
|
32
|
+
startTime: (name, description) => {
|
|
33
|
+
timers.set(name, { description, start: performance.now() });
|
|
34
|
+
},
|
|
35
|
+
endTime: (name, precision) => {
|
|
36
|
+
const timer = timers.get(name);
|
|
37
|
+
if (!timer) {
|
|
38
|
+
console.warn(`timing: ${name} not found`);
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const { start: start2, description } = timer;
|
|
42
|
+
const dur = (performance.now() - start2).toFixed(precision ?? 1);
|
|
43
|
+
timers.delete(name);
|
|
44
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
45
|
+
headers.push(metric);
|
|
46
|
+
},
|
|
47
|
+
mark: (name, description, precision) => {
|
|
48
|
+
const dur = (performance.now() - start).toFixed(precision ?? 1);
|
|
49
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
50
|
+
headers.push(metric);
|
|
51
|
+
start = performance.now();
|
|
52
|
+
},
|
|
53
|
+
setMetric: (name, value, description, precision) => {
|
|
54
|
+
if (typeof value === "number") {
|
|
55
|
+
const dur = value.toFixed(precision ?? 1);
|
|
56
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
57
|
+
headers.push(metric);
|
|
58
|
+
} else {
|
|
59
|
+
const metric = value ? `${name};desc="${value}"` : `${name}`;
|
|
60
|
+
headers.push(metric);
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
setTiming: (response) => {
|
|
64
|
+
if (!enabled) return;
|
|
65
|
+
response.headers.append("Server-Timing", headers.join(","));
|
|
66
|
+
response.headers.append("Timing-Allow-Origin", crossOrigin ?? "*");
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
71
|
+
0 && (module.exports = {
|
|
72
|
+
timing
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=timing.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/timing.ts"],"sourcesContent":["interface Timer {\n description?: string;\n start: number;\n}\n\nexport interface Options {\n enabled: boolean;\n crossOrigin?: string;\n}\n\nexport function timing(options: Options = { enabled: true }) {\n const { enabled = true, crossOrigin } = options;\n let start = performance.now();\n const headers: string[] = [];\n const timers = new Map<string, Timer>();\n\n return {\n startTime: (name: Lowercase<string>, description?: string) => {\n timers.set(name, { description, start: performance.now() });\n },\n endTime: (name: Lowercase<string>, precision?: number) => {\n const timer = timers.get(name);\n if (!timer) {\n console.warn(`timing: ${name} not found`);\n return;\n }\n const { start, description } = timer;\n const dur = (performance.now() - start).toFixed(precision ?? 1);\n timers.delete(name);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n },\n mark: (name: Lowercase<string>, description?: string, precision?: number) => {\n const dur = (performance.now() - start).toFixed(precision ?? 1);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n start = performance.now();\n },\n setMetric: (\n name: Lowercase<string>,\n value: number | string | undefined,\n description?: string,\n precision?: number\n ) => {\n if (typeof value === 'number') {\n const dur = value.toFixed(precision ?? 1);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n } else {\n const metric = value ? `${name};desc=\"${value}\"` : `${name}`;\n headers.push(metric);\n }\n },\n setTiming: (response: Response) => {\n if (!enabled) return;\n response.headers.append('Server-Timing', headers.join(','));\n response.headers.append('Timing-Allow-Origin', crossOrigin ?? '*');\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,SAAS,OAAO,UAAmB,EAAE,SAAS,KAAK,GAAG;AAC3D,QAAM,EAAE,UAAU,MAAM,YAAY,IAAI;AACxC,MAAI,QAAQ,YAAY,IAAI;AAC5B,QAAM,UAAoB,CAAC;AAC3B,QAAM,SAAS,oBAAI,IAAmB;AAEtC,SAAO;AAAA,IACL,WAAW,CAAC,MAAyB,gBAAyB;AAC5D,aAAO,IAAI,MAAM,EAAE,aAAa,OAAO,YAAY,IAAI,EAAE,CAAC;AAAA,IAC5D;AAAA,IACA,SAAS,CAAC,MAAyB,cAAuB;AACxD,YAAM,QAAQ,OAAO,IAAI,IAAI;AAC7B,UAAI,CAAC,OAAO;AACV,gBAAQ,KAAK,WAAW,IAAI,YAAY;AACxC;AAAA,MACF;AAC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+
startTime: (name: Lowercase<string>, description?: string) => void;
|
|
7
|
+
endTime: (name: Lowercase<string>, precision?: number) => void;
|
|
8
|
+
mark: (name: Lowercase<string>, description?: string, precision?: number) => void;
|
|
9
|
+
setMetric: (name: Lowercase<string>, value: number | string | undefined, description?: string, precision?: number) => void;
|
|
10
|
+
setTiming: (response: Response) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { type Options, timing };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface Options {
|
|
2
|
+
enabled: boolean;
|
|
3
|
+
crossOrigin?: string;
|
|
4
|
+
}
|
|
5
|
+
declare function timing(options?: Options): {
|
|
6
|
+
startTime: (name: Lowercase<string>, description?: string) => void;
|
|
7
|
+
endTime: (name: Lowercase<string>, precision?: number) => void;
|
|
8
|
+
mark: (name: Lowercase<string>, description?: string, precision?: number) => void;
|
|
9
|
+
setMetric: (name: Lowercase<string>, value: number | string | undefined, description?: string, precision?: number) => void;
|
|
10
|
+
setTiming: (response: Response) => void;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export { type Options, timing };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/utils/timing.ts
|
|
2
|
+
function timing(options = { enabled: true }) {
|
|
3
|
+
const { enabled = true, crossOrigin } = options;
|
|
4
|
+
let start = performance.now();
|
|
5
|
+
const headers = [];
|
|
6
|
+
const timers = /* @__PURE__ */ new Map();
|
|
7
|
+
return {
|
|
8
|
+
startTime: (name, description) => {
|
|
9
|
+
timers.set(name, { description, start: performance.now() });
|
|
10
|
+
},
|
|
11
|
+
endTime: (name, precision) => {
|
|
12
|
+
const timer = timers.get(name);
|
|
13
|
+
if (!timer) {
|
|
14
|
+
console.warn(`timing: ${name} not found`);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const { start: start2, description } = timer;
|
|
18
|
+
const dur = (performance.now() - start2).toFixed(precision ?? 1);
|
|
19
|
+
timers.delete(name);
|
|
20
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
21
|
+
headers.push(metric);
|
|
22
|
+
},
|
|
23
|
+
mark: (name, description, precision) => {
|
|
24
|
+
const dur = (performance.now() - start).toFixed(precision ?? 1);
|
|
25
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
26
|
+
headers.push(metric);
|
|
27
|
+
start = performance.now();
|
|
28
|
+
},
|
|
29
|
+
setMetric: (name, value, description, precision) => {
|
|
30
|
+
if (typeof value === "number") {
|
|
31
|
+
const dur = value.toFixed(precision ?? 1);
|
|
32
|
+
const metric = description ? `${name};dur=${dur};desc="${description}"` : `${name};dur=${dur}`;
|
|
33
|
+
headers.push(metric);
|
|
34
|
+
} else {
|
|
35
|
+
const metric = value ? `${name};desc="${value}"` : `${name}`;
|
|
36
|
+
headers.push(metric);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setTiming: (response) => {
|
|
40
|
+
if (!enabled) return;
|
|
41
|
+
response.headers.append("Server-Timing", headers.join(","));
|
|
42
|
+
response.headers.append("Timing-Allow-Origin", crossOrigin ?? "*");
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
timing
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=timing.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/timing.ts"],"sourcesContent":["interface Timer {\n description?: string;\n start: number;\n}\n\nexport interface Options {\n enabled: boolean;\n crossOrigin?: string;\n}\n\nexport function timing(options: Options = { enabled: true }) {\n const { enabled = true, crossOrigin } = options;\n let start = performance.now();\n const headers: string[] = [];\n const timers = new Map<string, Timer>();\n\n return {\n startTime: (name: Lowercase<string>, description?: string) => {\n timers.set(name, { description, start: performance.now() });\n },\n endTime: (name: Lowercase<string>, precision?: number) => {\n const timer = timers.get(name);\n if (!timer) {\n console.warn(`timing: ${name} not found`);\n return;\n }\n const { start, description } = timer;\n const dur = (performance.now() - start).toFixed(precision ?? 1);\n timers.delete(name);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n },\n mark: (name: Lowercase<string>, description?: string, precision?: number) => {\n const dur = (performance.now() - start).toFixed(precision ?? 1);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n start = performance.now();\n },\n setMetric: (\n name: Lowercase<string>,\n value: number | string | undefined,\n description?: string,\n precision?: number\n ) => {\n if (typeof value === 'number') {\n const dur = value.toFixed(precision ?? 1);\n const metric = description\n ? `${name};dur=${dur};desc=\"${description}\"`\n : `${name};dur=${dur}`;\n headers.push(metric);\n } else {\n const metric = value ? `${name};desc=\"${value}\"` : `${name}`;\n headers.push(metric);\n }\n },\n setTiming: (response: Response) => {\n if (!enabled) return;\n response.headers.append('Server-Timing', headers.join(','));\n response.headers.append('Timing-Allow-Origin', crossOrigin ?? '*');\n },\n };\n}\n"],"mappings":";AAUO,SAAS,OAAO,UAAmB,EAAE,SAAS,KAAK,GAAG;AAC3D,QAAM,EAAE,UAAU,MAAM,YAAY,IAAI;AACxC,MAAI,QAAQ,YAAY,IAAI;AAC5B,QAAM,UAAoB,CAAC;AAC3B,QAAM,SAAS,oBAAI,IAAmB;AAEtC,SAAO;AAAA,IACL,WAAW,CAAC,MAAyB,gBAAyB;AAC5D,aAAO,IAAI,MAAM,EAAE,aAAa,OAAO,YAAY,IAAI,EAAE,CAAC;AAAA,IAC5D;AAAA,IACA,SAAS,CAAC,MAAyB,cAAuB;AACxD,YAAM,QAAQ,OAAO,IAAI,IAAI;AAC7B,UAAI,CAAC,OAAO;AACV,gBAAQ,KAAK,WAAW,IAAI,YAAY;AACxC;AAAA,MACF;AACA,YAAM,EAAE,OAAAA,QAAO,YAAY,IAAI;AAC/B,YAAM,OAAO,YAAY,IAAI,IAAIA,QAAO,QAAQ,aAAa,CAAC;AAC9D,aAA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