@webex/ladon-ts 5.5.0 → 5.6.0
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/CHANGELOG.md +14 -0
- package/build/module/lib/config-builder.js +1 -1
- package/build/module/lib/config-builder.js.map +1 -1
- package/build/module/lib/generator-types.d.ts +9 -1
- package/build/module/lib/pipeline.d.ts +3 -2
- package/build/module/lib/pipeline.js +15 -14
- package/build/module/lib/pipeline.js.map +1 -1
- package/build/module/lib/renderer/blur-renderer.js +21 -21
- package/build/module/lib/renderer/blur-renderer.js.map +1 -1
- package/build/module/lib/renderer/replacement-renderer.js +2 -2
- package/build/module/lib/renderer/replacement-renderer.js.map +1 -1
- package/build/module/lib/renderer/webgl-renderer.js +7 -7
- package/build/module/lib/renderer/webgl-renderer.js.map +1 -1
- package/build/module/lib/util.js +14 -14
- package/build/module/lib/util.js.map +1 -1
- package/build/module/lib/version.d.ts +1 -1
- package/build/module/lib/version.js +1 -1
- package/build/module/lib/version.js.map +1 -1
- package/build/module/lib/worker-generator.d.ts +26 -5
- package/build/module/lib/worker-generator.js +62 -58
- package/build/module/lib/worker-generator.js.map +1 -1
- package/build/module/lib/worker-manager.d.ts +60 -3
- package/build/module/lib/worker-manager.js +113 -27
- package/build/module/lib/worker-manager.js.map +1 -1
- package/build/worker/segmentation.js +253 -253
- package/build/worker/segmentation.js.map +1 -1
- package/package.json +2 -1
|
@@ -1,22 +1,58 @@
|
|
|
1
|
-
import { resourceLoader as
|
|
2
|
-
class
|
|
1
|
+
import { resourceLoader as a } from "./resource-loader.js";
|
|
2
|
+
class l {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.destroyPromise = null, this.onInitializedCallbacks = [], this.onGeneratedCallbacks = [], this.onLogCallbacks = [];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Get the current worker instance.
|
|
8
|
+
*
|
|
9
|
+
* @returns The current worker instance or undefined if not initialized.
|
|
10
|
+
*/
|
|
11
|
+
getWorker() {
|
|
12
|
+
return this.worker;
|
|
13
|
+
}
|
|
3
14
|
/**
|
|
4
15
|
* Initialize the worker using the provided configuration.
|
|
5
16
|
*
|
|
6
17
|
* @param config - The configuration object.
|
|
7
18
|
* @returns A promise that resolves when the worker is initialized.
|
|
8
19
|
*/
|
|
9
|
-
async initializeWorker(
|
|
20
|
+
async initializeWorker(e) {
|
|
10
21
|
if (typeof Worker > "u")
|
|
11
22
|
throw new Error("[ladon-ts] web workers are not supported in this environment");
|
|
12
|
-
|
|
13
|
-
|
|
23
|
+
this.destroyPromise && (await this.destroyPromise, this.destroyPromise = null), this.worker && (this.destroyPromise = this.destroyWorker(), await this.destroyPromise, this.destroyPromise = null);
|
|
24
|
+
const r = await a.resolveUri(e, e.mask.workerUri), o = await (await fetch(r, { cache: "force-cache" })).text();
|
|
25
|
+
return this.workerUrl = URL.createObjectURL(new Blob([o], { type: "text/javascript" })), this.worker = new Worker(this.workerUrl, { type: "module" }), this.worker.addEventListener("message", (i) => {
|
|
26
|
+
if (i.data.type === "log") {
|
|
27
|
+
const { message: t, severity: n } = i.data;
|
|
28
|
+
this.onLogCallbacks.forEach((k) => k(t, n));
|
|
29
|
+
} else i.data.status === "generated" ? this.onGeneratedCallbacks.forEach((t) => t(i.data)) : i.data.status === "initialized" && this.onInitializedCallbacks.forEach((t) => t());
|
|
30
|
+
}), this.worker;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Destroys the worker gracefully by sending a destroy message and waiting for confirmation.
|
|
34
|
+
*
|
|
35
|
+
* @returns A promise that resolves when the worker is destroyed.
|
|
36
|
+
* If no worker is available, it resolves immediately.
|
|
37
|
+
*/
|
|
38
|
+
destroyWorker() {
|
|
39
|
+
return new Promise((e) => {
|
|
40
|
+
const r = (s) => {
|
|
41
|
+
var o;
|
|
42
|
+
s.data.status === "destroyed" && ((o = this.worker) == null || o.removeEventListener("message", r), this.terminateWorker(), e());
|
|
43
|
+
};
|
|
44
|
+
if (!this.worker) {
|
|
45
|
+
console.warn("[ladon-ts] No worker to destroy"), e();
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.worker.addEventListener("message", r), this.worker.postMessage({ type: "destroy" });
|
|
49
|
+
});
|
|
14
50
|
}
|
|
15
51
|
/**
|
|
16
52
|
* Terminate the worker.
|
|
17
53
|
*/
|
|
18
54
|
terminateWorker() {
|
|
19
|
-
this.worker && (this.worker.terminate(), this.worker = void 0);
|
|
55
|
+
this.worker && (this.worker.terminate(), this.worker = void 0), this.workerUrl && (URL.revokeObjectURL(this.workerUrl), this.workerUrl = void 0);
|
|
20
56
|
}
|
|
21
57
|
/**
|
|
22
58
|
* Preload the worker using the provided configuration.
|
|
@@ -24,15 +60,9 @@ class i {
|
|
|
24
60
|
* @param config - The configuration object.
|
|
25
61
|
* @returns A promise that resolves when the worker is preloaded.
|
|
26
62
|
*/
|
|
27
|
-
async preloadWorker(
|
|
28
|
-
const
|
|
29
|
-
this.worker = await this.initializeWorker(
|
|
30
|
-
}
|
|
31
|
-
getWorker() {
|
|
32
|
-
return this.worker;
|
|
33
|
-
}
|
|
34
|
-
getWorkerUrl() {
|
|
35
|
-
return this.workerUrl;
|
|
63
|
+
async preloadWorker(e) {
|
|
64
|
+
const r = await this.prepareWorkerConfig(e);
|
|
65
|
+
this.worker = await this.initializeWorker(r), this.worker.postMessage({ type: "preload", config: r });
|
|
36
66
|
}
|
|
37
67
|
/**
|
|
38
68
|
* Prepare the worker configuration by resolving the final URLs and paths to send to the
|
|
@@ -42,22 +72,78 @@ class i {
|
|
|
42
72
|
* @param config - The preload configuration.
|
|
43
73
|
* @returns The worker configuration.
|
|
44
74
|
*/
|
|
45
|
-
async prepareWorkerConfig(
|
|
46
|
-
const t = { ...{
|
|
47
|
-
...
|
|
48
|
-
mask: {
|
|
49
|
-
|
|
50
|
-
modelUri: await o.resolveUri(r, r.mask.modelUri),
|
|
51
|
-
workerUri: await o.resolveUri(r, r.mask.workerUri)
|
|
52
|
-
},
|
|
53
|
-
wasmUri: await o.resolveUri(r, r.wasmUri)
|
|
75
|
+
async prepareWorkerConfig(e) {
|
|
76
|
+
const r = await a.resolveUri(e, e.mask.modelUri), s = await a.resolveUri(e, e.mask.workerUri), o = await a.resolveUri(e, e.wasmUri), t = { ...{
|
|
77
|
+
...e,
|
|
78
|
+
mask: { ...e.mask, modelUri: r, workerUri: s },
|
|
79
|
+
wasmUri: o
|
|
54
80
|
}, assetUrlResolver: void 0 };
|
|
55
81
|
return JSON.parse(JSON.stringify(t));
|
|
56
82
|
}
|
|
83
|
+
/**
|
|
84
|
+
* Register a callback for when the worker is initialized.
|
|
85
|
+
*/
|
|
86
|
+
onInitialized(e) {
|
|
87
|
+
this.onInitializedCallbacks.push(e);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Register a callback for when the worker generates output.
|
|
91
|
+
*
|
|
92
|
+
* @param callback - The callback function to be called with the generated data.
|
|
93
|
+
* @param data - The generated data from the worker.
|
|
94
|
+
* @param data.mask - The generated mask.
|
|
95
|
+
* @param data.facesAndLandmarks - The detected faces and landmarks.
|
|
96
|
+
* @param data.gesture - The detected gesture.
|
|
97
|
+
* @param data.motion - The detected motion.
|
|
98
|
+
*/
|
|
99
|
+
onGenerated(e) {
|
|
100
|
+
this.onGeneratedCallbacks.push(e);
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Register a callback for log messages from the worker.
|
|
104
|
+
*
|
|
105
|
+
* @param callback - The callback function to be called with the log message and severity.
|
|
106
|
+
* @param severity - The severity of the log message (e.g., 'info', 'warn', 'error').
|
|
107
|
+
*/
|
|
108
|
+
onLog(e) {
|
|
109
|
+
this.onLogCallbacks.push(e);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Send an init message to the worker.
|
|
113
|
+
*
|
|
114
|
+
* @param config - The configuration object to initialize the worker.
|
|
115
|
+
* @param config.baseUrl - The base URL for loading assets.
|
|
116
|
+
* @param config.input - The input configuration for the worker.
|
|
117
|
+
* @param config.mask - The mask configuration for the worker.
|
|
118
|
+
* @param config.wasmUri - The URI for the WebAssembly module.
|
|
119
|
+
* @param config.workerUri - The URI for the worker script.
|
|
120
|
+
* @param config.assetUrlResolver - The function to resolve asset URLs.
|
|
121
|
+
*/
|
|
122
|
+
sendInit(e) {
|
|
123
|
+
var r;
|
|
124
|
+
(r = this.worker) == null || r.postMessage({ type: "init", config: e });
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Send a generate message to the worker.
|
|
128
|
+
*
|
|
129
|
+
* @param input - The input image data as a Uint8ClampedArray.
|
|
130
|
+
* @param timestamp - The timestamp of the input image.
|
|
131
|
+
*/
|
|
132
|
+
sendGenerate(e, r) {
|
|
133
|
+
var s;
|
|
134
|
+
(s = this.worker) == null || s.postMessage(
|
|
135
|
+
{
|
|
136
|
+
type: "generate",
|
|
137
|
+
image: e,
|
|
138
|
+
timestamp: r
|
|
139
|
+
},
|
|
140
|
+
[e.buffer]
|
|
141
|
+
);
|
|
142
|
+
}
|
|
57
143
|
}
|
|
58
|
-
const
|
|
144
|
+
const w = new l();
|
|
59
145
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
146
|
+
l as WorkerManager,
|
|
147
|
+
w as workerManager
|
|
62
148
|
};
|
|
63
149
|
//# sourceMappingURL=worker-manager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-manager.js","sources":["../../../src/lib/worker-manager.ts"],"sourcesContent":["import { PreloadConfig, WorkerConfig } from './config-types';\nimport { resourceLoader } from './resource-loader';\n\n/**\n * Worker manager class to handle the initialization and termination of the segmenation\n * web worker. This class is responsible for loading the worker script, resolving the\n * configuration, and managing the worker lifecycle. It also provides methods to\n * preload the worker and terminate it when no longer needed.\n */\nexport class WorkerManager {\n private worker?: Worker;\n private workerUrl?: string;\n\n /**\n * Initialize the worker using the provided configuration.\n *\n * @param config - The configuration object.\n * @returns A promise that resolves when the worker is initialized.\n */\n public async initializeWorker(config: WorkerConfig): Promise<Worker> {\n if (typeof Worker === 'undefined') {\n throw new Error('[ladon-ts] web workers are not supported in this environment');\n }\n\n const scriptUri = await resourceLoader.resolveUri(config, config.mask.workerUri);\n const response = await fetch(scriptUri, { cache: 'force-cache' });\n const workerSource = await response.text();\n\n this.workerUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));\n\n return new Worker(this.workerUrl, { type: 'module' });\n }\n\n /**\n * Terminate the worker.\n */\n public terminateWorker() {\n if (this.worker) {\n this.worker.terminate();\n this.worker = undefined;\n }\n }\n\n /**\n * Preload the worker using the provided configuration.\n *\n * @param config - The configuration object.\n * @returns A promise that resolves when the worker is preloaded.\n */\n public async preloadWorker(config: PreloadConfig) {\n const workerConfig = await this.prepareWorkerConfig(config);\n\n this.worker = await this.initializeWorker(workerConfig);\n this.worker.postMessage({ type: 'preload', config: workerConfig });\n }\n\n public getWorker() {\n return this.worker;\n }\n\n public getWorkerUrl() {\n return this.workerUrl;\n }\n\n /**\n * Prepare the worker configuration by resolving the final URLs and paths to send to the\n * worker. This is necessary because we can't send functions to the worker. We also need to\n * remove the assetUrlResolver function from the configuration.\n *\n * @param config - The preload configuration.\n * @returns The worker configuration.\n */\n public async prepareWorkerConfig(config: PreloadConfig) {\n // Resolve and cache the URIs before sending the config to the worker. Future calls to the\n // resolveUri method will use the cache.\n const resolvedConfig: PreloadConfig = {\n ...config,\n mask: {\n ...config.mask,\n modelUri: await resourceLoader.resolveUri(config, config.mask.modelUri),\n workerUri: await resourceLoader.resolveUri(config, config.mask.workerUri),\n },\n wasmUri: await resourceLoader.resolveUri(config, config.wasmUri),\n };\n\n // We can't send the assetUrlResolver function to the worker so we remove it from the config.\n const workerConfig = { ...resolvedConfig, assetUrlResolver: undefined };\n\n // This is a workaround to ensure the worker configuration can be sent to the worker.\n return JSON.parse(JSON.stringify(workerConfig));\n }\n}\n\n// Global instance of the shared resource manager.\nexport const workerManager = new WorkerManager();\n"],"names":["WorkerManager","config","scriptUri","resourceLo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AAA,MACA,SAAS,MAAME,EAAe,WAAWF,GAAQA,EAAO,OAAO;AAAA,IACnE,GAG0C,kBAAkB,OAAU;AAGtE,WAAO,KAAK,MAAM,KAAK,UAAUI,CAAY,CAAC;AAAA,EAAA;AAEtD;AAGa,MAAAC,IAAgB,IAAIN,EAAc;"}
|
|
1
|
+
{"version":3,"file":"worker-manager.js","sources":["../../../src/lib/worker-manager.ts"],"sourcesContent":["import { PipelineConfig, PreloadConfig, WorkerConfig } from './config-types';\nimport { WorkerGeneratedResult } from './generator-types';\nimport { resourceLoader } from './resource-loader';\n\n/**\n * Worker manager class to handle the initialization and termination of the segmenation\n * web worker. This class is responsible for loading the worker script, resolving the\n * configuration, and managing the worker lifecycle. It also provides methods to\n * preload the worker and terminate it when no longer needed.\n */\nexport class WorkerManager {\n private worker?: Worker;\n private workerUrl?: string;\n private destroyPromise: Promise<void> | null = null;\n\n // Event callback registries\n private onInitializedCallbacks: Array<() => void> = [];\n private onGeneratedCallbacks: Array<(data: WorkerGeneratedResult) => void> = [];\n private onLogCallbacks: Array<(message: string, severity: string) => void> = [];\n\n /**\n * Get the current worker instance.\n *\n * @returns The current worker instance or undefined if not initialized.\n */\n public getWorker() {\n return this.worker;\n }\n\n /**\n * Initialize the worker using the provided configuration.\n *\n * @param config - The configuration object.\n * @returns A promise that resolves when the worker is initialized.\n */\n public async initializeWorker(config: WorkerConfig): Promise<Worker> {\n if (typeof Worker === 'undefined') {\n throw new Error('[ladon-ts] web workers are not supported in this environment');\n }\n\n // Wait for any ongoing destroy operation to finish\n if (this.destroyPromise) {\n await this.destroyPromise;\n this.destroyPromise = null;\n }\n\n if (this.worker) {\n this.destroyPromise = this.destroyWorker();\n await this.destroyPromise;\n this.destroyPromise = null;\n }\n\n const scriptUri = await resourceLoader.resolveUri(config, config.mask.workerUri);\n const response = await fetch(scriptUri, { cache: 'force-cache' });\n const workerSource = await response.text();\n\n this.workerUrl = URL.createObjectURL(new Blob([workerSource], { type: 'text/javascript' }));\n this.worker = new Worker(this.workerUrl, { type: 'module' });\n\n // Attach a single message handler for all events\n this.worker.addEventListener('message', (event: MessageEvent) => {\n if (event.data.type === 'log') {\n const { message, severity } = event.data;\n this.onLogCallbacks.forEach((cb) => cb(message, severity));\n } else if (event.data.status === 'generated') {\n this.onGeneratedCallbacks.forEach((cb) => cb(event.data));\n } else if (event.data.status === 'initialized') {\n this.onInitializedCallbacks.forEach((cb) => cb());\n }\n // 'destroyed' is handled in destroyWorker\n });\n\n return this.worker;\n }\n\n /**\n * Destroys the worker gracefully by sending a destroy message and waiting for confirmation.\n *\n * @returns A promise that resolves when the worker is destroyed.\n * If no worker is available, it resolves immediately.\n */\n public destroyWorker(): Promise<void> {\n return new Promise<void>((resolve) => {\n const handleMessage = (event: MessageEvent) => {\n if (event.data.status === 'destroyed') {\n this.worker?.removeEventListener('message', handleMessage);\n this.terminateWorker();\n resolve();\n }\n };\n\n if (!this.worker) {\n console.warn('[ladon-ts] No worker to destroy');\n resolve();\n return;\n }\n\n this.worker.addEventListener('message', handleMessage);\n this.worker.postMessage({ type: 'destroy' });\n });\n }\n\n /**\n * Terminate the worker.\n */\n public terminateWorker() {\n if (this.worker) {\n this.worker.terminate();\n this.worker = undefined;\n }\n if (this.workerUrl) {\n URL.revokeObjectURL(this.workerUrl);\n this.workerUrl = undefined;\n }\n }\n\n /**\n * Preload the worker using the provided configuration.\n *\n * @param config - The configuration object.\n * @returns A promise that resolves when the worker is preloaded.\n */\n public async preloadWorker(config: PreloadConfig) {\n const workerConfig = await this.prepareWorkerConfig(config);\n this.worker = await this.initializeWorker(workerConfig);\n this.worker.postMessage({ type: 'preload', config: workerConfig });\n }\n\n /**\n * Prepare the worker configuration by resolving the final URLs and paths to send to the\n * worker. This is necessary because we can't send functions to the worker. We also need to\n * remove the assetUrlResolver function from the configuration.\n *\n * @param config - The preload configuration.\n * @returns The worker configuration.\n */\n public async prepareWorkerConfig(config: PreloadConfig) {\n // Resolve and cache the URIs before sending the config to the worker.\n // Future calls to the resolveUri method will use the cache.\n const modelUri = await resourceLoader.resolveUri(config, config.mask.modelUri);\n const workerUri = await resourceLoader.resolveUri(config, config.mask.workerUri);\n const wasmUri = await resourceLoader.resolveUri(config, config.wasmUri);\n const resolvedConfig: PreloadConfig = {\n ...config,\n mask: { ...config.mask, modelUri, workerUri },\n wasmUri,\n };\n\n // We can't send the assetUrlResolver function to the worker so we remove it from the config.\n const workerConfig = { ...resolvedConfig, assetUrlResolver: undefined };\n\n // This is a workaround to ensure the worker configuration can be sent to the worker.\n return JSON.parse(JSON.stringify(workerConfig));\n }\n\n /**\n * Register a callback for when the worker is initialized.\n */\n public onInitialized(callback: () => void) {\n this.onInitializedCallbacks.push(callback);\n }\n\n /**\n * Register a callback for when the worker generates output.\n *\n * @param callback - The callback function to be called with the generated data.\n * @param data - The generated data from the worker.\n * @param data.mask - The generated mask.\n * @param data.facesAndLandmarks - The detected faces and landmarks.\n * @param data.gesture - The detected gesture.\n * @param data.motion - The detected motion.\n */\n public onGenerated(callback: (data: WorkerGeneratedResult) => void) {\n this.onGeneratedCallbacks.push(callback);\n }\n\n /**\n * Register a callback for log messages from the worker.\n *\n * @param callback - The callback function to be called with the log message and severity.\n * @param severity - The severity of the log message (e.g., 'info', 'warn', 'error').\n */\n public onLog(callback: (message: string, severity: string) => void) {\n this.onLogCallbacks.push(callback);\n }\n\n /**\n * Send an init message to the worker.\n *\n * @param config - The configuration object to initialize the worker.\n * @param config.baseUrl - The base URL for loading assets.\n * @param config.input - The input configuration for the worker.\n * @param config.mask - The mask configuration for the worker.\n * @param config.wasmUri - The URI for the WebAssembly module.\n * @param config.workerUri - The URI for the worker script.\n * @param config.assetUrlResolver - The function to resolve asset URLs.\n */\n public sendInit(config: PipelineConfig) {\n this.worker?.postMessage({ type: 'init', config });\n }\n\n /**\n * Send a generate message to the worker.\n *\n * @param input - The input image data as a Uint8ClampedArray.\n * @param timestamp - The timestamp of the input image.\n */\n public sendGenerate(input: Uint8ClampedArray, timestamp: number) {\n this.worker?.postMessage(\n {\n type: 'generate',\n image: input,\n timestamp,\n },\n [input.buffer]\n );\n }\n}\n\n// Global instance of the shared resource manager.\nexport const workerManager = new WorkerManager();\n"],"names":["WorkerManager","config","scriptUri","resourceLoader","workerSource","event","message","severity","cb","resolve","handleMessage","_a","workerConfig","modelUri","workerUri","wasmUri","callback","input","timestamp","workerManager"],"mappings":";AAUO,MAAMA,EAAc;AAAA,EAApB,cAAA;AAGH,SAAQ,iBAAuC,MAG/C,KAAQ,yBAA4C,CAAC,GACrD,KAAQ,uBAAqE,CAAC,GAC9E,KAAQ,iBAAqE,CAAC;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOvE,YAAY;AACf,WAAO,KAAK;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAShB,MAAa,iBAAiBC,GAAuC;AAC7D,QAAA,OAAO,SAAW;AACZ,YAAA,IAAI,MAAM,8DAA8D;AAIlF,IAAI,KAAK,mBACL,MAAM,KAAK,gBACX,KAAK,iBAAiB,OAGtB,KAAK,WACA,KAAA,iBAAiB,KAAK,cAAc,GACzC,MAAM,KAAK,gBACX,KAAK,iBAAiB;AAG1B,UAAMC,IAAY,MAAMC,EAAe,WAAWF,GAAQA,EAAO,KAAK,SAAS,GAEzEG,IAAe,OADJ,MAAM,MAAMF,GAAW,EAAE,OAAO,eAAe,GAC5B,KAAK;AAEzC,gBAAK,YAAY,IAAI,gBAAgB,IAAI,KAAK,CAACE,CAAY,GAAG,EAAE,MAAM,kBAAmB,CAAA,CAAC,GACrF,KAAA,SAAS,IAAI,OAAO,KAAK,WAAW,EAAE,MAAM,UAAU,GAG3D,KAAK,OAAO,iBAAiB,WAAW,CAACC,MAAwB;AACzD,UAAAA,EAAM,KAAK,SAAS,OAAO;AAC3B,cAAM,EAAE,SAAAC,GAAS,UAAAC,EAAS,IAAIF,EAAM;AACpC,aAAK,eAAe,QAAQ,CAACG,MAAOA,EAAGF,GAASC,CAAQ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