sgerp-frontend-lib 0.1.4 → 0.1.5
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.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/locales/locale-server.d.ts +1 -1
- package/dist/locales/locale-server.d.ts.map +1 -1
- package/dist/locales/locale-server.js +5 -0
- package/dist/locales/locale.d.ts +1 -1
- package/dist/locales/locale.d.ts.map +1 -1
- package/dist/locales/locale.js +6 -2
- package/dist/locales/locale_en.d.ts.map +1 -1
- package/dist/locales/locale_en.js +77 -1
- package/dist/locales/locale_id.d.ts +2 -0
- package/dist/locales/locale_id.d.ts.map +1 -0
- package/dist/locales/locale_id.js +2473 -0
- package/dist/locales/locale_ja.d.ts.map +1 -1
- package/dist/locales/locale_ja.js +76 -1
- package/dist/locales/locale_ms.d.ts.map +1 -1
- package/dist/locales/locale_ms.js +60 -1
- package/dist/locales/locale_tl.d.ts +2 -0
- package/dist/locales/locale_tl.d.ts.map +1 -0
- package/dist/locales/locale_tl.js +1122 -0
- package/dist/sgerp/collection.d.ts.map +1 -1
- package/dist/sgerp/collection.js +18 -4
- package/dist/sgerp/domains.d.ts +16 -2
- package/dist/sgerp/domains.d.ts.map +1 -1
- package/dist/sgerp/domains.js +47 -1
- package/dist/sgerp/hooks/use-selection-state.d.ts +37 -0
- package/dist/sgerp/hooks/use-selection-state.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-selection-state.js +121 -0
- package/dist/sgerp/hooks/use-simulation-data.d.ts +105 -0
- package/dist/sgerp/hooks/use-simulation-data.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-simulation-data.js +146 -0
- package/dist/sgerp/hooks/use-simulation-state.d.ts +80 -0
- package/dist/sgerp/hooks/use-simulation-state.d.ts.map +1 -0
- package/dist/sgerp/hooks/use-simulation-state.js +161 -0
- package/dist/sgerp/index.d.ts +10 -3
- package/dist/sgerp/index.d.ts.map +1 -1
- package/dist/sgerp/index.js +24 -2
- package/dist/sgerp/simulation-logic/fetchUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/fetchUtils.js +2 -0
- package/dist/sgerp/simulation-logic/index.d.ts +3 -1
- package/dist/sgerp/simulation-logic/index.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/index.js +10 -1
- package/dist/sgerp/simulation-logic/liveUpdates.d.ts +102 -0
- package/dist/sgerp/simulation-logic/liveUpdates.d.ts.map +1 -0
- package/dist/sgerp/simulation-logic/liveUpdates.js +87 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.d.ts +36 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.d.ts.map +1 -0
- package/dist/sgerp/simulation-logic/prepareSimulationData.js +34 -0
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts +7 -1
- package/dist/sgerp/simulation-logic/routeCalculationUtils.d.ts.map +1 -1
- package/dist/sgerp/simulation-logic/routeCalculationUtils.js +81 -0
- package/dist/vrptoolbox/collection.d.ts +16 -0
- package/dist/vrptoolbox/collection.d.ts.map +1 -0
- package/dist/vrptoolbox/collection.js +62 -0
- package/dist/vrptoolbox/index.d.ts +6 -0
- package/dist/vrptoolbox/index.d.ts.map +1 -0
- package/dist/vrptoolbox/index.js +8 -0
- package/dist/vrptoolbox/types/job.d.ts +46 -0
- package/dist/vrptoolbox/types/job.d.ts.map +1 -0
- package/dist/vrptoolbox/types/job.js +5 -0
- package/package.json +7 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../sgerplib/sgerp/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,KAAK,EAAE,wBAAwB,EAAkB,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AA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E,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE;IAI1D;;OAEG;cACa,qBAAqB,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyG5E;;OAEG;IACG,KAAK,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBpE;;OAEG;IACG,SAAS,CAAC,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAyBtD;;OAEG;IACG,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAWvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAkCG;IACH,SAAS,CAAC,SAAS,CAAC,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,wBAAwB,GAAG,IAAI;CAgB5E"}
|
package/dist/sgerp/collection.js
CHANGED
|
@@ -212,9 +212,13 @@ class Collection {
|
|
|
212
212
|
// Update or add to models array
|
|
213
213
|
const existingIndex = newModels.findIndex(m => m.id === model.id);
|
|
214
214
|
if (existingIndex >= 0) {
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
|
|
215
|
+
// Merge with existing model to preserve client-side attributes
|
|
216
|
+
// Spread existing first, then new data, so server data takes precedence
|
|
217
|
+
// But client-side-only attributes (like visible_position) are preserved if not in new data
|
|
218
|
+
const existingModel = newModels[existingIndex];
|
|
219
|
+
const mergedModel = Object.assign(Object.assign({}, existingModel), model);
|
|
220
|
+
newModels[existingIndex] = mergedModel;
|
|
221
|
+
this._index.set(model.id, mergedModel);
|
|
218
222
|
hasChanges = true;
|
|
219
223
|
}
|
|
220
224
|
else {
|
|
@@ -225,8 +229,18 @@ class Collection {
|
|
|
225
229
|
});
|
|
226
230
|
// Only update and notify if something actually changed
|
|
227
231
|
if (hasChanges) {
|
|
232
|
+
// Safety check: deduplicate by ID (should not happen, but prevents React key errors)
|
|
233
|
+
const seen = new Set();
|
|
234
|
+
const deduplicated = newModels.filter(model => {
|
|
235
|
+
if (seen.has(model.id)) {
|
|
236
|
+
console.warn(`[Collection] Duplicate model with ID ${model.id} detected and removed`);
|
|
237
|
+
return false;
|
|
238
|
+
}
|
|
239
|
+
seen.add(model.id);
|
|
240
|
+
return true;
|
|
241
|
+
});
|
|
228
242
|
// Create new array reference for React to detect changes
|
|
229
|
-
this._models =
|
|
243
|
+
this._models = deduplicated;
|
|
230
244
|
this._notifyChange();
|
|
231
245
|
}
|
|
232
246
|
}
|
package/dist/sgerp/domains.d.ts
CHANGED
|
@@ -37,11 +37,25 @@ export declare const DEFAULT_SERVERS: {
|
|
|
37
37
|
url: string;
|
|
38
38
|
}[];
|
|
39
39
|
/**
|
|
40
|
-
*
|
|
40
|
+
* Backend environment type (for OSRM routing)
|
|
41
41
|
*/
|
|
42
|
-
export type
|
|
42
|
+
export type BackendEnvironment = 'development' | 'staging' | 'production' | 'tc' | 'tcp' | 'ppe';
|
|
43
43
|
/**
|
|
44
44
|
* OSRM backend type
|
|
45
45
|
*/
|
|
46
46
|
export type OSRMBackend = keyof typeof SGERP_DOMAINS.osrm;
|
|
47
|
+
/**
|
|
48
|
+
* Backend environment detection rules
|
|
49
|
+
* Maps URL patterns to backend environment types
|
|
50
|
+
*/
|
|
51
|
+
export declare const BACKEND_DETECTION_RULES: Array<{
|
|
52
|
+
patterns: string[];
|
|
53
|
+
backend: OSRMBackend;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Detect backend environment from base URL
|
|
57
|
+
* @param baseUrl - The SGERP API base URL
|
|
58
|
+
* @returns The detected backend environment or 'development' as default
|
|
59
|
+
*/
|
|
60
|
+
export declare function detectBackendFromUrl(baseUrl: string): OSRMBackend;
|
|
47
61
|
//# sourceMappingURL=domains.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../sgerplib/sgerp/domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;CAehB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;GAK8B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../sgerplib/sgerp/domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,eAAO,MAAM,aAAa;;;;;;;;;;;;CAehB,CAAC;AAEX;;;;GAIG;AACH,eAAO,MAAM,eAAe;;;GAK8B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,aAAa,GAAG,SAAS,GAAG,YAAY,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjG;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,aAAa,CAAC,IAAI,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC;IAC1C,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CA0BA,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,WAAW,CAUjE"}
|
package/dist/sgerp/domains.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
* - NEXT_PUBLIC_OSRM_DOMAIN_PPE
|
|
17
17
|
*/
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.DEFAULT_SERVERS = exports.SGERP_DOMAINS = void 0;
|
|
19
|
+
exports.BACKEND_DETECTION_RULES = exports.DEFAULT_SERVERS = exports.SGERP_DOMAINS = void 0;
|
|
20
|
+
exports.detectBackendFromUrl = detectBackendFromUrl;
|
|
20
21
|
exports.SGERP_DOMAINS = {
|
|
21
22
|
// SGERP API Domains
|
|
22
23
|
staging: process.env.NEXT_PUBLIC_SGERP_DOMAIN_STAGING || '',
|
|
@@ -43,3 +44,48 @@ exports.DEFAULT_SERVERS = [
|
|
|
43
44
|
{ labelKey: "env.tcp", url: exports.SGERP_DOMAINS.tcp },
|
|
44
45
|
{ labelKey: "env.ppe", url: exports.SGERP_DOMAINS.ppe },
|
|
45
46
|
].filter(server => server.url && server.url.trim() !== '');
|
|
47
|
+
/**
|
|
48
|
+
* Backend environment detection rules
|
|
49
|
+
* Maps URL patterns to backend environment types
|
|
50
|
+
*/
|
|
51
|
+
exports.BACKEND_DETECTION_RULES = [
|
|
52
|
+
{
|
|
53
|
+
patterns: ['gcdev', 'gcstage', 'staging', 'stage', 'dev'],
|
|
54
|
+
backend: 'development',
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
patterns: ['gcprod', 'prod'],
|
|
58
|
+
backend: 'production',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
patterns: [
|
|
62
|
+
process.env.NEXT_PUBLIC_BACKEND_TC_PATTERN || 'tc.example',
|
|
63
|
+
],
|
|
64
|
+
backend: 'tc',
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
patterns: [
|
|
68
|
+
process.env.NEXT_PUBLIC_BACKEND_TCP_PATTERN || 'tcp.example',
|
|
69
|
+
process.env.NEXT_PUBLIC_BACKEND_TCP_PATTERN_2 || 'tms-planning.example',
|
|
70
|
+
],
|
|
71
|
+
backend: 'tcp',
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
patterns: ['ppe'],
|
|
75
|
+
backend: 'ppe',
|
|
76
|
+
},
|
|
77
|
+
];
|
|
78
|
+
/**
|
|
79
|
+
* Detect backend environment from base URL
|
|
80
|
+
* @param baseUrl - The SGERP API base URL
|
|
81
|
+
* @returns The detected backend environment or 'development' as default
|
|
82
|
+
*/
|
|
83
|
+
function detectBackendFromUrl(baseUrl) {
|
|
84
|
+
const lowerUrl = baseUrl.toLowerCase();
|
|
85
|
+
for (const rule of exports.BACKEND_DETECTION_RULES) {
|
|
86
|
+
if (rule.patterns.some(pattern => lowerUrl.includes(pattern))) {
|
|
87
|
+
return rule.backend;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return 'development'; // Default fallback
|
|
91
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for managing selection state (vehicles, bookings, etc.)
|
|
3
|
+
* Provides consistent selection management across simulation pages
|
|
4
|
+
*/
|
|
5
|
+
export interface SelectionState<T extends number | string> {
|
|
6
|
+
selected: Set<T>;
|
|
7
|
+
count: number;
|
|
8
|
+
isSelected: (id: T) => boolean;
|
|
9
|
+
toggle: (id: T) => void;
|
|
10
|
+
selectAll: (ids: T[]) => void;
|
|
11
|
+
clearAll: () => void;
|
|
12
|
+
setSelection: (ids: T[]) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Hook for managing selection state with Set-based storage
|
|
16
|
+
* Useful for checkbox selections, multi-select, etc.
|
|
17
|
+
*
|
|
18
|
+
* @param initialIds - Initial selected IDs
|
|
19
|
+
* @returns Selection state and methods
|
|
20
|
+
*/
|
|
21
|
+
export declare function useSelectionState<T extends number | string>(initialIds?: T[]): SelectionState<T>;
|
|
22
|
+
/**
|
|
23
|
+
* Hook for tracking recently changed items (for visual feedback)
|
|
24
|
+
* Automatically clears highlights after a timeout
|
|
25
|
+
*
|
|
26
|
+
* @param timeoutMs - How long to highlight changes (default: 3000ms)
|
|
27
|
+
*/
|
|
28
|
+
export declare function useRecentChanges<T extends number | string>(timeoutMs?: number): {
|
|
29
|
+
recentlyChanged: Set<T>;
|
|
30
|
+
isRecentlyChanged: (id: T) => boolean;
|
|
31
|
+
detectChanges: (items: Array<{
|
|
32
|
+
id?: T;
|
|
33
|
+
uid?: T;
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}>, stateKey: string) => void;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=use-selection-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-selection-state.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/hooks/use-selection-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACvD,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,OAAO,CAAC;IAC/B,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,IAAI,CAAC;IACxB,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;IAC9B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,YAAY,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,IAAI,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACzD,UAAU,GAAE,CAAC,EAAO,GACnB,cAAc,CAAC,CAAC,CAAC,CAsDnB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EACxD,SAAS,GAAE,MAAa;;4BA8CjB,CAAC,KAAG,OAAO;2BAvCR,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC,YAAY,MAAM;EA2D3E"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hook for managing selection state (vehicles, bookings, etc.)
|
|
4
|
+
* Provides consistent selection management across simulation pages
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.useSelectionState = useSelectionState;
|
|
8
|
+
exports.useRecentChanges = useRecentChanges;
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
/**
|
|
11
|
+
* Hook for managing selection state with Set-based storage
|
|
12
|
+
* Useful for checkbox selections, multi-select, etc.
|
|
13
|
+
*
|
|
14
|
+
* @param initialIds - Initial selected IDs
|
|
15
|
+
* @returns Selection state and methods
|
|
16
|
+
*/
|
|
17
|
+
function useSelectionState(initialIds = []) {
|
|
18
|
+
const selectedRef = (0, react_1.useRef)(new Set(initialIds));
|
|
19
|
+
const [count, setCount] = (0, react_1.useState)(initialIds.length);
|
|
20
|
+
const [refreshCounter, setRefreshCounter] = (0, react_1.useState)(0);
|
|
21
|
+
// Keep ref in sync with initial value changes
|
|
22
|
+
(0, react_1.useEffect)(() => {
|
|
23
|
+
if (initialIds.length > 0 && selectedRef.current.size === 0) {
|
|
24
|
+
selectedRef.current = new Set(initialIds);
|
|
25
|
+
setCount(initialIds.length);
|
|
26
|
+
}
|
|
27
|
+
}, [initialIds]);
|
|
28
|
+
const isSelected = (0, react_1.useCallback)((id) => {
|
|
29
|
+
return selectedRef.current.has(id);
|
|
30
|
+
}, [refreshCounter]); // Refresh when counter changes
|
|
31
|
+
const toggle = (0, react_1.useCallback)((id) => {
|
|
32
|
+
if (selectedRef.current.has(id)) {
|
|
33
|
+
selectedRef.current.delete(id);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
selectedRef.current.add(id);
|
|
37
|
+
}
|
|
38
|
+
setCount(selectedRef.current.size);
|
|
39
|
+
setRefreshCounter((c) => c + 1);
|
|
40
|
+
}, []);
|
|
41
|
+
const selectAll = (0, react_1.useCallback)((ids) => {
|
|
42
|
+
selectedRef.current = new Set(ids);
|
|
43
|
+
setCount(ids.length);
|
|
44
|
+
setRefreshCounter((c) => c + 1);
|
|
45
|
+
}, []);
|
|
46
|
+
const clearAll = (0, react_1.useCallback)(() => {
|
|
47
|
+
selectedRef.current.clear();
|
|
48
|
+
setCount(0);
|
|
49
|
+
setRefreshCounter((c) => c + 1);
|
|
50
|
+
}, []);
|
|
51
|
+
const setSelection = (0, react_1.useCallback)((ids) => {
|
|
52
|
+
selectedRef.current = new Set(ids);
|
|
53
|
+
setCount(ids.length);
|
|
54
|
+
setRefreshCounter((c) => c + 1);
|
|
55
|
+
}, []);
|
|
56
|
+
return {
|
|
57
|
+
selected: selectedRef.current,
|
|
58
|
+
count,
|
|
59
|
+
isSelected,
|
|
60
|
+
toggle,
|
|
61
|
+
selectAll,
|
|
62
|
+
clearAll,
|
|
63
|
+
setSelection,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Hook for tracking recently changed items (for visual feedback)
|
|
68
|
+
* Automatically clears highlights after a timeout
|
|
69
|
+
*
|
|
70
|
+
* @param timeoutMs - How long to highlight changes (default: 3000ms)
|
|
71
|
+
*/
|
|
72
|
+
function useRecentChanges(timeoutMs = 3000) {
|
|
73
|
+
const [recentlyChanged, setRecentlyChanged] = (0, react_1.useState)(new Set());
|
|
74
|
+
const previousStatesRef = (0, react_1.useRef)(new Map());
|
|
75
|
+
const timeoutRef = (0, react_1.useRef)(null);
|
|
76
|
+
const detectChanges = (0, react_1.useCallback)((items, stateKey) => {
|
|
77
|
+
const changedIds = new Set();
|
|
78
|
+
items.forEach((item) => {
|
|
79
|
+
const id = (item.id || item.uid);
|
|
80
|
+
if (!id)
|
|
81
|
+
return;
|
|
82
|
+
const previousState = previousStatesRef.current.get(id);
|
|
83
|
+
const currentState = item[stateKey];
|
|
84
|
+
// If we have a previous state and it's different from current, mark as changed
|
|
85
|
+
if (previousState !== undefined && previousState !== currentState) {
|
|
86
|
+
changedIds.add(id);
|
|
87
|
+
}
|
|
88
|
+
// Update the previous state map
|
|
89
|
+
previousStatesRef.current.set(id, currentState);
|
|
90
|
+
});
|
|
91
|
+
// If we detected changes, highlight them
|
|
92
|
+
if (changedIds.size > 0) {
|
|
93
|
+
setRecentlyChanged(changedIds);
|
|
94
|
+
// Clear existing timeout
|
|
95
|
+
if (timeoutRef.current) {
|
|
96
|
+
clearTimeout(timeoutRef.current);
|
|
97
|
+
}
|
|
98
|
+
// Set new timeout to clear highlights
|
|
99
|
+
timeoutRef.current = setTimeout(() => {
|
|
100
|
+
setRecentlyChanged(new Set());
|
|
101
|
+
timeoutRef.current = null;
|
|
102
|
+
}, timeoutMs);
|
|
103
|
+
}
|
|
104
|
+
}, [timeoutMs]);
|
|
105
|
+
const isRecentlyChanged = (0, react_1.useCallback)((id) => {
|
|
106
|
+
return recentlyChanged.has(id);
|
|
107
|
+
}, [recentlyChanged]);
|
|
108
|
+
// Cleanup timeout on unmount
|
|
109
|
+
(0, react_1.useEffect)(() => {
|
|
110
|
+
return () => {
|
|
111
|
+
if (timeoutRef.current) {
|
|
112
|
+
clearTimeout(timeoutRef.current);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
}, []);
|
|
116
|
+
return {
|
|
117
|
+
recentlyChanged,
|
|
118
|
+
isRecentlyChanged,
|
|
119
|
+
detectChanges,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { SGERPClient } from '../client';
|
|
2
|
+
import type { Simulation } from '../types/simulation/simulation';
|
|
3
|
+
import type { Booking } from '../types/simulation/booking';
|
|
4
|
+
import type { Vehicle } from '../types/simulation/vehicle';
|
|
5
|
+
import type { Driver } from '../types/simulation/driver';
|
|
6
|
+
import type { Geofence } from '../types/simulation/geofence';
|
|
7
|
+
import type { Node } from '../types/simulation/node';
|
|
8
|
+
import { type RouteNode } from '../utils/routeUtils';
|
|
9
|
+
export interface SimulationDataState {
|
|
10
|
+
vehicles: Vehicle[];
|
|
11
|
+
bookings: Booking[];
|
|
12
|
+
nodes: Node[];
|
|
13
|
+
drivers: Driver[];
|
|
14
|
+
geofences: Geofence[];
|
|
15
|
+
mainGeofence: Geofence | null;
|
|
16
|
+
vehicleRoutes: Map<number, {
|
|
17
|
+
waypoints: any[];
|
|
18
|
+
polyline?: any;
|
|
19
|
+
}>;
|
|
20
|
+
vehicleData: Map<number, {
|
|
21
|
+
assigned_nodes: RouteNode[];
|
|
22
|
+
completed_nodes: RouteNode[];
|
|
23
|
+
assigned_booking_uids: Set<string>;
|
|
24
|
+
completed_booking_uids: Set<string>;
|
|
25
|
+
}>;
|
|
26
|
+
loading: boolean;
|
|
27
|
+
error: Error | null;
|
|
28
|
+
}
|
|
29
|
+
export interface UseSimulationDataOptions {
|
|
30
|
+
/**
|
|
31
|
+
* Enable automatic data fetching on mount
|
|
32
|
+
* @default true
|
|
33
|
+
*/
|
|
34
|
+
enabled?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Enable live updates for vehicles, bookings, and nodes
|
|
37
|
+
* @default false
|
|
38
|
+
*/
|
|
39
|
+
enableLiveUpdates?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Live update interval in milliseconds
|
|
42
|
+
* @default 5000
|
|
43
|
+
*/
|
|
44
|
+
liveUpdateInterval?: number;
|
|
45
|
+
/**
|
|
46
|
+
* Callback when data is successfully loaded
|
|
47
|
+
*/
|
|
48
|
+
onSuccess?: (data: Omit<SimulationDataState, 'loading' | 'error'>) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Callback when data loading fails
|
|
51
|
+
*/
|
|
52
|
+
onError?: (error: Error) => void;
|
|
53
|
+
/**
|
|
54
|
+
* Callback when live update occurs
|
|
55
|
+
*/
|
|
56
|
+
onLiveUpdate?: () => void;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* React hook for fetching and managing simulation data
|
|
60
|
+
* Encapsulates the full data loading pipeline: fetch, attach references, generate routes
|
|
61
|
+
*
|
|
62
|
+
* @param api - SGERP client instance
|
|
63
|
+
* @param simulationId - Simulation ID to fetch data for
|
|
64
|
+
* @param simulation - Optional simulation object (for fetching main geofence)
|
|
65
|
+
* @param options - Hook options
|
|
66
|
+
* @returns Simulation data state and control functions
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* ```tsx
|
|
70
|
+
* function SimulationPage({ simulationId }) {
|
|
71
|
+
* const api = useSGERP();
|
|
72
|
+
* const simulation = useCollection(api?.collections.simulation ?? null)
|
|
73
|
+
* ?.find(s => s.id === simulationId);
|
|
74
|
+
*
|
|
75
|
+
* // Basic usage - fetches data once
|
|
76
|
+
* const {
|
|
77
|
+
* vehicles,
|
|
78
|
+
* bookings,
|
|
79
|
+
* nodes,
|
|
80
|
+
* vehicleRoutes,
|
|
81
|
+
* vehicleData,
|
|
82
|
+
* loading,
|
|
83
|
+
* error,
|
|
84
|
+
* refetch
|
|
85
|
+
* } = useSimulationData(api, simulationId, simulation);
|
|
86
|
+
*
|
|
87
|
+
* // With live updates - automatically refreshes every 5 seconds
|
|
88
|
+
* const data = useSimulationData(api, simulationId, simulation, {
|
|
89
|
+
* enableLiveUpdates: true,
|
|
90
|
+
* liveUpdateInterval: 5000,
|
|
91
|
+
* onLiveUpdate: () => console.log('Data updated!')
|
|
92
|
+
* });
|
|
93
|
+
*
|
|
94
|
+
* if (loading) return <Spinner />;
|
|
95
|
+
* if (error) return <Error message={error.message} />;
|
|
96
|
+
*
|
|
97
|
+
* // All data is already processed - routes generated, references attached
|
|
98
|
+
* return <SimulationView vehicles={vehicles} bookings={bookings} routes={vehicleRoutes} />;
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
export declare function useSimulationData(api: SGERPClient | null, simulationId: number | string | null, simulation?: Simulation | null, options?: UseSimulationDataOptions): SimulationDataState & {
|
|
103
|
+
refetch: () => Promise<void>;
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=use-simulation-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulation-data.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/hooks/use-simulation-data.ts"],"names":[],"mapp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AAC;IAElB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAE5B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACH,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,mBAAmB,EAAE,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC;IAE3E;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IAEjC;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,iBAAiB,CAC/B,GAAG,EAAE,WAAW,GAAG,IAAI,EACvB,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,EACpC,UAAU,GAAE,UAAU,GAAG,IAAW,EACpC,OAAO,GAAE,wBAA6B,GACrC,mBAAmB,GAAG;IAAE,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,CA2JxD"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useSimulationData = useSimulationData;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const fetchUtils_1 = require("../simulation-logic/fetchUtils");
|
|
6
|
+
const referenceUtils_1 = require("../simulation-logic/referenceUtils");
|
|
7
|
+
const routeUtils_1 = require("../utils/routeUtils");
|
|
8
|
+
const use_live_updates_1 = require("./use-live-updates");
|
|
9
|
+
/**
|
|
10
|
+
* React hook for fetching and managing simulation data
|
|
11
|
+
* Encapsulates the full data loading pipeline: fetch, attach references, generate routes
|
|
12
|
+
*
|
|
13
|
+
* @param api - SGERP client instance
|
|
14
|
+
* @param simulationId - Simulation ID to fetch data for
|
|
15
|
+
* @param simulation - Optional simulation object (for fetching main geofence)
|
|
16
|
+
* @param options - Hook options
|
|
17
|
+
* @returns Simulation data state and control functions
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* function SimulationPage({ simulationId }) {
|
|
22
|
+
* const api = useSGERP();
|
|
23
|
+
* const simulation = useCollection(api?.collections.simulation ?? null)
|
|
24
|
+
* ?.find(s => s.id === simulationId);
|
|
25
|
+
*
|
|
26
|
+
* // Basic usage - fetches data once
|
|
27
|
+
* const {
|
|
28
|
+
* vehicles,
|
|
29
|
+
* bookings,
|
|
30
|
+
* nodes,
|
|
31
|
+
* vehicleRoutes,
|
|
32
|
+
* vehicleData,
|
|
33
|
+
* loading,
|
|
34
|
+
* error,
|
|
35
|
+
* refetch
|
|
36
|
+
* } = useSimulationData(api, simulationId, simulation);
|
|
37
|
+
*
|
|
38
|
+
* // With live updates - automatically refreshes every 5 seconds
|
|
39
|
+
* const data = useSimulationData(api, simulationId, simulation, {
|
|
40
|
+
* enableLiveUpdates: true,
|
|
41
|
+
* liveUpdateInterval: 5000,
|
|
42
|
+
* onLiveUpdate: () => console.log('Data updated!')
|
|
43
|
+
* });
|
|
44
|
+
*
|
|
45
|
+
* if (loading) return <Spinner />;
|
|
46
|
+
* if (error) return <Error message={error.message} />;
|
|
47
|
+
*
|
|
48
|
+
* // All data is already processed - routes generated, references attached
|
|
49
|
+
* return <SimulationView vehicles={vehicles} bookings={bookings} routes={vehicleRoutes} />;
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
function useSimulationData(api, simulationId, simulation = null, options = {}) {
|
|
54
|
+
var _a, _b, _c;
|
|
55
|
+
const { enabled = true, enableLiveUpdates = false, liveUpdateInterval = 5000, onSuccess, onError, onLiveUpdate } = options;
|
|
56
|
+
const [state, setState] = (0, react_1.useState)({
|
|
57
|
+
vehicles: [],
|
|
58
|
+
bookings: [],
|
|
59
|
+
nodes: [],
|
|
60
|
+
drivers: [],
|
|
61
|
+
geofences: [],
|
|
62
|
+
mainGeofence: null,
|
|
63
|
+
vehicleRoutes: new Map(),
|
|
64
|
+
vehicleData: new Map(),
|
|
65
|
+
loading: false,
|
|
66
|
+
error: null
|
|
67
|
+
});
|
|
68
|
+
const fetchData = (0, react_1.useCallback)(async () => {
|
|
69
|
+
if (!api || !simulationId) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { loading: true, error: null })));
|
|
73
|
+
try {
|
|
74
|
+
// Step 1: Fetch all data
|
|
75
|
+
const { vehicles, bookings, nodes, drivers, geofences, mainGeofence } = await (0, fetchUtils_1.fetchSimulationData)(api, simulationId, simulation);
|
|
76
|
+
// Step 2: Attach references between models
|
|
77
|
+
const { vehicleData } = (0, referenceUtils_1.attachReferences)(bookings, vehicles, nodes);
|
|
78
|
+
// Step 3: Generate vehicle routes from nodes
|
|
79
|
+
const vehicleIds = vehicles.map(v => v.id);
|
|
80
|
+
const vehicleRoutes = (0, routeUtils_1.createVehicleRoutesFromNodes)(nodes, vehicleIds);
|
|
81
|
+
const result = {
|
|
82
|
+
vehicles,
|
|
83
|
+
bookings,
|
|
84
|
+
nodes,
|
|
85
|
+
drivers,
|
|
86
|
+
geofences,
|
|
87
|
+
mainGeofence,
|
|
88
|
+
vehicleRoutes,
|
|
89
|
+
vehicleData
|
|
90
|
+
};
|
|
91
|
+
setState(Object.assign(Object.assign({}, result), { loading: false, error: null }));
|
|
92
|
+
onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess(result);
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
const err = error instanceof Error ? error : new Error(String(error));
|
|
96
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { loading: false, error: err })));
|
|
97
|
+
onError === null || onError === void 0 ? void 0 : onError(err);
|
|
98
|
+
}
|
|
99
|
+
}, [api, simulationId, simulation, onSuccess, onError]);
|
|
100
|
+
(0, react_1.useEffect)(() => {
|
|
101
|
+
if (enabled && api && simulationId) {
|
|
102
|
+
fetchData();
|
|
103
|
+
}
|
|
104
|
+
}, [enabled, api, simulationId, fetchData]);
|
|
105
|
+
// Set up live updates for vehicles, bookings, and nodes
|
|
106
|
+
const handleLiveUpdate = (0, react_1.useCallback)(() => {
|
|
107
|
+
if (!api || !simulationId)
|
|
108
|
+
return;
|
|
109
|
+
// Get updated data from collections (already fetched by useLiveUpdates)
|
|
110
|
+
const updatedVehicles = api.collections.vehicle.models;
|
|
111
|
+
const updatedBookings = api.collections.booking.models;
|
|
112
|
+
const updatedNodes = api.collections.node.models;
|
|
113
|
+
// Re-attach references to update denormalized fields
|
|
114
|
+
const { vehicleData } = (0, referenceUtils_1.attachReferences)(updatedBookings, updatedVehicles, updatedNodes);
|
|
115
|
+
// Regenerate routes from updated nodes
|
|
116
|
+
const vehicleIds = updatedVehicles.map(v => v.id);
|
|
117
|
+
const vehicleRoutes = (0, routeUtils_1.createVehicleRoutesFromNodes)(updatedNodes, vehicleIds);
|
|
118
|
+
// Update state with processed data
|
|
119
|
+
setState(prev => (Object.assign(Object.assign({}, prev), { vehicles: updatedVehicles, bookings: updatedBookings, nodes: updatedNodes, vehicleRoutes,
|
|
120
|
+
vehicleData })));
|
|
121
|
+
onLiveUpdate === null || onLiveUpdate === void 0 ? void 0 : onLiveUpdate();
|
|
122
|
+
}, [api, simulationId, onLiveUpdate]);
|
|
123
|
+
// Use live updates for each collection
|
|
124
|
+
(0, use_live_updates_1.useLiveUpdates)((_a = api === null || api === void 0 ? void 0 : api.collections.vehicle) !== null && _a !== void 0 ? _a : null, {
|
|
125
|
+
enabled: enableLiveUpdates && !!simulationId,
|
|
126
|
+
params: { simulation_id: simulationId },
|
|
127
|
+
interval: liveUpdateInterval,
|
|
128
|
+
onUpdate: handleLiveUpdate
|
|
129
|
+
});
|
|
130
|
+
(0, use_live_updates_1.useLiveUpdates)((_b = api === null || api === void 0 ? void 0 : api.collections.booking) !== null && _b !== void 0 ? _b : null, {
|
|
131
|
+
enabled: enableLiveUpdates && !!simulationId,
|
|
132
|
+
params: {
|
|
133
|
+
booking_type: 'customer',
|
|
134
|
+
simulation_id: simulationId
|
|
135
|
+
},
|
|
136
|
+
interval: liveUpdateInterval,
|
|
137
|
+
onUpdate: handleLiveUpdate
|
|
138
|
+
});
|
|
139
|
+
(0, use_live_updates_1.useLiveUpdates)((_c = api === null || api === void 0 ? void 0 : api.collections.node) !== null && _c !== void 0 ? _c : null, {
|
|
140
|
+
enabled: enableLiveUpdates && !!simulationId,
|
|
141
|
+
params: { simulation_id: simulationId },
|
|
142
|
+
interval: liveUpdateInterval,
|
|
143
|
+
onUpdate: handleLiveUpdate
|
|
144
|
+
});
|
|
145
|
+
return Object.assign(Object.assign({}, state), { refetch: fetchData });
|
|
146
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hook for managing simulation page state and derived calculations
|
|
3
|
+
* Extracts business logic from simulation-detail-page component
|
|
4
|
+
*/
|
|
5
|
+
import type { Booking } from '../types/simulation/booking';
|
|
6
|
+
import type { Vehicle } from '../types/simulation/vehicle';
|
|
7
|
+
/**
|
|
8
|
+
* Booking state distribution counts
|
|
9
|
+
*/
|
|
10
|
+
export interface StateDistribution {
|
|
11
|
+
unassigned: number;
|
|
12
|
+
calculating: number;
|
|
13
|
+
assigned: number;
|
|
14
|
+
rejected_by_system: number;
|
|
15
|
+
sent_offer: number;
|
|
16
|
+
enroute: number;
|
|
17
|
+
completed: number;
|
|
18
|
+
cancelled_by_user: number;
|
|
19
|
+
cancelled_in_calc: number;
|
|
20
|
+
fail_to_board: number;
|
|
21
|
+
fail_to_deliver: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Per-vehicle booking statistics
|
|
25
|
+
*/
|
|
26
|
+
export interface VehicleStats {
|
|
27
|
+
[vehicleId: number]: {
|
|
28
|
+
total: number;
|
|
29
|
+
completed: number;
|
|
30
|
+
assigned: number;
|
|
31
|
+
enroute: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* JIT shift statistics
|
|
36
|
+
*/
|
|
37
|
+
export interface ShiftStats {
|
|
38
|
+
[shiftId: string]: {
|
|
39
|
+
bookings: number;
|
|
40
|
+
vehiclesAllocated: number;
|
|
41
|
+
vehiclesAssigned: number;
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Calculate booking state distribution
|
|
46
|
+
*/
|
|
47
|
+
export declare function calculateStateDistribution(bookings: Booking[]): StateDistribution;
|
|
48
|
+
/**
|
|
49
|
+
* Calculate per-vehicle booking statistics
|
|
50
|
+
*/
|
|
51
|
+
export declare function calculateVehicleStats(bookings: Booking[]): VehicleStats;
|
|
52
|
+
/**
|
|
53
|
+
* Calculate JIT shift statistics
|
|
54
|
+
*/
|
|
55
|
+
export declare function calculateShiftStats(bookings: Booking[], shifts: Array<{
|
|
56
|
+
id: number | string;
|
|
57
|
+
shift_id?: string;
|
|
58
|
+
}>): ShiftStats;
|
|
59
|
+
/**
|
|
60
|
+
* Filter bookings by state
|
|
61
|
+
*/
|
|
62
|
+
export declare function filterBookingsByState(bookings: Booking[], stateFilters: string[]): Booking[];
|
|
63
|
+
/**
|
|
64
|
+
* Hook for simulation state calculations
|
|
65
|
+
* Provides memoized state distribution, vehicle stats, and filtered bookings
|
|
66
|
+
*/
|
|
67
|
+
export declare function useSimulationState(bookings: Booking[], vehicles: Vehicle[], stateFilters?: string[], shifts?: Array<{
|
|
68
|
+
id: number | string;
|
|
69
|
+
shift_id?: string;
|
|
70
|
+
}>): {
|
|
71
|
+
stateDistribution: StateDistribution;
|
|
72
|
+
vehicleStats: VehicleStats;
|
|
73
|
+
shiftStats: ShiftStats;
|
|
74
|
+
filteredBookings: Booking[];
|
|
75
|
+
autoplanStats: {
|
|
76
|
+
unassignedCount: number;
|
|
77
|
+
vehicleCount: number;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
//# sourceMappingURL=use-simulation-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-simulation-state.d.ts","sourceRoot":"","sources":["../../../sgerplib/sgerp/hooks/use-simulation-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAG3D;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,CAAC,OAAO,EAAE,MAAM,GAAG;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,iBAAiB,EAAE,MAAM,CAAC;QAC1B,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,iBAAiB,CA6BjF;AAED;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,YAAY,CA2BvE;AAED;;G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