@cratis/arc 20.28.0 → 20.33.2
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/cjs/queries/ObservableQueryDiagnostics.d.ts.map +1 -1
- package/dist/cjs/queries/ObservableQueryDiagnostics.js +0 -3
- package/dist/cjs/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/esm/queries/ObservableQueryDiagnostics.d.ts.map +1 -1
- package/dist/esm/queries/ObservableQueryDiagnostics.js +0 -3
- package/dist/esm/queries/ObservableQueryDiagnostics.js.map +1 -1
- package/dist/esm/queries/for_ObservableQueryDiagnostics/when_tracking_owners.js +16 -0
- package/dist/esm/queries/for_ObservableQueryDiagnostics/when_tracking_owners.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/queries/ObservableQueryDiagnostics.ts +0 -4
- package/queries/for_ObservableQueryDiagnostics/when_tracking_owners.ts +25 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryDiagnostics.d.ts","sourceRoot":"","sources":["../../../queries/ObservableQueryDiagnostics.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAW,MAAM,MAAM,CAAC;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAC5E,OAAO,EACH,kCAAkC,EAElC,oBAAoB,EAGvB,MAAM,sCAAsC,CAAC;AAM9C,qBAAa,0BAA2B,YAAW,2BAA2B;IAWtE,OAAO,CAAC,QAAQ,CAAC,MAAM;IACvB,OAAO,CAAC,QAAQ,CAAC,eAAe;IAChC,OAAO,CAAC,QAAQ,CAAC,mBAAmB;IAZxC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAqD;IAChF,OAAO,CAAC,QAAQ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IAAI,kCAAkC;IAOjD,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAMpD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAKnC,OAAO,CAAC,4BAA4B;IAwBpC,OAAO,CAAC,eAAe;IAkCvB,OAAO,CAAC,gBAAgB;CAG3B"}
|
|
@@ -79,9 +79,6 @@ class ObservableQueryDiagnostics {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
_publishSnapshot(snapshot) {
|
|
82
|
-
if (typeof window !== 'undefined') {
|
|
83
|
-
window.dispatchEvent(new CustomEvent('cratis:observable-query-diagnostics', { detail: snapshot }));
|
|
84
|
-
}
|
|
85
82
|
this._snapshots.next(snapshot);
|
|
86
83
|
}
|
|
87
84
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryDiagnostics.js","sources":["../../../queries/ObservableQueryDiagnostics.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Observable, Subject } from 'rxjs';\nimport { QueryInstanceCache } from './QueryInstanceCache';\nimport { ObservableQueryMultiplexer } from './ObservableQueryMultiplexer';\nimport { IObservableQueryDiagnostics } from './IObservableQueryDiagnostics';\nimport {\n ObservableQueryDiagnosticsSnapshot,\n MultiplexerDiagnostics,\n TransportDiagnostics,\n HealthDiagnostics,\n OwnershipDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot';\n\n/**\n * Implements the {@link IObservableQueryDiagnostics} contract by collecting live state from\n * the {@link QueryInstanceCache} and the shared {@link ObservableQueryMultiplexer}.\n */\nexport class ObservableQueryDiagnostics implements IObservableQueryDiagnostics {\n private readonly _snapshots = new Subject<ObservableQueryDiagnosticsSnapshot>();\n private readonly _ownersByKey = new Map<string, string>();\n\n /**\n * Initializes a new instance of {@link ObservableQueryDiagnostics}.\n * @param _cache The {@link QueryInstanceCache} whose state will be reflected.\n * @param _getMultiplexer Factory that returns the current shared multiplexer, or {@code undefined}.\n * @param _getTransportConfig Factory that returns the current transport diagnostics.\n */\n constructor(\n private readonly _cache: QueryInstanceCache,\n private readonly _getMultiplexer: () => ObservableQueryMultiplexer | undefined,\n private readonly _getTransportConfig: () => TransportDiagnostics,\n ) {}\n\n /**\n * Stream of diagnostics snapshots.\n */\n get snapshots$(): Observable<ObservableQueryDiagnosticsSnapshot> {\n return this._snapshots.asObservable();\n }\n\n /** @inheritdoc */\n getSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const snapshot = this._createSnapshot();\n this._publishSnapshot(snapshot);\n return snapshot;\n }\n\n /** @inheritdoc */\n beginTracking(cacheKey: string, owner: string): void {\n this._ownersByKey.set(cacheKey, owner);\n this._publishSnapshot(this._createSnapshot());\n }\n\n /** @inheritdoc */\n endTracking(cacheKey: string): void {\n this._ownersByKey.delete(cacheKey);\n this._publishSnapshot(this._createSnapshot());\n }\n\n private _buildMultiplexerDiagnostics(): MultiplexerDiagnostics {\n const mux = this._getMultiplexer();\n if (!mux) {\n return {\n isConnected: false,\n configuredConnectionCount: 0,\n effectiveConnectionCount: 0,\n activeConnectionCount: 0,\n connections: [],\n };\n }\n\n const connections = mux.getConnectionsSnapshot();\n const activeConnectionCount = connections.filter(c => c.isConnected).length;\n\n return {\n isConnected: activeConnectionCount > 0,\n configuredConnectionCount: connections.length,\n effectiveConnectionCount: connections.length,\n activeConnectionCount,\n connections,\n };\n }\n\n private _createSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const transport = this._getTransportConfig();\n const multiplexer = this._buildMultiplexerDiagnostics();\n const cache = this._cache.getDiagnosticsSnapshot();\n\n const ownersByQueryKey: Record<string, string> = {};\n const queriesByOwner: Record<string, string[]> = {};\n\n for (const [key, owner] of this._ownersByKey) {\n ownersByQueryKey[key] = owner;\n if (!queriesByOwner[owner]) {\n queriesByOwner[owner] = [];\n }\n queriesByOwner[owner].push(key);\n }\n\n const ownership: OwnershipDiagnostics = { ownersByQueryKey, queriesByOwner };\n\n const disconnectedQueryCount = multiplexer.connections.filter(c => !c.isConnected).length;\n const health: HealthDiagnostics = {\n allQueriesConnected: multiplexer.isConnected && cache.healthy,\n disconnectedQueryCount,\n };\n\n return {\n health,\n transport,\n multiplexer,\n cache,\n ownership,\n timestamp: new Date().toISOString(),\n };\n }\n\n private _publishSnapshot(snapshot: ObservableQueryDiagnosticsSnapshot): void {\n
|
|
1
|
+
{"version":3,"file":"ObservableQueryDiagnostics.js","sources":["../../../queries/ObservableQueryDiagnostics.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Observable, Subject } from 'rxjs';\nimport { QueryInstanceCache } from './QueryInstanceCache';\nimport { ObservableQueryMultiplexer } from './ObservableQueryMultiplexer';\nimport { IObservableQueryDiagnostics } from './IObservableQueryDiagnostics';\nimport {\n ObservableQueryDiagnosticsSnapshot,\n MultiplexerDiagnostics,\n TransportDiagnostics,\n HealthDiagnostics,\n OwnershipDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot';\n\n/**\n * Implements the {@link IObservableQueryDiagnostics} contract by collecting live state from\n * the {@link QueryInstanceCache} and the shared {@link ObservableQueryMultiplexer}.\n */\nexport class ObservableQueryDiagnostics implements IObservableQueryDiagnostics {\n private readonly _snapshots = new Subject<ObservableQueryDiagnosticsSnapshot>();\n private readonly _ownersByKey = new Map<string, string>();\n\n /**\n * Initializes a new instance of {@link ObservableQueryDiagnostics}.\n * @param _cache The {@link QueryInstanceCache} whose state will be reflected.\n * @param _getMultiplexer Factory that returns the current shared multiplexer, or {@code undefined}.\n * @param _getTransportConfig Factory that returns the current transport diagnostics.\n */\n constructor(\n private readonly _cache: QueryInstanceCache,\n private readonly _getMultiplexer: () => ObservableQueryMultiplexer | undefined,\n private readonly _getTransportConfig: () => TransportDiagnostics,\n ) {}\n\n /**\n * Stream of diagnostics snapshots.\n */\n get snapshots$(): Observable<ObservableQueryDiagnosticsSnapshot> {\n return this._snapshots.asObservable();\n }\n\n /** @inheritdoc */\n getSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const snapshot = this._createSnapshot();\n this._publishSnapshot(snapshot);\n return snapshot;\n }\n\n /** @inheritdoc */\n beginTracking(cacheKey: string, owner: string): void {\n this._ownersByKey.set(cacheKey, owner);\n this._publishSnapshot(this._createSnapshot());\n }\n\n /** @inheritdoc */\n endTracking(cacheKey: string): void {\n this._ownersByKey.delete(cacheKey);\n this._publishSnapshot(this._createSnapshot());\n }\n\n private _buildMultiplexerDiagnostics(): MultiplexerDiagnostics {\n const mux = this._getMultiplexer();\n if (!mux) {\n return {\n isConnected: false,\n configuredConnectionCount: 0,\n effectiveConnectionCount: 0,\n activeConnectionCount: 0,\n connections: [],\n };\n }\n\n const connections = mux.getConnectionsSnapshot();\n const activeConnectionCount = connections.filter(c => c.isConnected).length;\n\n return {\n isConnected: activeConnectionCount > 0,\n configuredConnectionCount: connections.length,\n effectiveConnectionCount: connections.length,\n activeConnectionCount,\n connections,\n };\n }\n\n private _createSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const transport = this._getTransportConfig();\n const multiplexer = this._buildMultiplexerDiagnostics();\n const cache = this._cache.getDiagnosticsSnapshot();\n\n const ownersByQueryKey: Record<string, string> = {};\n const queriesByOwner: Record<string, string[]> = {};\n\n for (const [key, owner] of this._ownersByKey) {\n ownersByQueryKey[key] = owner;\n if (!queriesByOwner[owner]) {\n queriesByOwner[owner] = [];\n }\n queriesByOwner[owner].push(key);\n }\n\n const ownership: OwnershipDiagnostics = { ownersByQueryKey, queriesByOwner };\n\n const disconnectedQueryCount = multiplexer.connections.filter(c => !c.isConnected).length;\n const health: HealthDiagnostics = {\n allQueriesConnected: multiplexer.isConnected && cache.healthy,\n disconnectedQueryCount,\n };\n\n return {\n health,\n transport,\n multiplexer,\n cache,\n ownership,\n timestamp: new Date().toISOString(),\n };\n }\n\n private _publishSnapshot(snapshot: ObservableQueryDi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
|
}
|
|
79
79
|
_publishSnapshot(snapshot) {
|
|
80
|
-
if (typeof window !== 'undefined') {
|
|
81
|
-
window.dispatchEvent(new CustomEvent('cratis:observable-query-diagnostics', { detail: snapshot }));
|
|
82
|
-
}
|
|
83
80
|
this._snapshots.next(snapshot);
|
|
84
81
|
}
|
|
85
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableQueryDiagnostics.js","sources":["../../../queries/ObservableQueryDiagnostics.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Observable, Subject } from 'rxjs';\nimport { QueryInstanceCache } from './QueryInstanceCache';\nimport { ObservableQueryMultiplexer } from './ObservableQueryMultiplexer';\nimport { IObservableQueryDiagnostics } from './IObservableQueryDiagnostics';\nimport {\n ObservableQueryDiagnosticsSnapshot,\n MultiplexerDiagnostics,\n TransportDiagnostics,\n HealthDiagnostics,\n OwnershipDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot';\n\n/**\n * Implements the {@link IObservableQueryDiagnostics} contract by collecting live state from\n * the {@link QueryInstanceCache} and the shared {@link ObservableQueryMultiplexer}.\n */\nexport class ObservableQueryDiagnostics implements IObservableQueryDiagnostics {\n private readonly _snapshots = new Subject<ObservableQueryDiagnosticsSnapshot>();\n private readonly _ownersByKey = new Map<string, string>();\n\n /**\n * Initializes a new instance of {@link ObservableQueryDiagnostics}.\n * @param _cache The {@link QueryInstanceCache} whose state will be reflected.\n * @param _getMultiplexer Factory that returns the current shared multiplexer, or {@code undefined}.\n * @param _getTransportConfig Factory that returns the current transport diagnostics.\n */\n constructor(\n private readonly _cache: QueryInstanceCache,\n private readonly _getMultiplexer: () => ObservableQueryMultiplexer | undefined,\n private readonly _getTransportConfig: () => TransportDiagnostics,\n ) {}\n\n /**\n * Stream of diagnostics snapshots.\n */\n get snapshots$(): Observable<ObservableQueryDiagnosticsSnapshot> {\n return this._snapshots.asObservable();\n }\n\n /** @inheritdoc */\n getSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const snapshot = this._createSnapshot();\n this._publishSnapshot(snapshot);\n return snapshot;\n }\n\n /** @inheritdoc */\n beginTracking(cacheKey: string, owner: string): void {\n this._ownersByKey.set(cacheKey, owner);\n this._publishSnapshot(this._createSnapshot());\n }\n\n /** @inheritdoc */\n endTracking(cacheKey: string): void {\n this._ownersByKey.delete(cacheKey);\n this._publishSnapshot(this._createSnapshot());\n }\n\n private _buildMultiplexerDiagnostics(): MultiplexerDiagnostics {\n const mux = this._getMultiplexer();\n if (!mux) {\n return {\n isConnected: false,\n configuredConnectionCount: 0,\n effectiveConnectionCount: 0,\n activeConnectionCount: 0,\n connections: [],\n };\n }\n\n const connections = mux.getConnectionsSnapshot();\n const activeConnectionCount = connections.filter(c => c.isConnected).length;\n\n return {\n isConnected: activeConnectionCount > 0,\n configuredConnectionCount: connections.length,\n effectiveConnectionCount: connections.length,\n activeConnectionCount,\n connections,\n };\n }\n\n private _createSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const transport = this._getTransportConfig();\n const multiplexer = this._buildMultiplexerDiagnostics();\n const cache = this._cache.getDiagnosticsSnapshot();\n\n const ownersByQueryKey: Record<string, string> = {};\n const queriesByOwner: Record<string, string[]> = {};\n\n for (const [key, owner] of this._ownersByKey) {\n ownersByQueryKey[key] = owner;\n if (!queriesByOwner[owner]) {\n queriesByOwner[owner] = [];\n }\n queriesByOwner[owner].push(key);\n }\n\n const ownership: OwnershipDiagnostics = { ownersByQueryKey, queriesByOwner };\n\n const disconnectedQueryCount = multiplexer.connections.filter(c => !c.isConnected).length;\n const health: HealthDiagnostics = {\n allQueriesConnected: multiplexer.isConnected && cache.healthy,\n disconnectedQueryCount,\n };\n\n return {\n health,\n transport,\n multiplexer,\n cache,\n ownership,\n timestamp: new Date().toISOString(),\n };\n }\n\n private _publishSnapshot(snapshot: ObservableQueryDiagnosticsSnapshot): void {\n
|
|
1
|
+
{"version":3,"file":"ObservableQueryDiagnostics.js","sources":["../../../queries/ObservableQueryDiagnostics.ts"],"sourcesContent":["// Copyright (c) Cratis. All rights reserved.\n// Licensed under the MIT license. See LICENSE file in the project root for full license information.\n\nimport { Observable, Subject } from 'rxjs';\nimport { QueryInstanceCache } from './QueryInstanceCache';\nimport { ObservableQueryMultiplexer } from './ObservableQueryMultiplexer';\nimport { IObservableQueryDiagnostics } from './IObservableQueryDiagnostics';\nimport {\n ObservableQueryDiagnosticsSnapshot,\n MultiplexerDiagnostics,\n TransportDiagnostics,\n HealthDiagnostics,\n OwnershipDiagnostics,\n} from './ObservableQueryDiagnosticsSnapshot';\n\n/**\n * Implements the {@link IObservableQueryDiagnostics} contract by collecting live state from\n * the {@link QueryInstanceCache} and the shared {@link ObservableQueryMultiplexer}.\n */\nexport class ObservableQueryDiagnostics implements IObservableQueryDiagnostics {\n private readonly _snapshots = new Subject<ObservableQueryDiagnosticsSnapshot>();\n private readonly _ownersByKey = new Map<string, string>();\n\n /**\n * Initializes a new instance of {@link ObservableQueryDiagnostics}.\n * @param _cache The {@link QueryInstanceCache} whose state will be reflected.\n * @param _getMultiplexer Factory that returns the current shared multiplexer, or {@code undefined}.\n * @param _getTransportConfig Factory that returns the current transport diagnostics.\n */\n constructor(\n private readonly _cache: QueryInstanceCache,\n private readonly _getMultiplexer: () => ObservableQueryMultiplexer | undefined,\n private readonly _getTransportConfig: () => TransportDiagnostics,\n ) {}\n\n /**\n * Stream of diagnostics snapshots.\n */\n get snapshots$(): Observable<ObservableQueryDiagnosticsSnapshot> {\n return this._snapshots.asObservable();\n }\n\n /** @inheritdoc */\n getSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const snapshot = this._createSnapshot();\n this._publishSnapshot(snapshot);\n return snapshot;\n }\n\n /** @inheritdoc */\n beginTracking(cacheKey: string, owner: string): void {\n this._ownersByKey.set(cacheKey, owner);\n this._publishSnapshot(this._createSnapshot());\n }\n\n /** @inheritdoc */\n endTracking(cacheKey: string): void {\n this._ownersByKey.delete(cacheKey);\n this._publishSnapshot(this._createSnapshot());\n }\n\n private _buildMultiplexerDiagnostics(): MultiplexerDiagnostics {\n const mux = this._getMultiplexer();\n if (!mux) {\n return {\n isConnected: false,\n configuredConnectionCount: 0,\n effectiveConnectionCount: 0,\n activeConnectionCount: 0,\n connections: [],\n };\n }\n\n const connections = mux.getConnectionsSnapshot();\n const activeConnectionCount = connections.filter(c => c.isConnected).length;\n\n return {\n isConnected: activeConnectionCount > 0,\n configuredConnectionCount: connections.length,\n effectiveConnectionCount: connections.length,\n activeConnectionCount,\n connections,\n };\n }\n\n private _createSnapshot(): ObservableQueryDiagnosticsSnapshot {\n const transport = this._getTransportConfig();\n const multiplexer = this._buildMultiplexerDiagnostics();\n const cache = this._cache.getDiagnosticsSnapshot();\n\n const ownersByQueryKey: Record<string, string> = {};\n const queriesByOwner: Record<string, string[]> = {};\n\n for (const [key, owner] of this._ownersByKey) {\n ownersByQueryKey[key] = owner;\n if (!queriesByOwner[owner]) {\n queriesByOwner[owner] = [];\n }\n queriesByOwner[owner].push(key);\n }\n\n const ownership: OwnershipDiagnostics = { ownersByQueryKey, queriesByOwner };\n\n const disconnectedQueryCount = multiplexer.connections.filter(c => !c.isConnected).length;\n const health: HealthDiagnostics = {\n allQueriesConnected: multiplexer.isConnected && cache.healthy,\n disconnectedQueryCount,\n };\n\n return {\n health,\n transport,\n multiplexer,\n cache,\n ownership,\n timestamp: new Date().toISOString(),\n };\n }\n\n private _publishSnapshot(snapshot: ObservableQueryDiagnosticsSnapshot): void {\n this._snapshots.next(snapshot);\n }\n}\n"],"names":[],"mappings":";;MAmBa,0BAA0B,CAAA;AAWd,IAAA,MAAA;AACA,IAAA,eAAA;AACA,IAAA,mBAAA;AAZJ,IAAA,UAAU,GAAG,IAAI,OAAO,EAAsC;AAC9D,IAAA,YAAY,GAAG,IAAI,GAAG,EAAkB;AAQzD,IAAA,WAAA,CACqB,MAA0B,EAC1B,eAA6D,EAC7D,mBAA+C,EAAA;QAF/C,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@ -13,5 +13,21 @@ describe('when tracking query owners', () => {
|
|
|
13
13
|
snapshots.should.have.lengthOf(2);
|
|
14
14
|
snapshots[1].should.equal('{"ownersByQueryKey":{},"queriesByOwner":{}}');
|
|
15
15
|
});
|
|
16
|
+
it('should not dispatch browser events when publishing snapshots', () => {
|
|
17
|
+
const diagnostics = new ObservableQueryDiagnostics(new QueryInstanceCache(0), () => undefined, () => ({ queryTransportMethod: 'ServerSentEvents', queryDirectMode: false }));
|
|
18
|
+
const globalWithWindow = globalThis;
|
|
19
|
+
const originalWindow = globalWithWindow.window;
|
|
20
|
+
const dispatchEvent = function () {
|
|
21
|
+
throw new Error('dispatchEvent should not be called');
|
|
22
|
+
};
|
|
23
|
+
try {
|
|
24
|
+
globalWithWindow.window = { dispatchEvent };
|
|
25
|
+
diagnostics.beginTracking('cache-key', 'OrdersPage');
|
|
26
|
+
diagnostics.endTracking('cache-key');
|
|
27
|
+
}
|
|
28
|
+
finally {
|
|
29
|
+
globalWithWindow.window = originalWindow;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
16
32
|
});
|
|
17
33
|
//# sourceMappingURL=when_tracking_owners.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"when_tracking_owners.js","sourceRoot":"","sources":["../../../../queries/for_ObservableQueryDiagnostics/when_tracking_owners.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"when_tracking_owners.js","sourceRoot":"","sources":["../../../../queries/for_ObservableQueryDiagnostics/when_tracking_owners.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE/E,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,4DAA4D,EAAE,GAAG,EAAE;QAClE,MAAM,WAAW,GAAG,IAAI,0BAA0B,CAC9C,IAAI,kBAAkB,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