@signalk/charts-plugin 3.6.2 → 3.8.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/.prettierignore +1 -0
- package/CHANGELOG.md +109 -0
- package/README.md +72 -0
- package/docs/screenshots/1_overview.png +0 -0
- package/docs/screenshots/2_region.png +0 -0
- package/docs/screenshots/3_jobs.png +0 -0
- package/package.json +20 -12
- package/plugin/cacheLayout.d.ts +72 -0
- package/plugin/cacheLayout.d.ts.map +1 -0
- package/plugin/cacheLayout.js +243 -0
- package/plugin/cacheLayout.js.map +1 -0
- package/plugin/chartDownloader.d.ts +122 -29
- package/plugin/chartDownloader.d.ts.map +1 -1
- package/plugin/chartDownloader.js +488 -313
- package/plugin/chartDownloader.js.map +1 -1
- package/plugin/chartDownloaderMBTilesHelpers.d.ts +10 -0
- package/plugin/chartDownloaderMBTilesHelpers.d.ts.map +1 -0
- package/plugin/chartDownloaderMBTilesHelpers.js +235 -0
- package/plugin/chartDownloaderMBTilesHelpers.js.map +1 -0
- package/plugin/chartDownloaderTileHelpers.d.ts +30 -0
- package/plugin/chartDownloaderTileHelpers.d.ts.map +1 -0
- package/plugin/chartDownloaderTileHelpers.js +277 -0
- package/plugin/chartDownloaderTileHelpers.js.map +1 -0
- package/plugin/charts.d.ts.map +1 -1
- package/plugin/charts.js +23 -5
- package/plugin/charts.js.map +1 -1
- package/plugin/constants.d.ts.map +1 -1
- package/plugin/index.d.ts.map +1 -1
- package/plugin/index.js +561 -48
- package/plugin/index.js.map +1 -1
- package/plugin/pluginStatus.js.map +1 -1
- package/plugin/projection.js.map +1 -1
- package/plugin/tileServer.d.ts +4 -1
- package/plugin/tileServer.d.ts.map +1 -1
- package/plugin/tileServer.js +48 -10
- package/plugin/tileServer.js.map +1 -1
- package/plugin/tokenProvider.d.ts +63 -0
- package/plugin/tokenProvider.d.ts.map +1 -0
- package/plugin/tokenProvider.js +258 -0
- package/plugin/tokenProvider.js.map +1 -0
- package/plugin/types.d.ts +37 -2
- package/plugin/types.d.ts.map +1 -1
- package/public/images/jobs.png +0 -0
- package/public/images/overview.png +0 -0
- package/public/images/region.png +0 -0
- package/public/index.html +392 -113
- package/public/js/index.js +620 -0
- package/public/leaflet/images/downloads.png +0 -0
- package/public/leaflet/images/layers-2x.png +0 -0
- package/public/leaflet/images/layers.png +0 -0
- package/public/leaflet/images/lifebuoy.png +0 -0
- package/public/leaflet/images/spritesheet-2x.png +0 -0
- package/public/leaflet/images/spritesheet.svg +156 -0
- package/public/leaflet/leaflet.css +677 -0
- package/public/leaflet/leaflet.draw.css +253 -0
- package/public/leaflet/leaflet.draw.js +2957 -0
- package/public/leaflet/leaflet.js +7467 -0
- package/public/logo.svg +0 -2
- package/public/style.css +351 -37
- package/public/index.js +0 -349
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Declarative token-based chart providers.
|
|
4
|
+
*
|
|
5
|
+
* Providers that need runtime-computed URLs (Navionics, ArcGIS-style key
|
|
6
|
+
* rotation, OAuth client_credentials) typically just need: fetch a
|
|
7
|
+
* token from a known URL, cache it for some TTL, template it into the
|
|
8
|
+
* tile URL and request headers. That shape is expressed here as JSON
|
|
9
|
+
* config — no executable code, no admin-supplied modules.
|
|
10
|
+
*
|
|
11
|
+
* Providers that need request signing or HMAC are out of scope; the
|
|
12
|
+
* right answer for those is a sandboxed extension point
|
|
13
|
+
* (worker_threads with a fixed message API), not arbitrary code
|
|
14
|
+
* execution.
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.TokenProvider = void 0;
|
|
18
|
+
exports.chartProviderFromTokenConfig = chartProviderFromTokenConfig;
|
|
19
|
+
exports.validateTokenProviderConfig = validateTokenProviderConfig;
|
|
20
|
+
// Random-range placeholder used for sharded tile hostnames like
|
|
21
|
+
// `tile{1-5}.host.com`. Inclusive on both ends.
|
|
22
|
+
const RANGE_PLACEHOLDER = /\{(\d+)-(\d+)\}/g;
|
|
23
|
+
const TOKEN_PLACEHOLDER = /\{token\.([a-zA-Z0-9_]+)\}/g;
|
|
24
|
+
// Strip query string and userinfo from a URL before logging. Token
|
|
25
|
+
// endpoints commonly carry secrets in query params (?api_key=...) or
|
|
26
|
+
// userinfo (https://user:pass@host); the host alone is enough context
|
|
27
|
+
// for an admin to recognise which provider failed without the secrets
|
|
28
|
+
// landing in shared logs.
|
|
29
|
+
function redactUrl(raw) {
|
|
30
|
+
try {
|
|
31
|
+
const u = new URL(raw);
|
|
32
|
+
return `${u.protocol}//${u.host}${u.pathname}`;
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return '<unparseable url>';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const DEFAULT_CLOCK = {
|
|
39
|
+
now: () => Date.now(),
|
|
40
|
+
rand: () => Math.random()
|
|
41
|
+
};
|
|
42
|
+
class TokenProvider {
|
|
43
|
+
config;
|
|
44
|
+
clock;
|
|
45
|
+
// Resolved token fields (string-valued only; non-strings from the JSON
|
|
46
|
+
// response are dropped during fetchToken to keep template substitution
|
|
47
|
+
// unambiguous).
|
|
48
|
+
token = {};
|
|
49
|
+
// Epoch-millis at which the cached token is considered stale. Zero forces
|
|
50
|
+
// a fetch on the first ensureFreshToken() call.
|
|
51
|
+
tokenExpiry = 0;
|
|
52
|
+
// Coalesces concurrent refresh attempts: the first caller wins, the rest
|
|
53
|
+
// await the same in-flight promise instead of triggering parallel fetches
|
|
54
|
+
// (which would all race to write `this.token`).
|
|
55
|
+
inFlight = null;
|
|
56
|
+
constructor(config, clock = DEFAULT_CLOCK) {
|
|
57
|
+
this.config = config;
|
|
58
|
+
this.clock = clock;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Refresh the cached token if it has expired. Safe to call on the hot
|
|
62
|
+
* path: a fresh-enough token short-circuits without I/O. Concurrent
|
|
63
|
+
* callers share the same in-flight fetch.
|
|
64
|
+
*
|
|
65
|
+
* Errors are swallowed to a console warning rather than thrown: a token
|
|
66
|
+
* fetch failure shouldn't take down a tile request that might still
|
|
67
|
+
* succeed against a stale token (worst case the upstream returns 401
|
|
68
|
+
* and the next request will re-attempt the refresh).
|
|
69
|
+
*/
|
|
70
|
+
async ensureFreshToken() {
|
|
71
|
+
if (this.clock.now() < this.tokenExpiry)
|
|
72
|
+
return;
|
|
73
|
+
if (this.inFlight)
|
|
74
|
+
return this.inFlight;
|
|
75
|
+
this.inFlight = this.fetchToken()
|
|
76
|
+
.catch((err) => {
|
|
77
|
+
console.warn(`Token provider ${this.config.identifier}: token fetch failed: ${err.message}`);
|
|
78
|
+
})
|
|
79
|
+
.finally(() => {
|
|
80
|
+
this.inFlight = null;
|
|
81
|
+
});
|
|
82
|
+
return this.inFlight;
|
|
83
|
+
}
|
|
84
|
+
async fetchToken() {
|
|
85
|
+
const ep = this.config.tokenEndpoint;
|
|
86
|
+
const timeoutMs = ep.timeoutMs ?? 10000;
|
|
87
|
+
const controller = new AbortController();
|
|
88
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
89
|
+
let res;
|
|
90
|
+
try {
|
|
91
|
+
res = await fetch(ep.url, {
|
|
92
|
+
method: ep.method ?? 'GET',
|
|
93
|
+
headers: ep.headers,
|
|
94
|
+
body: ep.body,
|
|
95
|
+
signal: controller.signal
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
finally {
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
}
|
|
101
|
+
if (!res.ok) {
|
|
102
|
+
// Avoid embedding the full URL in the error: token endpoints often
|
|
103
|
+
// carry secrets in query params, and this message lands in
|
|
104
|
+
// ensureFreshToken's console.warn.
|
|
105
|
+
throw new Error(`token endpoint ${redactUrl(ep.url)} returned ${res.status}`);
|
|
106
|
+
}
|
|
107
|
+
const data = (await res.json());
|
|
108
|
+
if (typeof data !== 'object' || data === null) {
|
|
109
|
+
throw new Error(`token endpoint ${redactUrl(ep.url)} returned non-object`);
|
|
110
|
+
}
|
|
111
|
+
const next = {};
|
|
112
|
+
for (const [k, v] of Object.entries(data)) {
|
|
113
|
+
if (typeof v === 'string')
|
|
114
|
+
next[k] = v;
|
|
115
|
+
}
|
|
116
|
+
this.token = next;
|
|
117
|
+
this.tokenExpiry = this.clock.now() + ep.ttlSeconds * 1000;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Force-invalidate the cached token. Used by the proxy fetch path when
|
|
121
|
+
* the upstream returns 401: next request will re-fetch the token rather
|
|
122
|
+
* than hammering with the stale one.
|
|
123
|
+
*/
|
|
124
|
+
invalidateToken() {
|
|
125
|
+
this.tokenExpiry = 0;
|
|
126
|
+
}
|
|
127
|
+
/** Templated tile URL with the current token and any range placeholders. */
|
|
128
|
+
resolveUrl() {
|
|
129
|
+
return this.applyTemplates(this.config.tile.url);
|
|
130
|
+
}
|
|
131
|
+
/** Templated tile request headers with the current token. */
|
|
132
|
+
resolveHeaders() {
|
|
133
|
+
const out = {};
|
|
134
|
+
for (const [k, v] of Object.entries(this.config.tile.headers ?? {})) {
|
|
135
|
+
out[k] = this.applyTemplates(v);
|
|
136
|
+
}
|
|
137
|
+
return out;
|
|
138
|
+
}
|
|
139
|
+
// Substitute {token.<field>} from the cached token, then {<a>-<b>} with a
|
|
140
|
+
// random integer in [a, b]. Token comes first so a sharded hostname
|
|
141
|
+
// referenced inside a token field still randomises correctly.
|
|
142
|
+
applyTemplates(s) {
|
|
143
|
+
return s
|
|
144
|
+
.replace(TOKEN_PLACEHOLDER, (_, key) => this.token[key] ?? '')
|
|
145
|
+
.replace(RANGE_PLACEHOLDER, (_, lo, hi) => {
|
|
146
|
+
const a = parseInt(lo, 10);
|
|
147
|
+
const b = parseInt(hi, 10);
|
|
148
|
+
const span = b - a + 1;
|
|
149
|
+
return String(a + Math.floor(this.clock.rand() * span));
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.TokenProvider = TokenProvider;
|
|
154
|
+
/**
|
|
155
|
+
* Build a ChartProvider view of a token-provider config. The returned
|
|
156
|
+
* object has property getters for `remoteUrl` and `headers` so the
|
|
157
|
+
* existing tile-serving code keeps reading provider.remoteUrl /
|
|
158
|
+
* provider.headers without knowing about token rotation. The proxy path
|
|
159
|
+
* is responsible for awaiting `_tokenProvider.ensureFreshToken()`
|
|
160
|
+
* before the fetch.
|
|
161
|
+
*/
|
|
162
|
+
function chartProviderFromTokenConfig(cfg) {
|
|
163
|
+
const tp = new TokenProvider(cfg);
|
|
164
|
+
const provider = {
|
|
165
|
+
identifier: cfg.identifier,
|
|
166
|
+
name: cfg.name,
|
|
167
|
+
description: cfg.description ?? '',
|
|
168
|
+
type: cfg.type ?? 'tilelayer',
|
|
169
|
+
scale: cfg.scale ?? 250000,
|
|
170
|
+
proxy: true,
|
|
171
|
+
_filePath: '',
|
|
172
|
+
_tokenProvider: tp
|
|
173
|
+
};
|
|
174
|
+
if (cfg.format !== undefined)
|
|
175
|
+
provider.format = cfg.format;
|
|
176
|
+
if (cfg.minzoom !== undefined)
|
|
177
|
+
provider.minzoom = cfg.minzoom;
|
|
178
|
+
if (cfg.maxzoom !== undefined)
|
|
179
|
+
provider.maxzoom = cfg.maxzoom;
|
|
180
|
+
if (cfg.bounds !== undefined)
|
|
181
|
+
provider.bounds = cfg.bounds;
|
|
182
|
+
// Defining as accessors rather than data properties so every read pulls
|
|
183
|
+
// a freshly-templated string from the current token. The plain
|
|
184
|
+
// ChartProvider interface declares these as `string` / `object`; the
|
|
185
|
+
// getter shape is compatible at the call site.
|
|
186
|
+
Object.defineProperty(provider, 'remoteUrl', {
|
|
187
|
+
enumerable: true,
|
|
188
|
+
configurable: false,
|
|
189
|
+
get: () => tp.resolveUrl()
|
|
190
|
+
});
|
|
191
|
+
Object.defineProperty(provider, 'headers', {
|
|
192
|
+
enumerable: true,
|
|
193
|
+
configurable: false,
|
|
194
|
+
get: () => tp.resolveHeaders()
|
|
195
|
+
});
|
|
196
|
+
provider.v1 = {
|
|
197
|
+
tilemapUrl: `~tilePath~/${cfg.identifier}/{z}/{x}/{y}`,
|
|
198
|
+
chartLayers: []
|
|
199
|
+
};
|
|
200
|
+
provider.v2 = {
|
|
201
|
+
url: `~tilePath~/${cfg.identifier}/{z}/{x}/{y}`,
|
|
202
|
+
layers: []
|
|
203
|
+
};
|
|
204
|
+
return provider;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Lightweight validation of a parsed token-provider config. Returns the
|
|
208
|
+
* config on success and throws with a human-readable message on the first
|
|
209
|
+
* problem found. Validates the fields the implementation actually relies
|
|
210
|
+
* on; admins can still pass extra fields without error.
|
|
211
|
+
*/
|
|
212
|
+
// Identifier shape: URL-safe characters only. Identifier flows into
|
|
213
|
+
// filename construction (export mbtiles), tile-route URLs
|
|
214
|
+
// (~tilePath~/{id}/...), and chartProviders dict keys; an identifier
|
|
215
|
+
// containing slashes, dots, or whitespace produces malformed URLs and
|
|
216
|
+
// confused-deputy lookups, even though the export-path traversal is
|
|
217
|
+
// caught downstream. Defensive check at the validator.
|
|
218
|
+
const IDENTIFIER_RE = /^[A-Za-z0-9_-]+$/;
|
|
219
|
+
function validateTokenProviderConfig(raw, index) {
|
|
220
|
+
const where = `token provider #${index}`;
|
|
221
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
222
|
+
throw new Error(`${where}: expected an object`);
|
|
223
|
+
}
|
|
224
|
+
const c = raw;
|
|
225
|
+
if (typeof c['identifier'] !== 'string' || c['identifier'].length === 0) {
|
|
226
|
+
throw new Error(`${where}: identifier is required (non-empty string)`);
|
|
227
|
+
}
|
|
228
|
+
if (!IDENTIFIER_RE.test(c['identifier'])) {
|
|
229
|
+
throw new Error(`${where}: identifier "${c['identifier']}" must match /[A-Za-z0-9_-]+/ ` +
|
|
230
|
+
`(used as a URL path segment and filename component)`);
|
|
231
|
+
}
|
|
232
|
+
if (typeof c['name'] !== 'string' || c['name'].length === 0) {
|
|
233
|
+
throw new Error(`${where}: name is required (non-empty string)`);
|
|
234
|
+
}
|
|
235
|
+
const ep = c['tokenEndpoint'];
|
|
236
|
+
if (typeof ep !== 'object' || ep === null) {
|
|
237
|
+
throw new Error(`${where}: tokenEndpoint is required (object)`);
|
|
238
|
+
}
|
|
239
|
+
const epRec = ep;
|
|
240
|
+
if (typeof epRec['url'] !== 'string' || epRec['url'].length === 0) {
|
|
241
|
+
throw new Error(`${where}: tokenEndpoint.url is required (non-empty string)`);
|
|
242
|
+
}
|
|
243
|
+
if (typeof epRec['ttlSeconds'] !== 'number' ||
|
|
244
|
+
!Number.isFinite(epRec['ttlSeconds']) ||
|
|
245
|
+
epRec['ttlSeconds'] <= 0) {
|
|
246
|
+
throw new Error(`${where}: tokenEndpoint.ttlSeconds must be a positive number`);
|
|
247
|
+
}
|
|
248
|
+
const tile = c['tile'];
|
|
249
|
+
if (typeof tile !== 'object' || tile === null) {
|
|
250
|
+
throw new Error(`${where}: tile is required (object)`);
|
|
251
|
+
}
|
|
252
|
+
const tileRec = tile;
|
|
253
|
+
if (typeof tileRec['url'] !== 'string' || tileRec['url'].length === 0) {
|
|
254
|
+
throw new Error(`${where}: tile.url is required (non-empty string)`);
|
|
255
|
+
}
|
|
256
|
+
return c;
|
|
257
|
+
}
|
|
258
|
+
//# sourceMappingURL=tokenProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokenProvider.js","sourceRoot":"","sources":["../src/tokenProvider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;AAIH,gEAAgE;AAChE,gDAAgD;AAChD,MAAM,iBAAiB,GAAG,kBAAkB,CAAA;AAC5C,MAAM,iBAAiB,GAAG,6BAA6B,CAAA;AAEvD,mEAAmE;AACnE,qEAAqE;AACrE,sEAAsE;AACtE,sEAAsE;AACtE,0BAA0B;AAC1B,SAAS,SAAS,CAAC,GAAW;IAC5B,IAAI,CAAC;QACH,MAAM,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,C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B,CAAA;IAC/C,IAAI,OAAO,OAAO,CAAC,KAAK,CAAC,KAAK,QAAQ,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtE,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,2CAA2C,CAAC,CAAA;IACtE,CAAC;IACD,OAAO,CAAmC,CAAA;AAC5C,CAAC"}
|
package/plugin/types.d.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import type { OutgoingHttpHeaders } from 'http';
|
|
2
|
-
type
|
|
2
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
3
|
+
export type MapSourceType = 'tilelayer' | 'S-57' | 'WMS' | 'WMTS' | 'mapstyleJSON' | 'tileJSON';
|
|
3
4
|
export interface MBTilesHandle {
|
|
5
|
+
putTile: (z: number, x: number, y: number, tile: Buffer, callback: (err: Error | null) => void) => void;
|
|
6
|
+
startWriting: (callback: (err: Error | null) => void) => void;
|
|
7
|
+
putInfo: (info: MBTilesMetadata, callback: (err: Error | null) => void) => void;
|
|
4
8
|
getTile: (z: number, x: number, y: number, callback: (err: Error | null, tile: Buffer, headers: OutgoingHttpHeaders) => void) => void;
|
|
5
9
|
getInfo: (callback: (err: Error | null, metadata: MBTilesMetadata) => void) => void;
|
|
6
10
|
close: (callback: (err: Error | null) => void) => void;
|
|
7
11
|
on: (event: 'error', listener: (err: Error) => void) => MBTilesHandle;
|
|
12
|
+
_db?: DatabaseSync;
|
|
8
13
|
}
|
|
9
14
|
export interface MBTilesMetadata {
|
|
10
15
|
name?: string;
|
|
@@ -24,6 +29,10 @@ export interface ChartProvider {
|
|
|
24
29
|
_filePath: string;
|
|
25
30
|
_mbtilesHandle?: MBTilesHandle;
|
|
26
31
|
_flipY?: boolean;
|
|
32
|
+
_tokenProvider?: {
|
|
33
|
+
ensureFreshToken: () => Promise<void>;
|
|
34
|
+
invalidateToken: () => void;
|
|
35
|
+
};
|
|
27
36
|
identifier: string;
|
|
28
37
|
name: string;
|
|
29
38
|
description: string;
|
|
@@ -62,5 +71,31 @@ export interface OnlineChartProvider {
|
|
|
62
71
|
style: string;
|
|
63
72
|
layers: string[];
|
|
64
73
|
}
|
|
65
|
-
export {
|
|
74
|
+
export interface TokenProviderConfig {
|
|
75
|
+
identifier: string;
|
|
76
|
+
name: string;
|
|
77
|
+
description?: string;
|
|
78
|
+
type?: MapSourceType;
|
|
79
|
+
format?: string;
|
|
80
|
+
scale?: number;
|
|
81
|
+
minzoom?: number;
|
|
82
|
+
maxzoom?: number;
|
|
83
|
+
bounds?: number[];
|
|
84
|
+
tokenEndpoint: {
|
|
85
|
+
url: string;
|
|
86
|
+
method?: 'GET' | 'POST';
|
|
87
|
+
headers?: {
|
|
88
|
+
[key: string]: string;
|
|
89
|
+
};
|
|
90
|
+
body?: string;
|
|
91
|
+
ttlSeconds: number;
|
|
92
|
+
timeoutMs?: number;
|
|
93
|
+
};
|
|
94
|
+
tile: {
|
|
95
|
+
url: string;
|
|
96
|
+
headers?: {
|
|
97
|
+
[key: string]: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}
|
|
66
101
|
//# sourceMappingURL=types.d.ts.map
|
package/plugin/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,MAAM,CAAA;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAE/C,MAAM,MAAM,aAAa,GACvB,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,cAAc,GAAG,UAAU,CAAA;AAKrE,MAAM,WAAW,aAAa;IAC5B,OA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