@pablo2410/shared-ui 0.8.0 → 0.9.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/dist/chunk-4ATPOBMZ.js +442 -0
- package/dist/chunk-4ATPOBMZ.js.map +1 -0
- package/dist/{chunk-GU3OMCTY.js → chunk-RQEAFIJQ.js} +219 -158
- package/dist/chunk-RQEAFIJQ.js.map +1 -0
- package/dist/hierarchy/index.d.ts +9 -1
- package/dist/hierarchy/index.js +7 -431
- package/dist/hierarchy/index.js.map +1 -1
- package/dist/layout/index.d.ts +17 -1
- package/dist/layout/index.js +5 -1
- package/dist/shell/index.js +3 -1
- package/dist/shell/index.js.map +1 -1
- package/dist/shell/oplytics-shell.css +1 -1
- package/package.json +1 -1
- package/dist/chunk-GU3OMCTY.js.map +0 -1
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ACTIVE_ENTERPRISE_COOKIE,
|
|
3
|
+
ORG_HIERARCHY_EMPTY
|
|
4
|
+
} from "./chunk-NXSFRNI7.js";
|
|
5
|
+
import {
|
|
6
|
+
cn
|
|
7
|
+
} from "./chunk-JT3XLKKD.js";
|
|
8
|
+
|
|
9
|
+
// src/hierarchy/OrgHierarchyContext.tsx
|
|
10
|
+
import {
|
|
11
|
+
createContext,
|
|
12
|
+
useContext,
|
|
13
|
+
useCallback,
|
|
14
|
+
useMemo,
|
|
15
|
+
useState,
|
|
16
|
+
useEffect
|
|
17
|
+
} from "react";
|
|
18
|
+
import { jsx } from "react/jsx-runtime";
|
|
19
|
+
function readActiveEnterpriseCookie() {
|
|
20
|
+
if (typeof document === "undefined") return null;
|
|
21
|
+
const match = document.cookie.split(";").map((c) => c.trim()).find((c) => c.startsWith(`${ACTIVE_ENTERPRISE_COOKIE}=`));
|
|
22
|
+
if (!match) return null;
|
|
23
|
+
const value = decodeURIComponent(match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1));
|
|
24
|
+
return value.length ? value : null;
|
|
25
|
+
}
|
|
26
|
+
function createOrgHierarchyContext(options) {
|
|
27
|
+
const { storageKey, useHierarchyData } = options;
|
|
28
|
+
const OrgHierarchyCtx = createContext({
|
|
29
|
+
selection: ORG_HIERARCHY_EMPTY,
|
|
30
|
+
enterprises: [],
|
|
31
|
+
businessUnits: [],
|
|
32
|
+
sites: [],
|
|
33
|
+
areas: [],
|
|
34
|
+
assets: [],
|
|
35
|
+
selectEnterprise: () => {
|
|
36
|
+
},
|
|
37
|
+
selectBusinessUnit: () => {
|
|
38
|
+
},
|
|
39
|
+
selectSite: () => {
|
|
40
|
+
},
|
|
41
|
+
selectArea: () => {
|
|
42
|
+
},
|
|
43
|
+
selectAsset: () => {
|
|
44
|
+
},
|
|
45
|
+
canSwitchEnterprise: false,
|
|
46
|
+
loading: true,
|
|
47
|
+
breadcrumbs: []
|
|
48
|
+
});
|
|
49
|
+
function OrgHierarchyProvider({
|
|
50
|
+
children,
|
|
51
|
+
canSwitchEnterprise = false,
|
|
52
|
+
onEnterpriseSwitched
|
|
53
|
+
}) {
|
|
54
|
+
const [selection, setSelection] = useState(ORG_HIERARCHY_EMPTY);
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
try {
|
|
57
|
+
sessionStorage.removeItem(storageKey);
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
const activeAtMount = readActiveEnterpriseCookie();
|
|
61
|
+
const reloadIfEnterpriseChanged = () => {
|
|
62
|
+
if (typeof window !== "undefined" && readActiveEnterpriseCookie() !== activeAtMount) {
|
|
63
|
+
window.location.reload();
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
if (typeof window !== "undefined") {
|
|
67
|
+
window.addEventListener("focus", reloadIfEnterpriseChanged);
|
|
68
|
+
document.addEventListener("visibilitychange", reloadIfEnterpriseChanged);
|
|
69
|
+
return () => {
|
|
70
|
+
window.removeEventListener("focus", reloadIfEnterpriseChanged);
|
|
71
|
+
document.removeEventListener("visibilitychange", reloadIfEnterpriseChanged);
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
return void 0;
|
|
75
|
+
}, []);
|
|
76
|
+
const { data: hierarchy, isLoading } = useHierarchyData();
|
|
77
|
+
const enterprises = useMemo(() => {
|
|
78
|
+
if (!hierarchy?.enterprises) return [];
|
|
79
|
+
return hierarchy.enterprises.map((e) => ({
|
|
80
|
+
id: e.id,
|
|
81
|
+
name: e.name,
|
|
82
|
+
code: e.code
|
|
83
|
+
}));
|
|
84
|
+
}, [hierarchy]);
|
|
85
|
+
const businessUnits = useMemo(() => {
|
|
86
|
+
if (!hierarchy?.businessUnits || !selection.enterprise) return [];
|
|
87
|
+
return hierarchy.businessUnits.filter((bu) => bu.enterpriseId === selection.enterprise.id).map((bu) => ({ id: bu.id, name: bu.name, code: bu.code }));
|
|
88
|
+
}, [hierarchy, selection.enterprise]);
|
|
89
|
+
const sites = useMemo(() => {
|
|
90
|
+
if (!hierarchy?.sites || !selection.enterprise) return [];
|
|
91
|
+
let filtered = hierarchy.sites.filter(
|
|
92
|
+
(s) => s.enterpriseId === selection.enterprise.id
|
|
93
|
+
);
|
|
94
|
+
if (selection.businessUnit) {
|
|
95
|
+
filtered = filtered.filter(
|
|
96
|
+
(s) => s.businessUnitId === selection.businessUnit.id
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
return filtered.map((s) => ({ id: s.id, name: s.name, code: s.code }));
|
|
100
|
+
}, [hierarchy, selection.enterprise, selection.businessUnit]);
|
|
101
|
+
const areas = useMemo(() => {
|
|
102
|
+
if (!hierarchy?.areas || !selection.site) return [];
|
|
103
|
+
return hierarchy.areas.filter((a) => a.siteId === selection.site.id).map((a) => ({ id: a.id, name: a.name, code: a.code }));
|
|
104
|
+
}, [hierarchy, selection.site]);
|
|
105
|
+
const assets = useMemo(() => {
|
|
106
|
+
if (!hierarchy?.assets || !selection.area) return [];
|
|
107
|
+
return hierarchy.assets.filter((a) => a.areaId === selection.area.id).map((a) => ({ id: a.id, name: a.name, code: a.code }));
|
|
108
|
+
}, [hierarchy, selection.area]);
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (isLoading || enterprises.length === 0) return;
|
|
111
|
+
if (!selection.enterprise) {
|
|
112
|
+
if (!canSwitchEnterprise || enterprises.length === 1) {
|
|
113
|
+
setSelection((prev) => ({ ...prev, enterprise: enterprises[0] }));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}, [isLoading, enterprises, selection.enterprise, canSwitchEnterprise]);
|
|
117
|
+
const selectEnterprise = useCallback((node) => {
|
|
118
|
+
setSelection({
|
|
119
|
+
enterprise: node,
|
|
120
|
+
businessUnit: null,
|
|
121
|
+
site: null,
|
|
122
|
+
area: null,
|
|
123
|
+
asset: null
|
|
124
|
+
});
|
|
125
|
+
if (canSwitchEnterprise && onEnterpriseSwitched) {
|
|
126
|
+
onEnterpriseSwitched(node?.id ?? null);
|
|
127
|
+
}
|
|
128
|
+
}, [canSwitchEnterprise, onEnterpriseSwitched]);
|
|
129
|
+
const selectBusinessUnit = useCallback((node) => {
|
|
130
|
+
setSelection((prev) => ({
|
|
131
|
+
...prev,
|
|
132
|
+
businessUnit: node,
|
|
133
|
+
site: null,
|
|
134
|
+
area: null,
|
|
135
|
+
asset: null
|
|
136
|
+
}));
|
|
137
|
+
}, []);
|
|
138
|
+
const selectSite = useCallback((node) => {
|
|
139
|
+
setSelection((prev) => ({
|
|
140
|
+
...prev,
|
|
141
|
+
site: node,
|
|
142
|
+
area: null,
|
|
143
|
+
asset: null
|
|
144
|
+
}));
|
|
145
|
+
}, []);
|
|
146
|
+
const selectArea = useCallback((node) => {
|
|
147
|
+
setSelection((prev) => ({
|
|
148
|
+
...prev,
|
|
149
|
+
area: node,
|
|
150
|
+
asset: null
|
|
151
|
+
}));
|
|
152
|
+
}, []);
|
|
153
|
+
const selectAsset = useCallback((node) => {
|
|
154
|
+
setSelection((prev) => ({
|
|
155
|
+
...prev,
|
|
156
|
+
asset: node
|
|
157
|
+
}));
|
|
158
|
+
}, []);
|
|
159
|
+
const breadcrumbs = useMemo(() => {
|
|
160
|
+
const crumbs = [];
|
|
161
|
+
if (selection.enterprise)
|
|
162
|
+
crumbs.push({ level: "Enterprise", node: selection.enterprise });
|
|
163
|
+
if (selection.businessUnit)
|
|
164
|
+
crumbs.push({ level: "Business Unit", node: selection.businessUnit });
|
|
165
|
+
if (selection.site)
|
|
166
|
+
crumbs.push({ level: "Site", node: selection.site });
|
|
167
|
+
if (selection.area)
|
|
168
|
+
crumbs.push({ level: "Area", node: selection.area });
|
|
169
|
+
if (selection.asset)
|
|
170
|
+
crumbs.push({ level: "Asset", node: selection.asset });
|
|
171
|
+
return crumbs;
|
|
172
|
+
}, [selection]);
|
|
173
|
+
const value = useMemo(
|
|
174
|
+
() => ({
|
|
175
|
+
selection,
|
|
176
|
+
enterprises,
|
|
177
|
+
businessUnits,
|
|
178
|
+
sites,
|
|
179
|
+
areas,
|
|
180
|
+
assets,
|
|
181
|
+
selectEnterprise,
|
|
182
|
+
selectBusinessUnit,
|
|
183
|
+
selectSite,
|
|
184
|
+
selectArea,
|
|
185
|
+
selectAsset,
|
|
186
|
+
canSwitchEnterprise,
|
|
187
|
+
loading: isLoading,
|
|
188
|
+
breadcrumbs
|
|
189
|
+
}),
|
|
190
|
+
[
|
|
191
|
+
selection,
|
|
192
|
+
enterprises,
|
|
193
|
+
businessUnits,
|
|
194
|
+
sites,
|
|
195
|
+
areas,
|
|
196
|
+
assets,
|
|
197
|
+
selectEnterprise,
|
|
198
|
+
selectBusinessUnit,
|
|
199
|
+
selectSite,
|
|
200
|
+
selectArea,
|
|
201
|
+
selectAsset,
|
|
202
|
+
canSwitchEnterprise,
|
|
203
|
+
isLoading,
|
|
204
|
+
breadcrumbs
|
|
205
|
+
]
|
|
206
|
+
);
|
|
207
|
+
return /* @__PURE__ */ jsx(OrgHierarchyCtx.Provider, { value, children });
|
|
208
|
+
}
|
|
209
|
+
function useOrgHierarchy() {
|
|
210
|
+
return useContext(OrgHierarchyCtx);
|
|
211
|
+
}
|
|
212
|
+
return { OrgHierarchyProvider, useOrgHierarchy };
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// src/hierarchy/HierarchyNavigator.tsx
|
|
216
|
+
import { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from "lucide-react";
|
|
217
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
218
|
+
function BreadcrumbLevel({
|
|
219
|
+
config,
|
|
220
|
+
isLast,
|
|
221
|
+
compact,
|
|
222
|
+
renderDropdown
|
|
223
|
+
}) {
|
|
224
|
+
const nodes = config.getNodes();
|
|
225
|
+
const selected = config.getSelected();
|
|
226
|
+
const Icon = config.icon;
|
|
227
|
+
const canSwitch = config.canSwitch !== false;
|
|
228
|
+
const hasMultiple = nodes.length > 1;
|
|
229
|
+
if (!selected) return null;
|
|
230
|
+
if (!hasMultiple || !canSwitch) {
|
|
231
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
232
|
+
/* @__PURE__ */ jsxs(
|
|
233
|
+
"div",
|
|
234
|
+
{
|
|
235
|
+
className: cn(
|
|
236
|
+
"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
|
|
237
|
+
"text-[#E2E8F0]",
|
|
238
|
+
compact && "px-1.5 py-0.5 text-xs"
|
|
239
|
+
),
|
|
240
|
+
children: [
|
|
241
|
+
/* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
242
|
+
/* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name })
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
),
|
|
246
|
+
!isLast && /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") })
|
|
247
|
+
] });
|
|
248
|
+
}
|
|
249
|
+
const trigger = /* @__PURE__ */ jsxs(
|
|
250
|
+
"button",
|
|
251
|
+
{
|
|
252
|
+
className: cn(
|
|
253
|
+
"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
|
|
254
|
+
"text-[#E2E8F0] hover:bg-[#1E2738] hover:text-white",
|
|
255
|
+
"transition-colors cursor-pointer outline-none",
|
|
256
|
+
"focus-visible:ring-1 focus-visible:ring-[#8C34E9]",
|
|
257
|
+
compact && "px-1.5 py-0.5 text-xs"
|
|
258
|
+
),
|
|
259
|
+
children: [
|
|
260
|
+
/* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0 text-[#8890A0]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
261
|
+
/* @__PURE__ */ jsx2("span", { className: "truncate max-w-[120px]", children: selected.name }),
|
|
262
|
+
/* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0 text-[#596475]", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
|
|
263
|
+
]
|
|
264
|
+
}
|
|
265
|
+
);
|
|
266
|
+
const items = nodes.map((node) => ({
|
|
267
|
+
key: node.id,
|
|
268
|
+
label: node.name,
|
|
269
|
+
code: node.code,
|
|
270
|
+
icon: Icon,
|
|
271
|
+
isActive: selected.id === node.id,
|
|
272
|
+
onClick: () => config.onSelect(node)
|
|
273
|
+
}));
|
|
274
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
275
|
+
renderDropdown ? renderDropdown({ trigger, items, align: "start" }) : (
|
|
276
|
+
// Fallback: simple select-style rendering
|
|
277
|
+
/* @__PURE__ */ jsx2("div", { className: "relative group", children: trigger })
|
|
278
|
+
),
|
|
279
|
+
!isLast && /* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") })
|
|
280
|
+
] });
|
|
281
|
+
}
|
|
282
|
+
function DrillDownPrompt({
|
|
283
|
+
label,
|
|
284
|
+
icon: Icon,
|
|
285
|
+
nodes,
|
|
286
|
+
onSelect,
|
|
287
|
+
compact,
|
|
288
|
+
renderDropdown
|
|
289
|
+
}) {
|
|
290
|
+
if (nodes.length === 0) return null;
|
|
291
|
+
if (nodes.length === 1) {
|
|
292
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
293
|
+
/* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
294
|
+
/* @__PURE__ */ jsxs(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
onClick: () => onSelect(nodes[0]),
|
|
298
|
+
className: cn(
|
|
299
|
+
"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
|
|
300
|
+
"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]",
|
|
301
|
+
"transition-colors cursor-pointer",
|
|
302
|
+
compact && "px-1.5 py-0.5 text-xs"
|
|
303
|
+
),
|
|
304
|
+
children: [
|
|
305
|
+
/* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
306
|
+
/* @__PURE__ */ jsx2("span", { className: "truncate", children: nodes[0].name })
|
|
307
|
+
]
|
|
308
|
+
}
|
|
309
|
+
)
|
|
310
|
+
] });
|
|
311
|
+
}
|
|
312
|
+
const trigger = /* @__PURE__ */ jsxs(
|
|
313
|
+
"button",
|
|
314
|
+
{
|
|
315
|
+
className: cn(
|
|
316
|
+
"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm",
|
|
317
|
+
"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]",
|
|
318
|
+
"transition-colors cursor-pointer outline-none",
|
|
319
|
+
"border border-dashed border-[#2A2A3E] hover:border-[#596475]",
|
|
320
|
+
compact && "px-1.5 py-0.5 text-xs"
|
|
321
|
+
),
|
|
322
|
+
children: [
|
|
323
|
+
/* @__PURE__ */ jsx2(Icon, { className: cn("shrink-0", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
324
|
+
/* @__PURE__ */ jsxs("span", { className: "truncate", children: [
|
|
325
|
+
"Select ",
|
|
326
|
+
label
|
|
327
|
+
] }),
|
|
328
|
+
/* @__PURE__ */ jsx2(ChevronDown, { className: cn("shrink-0", compact ? "h-2.5 w-2.5" : "h-3 w-3") })
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
const items = nodes.map((node) => ({
|
|
333
|
+
key: node.id,
|
|
334
|
+
label: node.name,
|
|
335
|
+
code: node.code,
|
|
336
|
+
icon: Icon,
|
|
337
|
+
isActive: false,
|
|
338
|
+
onClick: () => onSelect(node)
|
|
339
|
+
}));
|
|
340
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
|
|
341
|
+
/* @__PURE__ */ jsx2(ChevronRight, { className: cn("shrink-0 text-[#596475]", compact ? "h-3 w-3" : "h-3.5 w-3.5") }),
|
|
342
|
+
renderDropdown ? renderDropdown({ trigger, items, align: "start" }) : /* @__PURE__ */ jsx2("div", { className: "relative group", children: trigger })
|
|
343
|
+
] });
|
|
344
|
+
}
|
|
345
|
+
function HierarchyNavigator({
|
|
346
|
+
hierarchy: ctx,
|
|
347
|
+
compact = false,
|
|
348
|
+
maxDepth = 5,
|
|
349
|
+
className,
|
|
350
|
+
renderDropdown
|
|
351
|
+
}) {
|
|
352
|
+
if (ctx.loading) {
|
|
353
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2 animate-pulse", className), children: [
|
|
354
|
+
/* @__PURE__ */ jsx2("div", { className: "h-6 w-24 rounded bg-[#1E2738]" }),
|
|
355
|
+
/* @__PURE__ */ jsx2(ChevronRight, { className: "h-3.5 w-3.5 text-[#596475]" }),
|
|
356
|
+
/* @__PURE__ */ jsx2("div", { className: "h-6 w-20 rounded bg-[#1E2738]" })
|
|
357
|
+
] });
|
|
358
|
+
}
|
|
359
|
+
const levels = [
|
|
360
|
+
{
|
|
361
|
+
key: "enterprise",
|
|
362
|
+
label: "Enterprise",
|
|
363
|
+
icon: Building2,
|
|
364
|
+
getNodes: () => ctx.enterprises,
|
|
365
|
+
getSelected: () => ctx.selection.enterprise,
|
|
366
|
+
onSelect: ctx.selectEnterprise,
|
|
367
|
+
canSwitch: ctx.canSwitchEnterprise
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
key: "businessUnit",
|
|
371
|
+
label: "Business Unit",
|
|
372
|
+
icon: Network,
|
|
373
|
+
getNodes: () => ctx.businessUnits,
|
|
374
|
+
getSelected: () => ctx.selection.businessUnit,
|
|
375
|
+
onSelect: ctx.selectBusinessUnit
|
|
376
|
+
},
|
|
377
|
+
{
|
|
378
|
+
key: "site",
|
|
379
|
+
label: "Site",
|
|
380
|
+
icon: MapPin,
|
|
381
|
+
getNodes: () => ctx.sites,
|
|
382
|
+
getSelected: () => ctx.selection.site,
|
|
383
|
+
onSelect: ctx.selectSite
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
key: "area",
|
|
387
|
+
label: "Area",
|
|
388
|
+
icon: LayoutGrid,
|
|
389
|
+
getNodes: () => ctx.areas,
|
|
390
|
+
getSelected: () => ctx.selection.area,
|
|
391
|
+
onSelect: ctx.selectArea
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
key: "asset",
|
|
395
|
+
label: "Asset",
|
|
396
|
+
icon: Box,
|
|
397
|
+
getNodes: () => ctx.assets,
|
|
398
|
+
getSelected: () => ctx.selection.asset,
|
|
399
|
+
onSelect: ctx.selectAsset
|
|
400
|
+
}
|
|
401
|
+
].slice(0, maxDepth);
|
|
402
|
+
const selectedLevels = levels.filter((l) => l.getSelected() !== null);
|
|
403
|
+
const nextLevel = levels.find((l) => l.getSelected() === null && l.getNodes().length > 0);
|
|
404
|
+
return /* @__PURE__ */ jsxs(
|
|
405
|
+
"nav",
|
|
406
|
+
{
|
|
407
|
+
className: cn("flex items-center flex-wrap gap-0.5", className),
|
|
408
|
+
"aria-label": "Hierarchy navigation",
|
|
409
|
+
children: [
|
|
410
|
+
selectedLevels.map((level, idx) => /* @__PURE__ */ jsx2(
|
|
411
|
+
BreadcrumbLevel,
|
|
412
|
+
{
|
|
413
|
+
config: level,
|
|
414
|
+
isLast: idx === selectedLevels.length - 1 && !nextLevel,
|
|
415
|
+
compact,
|
|
416
|
+
renderDropdown
|
|
417
|
+
},
|
|
418
|
+
level.key
|
|
419
|
+
)),
|
|
420
|
+
nextLevel && /* @__PURE__ */ jsx2(
|
|
421
|
+
DrillDownPrompt,
|
|
422
|
+
{
|
|
423
|
+
label: nextLevel.label,
|
|
424
|
+
icon: nextLevel.icon,
|
|
425
|
+
nodes: nextLevel.getNodes(),
|
|
426
|
+
onSelect: nextLevel.onSelect,
|
|
427
|
+
compact,
|
|
428
|
+
renderDropdown
|
|
429
|
+
}
|
|
430
|
+
),
|
|
431
|
+
selectedLevels.length === 0 && !nextLevel && /* @__PURE__ */ jsx2("span", { className: "text-sm text-[#596475] italic", children: "No hierarchy data available" })
|
|
432
|
+
]
|
|
433
|
+
}
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export {
|
|
438
|
+
readActiveEnterpriseCookie,
|
|
439
|
+
createOrgHierarchyContext,
|
|
440
|
+
HierarchyNavigator
|
|
441
|
+
};
|
|
442
|
+
//# sourceMappingURL=chunk-4ATPOBMZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hierarchy/OrgHierarchyContext.tsx","../src/hierarchy/HierarchyNavigator.tsx"],"sourcesContent":["/**\n * OrgHierarchyContext — shared React context factory for the Organisational Hierarchy.\n *\n * Usage:\n * const { OrgHierarchyProvider, useOrgHierarchy } = createOrgHierarchyContext({\n * storageKey: \"oplytics-portal-org-hierarchy\",\n * useHierarchyData: () => {\n * const { data, isLoading } = trpc.hierarchy.flat.useQuery(...);\n * return { data: data ?? null, isLoading };\n * },\n * });\n *\n * All selection state, cascade setters, breadcrumbs, and session persistence\n * are handled here — no per-subdomain duplication.\n */\nimport {\n createContext,\n useContext,\n useCallback,\n useMemo,\n useState,\n useEffect,\n type ReactNode,\n} from \"react\";\nimport type {\n OrgHierarchyData,\n OrgHierarchyNode,\n OrgHierarchySelection,\n OrgHierarchyContextValue,\n} from \"./orgHierarchy\";\nimport { ORG_HIERARCHY_EMPTY } from \"./orgHierarchy\";\nimport { ACTIVE_ENTERPRISE_COOKIE } from \"./enterpriseOverride\";\n\n/* ── Active-enterprise cookie (the single cross-subdomain channel) ── */\n\n/**\n * Read the Portal-set active-enterprise cookie on the client. This is the only\n * signal a subdomain has that the platform admin switched enterprise; the value\n * is the active enterprise id (or null if unset). Server-side, the same cookie\n * drives applyEnterpriseOverride + scopeHierarchyToEnterprise, so the fetched\n * hierarchy is already scoped to it — the client only needs to react to changes.\n */\nexport function readActiveEnterpriseCookie(): string | null {\n if (typeof document === \"undefined\") return null;\n const match = document.cookie\n .split(\";\")\n .map((c) => c.trim())\n .find((c) => c.startsWith(`${ACTIVE_ENTERPRISE_COOKIE}=`));\n if (!match) return null;\n const value = decodeURIComponent(match.slice(ACTIVE_ENTERPRISE_COOKIE.length + 1));\n return value.length ? value : null;\n}\n\n/* ── Factory options ── */\n\nexport interface CreateOrgHierarchyContextOptions {\n /**\n * Unique sessionStorage key for this subdomain's selection persistence.\n * e.g. \"oplytics-portal-org-hierarchy\", \"oplytics-sqdcp-org-hierarchy\"\n */\n storageKey: string;\n\n /**\n * React hook that fetches the flat hierarchy data.\n * Must return { data, isLoading } where data is OrgHierarchyData | null.\n */\n useHierarchyData: () => {\n data: OrgHierarchyData | null;\n isLoading: boolean;\n };\n}\n\n/* ── Factory ── */\n\nexport function createOrgHierarchyContext(options: CreateOrgHierarchyContextOptions) {\n const { storageKey, useHierarchyData } = options;\n\n const OrgHierarchyCtx = createContext<OrgHierarchyContextValue>({\n selection: ORG_HIERARCHY_EMPTY,\n enterprises: [],\n businessUnits: [],\n sites: [],\n areas: [],\n assets: [],\n selectEnterprise: () => {},\n selectBusinessUnit: () => {},\n selectSite: () => {},\n selectArea: () => {},\n selectAsset: () => {},\n canSwitchEnterprise: false,\n loading: true,\n breadcrumbs: [],\n });\n\n function OrgHierarchyProvider({\n children,\n canSwitchEnterprise = false,\n onEnterpriseSwitched,\n }: {\n children: ReactNode;\n canSwitchEnterprise?: boolean;\n /**\n * Callback fired when a platform_admin switches enterprise.\n * Used to persist the switch to the backend (e.g. via auth.switchEnterprise mutation).\n * Only called when canSwitchEnterprise is true and the user explicitly changes enterprise.\n */\n onEnterpriseSwitched?: (enterpriseId: number | null) => void;\n }) {\n // Single source of truth = the server-scoped hierarchy. We deliberately do\n // NOT restore a persisted selection on load — that is exactly what let one\n // tab/subdomain show a different enterprise than another. We always\n // re-derive from the server (which is scoped to the active enterprise).\n const [selection, setSelection] = useState<OrgHierarchySelection>(ORG_HIERARCHY_EMPTY);\n\n // On mount: drop any legacy persisted selection, and hard-reload if the\n // active enterprise changes under us (i.e. the Portal admin switched).\n // Reloading lets the server re-scope this app to the new enterprise — the\n // single, identical propagation path for every subdomain. Cookies emit no\n // change event, so we re-check whenever the tab regains focus/visibility.\n useEffect(() => {\n try {\n sessionStorage.removeItem(storageKey);\n } catch {\n // ignore storage errors\n }\n\n const activeAtMount = readActiveEnterpriseCookie();\n const reloadIfEnterpriseChanged = () => {\n if (typeof window !== \"undefined\" && readActiveEnterpriseCookie() !== activeAtMount) {\n window.location.reload();\n }\n };\n if (typeof window !== \"undefined\") {\n window.addEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.addEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\n return () => {\n window.removeEventListener(\"focus\", reloadIfEnterpriseChanged);\n document.removeEventListener(\"visibilitychange\", reloadIfEnterpriseChanged);\n };\n }\n return undefined;\n // storageKey is stable for the lifetime of a factory instance.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n // Fetch hierarchy data via the provided hook\n const { data: hierarchy, isLoading } = useHierarchyData();\n\n // ── Derive filtered lists from flat data ──\n\n const enterprises = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.enterprises) return [];\n return hierarchy.enterprises.map((e) => ({\n id: e.id,\n name: e.name,\n code: e.code,\n }));\n }, [hierarchy]);\n\n const businessUnits = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.businessUnits || !selection.enterprise) return [];\n return hierarchy.businessUnits\n .filter((bu) => bu.enterpriseId === selection.enterprise!.id)\n .map((bu) => ({ id: bu.id, name: bu.name, code: bu.code }));\n }, [hierarchy, selection.enterprise]);\n\n const sites = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.sites || !selection.enterprise) return [];\n let filtered = hierarchy.sites.filter(\n (s) => s.enterpriseId === selection.enterprise!.id\n );\n if (selection.businessUnit) {\n filtered = filtered.filter(\n (s) => s.businessUnitId === selection.businessUnit!.id\n );\n }\n return filtered.map((s) => ({ id: s.id, name: s.name, code: s.code }));\n }, [hierarchy, selection.enterprise, selection.businessUnit]);\n\n const areas = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.areas || !selection.site) return [];\n return hierarchy.areas\n .filter((a) => a.siteId === selection.site!.id)\n .map((a) => ({ id: a.id, name: a.name, code: a.code }));\n }, [hierarchy, selection.site]);\n\n const assets = useMemo<OrgHierarchyNode[]>(() => {\n if (!hierarchy?.assets || !selection.area) return [];\n return hierarchy.assets\n .filter((a) => a.areaId === selection.area!.id)\n .map((a) => ({ id: a.id, name: a.name, code: a.code }));\n }, [hierarchy, selection.area]);\n\n // Auto-select first enterprise for non-platform_admin users\n useEffect(() => {\n if (isLoading || enterprises.length === 0) return;\n if (!selection.enterprise) {\n if (!canSwitchEnterprise || enterprises.length === 1) {\n setSelection((prev) => ({ ...prev, enterprise: enterprises[0] }));\n }\n }\n }, [isLoading, enterprises, selection.enterprise, canSwitchEnterprise]);\n\n // ── Cascade setters ──\n\n const selectEnterprise = useCallback((node: OrgHierarchyNode | null) => {\n setSelection({\n enterprise: node,\n businessUnit: null,\n site: null,\n area: null,\n asset: null,\n });\n // Notify backend of enterprise switch (platform_admin only)\n if (canSwitchEnterprise && onEnterpriseSwitched) {\n onEnterpriseSwitched(node?.id ?? null);\n }\n }, [canSwitchEnterprise, onEnterpriseSwitched]);\n\n const selectBusinessUnit = useCallback((node: OrgHierarchyNode | null) => {\n setSelection((prev) => ({\n ...prev,\n businessUnit: node,\n site: null,\n area: null,\n asset: null,\n }));\n }, []);\n\n const selectSite = useCallback((node: OrgHierarchyNode | null) => {\n setSelection((prev) => ({\n ...prev,\n site: node,\n area: null,\n asset: null,\n }));\n }, []);\n\n const selectArea = useCallback((node: OrgHierarchyNode | null) => {\n setSelection((prev) => ({\n ...prev,\n area: node,\n asset: null,\n }));\n }, []);\n\n const selectAsset = useCallback((node: OrgHierarchyNode | null) => {\n setSelection((prev) => ({\n ...prev,\n asset: node,\n }));\n }, []);\n\n // ── Breadcrumbs ──\n\n const breadcrumbs = useMemo(() => {\n const crumbs: { level: string; node: OrgHierarchyNode }[] = [];\n if (selection.enterprise)\n crumbs.push({ level: \"Enterprise\", node: selection.enterprise });\n if (selection.businessUnit)\n crumbs.push({ level: \"Business Unit\", node: selection.businessUnit });\n if (selection.site)\n crumbs.push({ level: \"Site\", node: selection.site });\n if (selection.area)\n crumbs.push({ level: \"Area\", node: selection.area });\n if (selection.asset)\n crumbs.push({ level: \"Asset\", node: selection.asset });\n return crumbs;\n }, [selection]);\n\n // ── Context value ──\n\n const value = useMemo<OrgHierarchyContextValue>(\n () => ({\n selection,\n enterprises,\n businessUnits,\n sites,\n areas,\n assets,\n selectEnterprise,\n selectBusinessUnit,\n selectSite,\n selectArea,\n selectAsset,\n canSwitchEnterprise,\n loading: isLoading,\n breadcrumbs,\n }),\n [\n selection,\n enterprises,\n businessUnits,\n sites,\n areas,\n assets,\n selectEnterprise,\n selectBusinessUnit,\n selectSite,\n selectArea,\n selectAsset,\n canSwitchEnterprise,\n isLoading,\n breadcrumbs,\n ]\n );\n\n return (\n <OrgHierarchyCtx.Provider value={value}>\n {children}\n </OrgHierarchyCtx.Provider>\n );\n }\n\n function useOrgHierarchy(): OrgHierarchyContextValue {\n return useContext(OrgHierarchyCtx);\n }\n\n return { OrgHierarchyProvider, useOrgHierarchy };\n}\n\n/* ── Re-export types for convenience ── */\nexport type {\n OrgHierarchyNode,\n OrgHierarchyData,\n OrgHierarchySelection,\n OrgHierarchyContextValue,\n} from \"./orgHierarchy\";\n","/**\n * HierarchyNavigator — breadcrumb-style hierarchy switcher.\n *\n * Displays: Enterprise / BU / Site / Area / Asset\n * Each level is a clickable dropdown to switch context.\n * Platform admins can switch enterprises; others see their scoped enterprise.\n *\n * NOTE: This component requires the consuming app to provide:\n * - A hierarchy context via useHierarchy prop\n * - shadcn/ui DropdownMenu components via the renderDropdown prop\n *\n * For apps using the createOrgHierarchyContext factory, pass the useOrgHierarchy hook.\n *\n * Oplytics dark theme: #0A0E1A bg, #8C34E9 accent, #E2E8F0 text, #8890A0 muted\n */\nimport { cn } from \"../utils/cn\";\nimport type { OrgHierarchyNode, OrgHierarchyContextValue } from \"./orgHierarchy\";\nimport { ChevronRight, ChevronDown, Building2, Network, MapPin, LayoutGrid, Box } from \"lucide-react\";\nimport type { ReactNode } from \"react\";\n\n/* ── Level config ── */\n\ninterface LevelConfig {\n key: string;\n label: string;\n icon: React.ElementType;\n getNodes: () => OrgHierarchyNode[];\n getSelected: () => OrgHierarchyNode | null;\n onSelect: (node: OrgHierarchyNode | null) => void;\n canSwitch?: boolean;\n}\n\n/* ── Dropdown render prop types ── */\n\nexport interface DropdownRenderProps {\n trigger: ReactNode;\n items: Array<{\n key: number;\n label: string;\n code?: string;\n icon: React.ElementType;\n isActive: boolean;\n onClick: () => void;\n }>;\n align?: \"start\" | \"end\";\n}\n\n/* ── Single breadcrumb level ── */\n\nfunction BreadcrumbLevel({\n config,\n isLast,\n compact,\n renderDropdown,\n}: {\n config: LevelConfig;\n isLast: boolean;\n compact?: boolean;\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n}) {\n const nodes = config.getNodes();\n const selected = config.getSelected();\n const Icon = config.icon;\n const canSwitch = config.canSwitch !== false;\n const hasMultiple = nodes.length > 1;\n\n if (!selected) return null;\n\n // If only one option or can't switch, show as static text\n if (!hasMultiple || !canSwitch) {\n return (\n <div className=\"flex items-center gap-1\">\n <div\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#E2E8F0]\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n </div>\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n )}\n </div>\n );\n }\n\n // Multiple options — use renderDropdown if provided, otherwise basic button\n const trigger = (\n <button\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#E2E8F0] hover:bg-[#1E2738] hover:text-white\",\n \"transition-colors cursor-pointer outline-none\",\n \"focus-visible:ring-1 focus-visible:ring-[#8C34E9]\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0 text-[#8890A0]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate max-w-[120px]\">{selected.name}</span>\n <ChevronDown className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\n </button>\n );\n\n const items = nodes.map((node) => ({\n key: node.id,\n label: node.name,\n code: node.code,\n icon: Icon,\n isActive: selected.id === node.id,\n onClick: () => config.onSelect(node),\n }));\n\n return (\n <div className=\"flex items-center gap-1\">\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n // Fallback: simple select-style rendering\n <div className=\"relative group\">\n {trigger}\n </div>\n )}\n {!isLast && (\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n )}\n </div>\n );\n}\n\n/* ── Drill-down prompt ── */\n\nfunction DrillDownPrompt({\n label,\n icon: Icon,\n nodes,\n onSelect,\n compact,\n renderDropdown,\n}: {\n label: string;\n icon: React.ElementType;\n nodes: OrgHierarchyNode[];\n onSelect: (node: OrgHierarchyNode) => void;\n compact?: boolean;\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n}) {\n if (nodes.length === 0) return null;\n\n // Auto-select if only one option\n if (nodes.length === 1) {\n return (\n <div className=\"flex items-center gap-1\">\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <button\n onClick={() => onSelect(nodes[0])}\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate\">{nodes[0].name}</span>\n </button>\n </div>\n );\n }\n\n const trigger = (\n <button\n className={cn(\n \"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm\",\n \"text-[#596475] hover:bg-[#1E2738] hover:text-[#8890A0]\",\n \"transition-colors cursor-pointer outline-none\",\n \"border border-dashed border-[#2A2A3E] hover:border-[#596475]\",\n compact && \"px-1.5 py-0.5 text-xs\"\n )}\n >\n <Icon className={cn(\"shrink-0\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n <span className=\"truncate\">Select {label}</span>\n <ChevronDown className={cn(\"shrink-0\", compact ? \"h-2.5 w-2.5\" : \"h-3 w-3\")} />\n </button>\n );\n\n const items = nodes.map((node) => ({\n key: node.id,\n label: node.name,\n code: node.code,\n icon: Icon,\n isActive: false,\n onClick: () => onSelect(node),\n }));\n\n return (\n <div className=\"flex items-center gap-1\">\n <ChevronRight className={cn(\"shrink-0 text-[#596475]\", compact ? \"h-3 w-3\" : \"h-3.5 w-3.5\")} />\n {renderDropdown ? (\n renderDropdown({ trigger, items, align: \"start\" })\n ) : (\n <div className=\"relative group\">\n {trigger}\n </div>\n )}\n </div>\n );\n}\n\n/* ── Main component ── */\n\nexport interface HierarchyNavigatorProps {\n /** The hierarchy context value — pass from useOrgHierarchy() */\n hierarchy: OrgHierarchyContextValue;\n /** Show in compact mode (smaller text, tighter spacing) */\n compact?: boolean;\n /** Maximum depth to show (default: all 5 levels) */\n maxDepth?: number;\n /** CSS class for the container */\n className?: string;\n /**\n * Render prop for dropdown menus. If not provided, dropdowns won't open.\n * Consuming apps should pass a function that renders their shadcn/ui DropdownMenu.\n */\n renderDropdown?: (props: DropdownRenderProps) => ReactNode;\n}\n\nexport function HierarchyNavigator({\n hierarchy: ctx,\n compact = false,\n maxDepth = 5,\n className,\n renderDropdown,\n}: HierarchyNavigatorProps) {\n if (ctx.loading) {\n return (\n <div className={cn(\"flex items-center gap-2 animate-pulse\", className)}>\n <div className=\"h-6 w-24 rounded bg-[#1E2738]\" />\n <ChevronRight className=\"h-3.5 w-3.5 text-[#596475]\" />\n <div className=\"h-6 w-20 rounded bg-[#1E2738]\" />\n </div>\n );\n }\n\n // Build the level configs\n const levels: LevelConfig[] = [\n {\n key: \"enterprise\",\n label: \"Enterprise\",\n icon: Building2,\n getNodes: () => ctx.enterprises,\n getSelected: () => ctx.selection.enterprise,\n onSelect: ctx.selectEnterprise,\n canSwitch: ctx.canSwitchEnterprise,\n },\n {\n key: \"businessUnit\",\n label: \"Business Unit\",\n icon: Network,\n getNodes: () => ctx.businessUnits,\n getSelected: () => ctx.selection.businessUnit,\n onSelect: ctx.selectBusinessUnit,\n },\n {\n key: \"site\",\n label: \"Site\",\n icon: MapPin,\n getNodes: () => ctx.sites,\n getSelected: () => ctx.selection.site,\n onSelect: ctx.selectSite,\n },\n {\n key: \"area\",\n label: \"Area\",\n icon: LayoutGrid,\n getNodes: () => ctx.areas,\n getSelected: () => ctx.selection.area,\n onSelect: ctx.selectArea,\n },\n {\n key: \"asset\",\n label: \"Asset\",\n icon: Box,\n getNodes: () => ctx.assets,\n getSelected: () => ctx.selection.asset,\n onSelect: ctx.selectAsset,\n },\n ].slice(0, maxDepth);\n\n // Determine which levels are selected and which is the next drill-down\n const selectedLevels = levels.filter((l) => l.getSelected() !== null);\n const nextLevel = levels.find((l) => l.getSelected() === null && l.getNodes().length > 0);\n\n return (\n <nav\n className={cn(\"flex items-center flex-wrap gap-0.5\", className)}\n aria-label=\"Hierarchy navigation\"\n >\n {selectedLevels.map((level, idx) => (\n <BreadcrumbLevel\n key={level.key}\n config={level}\n isLast={idx === selectedLevels.length - 1 && !nextLevel}\n compact={compact}\n renderDropdown={renderDropdown}\n />\n ))}\n {nextLevel && (\n <DrillDownPrompt\n label={nextLevel.label}\n icon={nextLevel.icon}\n nodes={nextLevel.getNodes()}\n onSelect={nextLevel.onSelect}\n compact={compact}\n renderDropdown={renderDropdown}\n />\n )}\n {selectedLevels.length === 0 && !nextLevel && (\n <span className=\"text-sm text-[#596475] italic\">No hierarchy data available</span>\n )}\n </nav>\n );\n}\n"],"mappings":";;;;;;;;;AAeA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA6RD;AA1QC,SAAS,6BAA4C;AAC1D,MAAI,OAAO,aAAa,YAAa,QAAO;AAC5C,QAAM,QAAQ,SAAS,OACpB,MAAM,GAAG,EACT,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EACnB,KAAK,CAAC,MAAM,EAAE,WAAW,GAAG,wBAAwB,GAAG,CAAC;AAC3D,MAAI,CAAC,MAAO,QAAO;AACnB,QAAM,QAAQ,mBAAmB,MAAM,MAAM,yBAAyB,SAAS,CAAC,CAAC;AACjF,SAAO,MAAM,SAAS,Q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