@optifye/dashboard-core 6.11.6 → 6.11.8

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.mjs CHANGED
@@ -1,16 +1,16 @@
1
1
  import * as React141 from 'react';
2
- import React141__default, { createContext, useRef, useCallback, useState, useMemo, useEffect, forwardRef, useImperativeHandle, useLayoutEffect, memo as memo$1, useContext, useId, Children, isValidElement, useInsertionEffect, Fragment as Fragment$1, createElement, Component } from 'react';
2
+ import React141__default, { createContext, useRef, useCallback, useState, useMemo, useEffect, forwardRef, useImperativeHandle, useLayoutEffect, memo as memo$1, useContext, useSyncExternalStore, useId, Children, isValidElement, useInsertionEffect, startTransition, Fragment as Fragment$1, createElement, Component } from 'react';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { useRouter } from 'next/router';
5
5
  import { fromZonedTime, formatInTimeZone, toZonedTime } from 'date-fns-tz';
6
- import { format, subMonths, endOfMonth, startOfMonth, endOfDay, eachDayOfInterval, getDay, isSameDay, isWithinInterval, startOfDay, addDays, differenceInMinutes, addMinutes, parseISO, subDays, addMonths, isValid, formatDistanceToNow, isToday, isFuture, isBefore } from 'date-fns';
6
+ import { format, addDays, subMonths, endOfMonth, startOfMonth, endOfDay, eachDayOfInterval, getDay, isSameDay, isWithinInterval, startOfDay, parseISO, subDays, differenceInMinutes, addMinutes, addMonths, isValid, formatDistanceToNow, isToday, isFuture, isBefore } from 'date-fns';
7
7
  import mixpanel from 'mixpanel-browser';
8
8
  import { EventEmitter } from 'events';
9
9
  import { createClient, REALTIME_SUBSCRIBE_STATES } from '@supabase/supabase-js';
10
10
  import Hls, { Events, ErrorTypes } from 'hls.js';
11
11
  import useSWR from 'swr';
12
12
  import { memo, noop, warning, invariant, progress, secondsToMilliseconds, millisecondsToSeconds } from 'motion-utils';
13
- import { Camera, AlertTriangle, ChevronDown, ChevronUp, Check, Map as Map$1, Video, ShieldCheck, Star, Award, Filter, X, Coffee, Plus, ArrowLeft, Clock, Calendar, Save, AlertCircle, Loader2, Minus, ArrowDown, ArrowUp, ChevronLeft, ChevronRight, TrendingUp, Sparkles, Pause, Play, Wrench, XCircle, Package, UserX, Zap, HelpCircle, Tag, Palette, CheckCircle2, RefreshCw, TrendingDown, FolderOpen, Folder, Sliders, Activity, Layers, Search, Edit2, ArrowRight, CheckCircle, User, Users, Shield, Building2, Mail, Lock, Info, Share2, Trophy, Target, Download, Sun, Moon, MousePointer, UserPlus, UserCog, Trash2, Eye, MoreVertical, BarChart3, Pencil, UserCheck, LogOut, Film, MessageSquare, Menu, Send, Copy, Settings, LifeBuoy, EyeOff, Flame, Crown, Medal } from 'lucide-react';
13
+ import { Camera, AlertTriangle, ChevronDown, ChevronUp, Check, Map as Map$1, Video, ShieldCheck, Star, Award, Filter, X, Coffee, Plus, ArrowUp, ArrowDown, ArrowRight, ArrowLeft, Clock, Calendar, Save, AlertCircle, Loader2, Minus, ChevronLeft, ChevronRight, TrendingUp, Sparkles, Pause, Play, Wrench, XCircle, Package, UserX, Zap, HelpCircle, Tag, Palette, CheckCircle2, RefreshCw, TrendingDown, FolderOpen, Folder, Sliders, Activity, Layers, Search, Edit2, CheckCircle, User, Users, Shield, Building2, Mail, Lock, Info, Share2, Trophy, Target, Download, Sun, Moon, MousePointer, UserPlus, UserCog, Trash2, Eye, MoreVertical, BarChart3, Pencil, UserCheck, LogOut, Film, MessageSquare, Menu, Send, Copy, Settings, LifeBuoy, EyeOff, Flame, Crown, Medal } from 'lucide-react';
14
14
  import { toast } from 'sonner';
15
15
  import { BarChart as BarChart$1, CartesianGrid, XAxis, YAxis, ReferenceLine, Tooltip, Legend, Bar, LabelList, ResponsiveContainer, LineChart as LineChart$1, Line, PieChart, Pie, Cell, ComposedChart, Area, ScatterChart, Scatter } from 'recharts';
16
16
  import { Slot } from '@radix-ui/react-slot';
@@ -25,12 +25,1550 @@ import { S3Client, ListObjectsV2Command, GetObjectCommand } from '@aws-sdk/clien
25
25
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
26
26
  import { Readable } from 'stream';
27
27
 
28
+ var __create = Object.create;
29
+ var __defProp = Object.defineProperty;
30
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
31
+ var __getOwnPropNames = Object.getOwnPropertyNames;
32
+ var __getProtoOf = Object.getPrototypeOf;
33
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
28
34
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
29
35
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
30
36
  }) : x)(function(x) {
31
37
  if (typeof require !== "undefined") return require.apply(this, arguments);
32
38
  throw Error('Dynamic require of "' + x + '" is not supported');
33
39
  });
40
+ var __commonJS = (cb, mod) => function __require2() {
41
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
42
+ };
43
+ var __copyProps = (to, from, except, desc) => {
44
+ if (from && typeof from === "object" || typeof from === "function") {
45
+ for (let key of __getOwnPropNames(from))
46
+ if (!__hasOwnProp.call(to, key) && key !== except)
47
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
48
+ }
49
+ return to;
50
+ };
51
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
52
+ // If the importer is in node compatibility mode or this is not an ESM
53
+ // file that has been converted to a CommonJS file using a Babel-
54
+ // compatible transform (i.e. "__esModule" has not been set), then set
55
+ // "default" to the CommonJS "module.exports" for node compatibility.
56
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
57
+ mod
58
+ ));
59
+
60
+ // ../../node_modules/lodash/_listCacheClear.js
61
+ var require_listCacheClear = __commonJS({
62
+ "../../node_modules/lodash/_listCacheClear.js"(exports, module) {
63
+ function listCacheClear() {
64
+ this.__data__ = [];
65
+ this.size = 0;
66
+ }
67
+ module.exports = listCacheClear;
68
+ }
69
+ });
70
+
71
+ // ../../node_modules/lodash/eq.js
72
+ var require_eq = __commonJS({
73
+ "../../node_modules/lodash/eq.js"(exports, module) {
74
+ function eq(value, other) {
75
+ return value === other || value !== value && other !== other;
76
+ }
77
+ module.exports = eq;
78
+ }
79
+ });
80
+
81
+ // ../../node_modules/lodash/_assocIndexOf.js
82
+ var require_assocIndexOf = __commonJS({
83
+ "../../node_modules/lodash/_assocIndexOf.js"(exports, module) {
84
+ var eq = require_eq();
85
+ function assocIndexOf(array, key) {
86
+ var length = array.length;
87
+ while (length--) {
88
+ if (eq(array[length][0], key)) {
89
+ return length;
90
+ }
91
+ }
92
+ return -1;
93
+ }
94
+ module.exports = assocIndexOf;
95
+ }
96
+ });
97
+
98
+ // ../../node_modules/lodash/_listCacheDelete.js
99
+ var require_listCacheDelete = __commonJS({
100
+ "../../node_modules/lodash/_listCacheDelete.js"(exports, module) {
101
+ var assocIndexOf = require_assocIndexOf();
102
+ var arrayProto = Array.prototype;
103
+ var splice = arrayProto.splice;
104
+ function listCacheDelete(key) {
105
+ var data = this.__data__, index = assocIndexOf(data, key);
106
+ if (index < 0) {
107
+ return false;
108
+ }
109
+ var lastIndex = data.length - 1;
110
+ if (index == lastIndex) {
111
+ data.pop();
112
+ } else {
113
+ splice.call(data, index, 1);
114
+ }
115
+ --this.size;
116
+ return true;
117
+ }
118
+ module.exports = listCacheDelete;
119
+ }
120
+ });
121
+
122
+ // ../../node_modules/lodash/_listCacheGet.js
123
+ var require_listCacheGet = __commonJS({
124
+ "../../node_modules/lodash/_listCacheGet.js"(exports, module) {
125
+ var assocIndexOf = require_assocIndexOf();
126
+ function listCacheGet(key) {
127
+ var data = this.__data__, index = assocIndexOf(data, key);
128
+ return index < 0 ? void 0 : data[index][1];
129
+ }
130
+ module.exports = listCacheGet;
131
+ }
132
+ });
133
+
134
+ // ../../node_modules/lodash/_listCacheHas.js
135
+ var require_listCacheHas = __commonJS({
136
+ "../../node_modules/lodash/_listCacheHas.js"(exports, module) {
137
+ var assocIndexOf = require_assocIndexOf();
138
+ function listCacheHas(key) {
139
+ return assocIndexOf(this.__data__, key) > -1;
140
+ }
141
+ module.exports = listCacheHas;
142
+ }
143
+ });
144
+
145
+ // ../../node_modules/lodash/_listCacheSet.js
146
+ var require_listCacheSet = __commonJS({
147
+ "../../node_modules/lodash/_listCacheSet.js"(exports, module) {
148
+ var assocIndexOf = require_assocIndexOf();
149
+ function listCacheSet(key, value) {
150
+ var data = this.__data__, index = assocIndexOf(data, key);
151
+ if (index < 0) {
152
+ ++this.size;
153
+ data.push([key, value]);
154
+ } else {
155
+ data[index][1] = value;
156
+ }
157
+ return this;
158
+ }
159
+ module.exports = listCacheSet;
160
+ }
161
+ });
162
+
163
+ // ../../node_modules/lodash/_ListCache.js
164
+ var require_ListCache = __commonJS({
165
+ "../../node_modules/lodash/_ListCache.js"(exports, module) {
166
+ var listCacheClear = require_listCacheClear();
167
+ var listCacheDelete = require_listCacheDelete();
168
+ var listCacheGet = require_listCacheGet();
169
+ var listCacheHas = require_listCacheHas();
170
+ var listCacheSet = require_listCacheSet();
171
+ function ListCache(entries) {
172
+ var index = -1, length = entries == null ? 0 : entries.length;
173
+ this.clear();
174
+ while (++index < length) {
175
+ var entry = entries[index];
176
+ this.set(entry[0], entry[1]);
177
+ }
178
+ }
179
+ ListCache.prototype.clear = listCacheClear;
180
+ ListCache.prototype["delete"] = listCacheDelete;
181
+ ListCache.prototype.get = listCacheGet;
182
+ ListCache.prototype.has = listCacheHas;
183
+ ListCache.prototype.set = listCacheSet;
184
+ module.exports = ListCache;
185
+ }
186
+ });
187
+
188
+ // ../../node_modules/lodash/_stackClear.js
189
+ var require_stackClear = __commonJS({
190
+ "../../node_modules/lodash/_stackClear.js"(exports, module) {
191
+ var ListCache = require_ListCache();
192
+ function stackClear() {
193
+ this.__data__ = new ListCache();
194
+ this.size = 0;
195
+ }
196
+ module.exports = stackClear;
197
+ }
198
+ });
199
+
200
+ // ../../node_modules/lodash/_stackDelete.js
201
+ var require_stackDelete = __commonJS({
202
+ "../../node_modules/lodash/_stackDelete.js"(exports, module) {
203
+ function stackDelete(key) {
204
+ var data = this.__data__, result = data["delete"](key);
205
+ this.size = data.size;
206
+ return result;
207
+ }
208
+ module.exports = stackDelete;
209
+ }
210
+ });
211
+
212
+ // ../../node_modules/lodash/_stackGet.js
213
+ var require_stackGet = __commonJS({
214
+ "../../node_modules/lodash/_stackGet.js"(exports, module) {
215
+ function stackGet(key) {
216
+ return this.__data__.get(key);
217
+ }
218
+ module.exports = stackGet;
219
+ }
220
+ });
221
+
222
+ // ../../node_modules/lodash/_stackHas.js
223
+ var require_stackHas = __commonJS({
224
+ "../../node_modules/lodash/_stackHas.js"(exports, module) {
225
+ function stackHas(key) {
226
+ return this.__data__.has(key);
227
+ }
228
+ module.exports = stackHas;
229
+ }
230
+ });
231
+
232
+ // ../../node_modules/lodash/_freeGlobal.js
233
+ var require_freeGlobal = __commonJS({
234
+ "../../node_modules/lodash/_freeGlobal.js"(exports, module) {
235
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
236
+ module.exports = freeGlobal;
237
+ }
238
+ });
239
+
240
+ // ../../node_modules/lodash/_root.js
241
+ var require_root = __commonJS({
242
+ "../../node_modules/lodash/_root.js"(exports, module) {
243
+ var freeGlobal = require_freeGlobal();
244
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
245
+ var root = freeGlobal || freeSelf || Function("return this")();
246
+ module.exports = root;
247
+ }
248
+ });
249
+
250
+ // ../../node_modules/lodash/_Symbol.js
251
+ var require_Symbol = __commonJS({
252
+ "../../node_modules/lodash/_Symbol.js"(exports, module) {
253
+ var root = require_root();
254
+ var Symbol2 = root.Symbol;
255
+ module.exports = Symbol2;
256
+ }
257
+ });
258
+
259
+ // ../../node_modules/lodash/_getRawTag.js
260
+ var require_getRawTag = __commonJS({
261
+ "../../node_modules/lodash/_getRawTag.js"(exports, module) {
262
+ var Symbol2 = require_Symbol();
263
+ var objectProto = Object.prototype;
264
+ var hasOwnProperty = objectProto.hasOwnProperty;
265
+ var nativeObjectToString = objectProto.toString;
266
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
267
+ function getRawTag(value) {
268
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
269
+ try {
270
+ value[symToStringTag] = void 0;
271
+ var unmasked = true;
272
+ } catch (e) {
273
+ }
274
+ var result = nativeObjectToString.call(value);
275
+ if (unmasked) {
276
+ if (isOwn) {
277
+ value[symToStringTag] = tag;
278
+ } else {
279
+ delete value[symToStringTag];
280
+ }
281
+ }
282
+ return result;
283
+ }
284
+ module.exports = getRawTag;
285
+ }
286
+ });
287
+
288
+ // ../../node_modules/lodash/_objectToString.js
289
+ var require_objectToString = __commonJS({
290
+ "../../node_modules/lodash/_objectToString.js"(exports, module) {
291
+ var objectProto = Object.prototype;
292
+ var nativeObjectToString = objectProto.toString;
293
+ function objectToString(value) {
294
+ return nativeObjectToString.call(value);
295
+ }
296
+ module.exports = objectToString;
297
+ }
298
+ });
299
+
300
+ // ../../node_modules/lodash/_baseGetTag.js
301
+ var require_baseGetTag = __commonJS({
302
+ "../../node_modules/lodash/_baseGetTag.js"(exports, module) {
303
+ var Symbol2 = require_Symbol();
304
+ var getRawTag = require_getRawTag();
305
+ var objectToString = require_objectToString();
306
+ var nullTag = "[object Null]";
307
+ var undefinedTag = "[object Undefined]";
308
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
309
+ function baseGetTag(value) {
310
+ if (value == null) {
311
+ return value === void 0 ? undefinedTag : nullTag;
312
+ }
313
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
314
+ }
315
+ module.exports = baseGetTag;
316
+ }
317
+ });
318
+
319
+ // ../../node_modules/lodash/isObject.js
320
+ var require_isObject = __commonJS({
321
+ "../../node_modules/lodash/isObject.js"(exports, module) {
322
+ function isObject2(value) {
323
+ var type = typeof value;
324
+ return value != null && (type == "object" || type == "function");
325
+ }
326
+ module.exports = isObject2;
327
+ }
328
+ });
329
+
330
+ // ../../node_modules/lodash/isFunction.js
331
+ var require_isFunction = __commonJS({
332
+ "../../node_modules/lodash/isFunction.js"(exports, module) {
333
+ var baseGetTag = require_baseGetTag();
334
+ var isObject2 = require_isObject();
335
+ var asyncTag = "[object AsyncFunction]";
336
+ var funcTag = "[object Function]";
337
+ var genTag = "[object GeneratorFunction]";
338
+ var proxyTag = "[object Proxy]";
339
+ function isFunction(value) {
340
+ if (!isObject2(value)) {
341
+ return false;
342
+ }
343
+ var tag = baseGetTag(value);
344
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
345
+ }
346
+ module.exports = isFunction;
347
+ }
348
+ });
349
+
350
+ // ../../node_modules/lodash/_coreJsData.js
351
+ var require_coreJsData = __commonJS({
352
+ "../../node_modules/lodash/_coreJsData.js"(exports, module) {
353
+ var root = require_root();
354
+ var coreJsData = root["__core-js_shared__"];
355
+ module.exports = coreJsData;
356
+ }
357
+ });
358
+
359
+ // ../../node_modules/lodash/_isMasked.js
360
+ var require_isMasked = __commonJS({
361
+ "../../node_modules/lodash/_isMasked.js"(exports, module) {
362
+ var coreJsData = require_coreJsData();
363
+ var maskSrcKey = function() {
364
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
365
+ return uid ? "Symbol(src)_1." + uid : "";
366
+ }();
367
+ function isMasked(func) {
368
+ return !!maskSrcKey && maskSrcKey in func;
369
+ }
370
+ module.exports = isMasked;
371
+ }
372
+ });
373
+
374
+ // ../../node_modules/lodash/_toSource.js
375
+ var require_toSource = __commonJS({
376
+ "../../node_modules/lodash/_toSource.js"(exports, module) {
377
+ var funcProto = Function.prototype;
378
+ var funcToString = funcProto.toString;
379
+ function toSource(func) {
380
+ if (func != null) {
381
+ try {
382
+ return funcToString.call(func);
383
+ } catch (e) {
384
+ }
385
+ try {
386
+ return func + "";
387
+ } catch (e) {
388
+ }
389
+ }
390
+ return "";
391
+ }
392
+ module.exports = toSource;
393
+ }
394
+ });
395
+
396
+ // ../../node_modules/lodash/_baseIsNative.js
397
+ var require_baseIsNative = __commonJS({
398
+ "../../node_modules/lodash/_baseIsNative.js"(exports, module) {
399
+ var isFunction = require_isFunction();
400
+ var isMasked = require_isMasked();
401
+ var isObject2 = require_isObject();
402
+ var toSource = require_toSource();
403
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
404
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
405
+ var funcProto = Function.prototype;
406
+ var objectProto = Object.prototype;
407
+ var funcToString = funcProto.toString;
408
+ var hasOwnProperty = objectProto.hasOwnProperty;
409
+ var reIsNative = RegExp(
410
+ "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
411
+ );
412
+ function baseIsNative(value) {
413
+ if (!isObject2(value) || isMasked(value)) {
414
+ return false;
415
+ }
416
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
417
+ return pattern.test(toSource(value));
418
+ }
419
+ module.exports = baseIsNative;
420
+ }
421
+ });
422
+
423
+ // ../../node_modules/lodash/_getValue.js
424
+ var require_getValue = __commonJS({
425
+ "../../node_modules/lodash/_getValue.js"(exports, module) {
426
+ function getValue(object, key) {
427
+ return object == null ? void 0 : object[key];
428
+ }
429
+ module.exports = getValue;
430
+ }
431
+ });
432
+
433
+ // ../../node_modules/lodash/_getNative.js
434
+ var require_getNative = __commonJS({
435
+ "../../node_modules/lodash/_getNative.js"(exports, module) {
436
+ var baseIsNative = require_baseIsNative();
437
+ var getValue = require_getValue();
438
+ function getNative(object, key) {
439
+ var value = getValue(object, key);
440
+ return baseIsNative(value) ? value : void 0;
441
+ }
442
+ module.exports = getNative;
443
+ }
444
+ });
445
+
446
+ // ../../node_modules/lodash/_Map.js
447
+ var require_Map = __commonJS({
448
+ "../../node_modules/lodash/_Map.js"(exports, module) {
449
+ var getNative = require_getNative();
450
+ var root = require_root();
451
+ var Map2 = getNative(root, "Map");
452
+ module.exports = Map2;
453
+ }
454
+ });
455
+
456
+ // ../../node_modules/lodash/_nativeCreate.js
457
+ var require_nativeCreate = __commonJS({
458
+ "../../node_modules/lodash/_nativeCreate.js"(exports, module) {
459
+ var getNative = require_getNative();
460
+ var nativeCreate = getNative(Object, "create");
461
+ module.exports = nativeCreate;
462
+ }
463
+ });
464
+
465
+ // ../../node_modules/lodash/_hashClear.js
466
+ var require_hashClear = __commonJS({
467
+ "../../node_modules/lodash/_hashClear.js"(exports, module) {
468
+ var nativeCreate = require_nativeCreate();
469
+ function hashClear() {
470
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
471
+ this.size = 0;
472
+ }
473
+ module.exports = hashClear;
474
+ }
475
+ });
476
+
477
+ // ../../node_modules/lodash/_hashDelete.js
478
+ var require_hashDelete = __commonJS({
479
+ "../../node_modules/lodash/_hashDelete.js"(exports, module) {
480
+ function hashDelete(key) {
481
+ var result = this.has(key) && delete this.__data__[key];
482
+ this.size -= result ? 1 : 0;
483
+ return result;
484
+ }
485
+ module.exports = hashDelete;
486
+ }
487
+ });
488
+
489
+ // ../../node_modules/lodash/_hashGet.js
490
+ var require_hashGet = __commonJS({
491
+ "../../node_modules/lodash/_hashGet.js"(exports, module) {
492
+ var nativeCreate = require_nativeCreate();
493
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
494
+ var objectProto = Object.prototype;
495
+ var hasOwnProperty = objectProto.hasOwnProperty;
496
+ function hashGet(key) {
497
+ var data = this.__data__;
498
+ if (nativeCreate) {
499
+ var result = data[key];
500
+ return result === HASH_UNDEFINED ? void 0 : result;
501
+ }
502
+ return hasOwnProperty.call(data, key) ? data[key] : void 0;
503
+ }
504
+ module.exports = hashGet;
505
+ }
506
+ });
507
+
508
+ // ../../node_modules/lodash/_hashHas.js
509
+ var require_hashHas = __commonJS({
510
+ "../../node_modules/lodash/_hashHas.js"(exports, module) {
511
+ var nativeCreate = require_nativeCreate();
512
+ var objectProto = Object.prototype;
513
+ var hasOwnProperty = objectProto.hasOwnProperty;
514
+ function hashHas(key) {
515
+ var data = this.__data__;
516
+ return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
517
+ }
518
+ module.exports = hashHas;
519
+ }
520
+ });
521
+
522
+ // ../../node_modules/lodash/_hashSet.js
523
+ var require_hashSet = __commonJS({
524
+ "../../node_modules/lodash/_hashSet.js"(exports, module) {
525
+ var nativeCreate = require_nativeCreate();
526
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
527
+ function hashSet(key, value) {
528
+ var data = this.__data__;
529
+ this.size += this.has(key) ? 0 : 1;
530
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
531
+ return this;
532
+ }
533
+ module.exports = hashSet;
534
+ }
535
+ });
536
+
537
+ // ../../node_modules/lodash/_Hash.js
538
+ var require_Hash = __commonJS({
539
+ "../../node_modules/lodash/_Hash.js"(exports, module) {
540
+ var hashClear = require_hashClear();
541
+ var hashDelete = require_hashDelete();
542
+ var hashGet = require_hashGet();
543
+ var hashHas = require_hashHas();
544
+ var hashSet = require_hashSet();
545
+ function Hash(entries) {
546
+ var index = -1, length = entries == null ? 0 : entries.length;
547
+ this.clear();
548
+ while (++index < length) {
549
+ var entry = entries[index];
550
+ this.set(entry[0], entry[1]);
551
+ }
552
+ }
553
+ Hash.prototype.clear = hashClear;
554
+ Hash.prototype["delete"] = hashDelete;
555
+ Hash.prototype.get = hashGet;
556
+ Hash.prototype.has = hashHas;
557
+ Hash.prototype.set = hashSet;
558
+ module.exports = Hash;
559
+ }
560
+ });
561
+
562
+ // ../../node_modules/lodash/_mapCacheClear.js
563
+ var require_mapCacheClear = __commonJS({
564
+ "../../node_modules/lodash/_mapCacheClear.js"(exports, module) {
565
+ var Hash = require_Hash();
566
+ var ListCache = require_ListCache();
567
+ var Map2 = require_Map();
568
+ function mapCacheClear() {
569
+ this.size = 0;
570
+ this.__data__ = {
571
+ "hash": new Hash(),
572
+ "map": new (Map2 || ListCache)(),
573
+ "string": new Hash()
574
+ };
575
+ }
576
+ module.exports = mapCacheClear;
577
+ }
578
+ });
579
+
580
+ // ../../node_modules/lodash/_isKeyable.js
581
+ var require_isKeyable = __commonJS({
582
+ "../../node_modules/lodash/_isKeyable.js"(exports, module) {
583
+ function isKeyable(value) {
584
+ var type = typeof value;
585
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
586
+ }
587
+ module.exports = isKeyable;
588
+ }
589
+ });
590
+
591
+ // ../../node_modules/lodash/_getMapData.js
592
+ var require_getMapData = __commonJS({
593
+ "../../node_modules/lodash/_getMapData.js"(exports, module) {
594
+ var isKeyable = require_isKeyable();
595
+ function getMapData(map, key) {
596
+ var data = map.__data__;
597
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
598
+ }
599
+ module.exports = getMapData;
600
+ }
601
+ });
602
+
603
+ // ../../node_modules/lodash/_mapCacheDelete.js
604
+ var require_mapCacheDelete = __commonJS({
605
+ "../../node_modules/lodash/_mapCacheDelete.js"(exports, module) {
606
+ var getMapData = require_getMapData();
607
+ function mapCacheDelete(key) {
608
+ var result = getMapData(this, key)["delete"](key);
609
+ this.size -= result ? 1 : 0;
610
+ return result;
611
+ }
612
+ module.exports = mapCacheDelete;
613
+ }
614
+ });
615
+
616
+ // ../../node_modules/lodash/_mapCacheGet.js
617
+ var require_mapCacheGet = __commonJS({
618
+ "../../node_modules/lodash/_mapCacheGet.js"(exports, module) {
619
+ var getMapData = require_getMapData();
620
+ function mapCacheGet(key) {
621
+ return getMapData(this, key).get(key);
622
+ }
623
+ module.exports = mapCacheGet;
624
+ }
625
+ });
626
+
627
+ // ../../node_modules/lodash/_mapCacheHas.js
628
+ var require_mapCacheHas = __commonJS({
629
+ "../../node_modules/lodash/_mapCacheHas.js"(exports, module) {
630
+ var getMapData = require_getMapData();
631
+ function mapCacheHas(key) {
632
+ return getMapData(this, key).has(key);
633
+ }
634
+ module.exports = mapCacheHas;
635
+ }
636
+ });
637
+
638
+ // ../../node_modules/lodash/_mapCacheSet.js
639
+ var require_mapCacheSet = __commonJS({
640
+ "../../node_modules/lodash/_mapCacheSet.js"(exports, module) {
641
+ var getMapData = require_getMapData();
642
+ function mapCacheSet(key, value) {
643
+ var data = getMapData(this, key), size = data.size;
644
+ data.set(key, value);
645
+ this.size += data.size == size ? 0 : 1;
646
+ return this;
647
+ }
648
+ module.exports = mapCacheSet;
649
+ }
650
+ });
651
+
652
+ // ../../node_modules/lodash/_MapCache.js
653
+ var require_MapCache = __commonJS({
654
+ "../../node_modules/lodash/_MapCache.js"(exports, module) {
655
+ var mapCacheClear = require_mapCacheClear();
656
+ var mapCacheDelete = require_mapCacheDelete();
657
+ var mapCacheGet = require_mapCacheGet();
658
+ var mapCacheHas = require_mapCacheHas();
659
+ var mapCacheSet = require_mapCacheSet();
660
+ function MapCache(entries) {
661
+ var index = -1, length = entries == null ? 0 : entries.length;
662
+ this.clear();
663
+ while (++index < length) {
664
+ var entry = entries[index];
665
+ this.set(entry[0], entry[1]);
666
+ }
667
+ }
668
+ MapCache.prototype.clear = mapCacheClear;
669
+ MapCache.prototype["delete"] = mapCacheDelete;
670
+ MapCache.prototype.get = mapCacheGet;
671
+ MapCache.prototype.has = mapCacheHas;
672
+ MapCache.prototype.set = mapCacheSet;
673
+ module.exports = MapCache;
674
+ }
675
+ });
676
+
677
+ // ../../node_modules/lodash/_stackSet.js
678
+ var require_stackSet = __commonJS({
679
+ "../../node_modules/lodash/_stackSet.js"(exports, module) {
680
+ var ListCache = require_ListCache();
681
+ var Map2 = require_Map();
682
+ var MapCache = require_MapCache();
683
+ var LARGE_ARRAY_SIZE = 200;
684
+ function stackSet(key, value) {
685
+ var data = this.__data__;
686
+ if (data instanceof ListCache) {
687
+ var pairs = data.__data__;
688
+ if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
689
+ pairs.push([key, value]);
690
+ this.size = ++data.size;
691
+ return this;
692
+ }
693
+ data = this.__data__ = new MapCache(pairs);
694
+ }
695
+ data.set(key, value);
696
+ this.size = data.size;
697
+ return this;
698
+ }
699
+ module.exports = stackSet;
700
+ }
701
+ });
702
+
703
+ // ../../node_modules/lodash/_Stack.js
704
+ var require_Stack = __commonJS({
705
+ "../../node_modules/lodash/_Stack.js"(exports, module) {
706
+ var ListCache = require_ListCache();
707
+ var stackClear = require_stackClear();
708
+ var stackDelete = require_stackDelete();
709
+ var stackGet = require_stackGet();
710
+ var stackHas = require_stackHas();
711
+ var stackSet = require_stackSet();
712
+ function Stack(entries) {
713
+ var data = this.__data__ = new ListCache(entries);
714
+ this.size = data.size;
715
+ }
716
+ Stack.prototype.clear = stackClear;
717
+ Stack.prototype["delete"] = stackDelete;
718
+ Stack.prototype.get = stackGet;
719
+ Stack.prototype.has = stackHas;
720
+ Stack.prototype.set = stackSet;
721
+ module.exports = Stack;
722
+ }
723
+ });
724
+
725
+ // ../../node_modules/lodash/_setCacheAdd.js
726
+ var require_setCacheAdd = __commonJS({
727
+ "../../node_modules/lodash/_setCacheAdd.js"(exports, module) {
728
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
729
+ function setCacheAdd(value) {
730
+ this.__data__.set(value, HASH_UNDEFINED);
731
+ return this;
732
+ }
733
+ module.exports = setCacheAdd;
734
+ }
735
+ });
736
+
737
+ // ../../node_modules/lodash/_setCacheHas.js
738
+ var require_setCacheHas = __commonJS({
739
+ "../../node_modules/lodash/_setCacheHas.js"(exports, module) {
740
+ function setCacheHas(value) {
741
+ return this.__data__.has(value);
742
+ }
743
+ module.exports = setCacheHas;
744
+ }
745
+ });
746
+
747
+ // ../../node_modules/lodash/_SetCache.js
748
+ var require_SetCache = __commonJS({
749
+ "../../node_modules/lodash/_SetCache.js"(exports, module) {
750
+ var MapCache = require_MapCache();
751
+ var setCacheAdd = require_setCacheAdd();
752
+ var setCacheHas = require_setCacheHas();
753
+ function SetCache(values) {
754
+ var index = -1, length = values == null ? 0 : values.length;
755
+ this.__data__ = new MapCache();
756
+ while (++index < length) {
757
+ this.add(values[index]);
758
+ }
759
+ }
760
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
761
+ SetCache.prototype.has = setCacheHas;
762
+ module.exports = SetCache;
763
+ }
764
+ });
765
+
766
+ // ../../node_modules/lodash/_arraySome.js
767
+ var require_arraySome = __commonJS({
768
+ "../../node_modules/lodash/_arraySome.js"(exports, module) {
769
+ function arraySome(array, predicate) {
770
+ var index = -1, length = array == null ? 0 : array.length;
771
+ while (++index < length) {
772
+ if (predicate(array[index], index, array)) {
773
+ return true;
774
+ }
775
+ }
776
+ return false;
777
+ }
778
+ module.exports = arraySome;
779
+ }
780
+ });
781
+
782
+ // ../../node_modules/lodash/_cacheHas.js
783
+ var require_cacheHas = __commonJS({
784
+ "../../node_modules/lodash/_cacheHas.js"(exports, module) {
785
+ function cacheHas(cache, key) {
786
+ return cache.has(key);
787
+ }
788
+ module.exports = cacheHas;
789
+ }
790
+ });
791
+
792
+ // ../../node_modules/lodash/_equalArrays.js
793
+ var require_equalArrays = __commonJS({
794
+ "../../node_modules/lodash/_equalArrays.js"(exports, module) {
795
+ var SetCache = require_SetCache();
796
+ var arraySome = require_arraySome();
797
+ var cacheHas = require_cacheHas();
798
+ var COMPARE_PARTIAL_FLAG = 1;
799
+ var COMPARE_UNORDERED_FLAG = 2;
800
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
801
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
802
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
803
+ return false;
804
+ }
805
+ var arrStacked = stack.get(array);
806
+ var othStacked = stack.get(other);
807
+ if (arrStacked && othStacked) {
808
+ return arrStacked == other && othStacked == array;
809
+ }
810
+ var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0;
811
+ stack.set(array, other);
812
+ stack.set(other, array);
813
+ while (++index < arrLength) {
814
+ var arrValue = array[index], othValue = other[index];
815
+ if (customizer) {
816
+ var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
817
+ }
818
+ if (compared !== void 0) {
819
+ if (compared) {
820
+ continue;
821
+ }
822
+ result = false;
823
+ break;
824
+ }
825
+ if (seen) {
826
+ if (!arraySome(other, function(othValue2, othIndex) {
827
+ if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
828
+ return seen.push(othIndex);
829
+ }
830
+ })) {
831
+ result = false;
832
+ break;
833
+ }
834
+ } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
835
+ result = false;
836
+ break;
837
+ }
838
+ }
839
+ stack["delete"](array);
840
+ stack["delete"](other);
841
+ return result;
842
+ }
843
+ module.exports = equalArrays;
844
+ }
845
+ });
846
+
847
+ // ../../node_modules/lodash/_Uint8Array.js
848
+ var require_Uint8Array = __commonJS({
849
+ "../../node_modules/lodash/_Uint8Array.js"(exports, module) {
850
+ var root = require_root();
851
+ var Uint8Array2 = root.Uint8Array;
852
+ module.exports = Uint8Array2;
853
+ }
854
+ });
855
+
856
+ // ../../node_modules/lodash/_mapToArray.js
857
+ var require_mapToArray = __commonJS({
858
+ "../../node_modules/lodash/_mapToArray.js"(exports, module) {
859
+ function mapToArray(map) {
860
+ var index = -1, result = Array(map.size);
861
+ map.forEach(function(value, key) {
862
+ result[++index] = [key, value];
863
+ });
864
+ return result;
865
+ }
866
+ module.exports = mapToArray;
867
+ }
868
+ });
869
+
870
+ // ../../node_modules/lodash/_setToArray.js
871
+ var require_setToArray = __commonJS({
872
+ "../../node_modules/lodash/_setToArray.js"(exports, module) {
873
+ function setToArray(set) {
874
+ var index = -1, result = Array(set.size);
875
+ set.forEach(function(value) {
876
+ result[++index] = value;
877
+ });
878
+ return result;
879
+ }
880
+ module.exports = setToArray;
881
+ }
882
+ });
883
+
884
+ // ../../node_modules/lodash/_equalByTag.js
885
+ var require_equalByTag = __commonJS({
886
+ "../../node_modules/lodash/_equalByTag.js"(exports, module) {
887
+ var Symbol2 = require_Symbol();
888
+ var Uint8Array2 = require_Uint8Array();
889
+ var eq = require_eq();
890
+ var equalArrays = require_equalArrays();
891
+ var mapToArray = require_mapToArray();
892
+ var setToArray = require_setToArray();
893
+ var COMPARE_PARTIAL_FLAG = 1;
894
+ var COMPARE_UNORDERED_FLAG = 2;
895
+ var boolTag = "[object Boolean]";
896
+ var dateTag = "[object Date]";
897
+ var errorTag = "[object Error]";
898
+ var mapTag = "[object Map]";
899
+ var numberTag = "[object Number]";
900
+ var regexpTag = "[object RegExp]";
901
+ var setTag = "[object Set]";
902
+ var stringTag = "[object String]";
903
+ var symbolTag = "[object Symbol]";
904
+ var arrayBufferTag = "[object ArrayBuffer]";
905
+ var dataViewTag = "[object DataView]";
906
+ var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
907
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
908
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
909
+ switch (tag) {
910
+ case dataViewTag:
911
+ if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
912
+ return false;
913
+ }
914
+ object = object.buffer;
915
+ other = other.buffer;
916
+ case arrayBufferTag:
917
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
918
+ return false;
919
+ }
920
+ return true;
921
+ case boolTag:
922
+ case dateTag:
923
+ case numberTag:
924
+ return eq(+object, +other);
925
+ case errorTag:
926
+ return object.name == other.name && object.message == other.message;
927
+ case regexpTag:
928
+ case stringTag:
929
+ return object == other + "";
930
+ case mapTag:
931
+ var convert = mapToArray;
932
+ case setTag:
933
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
934
+ convert || (convert = setToArray);
935
+ if (object.size != other.size && !isPartial) {
936
+ return false;
937
+ }
938
+ var stacked = stack.get(object);
939
+ if (stacked) {
940
+ return stacked == other;
941
+ }
942
+ bitmask |= COMPARE_UNORDERED_FLAG;
943
+ stack.set(object, other);
944
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
945
+ stack["delete"](object);
946
+ return result;
947
+ case symbolTag:
948
+ if (symbolValueOf) {
949
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
950
+ }
951
+ }
952
+ return false;
953
+ }
954
+ module.exports = equalByTag;
955
+ }
956
+ });
957
+
958
+ // ../../node_modules/lodash/_arrayPush.js
959
+ var require_arrayPush = __commonJS({
960
+ "../../node_modules/lodash/_arrayPush.js"(exports, module) {
961
+ function arrayPush(array, values) {
962
+ var index = -1, length = values.length, offset = array.length;
963
+ while (++index < length) {
964
+ array[offset + index] = values[index];
965
+ }
966
+ return array;
967
+ }
968
+ module.exports = arrayPush;
969
+ }
970
+ });
971
+
972
+ // ../../node_modules/lodash/isArray.js
973
+ var require_isArray = __commonJS({
974
+ "../../node_modules/lodash/isArray.js"(exports, module) {
975
+ var isArray = Array.isArray;
976
+ module.exports = isArray;
977
+ }
978
+ });
979
+
980
+ // ../../node_modules/lodash/_baseGetAllKeys.js
981
+ var require_baseGetAllKeys = __commonJS({
982
+ "../../node_modules/lodash/_baseGetAllKeys.js"(exports, module) {
983
+ var arrayPush = require_arrayPush();
984
+ var isArray = require_isArray();
985
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
986
+ var result = keysFunc(object);
987
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
988
+ }
989
+ module.exports = baseGetAllKeys;
990
+ }
991
+ });
992
+
993
+ // ../../node_modules/lodash/_arrayFilter.js
994
+ var require_arrayFilter = __commonJS({
995
+ "../../node_modules/lodash/_arrayFilter.js"(exports, module) {
996
+ function arrayFilter(array, predicate) {
997
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
998
+ while (++index < length) {
999
+ var value = array[index];
1000
+ if (predicate(value, index, array)) {
1001
+ result[resIndex++] = value;
1002
+ }
1003
+ }
1004
+ return result;
1005
+ }
1006
+ module.exports = arrayFilter;
1007
+ }
1008
+ });
1009
+
1010
+ // ../../node_modules/lodash/stubArray.js
1011
+ var require_stubArray = __commonJS({
1012
+ "../../node_modules/lodash/stubArray.js"(exports, module) {
1013
+ function stubArray() {
1014
+ return [];
1015
+ }
1016
+ module.exports = stubArray;
1017
+ }
1018
+ });
1019
+
1020
+ // ../../node_modules/lodash/_getSymbols.js
1021
+ var require_getSymbols = __commonJS({
1022
+ "../../node_modules/lodash/_getSymbols.js"(exports, module) {
1023
+ var arrayFilter = require_arrayFilter();
1024
+ var stubArray = require_stubArray();
1025
+ var objectProto = Object.prototype;
1026
+ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1027
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1028
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1029
+ if (object == null) {
1030
+ return [];
1031
+ }
1032
+ object = Object(object);
1033
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1034
+ return propertyIsEnumerable.call(object, symbol);
1035
+ });
1036
+ };
1037
+ module.exports = getSymbols;
1038
+ }
1039
+ });
1040
+
1041
+ // ../../node_modules/lodash/_baseTimes.js
1042
+ var require_baseTimes = __commonJS({
1043
+ "../../node_modules/lodash/_baseTimes.js"(exports, module) {
1044
+ function baseTimes(n, iteratee) {
1045
+ var index = -1, result = Array(n);
1046
+ while (++index < n) {
1047
+ result[index] = iteratee(index);
1048
+ }
1049
+ return result;
1050
+ }
1051
+ module.exports = baseTimes;
1052
+ }
1053
+ });
1054
+
1055
+ // ../../node_modules/lodash/isObjectLike.js
1056
+ var require_isObjectLike = __commonJS({
1057
+ "../../node_modules/lodash/isObjectLike.js"(exports, module) {
1058
+ function isObjectLike(value) {
1059
+ return value != null && typeof value == "object";
1060
+ }
1061
+ module.exports = isObjectLike;
1062
+ }
1063
+ });
1064
+
1065
+ // ../../node_modules/lodash/_baseIsArguments.js
1066
+ var require_baseIsArguments = __commonJS({
1067
+ "../../node_modules/lodash/_baseIsArguments.js"(exports, module) {
1068
+ var baseGetTag = require_baseGetTag();
1069
+ var isObjectLike = require_isObjectLike();
1070
+ var argsTag = "[object Arguments]";
1071
+ function baseIsArguments(value) {
1072
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
1073
+ }
1074
+ module.exports = baseIsArguments;
1075
+ }
1076
+ });
1077
+
1078
+ // ../../node_modules/lodash/isArguments.js
1079
+ var require_isArguments = __commonJS({
1080
+ "../../node_modules/lodash/isArguments.js"(exports, module) {
1081
+ var baseIsArguments = require_baseIsArguments();
1082
+ var isObjectLike = require_isObjectLike();
1083
+ var objectProto = Object.prototype;
1084
+ var hasOwnProperty = objectProto.hasOwnProperty;
1085
+ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1086
+ var isArguments = baseIsArguments(/* @__PURE__ */ function() {
1087
+ return arguments;
1088
+ }()) ? baseIsArguments : function(value) {
1089
+ return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
1090
+ };
1091
+ module.exports = isArguments;
1092
+ }
1093
+ });
1094
+
1095
+ // ../../node_modules/lodash/stubFalse.js
1096
+ var require_stubFalse = __commonJS({
1097
+ "../../node_modules/lodash/stubFalse.js"(exports, module) {
1098
+ function stubFalse() {
1099
+ return false;
1100
+ }
1101
+ module.exports = stubFalse;
1102
+ }
1103
+ });
1104
+
1105
+ // ../../node_modules/lodash/isBuffer.js
1106
+ var require_isBuffer = __commonJS({
1107
+ "../../node_modules/lodash/isBuffer.js"(exports, module) {
1108
+ var root = require_root();
1109
+ var stubFalse = require_stubFalse();
1110
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1111
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1112
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1113
+ var Buffer2 = moduleExports ? root.Buffer : void 0;
1114
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
1115
+ var isBuffer = nativeIsBuffer || stubFalse;
1116
+ module.exports = isBuffer;
1117
+ }
1118
+ });
1119
+
1120
+ // ../../node_modules/lodash/_isIndex.js
1121
+ var require_isIndex = __commonJS({
1122
+ "../../node_modules/lodash/_isIndex.js"(exports, module) {
1123
+ var MAX_SAFE_INTEGER = 9007199254740991;
1124
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1125
+ function isIndex(value, length) {
1126
+ var type = typeof value;
1127
+ length = length == null ? MAX_SAFE_INTEGER : length;
1128
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
1129
+ }
1130
+ module.exports = isIndex;
1131
+ }
1132
+ });
1133
+
1134
+ // ../../node_modules/lodash/isLength.js
1135
+ var require_isLength = __commonJS({
1136
+ "../../node_modules/lodash/isLength.js"(exports, module) {
1137
+ var MAX_SAFE_INTEGER = 9007199254740991;
1138
+ function isLength2(value) {
1139
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1140
+ }
1141
+ module.exports = isLength2;
1142
+ }
1143
+ });
1144
+
1145
+ // ../../node_modules/lodash/_baseIsTypedArray.js
1146
+ var require_baseIsTypedArray = __commonJS({
1147
+ "../../node_modules/lodash/_baseIsTypedArray.js"(exports, module) {
1148
+ var baseGetTag = require_baseGetTag();
1149
+ var isLength2 = require_isLength();
1150
+ var isObjectLike = require_isObjectLike();
1151
+ var argsTag = "[object Arguments]";
1152
+ var arrayTag = "[object Array]";
1153
+ var boolTag = "[object Boolean]";
1154
+ var dateTag = "[object Date]";
1155
+ var errorTag = "[object Error]";
1156
+ var funcTag = "[object Function]";
1157
+ var mapTag = "[object Map]";
1158
+ var numberTag = "[object Number]";
1159
+ var objectTag = "[object Object]";
1160
+ var regexpTag = "[object RegExp]";
1161
+ var setTag = "[object Set]";
1162
+ var stringTag = "[object String]";
1163
+ var weakMapTag = "[object WeakMap]";
1164
+ var arrayBufferTag = "[object ArrayBuffer]";
1165
+ var dataViewTag = "[object DataView]";
1166
+ var float32Tag = "[object Float32Array]";
1167
+ var float64Tag = "[object Float64Array]";
1168
+ var int8Tag = "[object Int8Array]";
1169
+ var int16Tag = "[object Int16Array]";
1170
+ var int32Tag = "[object Int32Array]";
1171
+ var uint8Tag = "[object Uint8Array]";
1172
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
1173
+ var uint16Tag = "[object Uint16Array]";
1174
+ var uint32Tag = "[object Uint32Array]";
1175
+ var typedArrayTags = {};
1176
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
1177
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
1178
+ function baseIsTypedArray(value) {
1179
+ return isObjectLike(value) && isLength2(value.length) && !!typedArrayTags[baseGetTag(value)];
1180
+ }
1181
+ module.exports = baseIsTypedArray;
1182
+ }
1183
+ });
1184
+
1185
+ // ../../node_modules/lodash/_baseUnary.js
1186
+ var require_baseUnary = __commonJS({
1187
+ "../../node_modules/lodash/_baseUnary.js"(exports, module) {
1188
+ function baseUnary(func) {
1189
+ return function(value) {
1190
+ return func(value);
1191
+ };
1192
+ }
1193
+ module.exports = baseUnary;
1194
+ }
1195
+ });
1196
+
1197
+ // ../../node_modules/lodash/_nodeUtil.js
1198
+ var require_nodeUtil = __commonJS({
1199
+ "../../node_modules/lodash/_nodeUtil.js"(exports, module) {
1200
+ var freeGlobal = require_freeGlobal();
1201
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1202
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1203
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1204
+ var freeProcess = moduleExports && freeGlobal.process;
1205
+ var nodeUtil = function() {
1206
+ try {
1207
+ var types = freeModule && freeModule.require && freeModule.require("util").types;
1208
+ if (types) {
1209
+ return types;
1210
+ }
1211
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
1212
+ } catch (e) {
1213
+ }
1214
+ }();
1215
+ module.exports = nodeUtil;
1216
+ }
1217
+ });
1218
+
1219
+ // ../../node_modules/lodash/isTypedArray.js
1220
+ var require_isTypedArray = __commonJS({
1221
+ "../../node_modules/lodash/isTypedArray.js"(exports, module) {
1222
+ var baseIsTypedArray = require_baseIsTypedArray();
1223
+ var baseUnary = require_baseUnary();
1224
+ var nodeUtil = require_nodeUtil();
1225
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1226
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1227
+ module.exports = isTypedArray;
1228
+ }
1229
+ });
1230
+
1231
+ // ../../node_modules/lodash/_arrayLikeKeys.js
1232
+ var require_arrayLikeKeys = __commonJS({
1233
+ "../../node_modules/lodash/_arrayLikeKeys.js"(exports, module) {
1234
+ var baseTimes = require_baseTimes();
1235
+ var isArguments = require_isArguments();
1236
+ var isArray = require_isArray();
1237
+ var isBuffer = require_isBuffer();
1238
+ var isIndex = require_isIndex();
1239
+ var isTypedArray = require_isTypedArray();
1240
+ var objectProto = Object.prototype;
1241
+ var hasOwnProperty = objectProto.hasOwnProperty;
1242
+ function arrayLikeKeys(value, inherited) {
1243
+ var isArr = isArray(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer(value), isType = !isArr && !isArg && !isBuff && isTypedArray(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
1244
+ for (var key in value) {
1245
+ if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
1246
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1247
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1248
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
1249
+ isIndex(key, length)))) {
1250
+ result.push(key);
1251
+ }
1252
+ }
1253
+ return result;
1254
+ }
1255
+ module.exports = arrayLikeKeys;
1256
+ }
1257
+ });
1258
+
1259
+ // ../../node_modules/lodash/_isPrototype.js
1260
+ var require_isPrototype = __commonJS({
1261
+ "../../node_modules/lodash/_isPrototype.js"(exports, module) {
1262
+ var objectProto = Object.prototype;
1263
+ function isPrototype(value) {
1264
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
1265
+ return value === proto;
1266
+ }
1267
+ module.exports = isPrototype;
1268
+ }
1269
+ });
1270
+
1271
+ // ../../node_modules/lodash/_overArg.js
1272
+ var require_overArg = __commonJS({
1273
+ "../../node_modules/lodash/_overArg.js"(exports, module) {
1274
+ function overArg(func, transform) {
1275
+ return function(arg) {
1276
+ return func(transform(arg));
1277
+ };
1278
+ }
1279
+ module.exports = overArg;
1280
+ }
1281
+ });
1282
+
1283
+ // ../../node_modules/lodash/_nativeKeys.js
1284
+ var require_nativeKeys = __commonJS({
1285
+ "../../node_modules/lodash/_nativeKeys.js"(exports, module) {
1286
+ var overArg = require_overArg();
1287
+ var nativeKeys = overArg(Object.keys, Object);
1288
+ module.exports = nativeKeys;
1289
+ }
1290
+ });
1291
+
1292
+ // ../../node_modules/lodash/_baseKeys.js
1293
+ var require_baseKeys = __commonJS({
1294
+ "../../node_modules/lodash/_baseKeys.js"(exports, module) {
1295
+ var isPrototype = require_isPrototype();
1296
+ var nativeKeys = require_nativeKeys();
1297
+ var objectProto = Object.prototype;
1298
+ var hasOwnProperty = objectProto.hasOwnProperty;
1299
+ function baseKeys(object) {
1300
+ if (!isPrototype(object)) {
1301
+ return nativeKeys(object);
1302
+ }
1303
+ var result = [];
1304
+ for (var key in Object(object)) {
1305
+ if (hasOwnProperty.call(object, key) && key != "constructor") {
1306
+ result.push(key);
1307
+ }
1308
+ }
1309
+ return result;
1310
+ }
1311
+ module.exports = baseKeys;
1312
+ }
1313
+ });
1314
+
1315
+ // ../../node_modules/lodash/isArrayLike.js
1316
+ var require_isArrayLike = __commonJS({
1317
+ "../../node_modules/lodash/isArrayLike.js"(exports, module) {
1318
+ var isFunction = require_isFunction();
1319
+ var isLength2 = require_isLength();
1320
+ function isArrayLike(value) {
1321
+ return value != null && isLength2(value.length) && !isFunction(value);
1322
+ }
1323
+ module.exports = isArrayLike;
1324
+ }
1325
+ });
1326
+
1327
+ // ../../node_modules/lodash/keys.js
1328
+ var require_keys = __commonJS({
1329
+ "../../node_modules/lodash/keys.js"(exports, module) {
1330
+ var arrayLikeKeys = require_arrayLikeKeys();
1331
+ var baseKeys = require_baseKeys();
1332
+ var isArrayLike = require_isArrayLike();
1333
+ function keys(object) {
1334
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1335
+ }
1336
+ module.exports = keys;
1337
+ }
1338
+ });
1339
+
1340
+ // ../../node_modules/lodash/_getAllKeys.js
1341
+ var require_getAllKeys = __commonJS({
1342
+ "../../node_modules/lodash/_getAllKeys.js"(exports, module) {
1343
+ var baseGetAllKeys = require_baseGetAllKeys();
1344
+ var getSymbols = require_getSymbols();
1345
+ var keys = require_keys();
1346
+ function getAllKeys(object) {
1347
+ return baseGetAllKeys(object, keys, getSymbols);
1348
+ }
1349
+ module.exports = getAllKeys;
1350
+ }
1351
+ });
1352
+
1353
+ // ../../node_modules/lodash/_equalObjects.js
1354
+ var require_equalObjects = __commonJS({
1355
+ "../../node_modules/lodash/_equalObjects.js"(exports, module) {
1356
+ var getAllKeys = require_getAllKeys();
1357
+ var COMPARE_PARTIAL_FLAG = 1;
1358
+ var objectProto = Object.prototype;
1359
+ var hasOwnProperty = objectProto.hasOwnProperty;
1360
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1361
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
1362
+ if (objLength != othLength && !isPartial) {
1363
+ return false;
1364
+ }
1365
+ var index = objLength;
1366
+ while (index--) {
1367
+ var key = objProps[index];
1368
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1369
+ return false;
1370
+ }
1371
+ }
1372
+ var objStacked = stack.get(object);
1373
+ var othStacked = stack.get(other);
1374
+ if (objStacked && othStacked) {
1375
+ return objStacked == other && othStacked == object;
1376
+ }
1377
+ var result = true;
1378
+ stack.set(object, other);
1379
+ stack.set(other, object);
1380
+ var skipCtor = isPartial;
1381
+ while (++index < objLength) {
1382
+ key = objProps[index];
1383
+ var objValue = object[key], othValue = other[key];
1384
+ if (customizer) {
1385
+ var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
1386
+ }
1387
+ if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
1388
+ result = false;
1389
+ break;
1390
+ }
1391
+ skipCtor || (skipCtor = key == "constructor");
1392
+ }
1393
+ if (result && !skipCtor) {
1394
+ var objCtor = object.constructor, othCtor = other.constructor;
1395
+ if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
1396
+ result = false;
1397
+ }
1398
+ }
1399
+ stack["delete"](object);
1400
+ stack["delete"](other);
1401
+ return result;
1402
+ }
1403
+ module.exports = equalObjects;
1404
+ }
1405
+ });
1406
+
1407
+ // ../../node_modules/lodash/_DataView.js
1408
+ var require_DataView = __commonJS({
1409
+ "../../node_modules/lodash/_DataView.js"(exports, module) {
1410
+ var getNative = require_getNative();
1411
+ var root = require_root();
1412
+ var DataView = getNative(root, "DataView");
1413
+ module.exports = DataView;
1414
+ }
1415
+ });
1416
+
1417
+ // ../../node_modules/lodash/_Promise.js
1418
+ var require_Promise = __commonJS({
1419
+ "../../node_modules/lodash/_Promise.js"(exports, module) {
1420
+ var getNative = require_getNative();
1421
+ var root = require_root();
1422
+ var Promise2 = getNative(root, "Promise");
1423
+ module.exports = Promise2;
1424
+ }
1425
+ });
1426
+
1427
+ // ../../node_modules/lodash/_Set.js
1428
+ var require_Set = __commonJS({
1429
+ "../../node_modules/lodash/_Set.js"(exports, module) {
1430
+ var getNative = require_getNative();
1431
+ var root = require_root();
1432
+ var Set2 = getNative(root, "Set");
1433
+ module.exports = Set2;
1434
+ }
1435
+ });
1436
+
1437
+ // ../../node_modules/lodash/_WeakMap.js
1438
+ var require_WeakMap = __commonJS({
1439
+ "../../node_modules/lodash/_WeakMap.js"(exports, module) {
1440
+ var getNative = require_getNative();
1441
+ var root = require_root();
1442
+ var WeakMap2 = getNative(root, "WeakMap");
1443
+ module.exports = WeakMap2;
1444
+ }
1445
+ });
1446
+
1447
+ // ../../node_modules/lodash/_getTag.js
1448
+ var require_getTag = __commonJS({
1449
+ "../../node_modules/lodash/_getTag.js"(exports, module) {
1450
+ var DataView = require_DataView();
1451
+ var Map2 = require_Map();
1452
+ var Promise2 = require_Promise();
1453
+ var Set2 = require_Set();
1454
+ var WeakMap2 = require_WeakMap();
1455
+ var baseGetTag = require_baseGetTag();
1456
+ var toSource = require_toSource();
1457
+ var mapTag = "[object Map]";
1458
+ var objectTag = "[object Object]";
1459
+ var promiseTag = "[object Promise]";
1460
+ var setTag = "[object Set]";
1461
+ var weakMapTag = "[object WeakMap]";
1462
+ var dataViewTag = "[object DataView]";
1463
+ var dataViewCtorString = toSource(DataView);
1464
+ var mapCtorString = toSource(Map2);
1465
+ var promiseCtorString = toSource(Promise2);
1466
+ var setCtorString = toSource(Set2);
1467
+ var weakMapCtorString = toSource(WeakMap2);
1468
+ var getTag = baseGetTag;
1469
+ if (DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag || Map2 && getTag(new Map2()) != mapTag || Promise2 && getTag(Promise2.resolve()) != promiseTag || Set2 && getTag(new Set2()) != setTag || WeakMap2 && getTag(new WeakMap2()) != weakMapTag) {
1470
+ getTag = function(value) {
1471
+ var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
1472
+ if (ctorString) {
1473
+ switch (ctorString) {
1474
+ case dataViewCtorString:
1475
+ return dataViewTag;
1476
+ case mapCtorString:
1477
+ return mapTag;
1478
+ case promiseCtorString:
1479
+ return promiseTag;
1480
+ case setCtorString:
1481
+ return setTag;
1482
+ case weakMapCtorString:
1483
+ return weakMapTag;
1484
+ }
1485
+ }
1486
+ return result;
1487
+ };
1488
+ }
1489
+ module.exports = getTag;
1490
+ }
1491
+ });
1492
+
1493
+ // ../../node_modules/lodash/_baseIsEqualDeep.js
1494
+ var require_baseIsEqualDeep = __commonJS({
1495
+ "../../node_modules/lodash/_baseIsEqualDeep.js"(exports, module) {
1496
+ var Stack = require_Stack();
1497
+ var equalArrays = require_equalArrays();
1498
+ var equalByTag = require_equalByTag();
1499
+ var equalObjects = require_equalObjects();
1500
+ var getTag = require_getTag();
1501
+ var isArray = require_isArray();
1502
+ var isBuffer = require_isBuffer();
1503
+ var isTypedArray = require_isTypedArray();
1504
+ var COMPARE_PARTIAL_FLAG = 1;
1505
+ var argsTag = "[object Arguments]";
1506
+ var arrayTag = "[object Array]";
1507
+ var objectTag = "[object Object]";
1508
+ var objectProto = Object.prototype;
1509
+ var hasOwnProperty = objectProto.hasOwnProperty;
1510
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1511
+ var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
1512
+ objTag = objTag == argsTag ? objectTag : objTag;
1513
+ othTag = othTag == argsTag ? objectTag : othTag;
1514
+ var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
1515
+ if (isSameTag && isBuffer(object)) {
1516
+ if (!isBuffer(other)) {
1517
+ return false;
1518
+ }
1519
+ objIsArr = true;
1520
+ objIsObj = false;
1521
+ }
1522
+ if (isSameTag && !objIsObj) {
1523
+ stack || (stack = new Stack());
1524
+ return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1525
+ }
1526
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
1527
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
1528
+ if (objIsWrapped || othIsWrapped) {
1529
+ var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
1530
+ stack || (stack = new Stack());
1531
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1532
+ }
1533
+ }
1534
+ if (!isSameTag) {
1535
+ return false;
1536
+ }
1537
+ stack || (stack = new Stack());
1538
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1539
+ }
1540
+ module.exports = baseIsEqualDeep;
1541
+ }
1542
+ });
1543
+
1544
+ // ../../node_modules/lodash/_baseIsEqual.js
1545
+ var require_baseIsEqual = __commonJS({
1546
+ "../../node_modules/lodash/_baseIsEqual.js"(exports, module) {
1547
+ var baseIsEqualDeep = require_baseIsEqualDeep();
1548
+ var isObjectLike = require_isObjectLike();
1549
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
1550
+ if (value === other) {
1551
+ return true;
1552
+ }
1553
+ if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
1554
+ return value !== value && other !== other;
1555
+ }
1556
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1557
+ }
1558
+ module.exports = baseIsEqual;
1559
+ }
1560
+ });
1561
+
1562
+ // ../../node_modules/lodash/isEqual.js
1563
+ var require_isEqual = __commonJS({
1564
+ "../../node_modules/lodash/isEqual.js"(exports, module) {
1565
+ var baseIsEqual = require_baseIsEqual();
1566
+ function isEqual2(value, other) {
1567
+ return baseIsEqual(value, other);
1568
+ }
1569
+ module.exports = isEqual2;
1570
+ }
1571
+ });
34
1572
 
35
1573
  // src/lib/types/ISTDate.ts
36
1574
  function formatISTDate(date, options) {
@@ -4026,11 +5564,18 @@ var getRoleLabel = (role) => {
4026
5564
  var getRoleDescription = (role) => {
4027
5565
  return getRoleMetadata(role)?.description || "";
4028
5566
  };
5567
+ var getRoleAssignmentKind = (role) => {
5568
+ return getRoleMetadata(role)?.assignmentKind || null;
5569
+ };
4029
5570
  var isFactoryScopedRole = (role) => {
4030
5571
  const normalizedRole = normalizeRoleLevel(role);
4031
5572
  return normalizedRole ? FACTORY_SCOPED_ROLE_SET.has(normalizedRole) : false;
4032
5573
  };
4033
5574
  var isSupervisorRole = (role) => normalizeRoleLevel(role) === "supervisor";
5575
+ var canRoleManageCompany = (role) => {
5576
+ const normalizedRole = normalizeRoleLevel(role);
5577
+ return normalizedRole === "owner" || normalizedRole === "it";
5578
+ };
4034
5579
  var canRoleManageUsers = (role) => {
4035
5580
  const normalizedRole = normalizeRoleLevel(role);
4036
5581
  return normalizedRole === "optifye" || normalizedRole === "owner" || normalizedRole === "it" || isFactoryScopedRole(normalizedRole);
@@ -4043,12 +5588,23 @@ var canRoleViewUsageStats = (role) => {
4043
5588
  const normalizedRole = normalizeRoleLevel(role);
4044
5589
  return normalizedRole === "optifye" || normalizedRole === "owner" || normalizedRole === "it";
4045
5590
  };
5591
+ var canRoleViewClipsCost = (role) => {
5592
+ const normalizedRole = normalizeRoleLevel(role);
5593
+ return normalizedRole === "optifye" || normalizedRole === "owner";
5594
+ };
4046
5595
  var canRoleAccessTeamManagement = (role) => {
4047
5596
  return canRoleManageUsers(role);
4048
5597
  };
4049
5598
  var getRoleNavPaths = (role) => {
4050
5599
  return getRoleMetadata(role)?.navPaths || [];
4051
5600
  };
5601
+ var canRoleAccessDashboardPath = (path, role) => {
5602
+ const basePath = `/${path.split("?")[0].split("/").filter(Boolean)[0] || ""}`.replace(/\/$/, "") || "/";
5603
+ if (basePath === "/clips-cost") {
5604
+ return canRoleViewClipsCost(role);
5605
+ }
5606
+ return getRoleNavPaths(role).includes(basePath);
5607
+ };
4052
5608
  var getVisibleRolesForCurrentUser = (currentRole) => {
4053
5609
  const normalizedRole = normalizeRoleLevel(currentRole);
4054
5610
  const visibleRolesByCurrentRole = {
@@ -5853,6 +7409,16 @@ var getClipCycleTimeFrames = (metadata) => {
5853
7409
  }
5854
7410
  return parseFiniteNumber(metadata?.request?.metadata?.cycle_time);
5855
7411
  };
7412
+ var getClipCaptureFps = (clip) => {
7413
+ return parseFiniteNumber(clip?.capture_fps) ?? parseFiniteNumber(clip?.metadata?.playlist?.fps) ?? 20;
7414
+ };
7415
+ var getClipCycleTimeSeconds = (clip) => {
7416
+ const cycleTimeFrames = getClipCycleTimeFrames(clip?.metadata);
7417
+ if (cycleTimeFrames === void 0) {
7418
+ return void 0;
7419
+ }
7420
+ return cycleTimeFrames / getClipCaptureFps(clip);
7421
+ };
5856
7422
  var getSupabaseClient = () => {
5857
7423
  const existing = _getSupabaseInstanceOptional();
5858
7424
  if (existing) {
@@ -6365,10 +7931,10 @@ var S3ClipsSupabaseService = class {
6365
7931
  const transformedClips = (response.clips || []).map((clip) => {
6366
7932
  const clipId = clip.id ?? clip.clip_id;
6367
7933
  const clipType = clip.type ?? clip.clip_type_name;
6368
- const cycleTimeSeconds = parseFiniteNumber(clip.cycle_time_seconds) ?? (() => {
6369
- const cycleTimeFrames = getClipCycleTimeFrames(clip.metadata);
6370
- return cycleTimeFrames !== void 0 ? cycleTimeFrames / (clip.metadata?.playlist?.fps || 20) : void 0;
6371
- })();
7934
+ const cycleTimeSeconds = parseFiniteNumber(clip.cycle_time_seconds) ?? getClipCycleTimeSeconds({
7935
+ capture_fps: clip.capture_fps,
7936
+ metadata: clip.metadata
7937
+ });
6372
7938
  return {
6373
7939
  id: clipId,
6374
7940
  src: clip.src ?? clip.playlist,
@@ -37918,7 +39484,7 @@ var FileManagerFilters = ({
37918
39484
  ] }) })
37919
39485
  ] }, node.id);
37920
39486
  };
37921
- return /* @__PURE__ */ jsxs("div", { className: `relative bg-white rounded-2xl shadow-lg border border-gray-100 h-full hover:shadow-xl transition-all duration-300 ease-out backdrop-blur-sm ${className}`, children: [
39487
+ return /* @__PURE__ */ jsxs("div", { className: `relative flex h-full min-h-[320px] flex-col bg-white rounded-2xl shadow-lg border border-gray-100 hover:shadow-xl transition-all duration-300 ease-out backdrop-blur-sm ${className}`, children: [
37922
39488
  /* @__PURE__ */ jsxs("div", { className: "p-4 border-b border-gray-50 bg-gradient-to-br from-slate-50/80 via-white to-blue-50/30", children: [
37923
39489
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
37924
39490
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -38000,7 +39566,7 @@ var FileManagerFilters = ({
38000
39566
  /* @__PURE__ */ jsxs(
38001
39567
  "div",
38002
39568
  {
38003
- className: "absolute top-14 right-16 z-50 bg-white rounded-xl shadow-xl border border-slate-200 w-[240px] animate-in slide-in-from-top-2 duration-200",
39569
+ className: "absolute top-14 right-2 z-50 bg-white rounded-xl shadow-xl border border-slate-200 w-[min(88vw,240px)] sm:right-16 animate-in slide-in-from-top-2 duration-200",
38004
39570
  onClick: (e) => e.stopPropagation(),
38005
39571
  children: [
38006
39572
  /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 flex items-center justify-between border-b border-slate-200", children: [
@@ -38057,7 +39623,7 @@ var FileManagerFilters = ({
38057
39623
  /* @__PURE__ */ jsxs(
38058
39624
  "div",
38059
39625
  {
38060
- className: "absolute top-14 right-4 z-50 bg-white rounded-xl shadow-xl border border-slate-200 w-[280px] animate-in slide-in-from-top-2 duration-200",
39626
+ className: "absolute top-14 right-2 z-50 bg-white rounded-xl shadow-xl border border-slate-200 w-[min(92vw,280px)] sm:right-4 animate-in slide-in-from-top-2 duration-200",
38061
39627
  onClick: (e) => e.stopPropagation(),
38062
39628
  children: [
38063
39629
  /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 flex items-center justify-between border-b border-slate-200", children: [
@@ -38174,7 +39740,7 @@ var FileManagerFilters = ({
38174
39740
  }
38175
39741
  )
38176
39742
  ] }),
38177
- /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 h-[calc(100%-8rem)] overflow-y-auto scrollbar-thin", children: [
39743
+ /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 flex-1 min-h-0 overflow-y-auto scrollbar-thin", children: [
38178
39744
  /* @__PURE__ */ jsx("div", { className: "space-y-2", children: filterTree.map((node) => renderNode(node)) }),
38179
39745
  filterTree.length === 0 && isTimeFilterActive && (startTime || endTime) && /* @__PURE__ */ jsxs("div", { className: "text-center py-12", children: [
38180
39746
  /* @__PURE__ */ jsx("div", { className: "text-slate-300 mb-4", children: /* @__PURE__ */ jsx(Clock, { className: "h-12 w-12 mx-auto" }) }),
@@ -40285,17 +41851,17 @@ var BottlenecksContent = ({
40285
41851
  }
40286
41852
  }, [workspaceTargetCycleTime]);
40287
41853
  if (!dashboardConfig?.s3Config) {
40288
- return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center h-[calc(100vh-12rem)] text-center", children: [
41854
+ return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center min-h-[calc(100dvh-12rem)] text-center", children: [
40289
41855
  /* @__PURE__ */ jsx(XCircle, { className: "w-12 h-12 text-red-400 mb-3" }),
40290
41856
  /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-red-700 mb-1", children: "S3 Configuration Missing" }),
40291
41857
  /* @__PURE__ */ jsx("p", { className: "text-gray-600 max-w-md", children: "S3 configuration is required to load video clips. Please check your dashboard configuration." })
40292
41858
  ] });
40293
41859
  }
40294
41860
  if (clipTypesLoading && allVideos.length === 0 && Object.keys(mergedCounts).length === 0) {
40295
- return /* @__PURE__ */ jsx("div", { className: "flex-grow p-4 flex items-center justify-center h-[calc(100vh-12rem)]", children: /* @__PURE__ */ jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading clips..." }) });
41861
+ return /* @__PURE__ */ jsx("div", { className: "flex-grow p-4 flex items-center justify-center min-h-[calc(100dvh-12rem)]", children: /* @__PURE__ */ jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading clips..." }) });
40296
41862
  }
40297
41863
  if (error && error.type === "fatal" && !hasInitialLoad || clipTypesError) {
40298
- return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center h-[calc(100vh-12rem)] text-center", children: [
41864
+ return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center min-h-[calc(100dvh-12rem)] text-center", children: [
40299
41865
  /* @__PURE__ */ jsx(XCircle, { className: "w-12 h-12 text-red-400 mb-3" }),
40300
41866
  /* @__PURE__ */ jsx("h3", { className: "text-lg font-semibold text-red-700 mb-1", children: "Error Loading Clips" }),
40301
41867
  /* @__PURE__ */ jsx("p", { className: "text-gray-600 max-w-md", children: error?.message || clipTypesError })
@@ -40310,7 +41876,7 @@ var BottlenecksContent = ({
40310
41876
  clipTypesError,
40311
41877
  mergedCounts
40312
41878
  });
40313
- return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-1.5 sm:p-2 lg:p-4 h-[calc(100vh-12rem)] relative", children: [
41879
+ return /* @__PURE__ */ jsxs("div", { className: "flex-grow p-1.5 sm:p-2 lg:p-4 min-h-[calc(100dvh-12rem)] lg:h-[calc(100dvh-12rem)] relative", children: [
40314
41880
  hasNewClips && newClipsNotification && /* @__PURE__ */ jsx(
40315
41881
  NewClipsNotification,
40316
41882
  {
@@ -40319,8 +41885,8 @@ var BottlenecksContent = ({
40319
41885
  onDismiss: clearNotification
40320
41886
  }
40321
41887
  ),
40322
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col lg:flex-row gap-4 h-full", children: [
40323
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0 lg:flex-[3]", children: /* @__PURE__ */ jsx("div", { className: "bg-white rounded-lg shadow-sm overflow-hidden h-full", children: filteredVideos.length > 0 && currentVideo && !isFullscreen ? /* @__PURE__ */ jsx("div", { className: "p-4 h-full", children: /* @__PURE__ */ jsx("div", { className: "relative h-full group", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full h-full overflow-hidden rounded-md shadow-inner bg-gray-900", children: [
41888
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:h-full", children: [
41889
+ /* @__PURE__ */ jsx("div", { className: "min-w-0 w-full lg:flex-[3] lg:h-full", children: /* @__PURE__ */ jsx("div", { className: "bg-white rounded-lg shadow-sm overflow-hidden lg:h-full", children: filteredVideos.length > 0 && currentVideo && !isFullscreen ? /* @__PURE__ */ jsx("div", { className: "p-4 lg:h-full", children: /* @__PURE__ */ jsx("div", { className: "relative group lg:h-full", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full aspect-video lg:aspect-auto lg:h-full overflow-hidden rounded-md shadow-inner bg-gray-900", children: [
40324
41890
  /* @__PURE__ */ jsx(
40325
41891
  "div",
40326
41892
  {
@@ -40470,23 +42036,23 @@ var BottlenecksContent = ({
40470
42036
  )
40471
42037
  ] }) }) }) : (
40472
42038
  /* Priority 5: Show "no clips found" only if we have counts and there are truly no clips for workspace */
40473
- hasInitialLoad && Object.keys(mergedCounts).length > 0 && Object.values(mergedCounts).every((count) => count === 0) ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center p-8", children: [
42039
+ hasInitialLoad && Object.keys(mergedCounts).length > 0 && Object.values(mergedCounts).every((count) => count === 0) ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-[220px] sm:min-h-[320px] lg:h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center p-8", children: [
40474
42040
  /* @__PURE__ */ jsx("svg", { className: "w-16 h-16 text-gray-300 mx-auto mb-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) }),
40475
42041
  /* @__PURE__ */ jsx("h3", { className: "text-xl font-medium text-gray-700 mb-2", children: "No Clips Found" }),
40476
42042
  /* @__PURE__ */ jsx("p", { className: "text-gray-500", children: "There were no video clips found for this workspace today." })
40477
42043
  ] }) }) : (
40478
42044
  /* Priority 6: Show "no matching clips" only if we have data loaded and specifically no clips for this filter */
40479
- hasInitialLoad && (mergedCounts[activeFilter] || 0) === 0 ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center p-8", children: [
42045
+ hasInitialLoad && (mergedCounts[activeFilter] || 0) === 0 ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center min-h-[220px] sm:min-h-[320px] lg:h-full", children: /* @__PURE__ */ jsxs("div", { className: "text-center p-8", children: [
40480
42046
  /* @__PURE__ */ jsx("svg", { className: "w-16 h-16 text-gray-300 mx-auto mb-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) }),
40481
42047
  /* @__PURE__ */ jsx("h3", { className: "text-xl font-medium text-gray-700 mb-2", children: "No Matching Clips" }),
40482
42048
  /* @__PURE__ */ jsx("p", { className: "text-gray-500", children: "There are no clips matching the selected filter." })
40483
42049
  ] }) }) : (
40484
42050
  /* Priority 7: Default loading state for any other case */
40485
- /* @__PURE__ */ jsx("div", { className: "p-4 h-full", children: /* @__PURE__ */ jsx("div", { className: "relative h-full", children: /* @__PURE__ */ jsx("div", { className: "relative w-full h-full overflow-hidden rounded-md shadow-inner bg-gray-900 flex items-center justify-center", children: /* @__PURE__ */ jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading..." }) }) }) })
42051
+ /* @__PURE__ */ jsx("div", { className: "p-4 lg:h-full", children: /* @__PURE__ */ jsx("div", { className: "relative lg:h-full", children: /* @__PURE__ */ jsx("div", { className: "relative w-full min-h-[220px] sm:min-h-[320px] lg:min-h-0 lg:h-full overflow-hidden rounded-md shadow-inner bg-gray-900 flex items-center justify-center", children: /* @__PURE__ */ jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading..." }) }) }) })
40486
42052
  )
40487
42053
  )
40488
42054
  ) }) }),
40489
- /* @__PURE__ */ jsx("div", { className: "flex-shrink-0 lg:flex-[1] lg:min-w-[280px] lg:max-w-[320px]", children: triageMode ? (
42055
+ /* @__PURE__ */ jsx("div", { className: "w-full lg:flex-shrink-0 lg:flex-[1] lg:min-w-[280px] lg:max-w-[320px] lg:h-full", children: triageMode ? (
40490
42056
  /* Triage Mode - Direct tile view for cycle completions and idle time */
40491
42057
  /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-lg shadow-sm h-full overflow-hidden flex flex-col", children: [
40492
42058
  /* @__PURE__ */ jsxs("div", { className: "px-4 py-3 border-b border-gray-100", children: [
@@ -42797,10 +44363,15 @@ var IdleTimeReasonChartComponent = ({
42797
44363
  data,
42798
44364
  isLoading = false,
42799
44365
  error = null,
42800
- hideTotalDuration = false
44366
+ hideTotalDuration = false,
44367
+ updateAnimation = "replay"
42801
44368
  }) => {
42802
44369
  const [activeData, setActiveData] = React141__default.useState([]);
42803
44370
  React141__default.useEffect(() => {
44371
+ if (updateAnimation === "smooth") {
44372
+ setActiveData(data && data.length > 0 ? data : []);
44373
+ return;
44374
+ }
42804
44375
  if (activeData.length > 0) {
42805
44376
  setActiveData([]);
42806
44377
  }
@@ -42814,7 +44385,7 @@ var IdleTimeReasonChartComponent = ({
42814
44385
  } else {
42815
44386
  setActiveData([]);
42816
44387
  }
42817
- }, [data]);
44388
+ }, [data, updateAnimation]);
42818
44389
  React141__default.useEffect(() => {
42819
44390
  if (!data || data.length === 0) return;
42820
44391
  data.forEach((entry, index) => {
@@ -42824,8 +44395,11 @@ var IdleTimeReasonChartComponent = ({
42824
44395
  });
42825
44396
  }, [data]);
42826
44397
  const pieKey = React141__default.useMemo(() => {
44398
+ if (updateAnimation === "smooth") {
44399
+ return "smooth";
44400
+ }
42827
44401
  return activeData.map((d) => `${d.name}-${d.value}`).join("|");
42828
- }, [activeData]);
44402
+ }, [activeData, updateAnimation]);
42829
44403
  if (isLoading) {
42830
44404
  return /* @__PURE__ */ jsx("div", { className: "w-full h-full" });
42831
44405
  }
@@ -49376,7 +50950,6 @@ var SettingsPopup = ({
49376
50950
  document.body
49377
50951
  );
49378
50952
  };
49379
- var formatPercent = (value) => typeof value === "number" && Number.isFinite(value) ? `${value.toFixed(1)}%` : "N/A";
49380
50953
  var formatRelativeTime2 = (value) => {
49381
50954
  const parsed = new Date(value);
49382
50955
  if (Number.isNaN(parsed.getTime())) return "Just now";
@@ -49542,8 +51115,7 @@ var AlertsPopup = ({
49542
51115
  !isLoading && error && /* @__PURE__ */ jsx("div", { className: "px-5 py-10 text-sm text-red-600", children: error }),
49543
51116
  !isLoading && !error && alerts.length === 0 && /* @__PURE__ */ jsx("div", { className: "px-5 py-10 text-sm text-gray-500", children: "No alerts right now." }),
49544
51117
  !isLoading && !error && alerts.map((alert2, index) => {
49545
- const isCritical = typeof alert2.delta_efficiency === "number" && alert2.delta_efficiency <= -10;
49546
- const description = `Now: ${formatPercent(alert2.current_efficiency)}. Usual for this shift: ${formatPercent(alert2.baseline_efficiency)}.`;
51118
+ const isCritical = alert2.alert_type === "recent_output_drop";
49547
51119
  return /* @__PURE__ */ jsx(
49548
51120
  motion.div,
49549
51121
  {
@@ -49565,8 +51137,8 @@ var AlertsPopup = ({
49565
51137
  formatRelativeTime2(alert2.evaluated_at)
49566
51138
  ] })
49567
51139
  ] }),
49568
- /* @__PURE__ */ jsx("p", { className: "text-[12px] font-medium text-[#475569] uppercase tracking-wide", children: alert2.monitoring_mode === "uptime" ? "Machine Utilization is low" : "Output is low" }),
49569
- /* @__PURE__ */ jsx("p", { className: "text-[13.5px] text-[#64748b] leading-[1.45] mt-1", children: description })
51140
+ /* @__PURE__ */ jsx("p", { className: "text-[12px] font-medium text-[#475569] uppercase tracking-wide", children: alert2.title }),
51141
+ /* @__PURE__ */ jsx("p", { className: "text-[13.5px] text-[#64748b] leading-[1.45] mt-1", children: alert2.message })
49570
51142
  ] })
49571
51143
  ] })
49572
51144
  },
@@ -49600,6 +51172,7 @@ var SideNavBar = memo$1(({
49600
51172
  const role = user?.role_level;
49601
51173
  const roleNavPaths = useMemo(() => getRoleNavPaths(role), [role]);
49602
51174
  const showLiveMonitorLink = roleNavPaths.includes("/live-monitor");
51175
+ const rootDashboardSurface = useMemo(() => role === "owner" || role === "plant_head" || role === "optifye" ? "operations_overview" : "monitor", [role]);
49603
51176
  const getBasePath = useCallback((path) => {
49604
51177
  const firstSegment = path.split("?")[0].split("/").filter(Boolean)[0];
49605
51178
  return firstSegment ? `/${firstSegment}` : "/";
@@ -49610,12 +51183,11 @@ var SideNavBar = memo$1(({
49610
51183
  const basePath = getBasePath(path);
49611
51184
  return roleNavPaths.includes(basePath);
49612
51185
  }, [role, isSuperAdmin, getBasePath, roleNavPaths]);
49613
- const lineId = entityConfig.defaultLineId || LINE_1_UUID;
49614
51186
  const skuEnabled = dashboardConfig?.skuConfig?.enabled || false;
49615
51187
  dashboardConfig?.supervisorConfig?.enabled || false;
49616
51188
  const showSupervisorManagement = false;
49617
51189
  const ticketsEnabled = dashboardConfig?.ticketsConfig?.enabled ?? true;
49618
- const { hasData: hasClipsCostData } = useCompanyClipsCost();
51190
+ const showBillingLink = canRoleViewClipsCost(role);
49619
51191
  console.log("\u{1F50D} [SideNavBar] dashboardConfig:", dashboardConfig);
49620
51192
  console.log("\u{1F50D} [SideNavBar] ticketsConfig:", dashboardConfig?.ticketsConfig);
49621
51193
  console.log("\u{1F50D} [SideNavBar] ticketsEnabled:", ticketsEnabled);
@@ -49626,19 +51198,20 @@ var SideNavBar = memo$1(({
49626
51198
  ${isActive ? "bg-blue-50/80 text-blue-600 font-medium" : "hover:bg-gray-50 text-gray-500 hover:text-gray-700 font-medium active:bg-gray-100"}
49627
51199
  transition-all duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`;
49628
51200
  }, [pathname]);
51201
+ const buildDashboardSurfaceTrackingEvent = useCallback((source, destinationPath, dashboardSurface) => ({
51202
+ name: dashboardSurface === "operations_overview" ? "Operations Overview clicked" : "monitor page clicked",
51203
+ properties: {
51204
+ source,
51205
+ destination_path: destinationPath,
51206
+ dashboard_surface: dashboardSurface
51207
+ }
51208
+ }), []);
49629
51209
  const handleHomeClick = useCallback(() => {
49630
51210
  navigate("/", {
49631
- trackingEvent: {
49632
- name: "Operations Overview Page Clicked",
49633
- properties: {
49634
- source: "side_nav",
49635
- line_id: lineId,
49636
- line_name: "Line 1"
49637
- }
49638
- }
51211
+ trackingEvent: buildDashboardSurfaceTrackingEvent("side_nav", "/", rootDashboardSurface)
49639
51212
  });
49640
51213
  onMobileMenuClose?.();
49641
- }, [navigate, lineId, onMobileMenuClose]);
51214
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent, rootDashboardSurface]);
49642
51215
  const handleLeaderboardClick = useCallback(() => {
49643
51216
  navigate(`/leaderboard`, {
49644
51217
  trackingEvent: {
@@ -49652,15 +51225,10 @@ var SideNavBar = memo$1(({
49652
51225
  }, [navigate, onMobileMenuClose]);
49653
51226
  const handleLiveClick = useCallback(() => {
49654
51227
  navigate("/live-monitor", {
49655
- trackingEvent: {
49656
- name: "Live Monitor Clicked",
49657
- properties: {
49658
- source: "side_nav"
49659
- }
49660
- }
51228
+ trackingEvent: buildDashboardSurfaceTrackingEvent("side_nav", "/live-monitor", "monitor")
49661
51229
  });
49662
51230
  onMobileMenuClose?.();
49663
- }, [navigate, onMobileMenuClose]);
51231
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent]);
49664
51232
  const handleKPIsClick = useCallback(() => {
49665
51233
  navigate(`/kpis`, {
49666
51234
  trackingEvent: {
@@ -49903,7 +51471,7 @@ var SideNavBar = memo$1(({
49903
51471
  isActive: pathname === "/tickets" || pathname.startsWith("/tickets/")
49904
51472
  });
49905
51473
  }
49906
- if (hasClipsCostData) {
51474
+ if (showBillingLink) {
49907
51475
  items.push({
49908
51476
  key: "clips-analysis",
49909
51477
  label: "Billing",
@@ -49928,7 +51496,7 @@ var SideNavBar = memo$1(({
49928
51496
  });
49929
51497
  }
49930
51498
  return items;
49931
- }, [handleTargetsClick, handleShiftsClick, handleTeamManagementClick, handleProfileClick, handleTicketsClick, handleClipsCostClick, handleHelpClick, pathname, ticketsEnabled, hasClipsCostData, canAccessPath]);
51499
+ }, [handleTargetsClick, handleShiftsClick, handleTeamManagementClick, handleProfileClick, handleTicketsClick, handleClipsCostClick, handleHelpClick, pathname, ticketsEnabled, showBillingLink, canAccessPath]);
49932
51500
  const handleLogout = useCallback(async () => {
49933
51501
  setIsSettingsOpen(false);
49934
51502
  try {
@@ -49938,10 +51506,11 @@ var SideNavBar = memo$1(({
49938
51506
  }
49939
51507
  }, [signOut]);
49940
51508
  const handleLogoClick = useCallback(() => {
49941
- trackCoreEvent("Operations Overview Page Clicked", { source: "logo" });
49942
- navigate("/");
51509
+ navigate("/", {
51510
+ trackingEvent: buildDashboardSurfaceTrackingEvent("logo", "/", rootDashboardSurface)
51511
+ });
49943
51512
  onMobileMenuClose?.();
49944
- }, [navigate, onMobileMenuClose]);
51513
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent, rootDashboardSurface]);
49945
51514
  const homeButtonClasses = useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
49946
51515
  const liveButtonClasses = useMemo(() => getButtonClasses("/live-monitor"), [getButtonClasses, pathname]);
49947
51516
  const leaderboardButtonClasses = useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
@@ -50325,6 +51894,18 @@ var SideNavBar = memo$1(({
50325
51894
  ]
50326
51895
  }
50327
51896
  ),
51897
+ showBillingLink && /* @__PURE__ */ jsxs(
51898
+ "button",
51899
+ {
51900
+ onClick: handleMobileNavClick(handleClipsCostClick),
51901
+ className: getMobileButtonClass("/clips-cost"),
51902
+ "aria-label": "Billing",
51903
+ children: [
51904
+ /* @__PURE__ */ jsx(CurrencyDollarIcon, { className: getIconClass("/clips-cost") }),
51905
+ /* @__PURE__ */ jsx("span", { className: "text-base font-medium", children: "Billing" })
51906
+ ]
51907
+ }
51908
+ ),
50328
51909
  canAccessPath("/help") && /* @__PURE__ */ jsxs(
50329
51910
  "button",
50330
51911
  {
@@ -56782,6 +58363,11 @@ function HomeView({
56782
58363
  useEffect(() => {
56783
58364
  setIsHydrated(true);
56784
58365
  }, []);
58366
+ useEffect(() => {
58367
+ trackCorePageView("Monitor", {
58368
+ dashboard_surface: "monitor"
58369
+ });
58370
+ }, []);
56785
58371
  useEffect(() => {
56786
58372
  if (metricsError) {
56787
58373
  setErrorMessage(metricsError.message);
@@ -56792,7 +58378,7 @@ function HomeView({
56792
58378
  const handleLineChange = useCallback((value) => {
56793
58379
  setIsChangingFilter(true);
56794
58380
  setSelectedLineId(value);
56795
- trackCoreEvent("Home Line Filter Changed", {
58381
+ trackCoreEvent("monitor line filter changed", {
56796
58382
  previous_line_id: selectedLineId,
56797
58383
  new_line_id: value,
56798
58384
  line_name: mergedLineNames[value] || (value === factoryViewId ? "All Lines" : `Line ${value.substring(0, 4)}`)
@@ -56813,10 +58399,11 @@ function HomeView({
56813
58399
  useEffect(() => {
56814
58400
  if (!metricsLoading && !hasInitialDataLoaded) {
56815
58401
  setHasInitialDataLoaded(true);
56816
- trackCoreEvent("Home View Loaded", {
58402
+ trackCoreEvent("monitor page loaded", {
56817
58403
  default_line_id: defaultLineId,
56818
58404
  factory_view_id: factoryViewId,
56819
- is_supervisor: isSupervisor
58405
+ is_supervisor: isSupervisor,
58406
+ dashboard_surface: "monitor"
56820
58407
  });
56821
58408
  }
56822
58409
  }, [metricsLoading, hasInitialDataLoaded, defaultLineId, factoryViewId, isSupervisor]);
@@ -57492,6 +59079,7 @@ var MonthlyRangeFilter = ({
57492
59079
  const [rangeEnd, setRangeEnd] = useState(parseDateKeyToDate(normalizedRange.endKey));
57493
59080
  const [selecting, setSelecting] = useState(false);
57494
59081
  const [activePreset, setActivePreset] = useState(null);
59082
+ const [pendingChangeMeta, setPendingChangeMeta] = useState(null);
57495
59083
  const today = useMemo(() => endOfDay(todayDate), [todayDate]);
57496
59084
  useEffect(() => {
57497
59085
  setCalendarMonth(month);
@@ -57511,6 +59099,7 @@ var MonthlyRangeFilter = ({
57511
59099
  return val.startKey === value.startKey && val.endKey === value.endKey;
57512
59100
  });
57513
59101
  setActivePreset(match ? match.label : "Custom");
59102
+ setPendingChangeMeta(null);
57514
59103
  }
57515
59104
  }, [isOpen, month, presets, value.endKey, value.startKey, year]);
57516
59105
  useEffect(() => {
@@ -57527,6 +59116,7 @@ var MonthlyRangeFilter = ({
57527
59116
  return;
57528
59117
  }
57529
59118
  setActivePreset("Custom");
59119
+ setPendingChangeMeta({ source: "custom" });
57530
59120
  if (!selecting || !rangeStart) {
57531
59121
  setRangeStart(day);
57532
59122
  setRangeEnd(null);
@@ -57549,6 +59139,7 @@ var MonthlyRangeFilter = ({
57549
59139
  setRangeEnd(end);
57550
59140
  setSelecting(false);
57551
59141
  setActivePreset(preset.label);
59142
+ setPendingChangeMeta({ source: "preset", presetLabel: preset.label });
57552
59143
  setCalendarMonth(start.getMonth());
57553
59144
  setCalendarYear(start.getFullYear());
57554
59145
  };
@@ -57567,7 +59158,7 @@ var MonthlyRangeFilter = ({
57567
59158
  const end = boundedStart <= boundedEnd ? boundedEnd : boundedStart;
57568
59159
  const startKey = format(start, "yyyy-MM-dd");
57569
59160
  const endKey = format(end, "yyyy-MM-dd");
57570
- onChange({ startKey, endKey });
59161
+ onChange({ startKey, endKey }, pendingChangeMeta || void 0);
57571
59162
  setIsOpen(false);
57572
59163
  }
57573
59164
  };
@@ -67505,13 +69096,7 @@ var WorkspaceHealthView = ({
67505
69096
  /* @__PURE__ */ jsx("span", { className: clsx("text-3xl font-bold", getUptimeColor(summary.uptimePercentage)), children: summary.uptimePercentage === null ? "No data" : `${summary.uptimePercentage.toFixed(1)}%` }),
67506
69097
  summary.uptimePercentage === null ? /* @__PURE__ */ jsx(Activity, { className: "h-5 w-5 text-gray-400" }) : summary.uptimePercentage >= 97 ? /* @__PURE__ */ jsx(TrendingUp, { className: "h-5 w-5 text-green-500" }) : summary.uptimePercentage >= 90 ? /* @__PURE__ */ jsx(Activity, { className: "h-5 w-5 text-yellow-500" }) : /* @__PURE__ */ jsx(TrendingDown, { className: "h-5 w-5 text-red-500" })
67507
69098
  ] }),
67508
- /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: summary.uptimePercentage === null ? "Uptime metrics unavailable for visible workspaces" : "Overall system uptime today" }),
67509
- summary.workspacesWithoutUptimeData > 0 && /* @__PURE__ */ jsxs("p", { className: "text-xs text-amber-600 mt-1", children: [
67510
- summary.workspacesWithoutUptimeData,
67511
- " workspace",
67512
- summary.workspacesWithoutUptimeData === 1 ? "" : "s",
67513
- " missing uptime data"
67514
- ] })
69099
+ /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400 mt-1", children: summary.uptimePercentage === null ? "Uptime metrics unavailable for visible workspaces" : "Overall system uptime today" })
67515
69100
  ] })
67516
69101
  ] }),
67517
69102
  /* @__PURE__ */ jsxs(Card2, { className: "bg-white", children: [
@@ -69206,6 +70791,12 @@ var getPositiveImprovementGain = ({
69206
70791
  pcsGain: issueGain !== null && issueGain > 0 ? issueGain : null
69207
70792
  };
69208
70793
  };
70794
+ var getImprovementPcsGainSortValue = (input) => {
70795
+ const { pcsGain } = getPositiveImprovementGain(input);
70796
+ if (pcsGain !== null) return pcsGain;
70797
+ const raw = toFiniteNumber(input.estimated_gain_pieces);
70798
+ return raw ?? null;
70799
+ };
69209
70800
  var getImprovementDisplayMetadata = ({
69210
70801
  location,
69211
70802
  line,
@@ -69269,26 +70860,21 @@ var compareImprovementRecommendationPriority = (left, right) => {
69269
70860
  };
69270
70861
  var ImprovementRecommendationSignals = ({
69271
70862
  recommendation,
69272
- className
70863
+ className,
70864
+ hideTargetsReadjustment = false
69273
70865
  }) => {
69274
70866
  const gainSummary = getImprovementGainSummary(recommendation);
69275
- const showTargetReadjustment = needsTargetReadjustment(recommendation);
70867
+ const showTargetReadjustment = !hideTargetsReadjustment && needsTargetReadjustment(recommendation);
69276
70868
  if (!gainSummary && !showTargetReadjustment) {
69277
70869
  return null;
69278
70870
  }
69279
70871
  return /* @__PURE__ */ jsxs("div", { className: className || "flex flex-wrap items-center gap-x-4 gap-y-3", children: [
69280
- gainSummary && /* @__PURE__ */ jsxs(
70872
+ gainSummary && /* @__PURE__ */ jsx(
69281
70873
  "span",
69282
70874
  {
69283
70875
  "data-testid": "improvement-gain-chip",
69284
- className: "inline-flex items-center gap-1.5 rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-sm font-medium text-emerald-700 shadow-sm",
69285
- children: [
69286
- /* @__PURE__ */ jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", className: "lucide lucide-trending-up w-4 h-4", children: [
69287
- /* @__PURE__ */ jsx("polyline", { points: "22 7 13.5 15.5 8.5 10.5 2 17" }),
69288
- /* @__PURE__ */ jsx("polyline", { points: "16 7 22 7 22 13" })
69289
- ] }),
69290
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: gainSummary.primary })
69291
- ]
70876
+ className: "inline-flex items-center rounded-full border border-emerald-200 bg-emerald-50 px-3 py-1.5 text-sm font-semibold text-emerald-700 shadow-sm",
70877
+ children: gainSummary.primary
69292
70878
  }
69293
70879
  ),
69294
70880
  showTargetReadjustment && /* @__PURE__ */ jsxs(
@@ -70089,6 +71675,7 @@ var ImprovementCenterView = () => {
70089
71675
  });
70090
71676
  }, [supervisorsByLineId]);
70091
71677
  const filteredRecommendations = useMemo(() => {
71678
+ const hasActiveFilters = selectedLineId !== "all" || selectedStatus !== "all" || selectedShift !== "all" || selectedWeeksRange !== "all" || selectedMemberId !== "all" || selectedSortBy !== "all";
70092
71679
  const sortedRecommendations = recommendations.filter((rec) => {
70093
71680
  if (selectedLineId !== "all" && rec.line_id !== selectedLineId) return false;
70094
71681
  if (selectedStatus === "resolved" && rec.ticket_status !== "solved") return false;
@@ -70103,22 +71690,22 @@ var ImprovementCenterView = () => {
70103
71690
  if (selectedMemberId !== "all" && !(rec.assigned_user_ids?.includes(selectedMemberId) || rec.assigned_to_user_id === selectedMemberId)) return false;
70104
71691
  return true;
70105
71692
  }).sort((a, b) => {
70106
- if (selectedSortBy === "highest_to_lowest") {
70107
- const gainA = toFiniteNumber2(a.estimated_gain_pieces) || 0;
70108
- const gainB = toFiniteNumber2(b.estimated_gain_pieces) || 0;
70109
- if (gainA !== gainB) {
70110
- return gainB - gainA;
70111
- }
70112
- } else if (selectedSortBy === "lowest_to_highest") {
70113
- const gainA = toFiniteNumber2(a.estimated_gain_pieces) || 0;
70114
- const gainB = toFiniteNumber2(b.estimated_gain_pieces) || 0;
70115
- if (gainA !== gainB) {
70116
- return gainA - gainB;
71693
+ if (selectedSortBy === "highest_to_lowest" || selectedSortBy === "lowest_to_highest") {
71694
+ const gainA = getImprovementPcsGainSortValue(a);
71695
+ const gainB = getImprovementPcsGainSortValue(b);
71696
+ const aMissing = gainA === null;
71697
+ const bMissing = gainB === null;
71698
+ if (aMissing && bMissing) ; else if (aMissing) {
71699
+ return 1;
71700
+ } else if (bMissing) {
71701
+ return -1;
71702
+ } else if (gainA !== gainB) {
71703
+ return selectedSortBy === "highest_to_lowest" ? gainB - gainA : gainA - gainB;
70117
71704
  }
70118
71705
  }
70119
71706
  return compareImprovementRecommendationPriority(a, b);
70120
71707
  });
70121
- if (!focusIssueId) {
71708
+ if (!focusIssueId || hasActiveFilters) {
70122
71709
  return sortedRecommendations;
70123
71710
  }
70124
71711
  const focusedIndex = sortedRecommendations.findIndex((rec) => rec.issue_id === focusIssueId);
@@ -70452,7 +72039,7 @@ var ImprovementCenterView = () => {
70452
72039
  /* @__PURE__ */ jsx("div", { className: "absolute left-6 top-full w-0 h-0 border-l-[6px] border-r-[6px] border-t-[6px] border-transparent border-t-white", style: { filter: "drop-shadow(0 1px 1px rgba(0,0,0,0.05))" } })
70453
72040
  ] })
70454
72041
  ] }),
70455
- /* @__PURE__ */ jsx(ImprovementRecommendationSignals_default, { recommendation: rec })
72042
+ /* @__PURE__ */ jsx(ImprovementRecommendationSignals_default, { recommendation: rec, hideTargetsReadjustment: true })
70456
72043
  ] })
70457
72044
  ] }),
70458
72045
  /* @__PURE__ */ jsx("div", { className: "w-full lg:w-5/12 bg-gray-50 rounded-lg p-4 border border-gray-100 flex-shrink-0", children: Array.isArray(rec.evidence) && rec.evidence.length > 0 ? /* @__PURE__ */ jsx(
@@ -72539,20 +74126,410 @@ var AIAgentView = () => {
72539
74126
  ] });
72540
74127
  };
72541
74128
  var AIAgentView_default = AIAgentView;
72542
- var EMPTY_OVERVIEW = {
72543
- scope: {
72544
- current_range: { day_count: null },
72545
- previous_range: { day_count: null },
72546
- available_line_modes: { has_output: false, has_uptime: false }
74129
+
74130
+ // src/views/operations-overview/store.ts
74131
+ var import_isEqual = __toESM(require_isEqual());
74132
+
74133
+ // src/views/operations-overview/types.ts
74134
+ var EMPTY_OVERVIEW_SCOPE = {
74135
+ current_range: { day_count: null },
74136
+ previous_range: { day_count: null },
74137
+ available_line_modes: { has_output: false, has_uptime: false },
74138
+ idle_time_vlm_enabled_line_count: null,
74139
+ idle_time_vlm_disabled_line_count: null
74140
+ };
74141
+ var EMPTY_OVERVIEW_SUMMARY = {
74142
+ plant_efficiency: { current: null, previous: null, delta_pp: null },
74143
+ avg_idle_per_workstation: {
74144
+ current_seconds: null,
74145
+ previous_seconds: null,
74146
+ delta_seconds: null,
74147
+ top_contributors: []
74148
+ }
74149
+ };
74150
+ var EMPTY_OVERVIEW_POOREST_LINES = {
74151
+ output: [],
74152
+ uptime: []
74153
+ };
74154
+ var EMPTY_OVERVIEW_TREND = {
74155
+ shift_mode: "all",
74156
+ points: []
74157
+ };
74158
+ var EMPTY_IDLE_BREAKDOWN = [];
74159
+ var EMPTY_IMPROVEMENTS = [];
74160
+ var LIVE_REFRESH_INTERVAL_MS = 6e4;
74161
+
74162
+ // src/views/operations-overview/store.ts
74163
+ var normalizeNumber = (value) => {
74164
+ if (typeof value === "number" && Number.isFinite(value)) return value;
74165
+ if (typeof value === "string" && value.trim().length > 0) {
74166
+ const parsed = Number(value);
74167
+ return Number.isFinite(parsed) ? parsed : null;
74168
+ }
74169
+ return null;
74170
+ };
74171
+ var normalizeScope = (value) => ({
74172
+ company_id: value?.company_id,
74173
+ line_ids: Array.isArray(value?.line_ids) ? value.line_ids.filter((lineId) => typeof lineId === "string" && lineId.length > 0) : [],
74174
+ line_count: typeof value?.line_count === "number" ? value.line_count : value?.line_count ?? null,
74175
+ shift_mode: value?.shift_mode,
74176
+ comparison_strategy: value?.comparison_strategy,
74177
+ current_range: {
74178
+ start_date: value?.current_range?.start_date,
74179
+ end_date: value?.current_range?.end_date,
74180
+ day_count: value?.current_range?.day_count ?? null
74181
+ },
74182
+ previous_range: {
74183
+ start_date: value?.previous_range?.start_date,
74184
+ end_date: value?.previous_range?.end_date,
74185
+ day_count: value?.previous_range?.day_count ?? null
74186
+ },
74187
+ available_line_modes: {
74188
+ has_output: !!value?.available_line_modes?.has_output,
74189
+ has_uptime: !!value?.available_line_modes?.has_uptime
72547
74190
  },
72548
- summary: {
72549
- plant_efficiency: { current: null, previous: null, delta_pp: null },
72550
- avg_idle_per_workstation: { current_seconds: null, previous_seconds: null, delta_seconds: null, top_contributors: [] }
74191
+ idle_time_vlm_enabled_line_count: value?.idle_time_vlm_enabled_line_count ?? null,
74192
+ idle_time_vlm_disabled_line_count: value?.idle_time_vlm_disabled_line_count ?? null
74193
+ });
74194
+ var normalizeTopContributor = (value) => ({
74195
+ workspace_id: value?.workspace_id,
74196
+ workspace_name: value?.workspace_name?.trim() || value?.workspace_id || "",
74197
+ line_id: value?.line_id,
74198
+ line_name: value?.line_name?.trim() || "",
74199
+ avg_idle_seconds: normalizeNumber(value?.avg_idle_seconds)
74200
+ });
74201
+ var normalizeIdleMetric = (value) => ({
74202
+ current_seconds: normalizeNumber(value?.current_seconds),
74203
+ previous_seconds: normalizeNumber(value?.previous_seconds),
74204
+ delta_seconds: normalizeNumber(value?.delta_seconds),
74205
+ top_contributors: (value?.top_contributors || []).map((item) => normalizeTopContributor(item))
74206
+ });
74207
+ var normalizeSummary = (value) => ({
74208
+ plant_efficiency: {
74209
+ current: normalizeNumber(value?.plant_efficiency?.current),
74210
+ previous: normalizeNumber(value?.plant_efficiency?.previous),
74211
+ delta_pp: normalizeNumber(value?.plant_efficiency?.delta_pp)
74212
+ },
74213
+ avg_idle_per_workstation: normalizeIdleMetric(value?.avg_idle_per_workstation)
74214
+ });
74215
+ var normalizeLineRow = (value) => ({
74216
+ line_id: value?.line_id,
74217
+ line_name: value?.line_name?.trim() || value?.line_id || "",
74218
+ avg_efficiency: normalizeNumber(value?.avg_efficiency),
74219
+ previous_avg_efficiency: normalizeNumber(value?.previous_avg_efficiency),
74220
+ delta_pp: normalizeNumber(value?.delta_pp)
74221
+ });
74222
+ var normalizePoorestLines = (value) => ({
74223
+ output: (value?.output || []).map((item) => normalizeLineRow(item)),
74224
+ uptime: (value?.uptime || []).map((item) => normalizeLineRow(item))
74225
+ });
74226
+ var normalizeTrend = (value) => ({
74227
+ shift_mode: value?.shift_mode || "all",
74228
+ points: (value?.points || []).map((point) => ({
74229
+ date: point?.date,
74230
+ avg_efficiency: normalizeNumber(point?.avg_efficiency)
74231
+ }))
74232
+ });
74233
+ var normalizeIdleBreakdown = (value) => (value || []).map((item) => ({
74234
+ reason: item?.reason?.trim() || "Unknown",
74235
+ percentage: normalizeNumber(item?.percentage),
74236
+ total_duration_seconds: normalizeNumber(item?.total_duration_seconds),
74237
+ efficiency_loss_percentage: normalizeNumber(item?.efficiency_loss_percentage),
74238
+ contributors: (item?.contributors || []).map((contributor) => ({
74239
+ workspace_id: contributor?.workspace_id,
74240
+ workspace_name: contributor?.workspace_name?.trim() || contributor?.workspace_id || "",
74241
+ total_duration_seconds: normalizeNumber(contributor?.total_duration_seconds),
74242
+ percentage_within_reason: normalizeNumber(contributor?.percentage_within_reason)
74243
+ }))
74244
+ }));
74245
+ var normalizeImprovements = (rows) => rows.map((row) => ({
74246
+ id: row.id,
74247
+ issueId: row.issueId,
74248
+ issueNumber: row.issueNumber,
74249
+ title: row.title,
74250
+ metric: row.metric,
74251
+ location: row.location,
74252
+ line: row.line,
74253
+ lineId: row.lineId,
74254
+ workspaceId: row.workspaceId
74255
+ }));
74256
+ var reuseIfEqual = (previous, next) => (0, import_isEqual.default)(previous, next) ? previous : next;
74257
+ var createInitialState = () => ({
74258
+ scope: EMPTY_OVERVIEW_SCOPE,
74259
+ snapshot: {
74260
+ data: {
74261
+ summary: EMPTY_OVERVIEW_SUMMARY,
74262
+ poorest_lines: EMPTY_OVERVIEW_POOREST_LINES
74263
+ },
74264
+ loading: false,
74265
+ error: null,
74266
+ hasLoadedOnce: false,
74267
+ lastUpdated: null
74268
+ },
74269
+ trend: {
74270
+ data: EMPTY_OVERVIEW_TREND,
74271
+ loading: false,
74272
+ error: null,
74273
+ lastUpdated: null
72551
74274
  },
72552
- poorest_lines: { output: [], uptime: [] },
72553
- trend: { shift_mode: "all", points: [] },
72554
- idle_reason_breakdown: []
74275
+ idle: {
74276
+ scope: EMPTY_OVERVIEW_SCOPE,
74277
+ data: EMPTY_IDLE_BREAKDOWN,
74278
+ loading: false,
74279
+ error: null,
74280
+ lastUpdated: null
74281
+ },
74282
+ improvements: {
74283
+ data: EMPTY_IMPROVEMENTS,
74284
+ loading: false,
74285
+ error: null,
74286
+ lastUpdated: null
74287
+ }
74288
+ });
74289
+ var hasSnapshotPayload = (state) => state.snapshot.hasLoadedOnce;
74290
+ var hasTrendPayload = (state) => state.trend.lastUpdated !== null;
74291
+ var hasIdlePayload = (state) => state.idle.lastUpdated !== null;
74292
+ var hasImprovementsPayload = (state) => state.improvements.lastUpdated !== null;
74293
+ var createOperationsOverviewStore = () => {
74294
+ let state = createInitialState();
74295
+ const listeners2 = /* @__PURE__ */ new Set();
74296
+ const emit = () => {
74297
+ listeners2.forEach((listener) => listener());
74298
+ };
74299
+ const setState = (updater, mode = "default") => {
74300
+ const next = updater(state);
74301
+ if (next === state) return;
74302
+ const commit = () => {
74303
+ state = next;
74304
+ emit();
74305
+ };
74306
+ if (mode === "transition") {
74307
+ startTransition(commit);
74308
+ return;
74309
+ }
74310
+ commit();
74311
+ };
74312
+ const subscribe = (listener) => {
74313
+ listeners2.add(listener);
74314
+ return () => {
74315
+ listeners2.delete(listener);
74316
+ };
74317
+ };
74318
+ const reset = () => {
74319
+ setState(() => createInitialState());
74320
+ };
74321
+ const beginSectionLoad = (section) => {
74322
+ setState((previous) => {
74323
+ if (section === "snapshot") {
74324
+ const showLoading2 = !hasSnapshotPayload(previous);
74325
+ if (previous.snapshot.loading === showLoading2 && previous.snapshot.error === null) {
74326
+ return previous;
74327
+ }
74328
+ return {
74329
+ ...previous,
74330
+ snapshot: {
74331
+ ...previous.snapshot,
74332
+ loading: showLoading2,
74333
+ error: null
74334
+ }
74335
+ };
74336
+ }
74337
+ if (section === "trend") {
74338
+ const showLoading2 = !hasTrendPayload(previous);
74339
+ if (previous.trend.loading === showLoading2 && previous.trend.error === null) {
74340
+ return previous;
74341
+ }
74342
+ return {
74343
+ ...previous,
74344
+ trend: {
74345
+ ...previous.trend,
74346
+ loading: showLoading2,
74347
+ error: null
74348
+ }
74349
+ };
74350
+ }
74351
+ if (section === "idle") {
74352
+ const showLoading2 = !hasIdlePayload(previous);
74353
+ if (previous.idle.loading === showLoading2 && previous.idle.error === null) {
74354
+ return previous;
74355
+ }
74356
+ return {
74357
+ ...previous,
74358
+ idle: {
74359
+ ...previous.idle,
74360
+ loading: showLoading2,
74361
+ error: null
74362
+ }
74363
+ };
74364
+ }
74365
+ const showLoading = !hasImprovementsPayload(previous);
74366
+ if (previous.improvements.loading === showLoading && previous.improvements.error === null) {
74367
+ return previous;
74368
+ }
74369
+ return {
74370
+ ...previous,
74371
+ improvements: {
74372
+ ...previous.improvements,
74373
+ loading: showLoading,
74374
+ error: null
74375
+ }
74376
+ };
74377
+ });
74378
+ };
74379
+ const failSectionLoad = (section, error) => {
74380
+ setState((previous) => {
74381
+ if (section === "snapshot") {
74382
+ if (hasSnapshotPayload(previous)) return previous;
74383
+ return {
74384
+ ...previous,
74385
+ snapshot: {
74386
+ ...previous.snapshot,
74387
+ loading: false,
74388
+ error
74389
+ }
74390
+ };
74391
+ }
74392
+ if (section === "trend") {
74393
+ if (hasTrendPayload(previous)) return previous;
74394
+ return {
74395
+ ...previous,
74396
+ trend: {
74397
+ ...previous.trend,
74398
+ loading: false,
74399
+ error
74400
+ }
74401
+ };
74402
+ }
74403
+ if (section === "idle") {
74404
+ if (hasIdlePayload(previous)) return previous;
74405
+ return {
74406
+ ...previous,
74407
+ idle: {
74408
+ ...previous.idle,
74409
+ loading: false,
74410
+ error
74411
+ }
74412
+ };
74413
+ }
74414
+ if (hasImprovementsPayload(previous)) return previous;
74415
+ return {
74416
+ ...previous,
74417
+ improvements: {
74418
+ ...previous.improvements,
74419
+ loading: false,
74420
+ error
74421
+ }
74422
+ };
74423
+ });
74424
+ };
74425
+ return {
74426
+ getState: () => state,
74427
+ subscribe,
74428
+ reset,
74429
+ beginSnapshotLoad: () => beginSectionLoad("snapshot"),
74430
+ applySnapshotResponse: (response, updatedAt, mode = "default") => {
74431
+ setState((previous) => {
74432
+ const nextScope = reuseIfEqual(previous.scope, normalizeScope(response.scope));
74433
+ const nextSummary = reuseIfEqual(previous.snapshot.data.summary, normalizeSummary(response.summary));
74434
+ const nextPoorestLines = reuseIfEqual(previous.snapshot.data.poorest_lines, normalizePoorestLines(response.poorest_lines));
74435
+ const nextData = nextSummary === previous.snapshot.data.summary && nextPoorestLines === previous.snapshot.data.poorest_lines ? previous.snapshot.data : {
74436
+ summary: nextSummary,
74437
+ poorest_lines: nextPoorestLines
74438
+ };
74439
+ const nextLastUpdated = nextData !== previous.snapshot.data || previous.snapshot.lastUpdated === null ? updatedAt : previous.snapshot.lastUpdated;
74440
+ if (nextScope === previous.scope && nextData === previous.snapshot.data && previous.snapshot.loading === false && previous.snapshot.error === null && previous.snapshot.hasLoadedOnce && nextLastUpdated === previous.snapshot.lastUpdated) {
74441
+ return previous;
74442
+ }
74443
+ return {
74444
+ ...previous,
74445
+ scope: nextScope,
74446
+ snapshot: {
74447
+ data: nextData,
74448
+ loading: false,
74449
+ error: null,
74450
+ hasLoadedOnce: true,
74451
+ lastUpdated: nextLastUpdated
74452
+ }
74453
+ };
74454
+ }, mode);
74455
+ },
74456
+ failSnapshotLoad: (error) => failSectionLoad("snapshot", error),
74457
+ beginTrendLoad: () => beginSectionLoad("trend"),
74458
+ applyTrendResponse: (response, updatedAt, mode = "default") => {
74459
+ setState((previous) => {
74460
+ const nextData = reuseIfEqual(previous.trend.data, normalizeTrend(response.trend));
74461
+ const nextLastUpdated = nextData !== previous.trend.data || previous.trend.lastUpdated === null ? updatedAt : previous.trend.lastUpdated;
74462
+ if (nextData === previous.trend.data && previous.trend.loading === false && previous.trend.error === null && nextLastUpdated === previous.trend.lastUpdated) {
74463
+ return previous;
74464
+ }
74465
+ return {
74466
+ ...previous,
74467
+ trend: {
74468
+ data: nextData,
74469
+ loading: false,
74470
+ error: null,
74471
+ lastUpdated: nextLastUpdated
74472
+ }
74473
+ };
74474
+ }, mode);
74475
+ },
74476
+ failTrendLoad: (error) => failSectionLoad("trend", error),
74477
+ beginIdleLoad: () => beginSectionLoad("idle"),
74478
+ applyIdleResponse: (response, updatedAt, mode = "default") => {
74479
+ setState((previous) => {
74480
+ const nextScope = reuseIfEqual(previous.idle.scope, normalizeScope(response.scope));
74481
+ const nextData = reuseIfEqual(previous.idle.data, normalizeIdleBreakdown(response.idle_reason_breakdown));
74482
+ const nextLastUpdated = nextData !== previous.idle.data || nextScope !== previous.idle.scope || previous.idle.lastUpdated === null ? updatedAt : previous.idle.lastUpdated;
74483
+ if (nextData === previous.idle.data && nextScope === previous.idle.scope && previous.idle.loading === false && previous.idle.error === null && nextLastUpdated === previous.idle.lastUpdated) {
74484
+ return previous;
74485
+ }
74486
+ return {
74487
+ ...previous,
74488
+ idle: {
74489
+ scope: nextScope,
74490
+ data: nextData,
74491
+ loading: false,
74492
+ error: null,
74493
+ lastUpdated: nextLastUpdated
74494
+ }
74495
+ };
74496
+ }, mode);
74497
+ },
74498
+ failIdleLoad: (error) => failSectionLoad("idle", error),
74499
+ beginImprovementsLoad: () => beginSectionLoad("improvements"),
74500
+ applyImprovements: (rows, updatedAt, mode = "default") => {
74501
+ setState((previous) => {
74502
+ const nextData = reuseIfEqual(previous.improvements.data, normalizeImprovements(rows));
74503
+ const nextLastUpdated = nextData !== previous.improvements.data || previous.improvements.lastUpdated === null ? updatedAt : previous.improvements.lastUpdated;
74504
+ if (nextData === previous.improvements.data && previous.improvements.loading === false && previous.improvements.error === null && nextLastUpdated === previous.improvements.lastUpdated) {
74505
+ return previous;
74506
+ }
74507
+ return {
74508
+ ...previous,
74509
+ improvements: {
74510
+ data: nextData,
74511
+ loading: false,
74512
+ error: null,
74513
+ lastUpdated: nextLastUpdated
74514
+ }
74515
+ };
74516
+ }, mode);
74517
+ },
74518
+ failImprovementsLoad: (error) => failSectionLoad("improvements", error)
74519
+ };
72555
74520
  };
74521
+ var useOperationsOverviewSelector = (store, selector) => {
74522
+ return useSyncExternalStore(
74523
+ store.subscribe,
74524
+ () => selector(store.getState()),
74525
+ () => selector(store.getState())
74526
+ );
74527
+ };
74528
+ var useOperationsOverviewScope = (store) => useOperationsOverviewSelector(store, (state) => state.scope);
74529
+ var useOperationsOverviewSnapshot = (store) => useOperationsOverviewSelector(store, (state) => state.snapshot);
74530
+ var useOperationsOverviewTrend = (store) => useOperationsOverviewSelector(store, (state) => state.trend);
74531
+ var useOperationsOverviewIdle = (store) => useOperationsOverviewSelector(store, (state) => state.idle);
74532
+ var useOperationsOverviewImprovements = (store) => useOperationsOverviewSelector(store, (state) => state.improvements);
72556
74533
  var efficiencyLineConfig = [
72557
74534
  {
72558
74535
  dataKey: "efficiency",
@@ -72564,6 +74541,9 @@ var efficiencyLineConfig = [
72564
74541
  activeDot: { r: 6, strokeWidth: 0, fill: "#00AB45" }
72565
74542
  }
72566
74543
  ];
74544
+ var bumpRenderCounter = (key) => {
74545
+ if (process.env.NODE_ENV === "test") ;
74546
+ };
72567
74547
  var toNumber3 = (value) => {
72568
74548
  if (typeof value === "number" && Number.isFinite(value)) return value;
72569
74549
  if (typeof value === "string" && value.trim().length > 0) {
@@ -72583,26 +74563,11 @@ var formatSignedIdleDuration = (seconds) => {
72583
74563
  const sign = seconds > 0 ? "+" : "-";
72584
74564
  return `${sign}${formatIdleDuration(Math.abs(seconds))}`;
72585
74565
  };
72586
- var formatComparisonWindow = (dayCount) => {
74566
+ var formatComparisonWindow = (dayCount, comparisonStrategy) => {
74567
+ if (comparisonStrategy === "previous_full_week") return "last week";
72587
74568
  if (!dayCount || !Number.isFinite(dayCount)) return "previous range";
72588
74569
  return `previous ${dayCount} ${dayCount === 1 ? "day" : "days"}`;
72589
74570
  };
72590
- var buildImprovementMetric = (recommendation) => {
72591
- const { pcsGain } = getPositiveImprovementGain(recommendation);
72592
- const metrics2 = recommendation.metrics || {};
72593
- if (pcsGain !== null) {
72594
- return formatImprovementPieceGain(pcsGain);
72595
- }
72596
- const idleMinutes = toNumber3(metrics2.idle_minutes);
72597
- if (idleMinutes !== null) {
72598
- return `-${Math.round(idleMinutes)}m Idle`;
72599
- }
72600
- const impactText = recommendation.impact?.trim();
72601
- if (impactText) {
72602
- return impactText.length > 22 ? `${impactText.slice(0, 22).trim()}...` : impactText;
72603
- }
72604
- return "Review Issue";
72605
- };
72606
74571
  var buildDeltaBadge = (delta, options) => {
72607
74572
  if (delta === null || delta === void 0 || !Number.isFinite(delta)) {
72608
74573
  return {
@@ -72670,368 +74635,225 @@ var OverviewImprovementsSkeleton = () => /* @__PURE__ */ jsx("div", { className:
72670
74635
  ] }),
72671
74636
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsx(SectionPulse, { className: "h-6 w-20 rounded-full" }) })
72672
74637
  ] }, index)) });
72673
- var PlantHeadView = () => {
72674
- const supabase = useSupabase();
72675
- const entityConfig = useEntityConfig();
72676
- const appTimezone = useAppTimezone() || "UTC";
72677
- const { navigate } = useNavigation();
72678
- const { accessibleLineIds } = useUserLineAccess();
72679
- const mobileMenuContext = useMobileMenu();
72680
- useHideMobileHeader(!!mobileMenuContext);
72681
- const [dateRange, setDateRange] = React141__default.useState(() => getCurrentWeekToDateRange(appTimezone));
72682
- const [trendMode, setTrendMode] = React141__default.useState("all");
72683
- const [poorestLineMode, setPoorestLineMode] = React141__default.useState("output");
72684
- const [overview, setOverview] = React141__default.useState(EMPTY_OVERVIEW);
72685
- const [isSnapshotLoading, setIsSnapshotLoading] = React141__default.useState(false);
72686
- const [isTrendLoading, setIsTrendLoading] = React141__default.useState(false);
72687
- const [trendFetchNonce, setTrendFetchNonce] = React141__default.useState(0);
72688
- const [trendViewOpenNonce] = React141__default.useState(() => Date.now());
72689
- const [idleReasonBreakdown, setIdleReasonBreakdown] = React141__default.useState([]);
72690
- const [idleReasonScope, setIdleReasonScope] = React141__default.useState(null);
72691
- const [isIdleReasonBreakdownLoading, setIsIdleReasonBreakdownLoading] = React141__default.useState(false);
72692
- const [improvements, setImprovements] = React141__default.useState([]);
72693
- const [isImprovementsLoading, setIsImprovementsLoading] = React141__default.useState(false);
74638
+ var OperationsOverviewHeader = React141__default.memo(({
74639
+ dateRange,
74640
+ trendMode,
74641
+ appTimezone,
74642
+ mobileMenuContext,
74643
+ onDateRangeChange,
74644
+ onTrendModeChange
74645
+ }) => {
74646
+ bumpRenderCounter();
72694
74647
  const [isFilterOpen, setIsFilterOpen] = React141__default.useState(false);
72695
- const [isIdleContributorsOpen, setIsIdleContributorsOpen] = React141__default.useState(false);
72696
- const [isIdleContributorsPinned, setIsIdleContributorsPinned] = React141__default.useState(false);
72697
74648
  const filterRef = React141__default.useRef(null);
72698
74649
  const filterButtonRef = React141__default.useRef(null);
72699
74650
  const mobileFilterButtonRef = React141__default.useRef(null);
72700
- const idleContributorsRef = React141__default.useRef(null);
72701
- React141__default.useEffect(() => {
72702
- trackCorePageView("Operations Overview");
72703
- }, []);
72704
- const handleDateRangeChange = React141__default.useCallback((range) => {
72705
- trackCoreEvent("Operations Overview Date Range Changed", {
72706
- start_date: range.startKey,
72707
- end_date: range.endKey
72708
- });
72709
- setDateRange(range);
72710
- }, []);
74651
+ const currentWeekRange = React141__default.useMemo(
74652
+ () => getCurrentWeekToDateRange(appTimezone),
74653
+ [appTimezone]
74654
+ );
74655
+ const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
74656
+ const mobileSubtitle = React141__default.useMemo(() => {
74657
+ if (isCurrentWeekToDateRange) {
74658
+ return `Week of ${format(parseDateKeyToDate(dateRange.startKey), "do MMM")}`;
74659
+ }
74660
+ return `${format(parseDateKeyToDate(dateRange.startKey), "do MMM")} - ${format(parseDateKeyToDate(dateRange.endKey), "do MMM, yyyy")}`;
74661
+ }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
74662
+ const desktopSubtitle = React141__default.useMemo(() => {
74663
+ if (isCurrentWeekToDateRange) {
74664
+ return `Week of ${format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")}`;
74665
+ }
74666
+ return `${format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")} - ${format(parseDateKeyToDate(dateRange.endKey), "do MMMM, yyyy")}`;
74667
+ }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
72711
74668
  const handleFilterToggle = React141__default.useCallback(() => {
72712
74669
  trackCoreEvent("Operations Overview Filter Toggled", {
72713
74670
  action: !isFilterOpen ? "open" : "close"
72714
74671
  });
72715
- setIsFilterOpen(!isFilterOpen);
74672
+ setIsFilterOpen((previous) => !previous);
72716
74673
  }, [isFilterOpen]);
72717
- const handleTrendModeChange = React141__default.useCallback((e) => {
72718
- const newMode = e.target.value;
74674
+ const handleTrendModeChange = React141__default.useCallback((event) => {
74675
+ const nextMode = event.target.value;
72719
74676
  trackCoreEvent("Operations Overview Shift Filter Changed", {
72720
- shift_mode: newMode
72721
- });
72722
- setTrendMode(newMode);
72723
- }, []);
72724
- const handlePoorestLineModeChange = React141__default.useCallback((mode) => {
72725
- trackCoreEvent("Operations Overview Poorest Line Mode Changed", {
72726
- mode
74677
+ shift_mode: nextMode
72727
74678
  });
72728
- setPoorestLineMode(mode);
72729
- }, []);
74679
+ onTrendModeChange(nextMode);
74680
+ }, [onTrendModeChange]);
72730
74681
  React141__default.useEffect(() => {
72731
- function handleClickOutside(event) {
74682
+ const handleClickOutside = (event) => {
72732
74683
  if (filterRef.current && !filterRef.current.contains(event.target) && filterButtonRef.current && !filterButtonRef.current.contains(event.target) && mobileFilterButtonRef.current && !mobileFilterButtonRef.current.contains(event.target)) {
72733
74684
  setIsFilterOpen(false);
72734
74685
  }
72735
- }
74686
+ };
72736
74687
  document.addEventListener("mousedown", handleClickOutside);
72737
74688
  return () => {
72738
74689
  document.removeEventListener("mousedown", handleClickOutside);
72739
74690
  };
72740
74691
  }, []);
72741
- const initializedTimezoneRef = React141__default.useRef(appTimezone);
72742
- React141__default.useEffect(() => {
72743
- if (initializedTimezoneRef.current === appTimezone) return;
72744
- setDateRange(getCurrentWeekToDateRange(appTimezone));
72745
- initializedTimezoneRef.current = appTimezone;
72746
- }, [appTimezone]);
72747
- const companyId = entityConfig.companyId;
72748
- const scopedLineIds = React141__default.useMemo(
72749
- () => Array.from(new Set((accessibleLineIds || []).filter(Boolean))),
72750
- [accessibleLineIds]
72751
- );
72752
- const lineIdsKey = React141__default.useMemo(
72753
- () => scopedLineIds.slice().sort().join(","),
72754
- [scopedLineIds]
72755
- );
72756
- React141__default.useEffect(() => {
72757
- setIsIdleContributorsOpen(false);
72758
- setIsIdleContributorsPinned(false);
72759
- }, [companyId, dateRange.endKey, dateRange.startKey, lineIdsKey, trendMode]);
72760
- const { supervisorsByLineId } = useSupervisorsByLineIds(scopedLineIds, {
72761
- enabled: !!companyId && scopedLineIds.length > 0,
72762
- companyId,
72763
- useBackend: true
72764
- });
72765
- React141__default.useEffect(() => {
72766
- if (!supabase || !companyId) return void 0;
72767
- if (scopedLineIds.length === 0) {
72768
- setOverview(EMPTY_OVERVIEW);
72769
- setIdleReasonBreakdown([]);
72770
- setIsSnapshotLoading(false);
72771
- return void 0;
72772
- }
72773
- let cancelled = false;
72774
- setOverview((prev) => ({
72775
- ...prev,
72776
- scope: EMPTY_OVERVIEW.scope,
72777
- summary: EMPTY_OVERVIEW.summary,
72778
- poorest_lines: EMPTY_OVERVIEW.poorest_lines
72779
- }));
72780
- setIsSnapshotLoading(true);
72781
- const fetchOverviewSnapshot = async () => {
72782
- const params = new URLSearchParams({
72783
- company_id: companyId,
72784
- start_date: dateRange.startKey,
72785
- end_date: dateRange.endKey,
72786
- trend_shift_mode: trendMode,
72787
- line_ids: scopedLineIds.join(",")
72788
- });
72789
- const response = await fetchBackendJson(
72790
- supabase,
72791
- `/api/dashboard/operations-overview/snapshot?${params.toString()}`
72792
- );
72793
- if (!cancelled) {
72794
- setOverview((prev) => ({
72795
- ...prev,
72796
- scope: response.scope || EMPTY_OVERVIEW.scope,
72797
- summary: response.summary || EMPTY_OVERVIEW.summary,
72798
- poorest_lines: response.poorest_lines || EMPTY_OVERVIEW.poorest_lines
72799
- }));
72800
- }
72801
- };
72802
- fetchOverviewSnapshot().catch((error) => {
72803
- console.error("[PlantHeadView] Failed to fetch operations overview snapshot", error);
72804
- if (!cancelled) {
72805
- setOverview((prev) => ({
72806
- ...prev,
72807
- scope: EMPTY_OVERVIEW.scope,
72808
- summary: EMPTY_OVERVIEW.summary,
72809
- poorest_lines: EMPTY_OVERVIEW.poorest_lines
72810
- }));
72811
- }
72812
- }).finally(() => {
72813
- if (!cancelled) {
72814
- setIsSnapshotLoading(false);
72815
- }
72816
- });
72817
- return () => {
72818
- cancelled = true;
72819
- };
72820
- }, [
72821
- companyId,
72822
- dateRange.endKey,
72823
- dateRange.startKey,
72824
- lineIdsKey,
72825
- scopedLineIds,
72826
- supabase,
72827
- trendMode
72828
- ]);
72829
- React141__default.useEffect(() => {
72830
- if (!supabase || !companyId) return void 0;
72831
- if (scopedLineIds.length === 0) {
72832
- setOverview((prev) => ({
72833
- ...prev,
72834
- trend: EMPTY_OVERVIEW.trend
72835
- }));
72836
- setIsTrendLoading(false);
72837
- return void 0;
72838
- }
72839
- let cancelled = false;
72840
- setIsTrendLoading(true);
72841
- const fetchOverviewTrend = async () => {
72842
- const params = new URLSearchParams({
72843
- company_id: companyId,
72844
- start_date: dateRange.startKey,
72845
- end_date: dateRange.endKey,
72846
- trend_shift_mode: trendMode,
72847
- line_ids: scopedLineIds.join(",")
72848
- });
72849
- const response = await fetchBackendJson(
72850
- supabase,
72851
- `/api/dashboard/operations-overview/trend?${params.toString()}`
72852
- );
72853
- if (!cancelled) {
72854
- setOverview((prev) => ({
72855
- ...prev,
72856
- trend: response.trend || EMPTY_OVERVIEW.trend
72857
- }));
72858
- setTrendFetchNonce((prev) => prev + 1);
72859
- }
72860
- };
72861
- fetchOverviewTrend().catch((error) => {
72862
- console.error("[PlantHeadView] Failed to fetch operations overview trend", error);
72863
- }).finally(() => {
72864
- if (!cancelled) {
72865
- setIsTrendLoading(false);
72866
- }
72867
- });
72868
- return () => {
72869
- cancelled = true;
72870
- };
72871
- }, [
72872
- companyId,
72873
- dateRange.endKey,
72874
- dateRange.startKey,
72875
- lineIdsKey,
72876
- scopedLineIds,
72877
- supabase,
72878
- trendMode
72879
- ]);
72880
- React141__default.useEffect(() => {
72881
- if (!supabase || !companyId) return void 0;
72882
- if (scopedLineIds.length === 0) {
72883
- setIdleReasonScope(null);
72884
- setIdleReasonBreakdown([]);
72885
- setIsIdleReasonBreakdownLoading(false);
72886
- return void 0;
72887
- }
72888
- let cancelled = false;
72889
- setIdleReasonScope(null);
72890
- setIdleReasonBreakdown([]);
72891
- setIsIdleReasonBreakdownLoading(true);
72892
- const fetchIdleReasonBreakdown = async () => {
72893
- const params = new URLSearchParams({
72894
- company_id: companyId,
72895
- start_date: dateRange.startKey,
72896
- end_date: dateRange.endKey,
72897
- trend_shift_mode: trendMode,
72898
- line_ids: scopedLineIds.join(",")
72899
- });
72900
- const response = await fetchBackendJson(
72901
- supabase,
72902
- `/api/dashboard/operations-overview/idle-reason-breakdown?${params.toString()}`
72903
- );
72904
- if (!cancelled) {
72905
- setIdleReasonScope(response.scope || null);
72906
- setIdleReasonBreakdown(response.idle_reason_breakdown || []);
72907
- }
72908
- };
72909
- fetchIdleReasonBreakdown().catch((error) => {
72910
- console.error("[PlantHeadView] Failed to fetch idle reason breakdown", error);
72911
- if (!cancelled) {
72912
- setIdleReasonScope(null);
72913
- setIdleReasonBreakdown([]);
72914
- }
72915
- }).finally(() => {
72916
- if (!cancelled) {
72917
- setIsIdleReasonBreakdownLoading(false);
72918
- }
72919
- });
72920
- return () => {
72921
- cancelled = true;
72922
- };
72923
- }, [
72924
- companyId,
72925
- dateRange.endKey,
72926
- dateRange.startKey,
72927
- lineIdsKey,
72928
- scopedLineIds,
72929
- supabase,
72930
- trendMode
72931
- ]);
72932
- React141__default.useEffect(() => {
72933
- if (!supabase || !companyId) return void 0;
72934
- if (scopedLineIds.length === 0) {
72935
- setImprovements([]);
72936
- setIsImprovementsLoading(false);
72937
- return void 0;
72938
- }
72939
- let cancelled = false;
72940
- setIsImprovementsLoading(true);
72941
- const fetchImprovements = async () => {
72942
- const params = new URLSearchParams({
72943
- company_id: companyId,
72944
- status: "open",
72945
- limit: "200",
72946
- line_ids: scopedLineIds.join(",")
72947
- });
72948
- const response = await fetchBackendJson(
72949
- supabase,
72950
- `/api/improvement-center/recommendations?${params.toString()}`
72951
- );
72952
- if (cancelled) return;
72953
- const allowedLineIds = new Set(scopedLineIds);
72954
- const scopedRecommendations = (response.recommendations || []).filter((recommendation) => {
72955
- return !recommendation.line_id || allowedLineIds.has(recommendation.line_id);
72956
- });
72957
- const nextImprovements = [...scopedRecommendations].sort(compareImprovementRecommendationPriority).slice(0, 3).map((recommendation) => ({
72958
- id: recommendation.issue_id || recommendation.id,
72959
- issueId: recommendation.issue_id || recommendation.id,
72960
- issueNumber: recommendation.issue_number,
72961
- title: recommendation.title?.trim() || "Untitled issue",
72962
- metric: buildImprovementMetric(recommendation),
72963
- location: recommendation.location,
72964
- line: recommendation.line,
72965
- lineId: recommendation.line_id,
72966
- workspaceId: recommendation.workspace_id
72967
- }));
72968
- setImprovements(nextImprovements);
72969
- };
72970
- fetchImprovements().catch((error) => {
72971
- console.error("[PlantHeadView] Failed to fetch improvements", error);
72972
- if (!cancelled) {
72973
- setImprovements([]);
72974
- }
72975
- }).finally(() => {
72976
- if (!cancelled) {
72977
- setIsImprovementsLoading(false);
72978
- }
72979
- });
72980
- return () => {
72981
- cancelled = true;
72982
- };
72983
- }, [companyId, lineIdsKey, scopedLineIds, supabase]);
72984
- const availableLineModes = overview.scope?.available_line_modes;
72985
- React141__default.useEffect(() => {
72986
- const hasOutput = !!availableLineModes?.has_output;
72987
- const hasUptime = !!availableLineModes?.has_uptime;
72988
- if (hasOutput && !hasUptime && poorestLineMode !== "output") {
72989
- setPoorestLineMode("output");
72990
- } else if (hasUptime && !hasOutput && poorestLineMode !== "uptime") {
72991
- setPoorestLineMode("uptime");
72992
- }
72993
- }, [availableLineModes?.has_output, availableLineModes?.has_uptime, poorestLineMode]);
72994
- const comparisonLabel = React141__default.useMemo(
72995
- () => formatComparisonWindow(overview.scope?.current_range?.day_count ?? null),
72996
- [overview.scope?.current_range?.day_count]
72997
- );
74692
+ return /* @__PURE__ */ jsx("header", { className: "sticky top-0 z-10 bg-white border-b flex-shrink-0 shadow-sm", children: /* @__PURE__ */ jsxs("div", { className: "px-3 sm:px-4 md:px-6 py-2 sm:py-3 relative", children: [
74693
+ /* @__PURE__ */ jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
74694
+ mobileMenuContext ? /* @__PURE__ */ jsx(
74695
+ HamburgerButton,
74696
+ {
74697
+ onClick: mobileMenuContext.onMobileMenuOpen || (() => {
74698
+ }),
74699
+ className: "flex-shrink-0 -ml-1"
74700
+ }
74701
+ ) : /* @__PURE__ */ jsx("div", { className: "w-8 flex-shrink-0" }),
74702
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col items-center justify-center", children: [
74703
+ /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold text-gray-900 text-center px-1 truncate max-w-[200px]", children: "Operations Overview" }),
74704
+ /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-slate-500 text-center mt-0.5", children: mobileSubtitle })
74705
+ ] }),
74706
+ /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 flex items-center gap-1.5", children: [
74707
+ /* @__PURE__ */ jsx(
74708
+ MonthlyRangeFilter_default,
74709
+ {
74710
+ month: parseDateKeyToDate(dateRange.startKey).getMonth(),
74711
+ year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
74712
+ timezone: appTimezone,
74713
+ value: dateRange,
74714
+ onChange: onDateRangeChange,
74715
+ showLabel: false
74716
+ }
74717
+ ),
74718
+ /* @__PURE__ */ jsxs(
74719
+ "button",
74720
+ {
74721
+ ref: mobileFilterButtonRef,
74722
+ onClick: handleFilterToggle,
74723
+ className: `p-2 rounded-full transition-colors relative ${isFilterOpen || trendMode !== "all" ? "bg-blue-50" : "active:bg-gray-100"}`,
74724
+ "aria-label": "Open filters",
74725
+ children: [
74726
+ /* @__PURE__ */ jsx(Filter, { className: `w-5 h-5 ${trendMode !== "all" ? "text-blue-600" : "text-gray-700"}` }),
74727
+ trendMode !== "all" ? /* @__PURE__ */ jsx("span", { className: "absolute -top-1 -right-1 flex items-center justify-center w-4 h-4 bg-blue-600 text-white text-[10px] rounded-full font-bold", children: "1" }) : null
74728
+ ]
74729
+ }
74730
+ )
74731
+ ] })
74732
+ ] }) }),
74733
+ /* @__PURE__ */ jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center relative min-h-[56px]", children: [
74734
+ /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 -translate-x-1/2 flex flex-col items-center pointer-events-none", children: [
74735
+ /* @__PURE__ */ jsx("h1", { className: "text-2xl md:text-3xl lg:text-4xl font-semibold text-gray-900 tracking-tight text-center pointer-events-auto leading-tight mb-0.5", children: "Operations Overview" }),
74736
+ /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium text-slate-500 text-center pointer-events-auto", children: desktopSubtitle })
74737
+ ] }),
74738
+ /* @__PURE__ */ jsxs("div", { className: "absolute right-0 flex items-center gap-3", children: [
74739
+ /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(
74740
+ MonthlyRangeFilter_default,
74741
+ {
74742
+ month: parseDateKeyToDate(dateRange.startKey).getMonth(),
74743
+ year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
74744
+ timezone: appTimezone,
74745
+ value: dateRange,
74746
+ onChange: onDateRangeChange,
74747
+ showLabel: false
74748
+ }
74749
+ ) }),
74750
+ /* @__PURE__ */ jsxs(
74751
+ "button",
74752
+ {
74753
+ ref: filterButtonRef,
74754
+ onClick: handleFilterToggle,
74755
+ className: `flex items-center gap-2 px-3 py-1.5 rounded-lg border text-sm font-medium transition-all shadow-sm ${isFilterOpen || trendMode !== "all" ? "border-blue-500 bg-blue-50 text-blue-700 ring-1 ring-blue-500" : "border-slate-200 bg-white text-slate-700 hover:bg-slate-50"}`,
74756
+ "aria-label": "Open filters",
74757
+ children: [
74758
+ /* @__PURE__ */ jsx(Filter, { className: `w-[18px] h-[18px] ${trendMode !== "all" ? "text-blue-600" : "text-slate-500"}` }),
74759
+ "Filters",
74760
+ /* @__PURE__ */ jsx(ChevronDown, { className: `w-4 h-4 ml-0.5 transition-transform duration-200 ${isFilterOpen ? "rotate-180" : ""}` })
74761
+ ]
74762
+ }
74763
+ )
74764
+ ] })
74765
+ ] }) }),
74766
+ isFilterOpen ? /* @__PURE__ */ jsxs("div", { ref: filterRef, className: "absolute right-3 sm:right-4 md:right-5 lg:right-6 top-full mt-2 w-72 bg-white rounded-xl shadow-xl border border-gray-100 p-4 z-50", children: [
74767
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
74768
+ /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-gray-900", children: "Filter View" }),
74769
+ trendMode !== "all" ? /* @__PURE__ */ jsx(
74770
+ "button",
74771
+ {
74772
+ onClick: () => {
74773
+ onTrendModeChange("all");
74774
+ setIsFilterOpen(false);
74775
+ },
74776
+ className: "text-xs text-red-600 hover:text-red-700 font-medium",
74777
+ children: "Clear all"
74778
+ }
74779
+ ) : null
74780
+ ] }),
74781
+ /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
74782
+ /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide ml-1", children: "Shift" }),
74783
+ /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
74784
+ "select",
74785
+ {
74786
+ value: trendMode,
74787
+ onChange: handleTrendModeChange,
74788
+ className: "w-full appearance-none pl-3 pr-8 py-2 text-sm bg-gray-50 border border-gray-200 hover:border-gray-300 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:bg-white transition-all cursor-pointer",
74789
+ style: {
74790
+ backgroundImage: `url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e")`,
74791
+ backgroundPosition: "right 0.75rem center",
74792
+ backgroundRepeat: "no-repeat",
74793
+ backgroundSize: "1.2em 1.2em"
74794
+ },
74795
+ children: [
74796
+ /* @__PURE__ */ jsx("option", { value: "all", children: "All Shifts" }),
74797
+ /* @__PURE__ */ jsx("option", { value: "day", children: "Day Shift" }),
74798
+ /* @__PURE__ */ jsx("option", { value: "night", children: "Night Shift" })
74799
+ ]
74800
+ }
74801
+ ) })
74802
+ ] }) })
74803
+ ] }) : null
74804
+ ] }) });
74805
+ });
74806
+ OperationsOverviewHeader.displayName = "OperationsOverviewHeader";
74807
+ var OverviewSummaryCards = React141__default.memo(({ store }) => {
74808
+ bumpRenderCounter();
74809
+ const scope = useOperationsOverviewScope(store);
74810
+ const snapshot = useOperationsOverviewSnapshot(store);
74811
+ const showSnapshotSkeleton = snapshot.loading && !snapshot.hasLoadedOnce;
74812
+ const comparisonLabel = React141__default.useMemo(() => {
74813
+ return formatComparisonWindow(
74814
+ scope.previous_range?.day_count ?? null,
74815
+ scope.comparison_strategy
74816
+ );
74817
+ }, [scope.comparison_strategy, scope.previous_range?.day_count]);
74818
+ const [isIdleContributorsOpen, setIsIdleContributorsOpen] = React141__default.useState(false);
74819
+ const [isIdleContributorsPinned, setIsIdleContributorsPinned] = React141__default.useState(false);
74820
+ const idleContributorsRef = React141__default.useRef(null);
72998
74821
  const plantEfficiencyBadge = React141__default.useMemo(() => {
72999
- return buildDeltaBadge(overview.summary?.plant_efficiency?.delta_pp, {
74822
+ return buildDeltaBadge(snapshot.data.summary.plant_efficiency?.delta_pp, {
73000
74823
  positiveIsGood: true,
73001
74824
  formatter: (value) => `${value >= 0 ? "+" : ""}${roundOne(value)}%`,
73002
74825
  comparisonLabel
73003
74826
  });
73004
- }, [comparisonLabel, overview.summary?.plant_efficiency?.delta_pp]);
74827
+ }, [comparisonLabel, snapshot.data.summary.plant_efficiency?.delta_pp]);
73005
74828
  const idleBadge = React141__default.useMemo(() => {
73006
- return buildDeltaBadge(overview.summary?.avg_idle_per_workstation?.delta_seconds, {
74829
+ return buildDeltaBadge(snapshot.data.summary.avg_idle_per_workstation?.delta_seconds, {
73007
74830
  positiveIsGood: false,
73008
74831
  formatter: (value) => formatSignedIdleDuration(value),
73009
74832
  comparisonLabel
73010
74833
  });
73011
- }, [comparisonLabel, overview.summary?.avg_idle_per_workstation?.delta_seconds]);
74834
+ }, [comparisonLabel, snapshot.data.summary.avg_idle_per_workstation?.delta_seconds]);
73012
74835
  const canInspectIdleContributors = React141__default.useMemo(() => {
73013
- return !isSnapshotLoading && overview.summary?.avg_idle_per_workstation?.current_seconds !== null && overview.summary?.avg_idle_per_workstation?.current_seconds !== void 0;
73014
- }, [isSnapshotLoading, overview.summary?.avg_idle_per_workstation?.current_seconds]);
74836
+ return !showSnapshotSkeleton && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== null && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== void 0;
74837
+ }, [showSnapshotSkeleton, snapshot.data.summary.avg_idle_per_workstation?.current_seconds]);
73015
74838
  const idleTopContributors = React141__default.useMemo(() => {
73016
- return (overview.summary?.avg_idle_per_workstation?.top_contributors || []).map((item) => ({
74839
+ return (snapshot.data.summary.avg_idle_per_workstation?.top_contributors || []).map((item) => ({
73017
74840
  workspaceId: item.workspace_id || "",
73018
74841
  workspaceName: item.workspace_name?.trim() || item.workspace_id || "Unknown",
73019
- lineId: item.line_id || "",
73020
74842
  lineName: item.line_name?.trim() || "Unknown Line",
73021
74843
  avgIdleSeconds: toNumber3(item.avg_idle_seconds)
73022
74844
  })).slice(0, 5);
73023
- }, [overview.summary?.avg_idle_per_workstation?.top_contributors]);
74845
+ }, [snapshot.data.summary.avg_idle_per_workstation?.top_contributors]);
73024
74846
  const showIdleContributorLineNames = React141__default.useMemo(() => {
73025
- return (overview.scope?.line_count ?? 0) > 1;
73026
- }, [overview.scope?.line_count]);
74847
+ return (scope.line_count ?? 0) > 1;
74848
+ }, [scope.line_count]);
73027
74849
  const closeIdleContributors = React141__default.useCallback(() => {
73028
74850
  setIsIdleContributorsOpen(false);
73029
74851
  setIsIdleContributorsPinned(false);
73030
74852
  }, []);
73031
74853
  const handleIdleContributorsToggle = React141__default.useCallback(() => {
73032
74854
  if (!canInspectIdleContributors) return;
73033
- setIsIdleContributorsPinned((prev) => {
73034
- const next = !prev;
74855
+ setIsIdleContributorsPinned((previous) => {
74856
+ const next = !previous;
73035
74857
  setIsIdleContributorsOpen(next);
73036
74858
  return next;
73037
74859
  });
@@ -73048,6 +74870,10 @@ var PlantHeadView = () => {
73048
74870
  closeIdleContributors();
73049
74871
  }
73050
74872
  }, [canInspectIdleContributors, closeIdleContributors, handleIdleContributorsToggle]);
74873
+ React141__default.useEffect(() => {
74874
+ setIsIdleContributorsOpen(false);
74875
+ setIsIdleContributorsPinned(false);
74876
+ }, [scope.comparison_strategy, scope.current_range?.start_date, scope.current_range?.end_date, scope.line_count, scope.shift_mode]);
73051
74877
  React141__default.useEffect(() => {
73052
74878
  if (!isIdleContributorsOpen) return void 0;
73053
74879
  const handleClickOutside = (event) => {
@@ -73070,14 +74896,298 @@ var PlantHeadView = () => {
73070
74896
  document.removeEventListener("keydown", handleEscape);
73071
74897
  };
73072
74898
  }, [closeIdleContributors, isIdleContributorsOpen, isIdleContributorsPinned]);
74899
+ return /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
74900
+ /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 p-4 md:p-5 flex flex-col justify-center min-h-[100px] text-left", children: [
74901
+ /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center mb-1", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Overall Efficiency" }) }),
74902
+ showSnapshotSkeleton ? /* @__PURE__ */ jsx(OverviewMetricCardSkeleton, {}) : snapshot.data.summary.plant_efficiency?.current !== null && snapshot.data.summary.plant_efficiency?.current !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
74903
+ /* @__PURE__ */ jsxs("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: [
74904
+ roundOne(snapshot.data.summary.plant_efficiency.current),
74905
+ "%"
74906
+ ] }),
74907
+ /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${plantEfficiencyBadge.className}`, children: [
74908
+ plantEfficiencyBadge.icon === "up" ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : plantEfficiencyBadge.icon === "down" ? /* @__PURE__ */ jsx(ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
74909
+ /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium", children: plantEfficiencyBadge.text })
74910
+ ] })
74911
+ ] }) : /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No efficiency data available" })
74912
+ ] }),
74913
+ /* @__PURE__ */ jsxs(
74914
+ "div",
74915
+ {
74916
+ ref: idleContributorsRef,
74917
+ "data-testid": "idle-kpi-card-region",
74918
+ className: "relative",
74919
+ onMouseEnter: () => {
74920
+ if (canInspectIdleContributors) {
74921
+ setIsIdleContributorsOpen(true);
74922
+ }
74923
+ },
74924
+ onMouseLeave: () => {
74925
+ if (!isIdleContributorsPinned) {
74926
+ setIsIdleContributorsOpen(false);
74927
+ }
74928
+ },
74929
+ onFocus: () => {
74930
+ if (canInspectIdleContributors) {
74931
+ setIsIdleContributorsOpen(true);
74932
+ }
74933
+ },
74934
+ onBlur: (event) => {
74935
+ if (isIdleContributorsPinned) return;
74936
+ const nextTarget = event.relatedTarget;
74937
+ if (nextTarget && idleContributorsRef.current?.contains(nextTarget)) return;
74938
+ setIsIdleContributorsOpen(false);
74939
+ },
74940
+ children: [
74941
+ /* @__PURE__ */ jsxs(
74942
+ "div",
74943
+ {
74944
+ "data-testid": "idle-kpi-card",
74945
+ role: canInspectIdleContributors ? "button" : void 0,
74946
+ tabIndex: canInspectIdleContributors ? 0 : -1,
74947
+ "aria-controls": canInspectIdleContributors ? "idle-kpi-popover" : void 0,
74948
+ "aria-expanded": canInspectIdleContributors ? isIdleContributorsOpen : void 0,
74949
+ className: `bg-white rounded-xl border p-4 md:p-5 flex flex-col justify-center min-h-[100px] text-left transition-all ${canInspectIdleContributors ? "cursor-pointer hover:shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-200" : ""} ${isIdleContributorsOpen ? "shadow-md border-indigo-100" : "shadow-sm border-slate-100"}`,
74950
+ onClick: handleIdleContributorsToggle,
74951
+ onKeyDown: handleIdleContributorsKeyDown,
74952
+ children: [
74953
+ /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time per Workstation" }) }),
74954
+ showSnapshotSkeleton ? /* @__PURE__ */ jsx(OverviewMetricCardSkeleton, {}) : snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== null && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
74955
+ /* @__PURE__ */ jsx("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: formatIdleDuration(snapshot.data.summary.avg_idle_per_workstation.current_seconds) }),
74956
+ /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${idleBadge.className}`, children: [
74957
+ idleBadge.icon === "up" ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : idleBadge.icon === "down" ? /* @__PURE__ */ jsx(ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
74958
+ /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium", children: idleBadge.text })
74959
+ ] })
74960
+ ] }) : /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No idle time data available" })
74961
+ ]
74962
+ }
74963
+ ),
74964
+ canInspectIdleContributors && isIdleContributorsOpen ? /* @__PURE__ */ jsxs(
74965
+ "div",
74966
+ {
74967
+ id: "idle-kpi-popover",
74968
+ "data-testid": "idle-kpi-popover",
74969
+ className: "absolute left-0 right-0 top-full z-20 mt-2 bg-white p-4 border border-gray-100 shadow-xl rounded-xl sm:left-auto sm:right-0 sm:w-[320px] min-w-[280px]",
74970
+ children: [
74971
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pb-3 mb-3 border-b border-slate-100", children: [
74972
+ /* @__PURE__ */ jsx("div", { className: "w-2.5 h-2.5 rounded-full flex-shrink-0 bg-red-500" }),
74973
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-800 text-[15px]", children: "Idle Time per Workstation" })
74974
+ ] }),
74975
+ /* @__PURE__ */ jsxs("div", { children: [
74976
+ /* @__PURE__ */ jsx("p", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400 mb-3", children: "TOP CONTRIBUTORS" }),
74977
+ idleTopContributors.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2.5", children: idleTopContributors.map((contributor, index) => /* @__PURE__ */ jsxs(
74978
+ "div",
74979
+ {
74980
+ className: "flex items-start justify-between gap-3",
74981
+ children: [
74982
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
74983
+ /* @__PURE__ */ jsx("div", { className: "text-slate-600 text-[13px] truncate", title: contributor.workspaceName, children: contributor.workspaceName }),
74984
+ showIdleContributorLineNames && contributor.lineName ? /* @__PURE__ */ jsx("div", { className: "text-[11px] font-medium text-slate-400 truncate", title: contributor.lineName, children: contributor.lineName }) : null
74985
+ ] }),
74986
+ /* @__PURE__ */ jsx("div", { className: "text-slate-500 text-[13px] text-right whitespace-nowrap", children: formatIdleDuration(contributor.avgIdleSeconds) })
74987
+ ]
74988
+ },
74989
+ `${contributor.workspaceId || contributor.workspaceName}-${index}`
74990
+ )) }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-500", children: "No workstation idle averages available for this range." })
74991
+ ] })
74992
+ ]
74993
+ }
74994
+ ) : null
74995
+ ]
74996
+ }
74997
+ )
74998
+ ] });
74999
+ });
75000
+ OverviewSummaryCards.displayName = "OverviewSummaryCards";
75001
+ var PoorestPerformersCard = React141__default.memo(({
75002
+ store,
75003
+ supervisorsByLineId,
75004
+ onViewAll,
75005
+ onLineClick
75006
+ }) => {
75007
+ bumpRenderCounter();
75008
+ const scope = useOperationsOverviewScope(store);
75009
+ const snapshot = useOperationsOverviewSnapshot(store);
75010
+ const [poorestLineMode, setPoorestLineMode] = React141__default.useState("output");
75011
+ const availableLineModes = scope.available_line_modes;
75012
+ React141__default.useEffect(() => {
75013
+ const hasOutput = !!availableLineModes?.has_output;
75014
+ const hasUptime = !!availableLineModes?.has_uptime;
75015
+ if (hasOutput && !hasUptime && poorestLineMode !== "output") {
75016
+ setPoorestLineMode("output");
75017
+ } else if (hasUptime && !hasOutput && poorestLineMode !== "uptime") {
75018
+ setPoorestLineMode("uptime");
75019
+ }
75020
+ }, [availableLineModes?.has_output, availableLineModes?.has_uptime, poorestLineMode]);
75021
+ const comparisonLabel = React141__default.useMemo(() => {
75022
+ return formatComparisonWindow(
75023
+ scope.previous_range?.day_count ?? null,
75024
+ scope.comparison_strategy
75025
+ );
75026
+ }, [scope.comparison_strategy, scope.previous_range?.day_count]);
75027
+ const showSnapshotSkeleton = snapshot.loading && !snapshot.hasLoadedOnce;
75028
+ const mergedPoorestLines = React141__default.useMemo(() => {
75029
+ const rows = snapshot.data.poorest_lines?.[poorestLineMode] || [];
75030
+ return rows.slice(0, 3).map((line) => {
75031
+ const lineId = line.line_id || "";
75032
+ const supervisors = supervisorsByLineId.get(lineId) || [];
75033
+ const supervisor = supervisors[0];
75034
+ return {
75035
+ id: lineId,
75036
+ name: line.line_name?.trim() || "Unknown Line",
75037
+ efficiency: roundOne(toNumber3(line.avg_efficiency) || 0),
75038
+ previousEfficiency: toNumber3(line.previous_avg_efficiency),
75039
+ delta: toNumber3(line.delta_pp),
75040
+ supervisor: supervisor?.displayName || "Unassigned",
75041
+ supervisorImage: supervisor?.profilePhotoUrl ?? null
75042
+ };
75043
+ });
75044
+ }, [poorestLineMode, snapshot.data.poorest_lines, supervisorsByLineId]);
75045
+ const showPoorestModeToggle = !!availableLineModes?.has_output && !!availableLineModes?.has_uptime;
75046
+ const poorestMetricLabel = poorestLineMode === "uptime" ? "Uptime" : "Efficiency";
75047
+ const handlePoorestLineModeChange = React141__default.useCallback((mode) => {
75048
+ trackCoreEvent("Operations Overview Poorest Line Mode Changed", { mode });
75049
+ setPoorestLineMode(mode);
75050
+ }, []);
75051
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
75052
+ /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 border-b border-slate-50 flex justify-between items-center gap-3 flex-wrap", children: [
75053
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
75054
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Poorest Performers" }),
75055
+ showPoorestModeToggle ? /* @__PURE__ */ jsxs("div", { className: "flex bg-slate-100 p-0.5 rounded-lg", children: [
75056
+ /* @__PURE__ */ jsx(
75057
+ "button",
75058
+ {
75059
+ type: "button",
75060
+ onClick: () => handlePoorestLineModeChange("output"),
75061
+ className: `px-3 py-1 text-[11px] font-bold rounded-md ${poorestLineMode === "output" ? "bg-white text-slate-800 shadow-sm" : "text-slate-500 hover:text-slate-800"}`,
75062
+ children: "Output"
75063
+ }
75064
+ ),
75065
+ /* @__PURE__ */ jsx(
75066
+ "button",
75067
+ {
75068
+ type: "button",
75069
+ onClick: () => handlePoorestLineModeChange("uptime"),
75070
+ className: `px-3 py-1 text-[11px] font-bold rounded-md ${poorestLineMode === "uptime" ? "bg-white text-slate-800 shadow-sm" : "text-slate-500 hover:text-slate-800"}`,
75071
+ children: "Uptime"
75072
+ }
75073
+ )
75074
+ ] }) : null
75075
+ ] }),
75076
+ /* @__PURE__ */ jsx(
75077
+ "button",
75078
+ {
75079
+ type: "button",
75080
+ "aria-label": "View all",
75081
+ onClick: onViewAll,
75082
+ className: "inline-flex items-center justify-center rounded-md p-1 text-slate-500 hover:text-slate-800 transition-colors",
75083
+ children: /* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 shrink-0", strokeWidth: 2.5, "aria-hidden": true })
75084
+ }
75085
+ )
75086
+ ] }),
75087
+ /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col p-0 overflow-auto", children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-slate-50 flex-1 px-5", children: [
75088
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between py-2", children: [
75089
+ /* @__PURE__ */ jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider min-w-[120px]", children: "Line" }),
75090
+ /* @__PURE__ */ jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider text-left shrink-0 w-[110px] flex items-center justify-between", children: poorestMetricLabel })
75091
+ ] }),
75092
+ showSnapshotSkeleton ? /* @__PURE__ */ jsx(OverviewListSkeleton, {}) : mergedPoorestLines.length > 0 ? mergedPoorestLines.map((line) => {
75093
+ const lineDelta = buildLineDeltaTone(line.delta, comparisonLabel);
75094
+ return /* @__PURE__ */ jsx(
75095
+ "div",
75096
+ {
75097
+ onClick: () => onLineClick(line.id, line.name),
75098
+ className: "block py-3 hover:bg-slate-50/50 transition-colors cursor-pointer group relative",
75099
+ children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
75100
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
75101
+ /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-full bg-slate-100 border border-slate-200 overflow-hidden flex-shrink-0", children: line.supervisorImage ? /* @__PURE__ */ jsx(
75102
+ "img",
75103
+ {
75104
+ src: line.supervisorImage,
75105
+ alt: line.supervisor,
75106
+ className: "w-full h-full object-cover"
75107
+ }
75108
+ ) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-[10px] font-bold text-slate-500", children: line.supervisor.split(" ").map((part) => part[0]).join("").slice(0, 2) }) }),
75109
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
75110
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "font-bold text-slate-800 text-[13px] truncate group-hover:text-indigo-600 transition-colors", children: line.name }) }),
75111
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 mt-0.5 flex-wrap", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400 font-medium", children: line.supervisor }) })
75112
+ ] })
75113
+ ] }),
75114
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between shrink-0 w-[110px]", children: [
75115
+ /* @__PURE__ */ jsxs("div", { className: "text-[15px] leading-none font-bold text-slate-800", children: [
75116
+ line.efficiency,
75117
+ "%"
75118
+ ] }),
75119
+ line.delta !== null && line.delta !== void 0 && Number.isFinite(line.delta) ? /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-0.5 px-2 py-0.5 rounded-full ${line.delta >= 0 ? "bg-[#ecfdf5] text-[#059669]" : "bg-[#FEF2F2] text-[#DC2626]"}`, children: [
75120
+ line.delta >= 0 ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3 h-3", strokeWidth: 2.5 }) : /* @__PURE__ */ jsx(ArrowDown, { className: "w-3 h-3", strokeWidth: 2.5 }),
75121
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] leading-none font-bold", children: lineDelta.text.split(" vs ")[0].replace("+", "") })
75122
+ ] }) : /* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5 px-2 py-0.5 rounded-full bg-slate-50 text-slate-400", children: /* @__PURE__ */ jsx("span", { className: "text-[11px] leading-none font-bold", children: "\u2014" }) })
75123
+ ] })
75124
+ ] })
75125
+ },
75126
+ line.id
75127
+ );
75128
+ }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: `No ${poorestLineMode} line data available` })
75129
+ ] }) })
75130
+ ] });
75131
+ });
75132
+ PoorestPerformersCard.displayName = "PoorestPerformersCard";
75133
+ var IdleBreakdownCard = React141__default.memo(({
75134
+ store,
75135
+ scopedLineCount
75136
+ }) => {
75137
+ bumpRenderCounter();
75138
+ const idle = useOperationsOverviewIdle(store);
75139
+ const showInitialSkeleton = idle.loading && idle.lastUpdated === null;
75140
+ const idleBreakdown = React141__default.useMemo(() => {
75141
+ return idle.data.map((item) => ({
75142
+ name: item.reason?.trim() || "Unknown",
75143
+ value: toNumber3(item.percentage) || 0,
75144
+ totalDurationSeconds: toNumber3(item.total_duration_seconds),
75145
+ efficiencyLossPercentage: toNumber3(item.efficiency_loss_percentage),
75146
+ contributors: (item.contributors || []).map((contributor) => ({
75147
+ workspaceId: contributor.workspace_id || "",
75148
+ workspaceName: contributor.workspace_name?.trim() || "Unknown",
75149
+ totalDurationSeconds: toNumber3(contributor.total_duration_seconds),
75150
+ percentageWithinReason: toNumber3(contributor.percentage_within_reason)
75151
+ }))
75152
+ })).filter((item) => item.value > 0);
75153
+ }, [idle.data]);
75154
+ const showIdleModuleNotEnabledState = React141__default.useMemo(() => {
75155
+ const enabledLineCount = idle.scope.idle_time_vlm_enabled_line_count;
75156
+ return !showInitialSkeleton && scopedLineCount > 0 && typeof enabledLineCount === "number" && enabledLineCount === 0;
75157
+ }, [idle.scope.idle_time_vlm_enabled_line_count, scopedLineCount, showInitialSkeleton]);
75158
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden text-left", children: [
75159
+ /* @__PURE__ */ jsx("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50 relative", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time Breakdown" }) }),
75160
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-[250px] p-4 pt-2 relative", children: showInitialSkeleton ? /* @__PURE__ */ jsx(OverviewIdleBreakdownSkeleton, {}) : showIdleModuleNotEnabledState ? /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center rounded-xl border border-dashed border-slate-200 bg-slate-50/80 px-6 text-center", children: /* @__PURE__ */ jsxs("div", { children: [
75161
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-slate-700", children: "Module not enabled" }),
75162
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-slate-500", children: "Enable idle-time classification on at least one line to view this breakdown." })
75163
+ ] }) }) : /* @__PURE__ */ jsx(
75164
+ IdleTimeReasonChart,
75165
+ {
75166
+ data: idleBreakdown,
75167
+ isLoading: false,
75168
+ hideTotalDuration: true,
75169
+ updateAnimation: "smooth"
75170
+ }
75171
+ ) })
75172
+ ] });
75173
+ });
75174
+ IdleBreakdownCard.displayName = "IdleBreakdownCard";
75175
+ var EfficiencyTrendCard = React141__default.memo(({
75176
+ store,
75177
+ dateRange,
75178
+ appTimezone
75179
+ }) => {
75180
+ bumpRenderCounter();
75181
+ const trend = useOperationsOverviewTrend(store);
73073
75182
  const currentWeekRange = React141__default.useMemo(
73074
75183
  () => getCurrentWeekToDateRange(appTimezone),
73075
75184
  [appTimezone]
73076
75185
  );
73077
75186
  const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
75187
+ const showInitialSkeleton = trend.loading && trend.lastUpdated === null;
73078
75188
  const trendData = React141__default.useMemo(() => {
73079
75189
  const pointsByDate = new Map(
73080
- (overview.trend?.points || []).flatMap((point) => {
75190
+ (trend.data.points || []).flatMap((point) => {
73081
75191
  if (!point.date) return [];
73082
75192
  const pointDate = parseDateKeyToDate(point.date);
73083
75193
  return [[point.date, {
@@ -73102,7 +75212,7 @@ var PlantHeadView = () => {
73102
75212
  };
73103
75213
  });
73104
75214
  }
73105
- return (overview.trend?.points || []).map((point) => {
75215
+ return (trend.data.points || []).map((point) => {
73106
75216
  const pointDate = point.date ? parseDateKeyToDate(point.date) : null;
73107
75217
  return {
73108
75218
  name: pointDate ? format(pointDate, "MMM d") : "",
@@ -73113,55 +75223,42 @@ var PlantHeadView = () => {
73113
75223
  })()
73114
75224
  };
73115
75225
  });
73116
- }, [currentWeekRange.startKey, isCurrentWeekToDateRange, overview.trend?.points]);
73117
- const trendPlayKey = React141__default.useMemo(() => {
73118
- return `${trendViewOpenNonce}:${trendFetchNonce}`;
73119
- }, [trendFetchNonce, trendViewOpenNonce]);
73120
- const idleBreakdown = React141__default.useMemo(() => {
73121
- return idleReasonBreakdown.map((item) => ({
73122
- name: item.reason?.trim() || "Unknown",
73123
- value: toNumber3(item.percentage) || 0,
73124
- totalDurationSeconds: toNumber3(item.total_duration_seconds),
73125
- efficiencyLossPercentage: toNumber3(item.efficiency_loss_percentage),
73126
- contributors: (item.contributors || []).map((contributor) => ({
73127
- workspaceId: contributor.workspace_id || "",
73128
- workspaceName: contributor.workspace_name?.trim() || "Unknown",
73129
- totalDurationSeconds: toNumber3(contributor.total_duration_seconds),
73130
- percentageWithinReason: toNumber3(contributor.percentage_within_reason)
73131
- }))
73132
- })).filter((item) => item.value > 0);
73133
- }, [idleReasonBreakdown]);
73134
- const showIdleModuleNotEnabledState = React141__default.useMemo(() => {
73135
- const enabledLineCount = idleReasonScope?.idle_time_vlm_enabled_line_count;
73136
- return !isIdleReasonBreakdownLoading && scopedLineIds.length > 0 && typeof enabledLineCount === "number" && enabledLineCount === 0;
73137
- }, [idleReasonScope?.idle_time_vlm_enabled_line_count, isIdleReasonBreakdownLoading, scopedLineIds.length]);
73138
- const mergedPoorestLines = React141__default.useMemo(() => {
73139
- const rows = overview.poorest_lines?.[poorestLineMode] || [];
73140
- return rows.slice(0, 3).map((line) => {
73141
- const lineId = line.line_id || "";
73142
- const supervisors = supervisorsByLineId.get(lineId) || [];
73143
- const supervisor = supervisors[0];
73144
- return {
73145
- id: lineId,
73146
- name: line.line_name?.trim() || "Unknown Line",
73147
- efficiency: roundOne(toNumber3(line.avg_efficiency) || 0),
73148
- previousEfficiency: toNumber3(line.previous_avg_efficiency),
73149
- delta: toNumber3(line.delta_pp),
73150
- supervisor: supervisor?.displayName || "Unassigned",
73151
- supervisorImage: supervisor?.profilePhotoUrl ?? null
73152
- };
73153
- });
73154
- }, [overview.poorest_lines, poorestLineMode, supervisorsByLineId]);
73155
- const showPoorestModeToggle = !!availableLineModes?.has_output && !!availableLineModes?.has_uptime;
73156
- availableLineModes?.has_uptime && !availableLineModes?.has_output ? "Uptime" : "Output";
73157
- const poorestMetricLabel = poorestLineMode === "uptime" ? "Uptime" : "Efficiency";
75226
+ }, [currentWeekRange.startKey, isCurrentWeekToDateRange, trend.data.points]);
73158
75227
  const trendTooltipLabelFormatter = React141__default.useCallback((label, payload) => {
73159
75228
  const dayOfWeek = payload?.[0]?.payload?.dayOfWeek;
73160
75229
  if (!dayOfWeek || typeof label !== "string") return label;
73161
75230
  return `${label} (${dayOfWeek})`;
73162
75231
  }, []);
75232
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-[0_2px_10px_-3px_rgba(6,81,237,0.1)] border border-slate-100 flex flex-col overflow-hidden text-left", children: [
75233
+ /* @__PURE__ */ jsx("div", { className: "px-6 py-5 flex-none flex justify-between items-center border-b border-slate-50/50", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Efficiency Trend" }) }),
75234
+ /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-[250px] w-full p-4 pt-4 relative", children: showInitialSkeleton ? /* @__PURE__ */ jsx(OverviewChartSkeleton, {}) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pb-2 pr-4 pl-1", children: /* @__PURE__ */ jsx(
75235
+ LineChart,
75236
+ {
75237
+ data: trendData,
75238
+ lines: efficiencyLineConfig,
75239
+ xAxisDataKey: "name",
75240
+ yAxisUnit: "%",
75241
+ yAxisDomain: [0, 100],
75242
+ showLegend: false,
75243
+ showGrid: true,
75244
+ fillContainer: true,
75245
+ tooltipLabelFormatter: trendTooltipLabelFormatter
75246
+ }
75247
+ ) }) })
75248
+ ] });
75249
+ });
75250
+ EfficiencyTrendCard.displayName = "EfficiencyTrendCard";
75251
+ var TopImprovementsCard = React141__default.memo(({
75252
+ store,
75253
+ supervisorsByLineId,
75254
+ onViewAll,
75255
+ onItemClick
75256
+ }) => {
75257
+ bumpRenderCounter();
75258
+ const improvements = useOperationsOverviewImprovements(store);
75259
+ const showInitialSkeleton = improvements.loading && improvements.lastUpdated === null;
73163
75260
  const displayImprovements = React141__default.useMemo(() => {
73164
- return improvements.map((item) => {
75261
+ return improvements.data.map((item) => {
73165
75262
  const supervisors = item.lineId ? supervisorsByLineId.get(item.lineId) || [] : [];
73166
75263
  return {
73167
75264
  ...item,
@@ -73174,436 +75271,592 @@ var PlantHeadView = () => {
73174
75271
  })
73175
75272
  };
73176
75273
  });
73177
- }, [improvements, supervisorsByLineId]);
73178
- const mobileSubtitle = React141__default.useMemo(() => {
73179
- if (isCurrentWeekToDateRange) {
73180
- return `Week of ${format(parseDateKeyToDate(dateRange.startKey), "do MMM")}`;
75274
+ }, [improvements.data, supervisorsByLineId]);
75275
+ return /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
75276
+ /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50", children: [
75277
+ /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Top improvements" }),
75278
+ /* @__PURE__ */ jsx(
75279
+ "button",
75280
+ {
75281
+ type: "button",
75282
+ "aria-label": "View all",
75283
+ onClick: onViewAll,
75284
+ className: "inline-flex items-center justify-center rounded-md p-1 text-slate-500 hover:text-slate-800 transition-colors",
75285
+ children: /* @__PURE__ */ jsx(ArrowRight, { className: "h-4 w-4 shrink-0", strokeWidth: 2.5, "aria-hidden": true })
75286
+ }
75287
+ )
75288
+ ] }),
75289
+ /* @__PURE__ */ jsx("div", { className: "flex-1 p-0 flex flex-col px-5 py-2 justify-start overflow-auto", children: showInitialSkeleton ? /* @__PURE__ */ jsx(OverviewImprovementsSkeleton, {}) : displayImprovements.length > 0 ? displayImprovements.map((item) => /* @__PURE__ */ jsxs(
75290
+ "div",
75291
+ {
75292
+ "data-testid": `plant-head-improvement-${item.issueId}`,
75293
+ onClick: () => onItemClick(item),
75294
+ className: "flex items-center justify-between py-3 border-b border-slate-50 last:border-0 group cursor-pointer",
75295
+ children: [
75296
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0 pr-4", children: [
75297
+ item.ticketLabel ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-full border border-indigo-100 bg-indigo-50 px-2 py-0.5 text-[10px] font-semibold text-indigo-600", children: item.ticketLabel }) }) : null,
75298
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
75299
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 min-w-0 mb-0.5", children: /* @__PURE__ */ jsx("h4", { className: "text-[13px] font-semibold text-slate-800 truncate transition-colors group-hover:text-indigo-600", children: item.title }) }),
75300
+ /* @__PURE__ */ jsx(
75301
+ "p",
75302
+ {
75303
+ className: "text-[10px] font-medium text-slate-400 truncate",
75304
+ title: item.metadataLabel,
75305
+ children: item.metadataLabel
75306
+ }
75307
+ )
75308
+ ] })
75309
+ ] }),
75310
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsx(
75311
+ "span",
75312
+ {
75313
+ className: `inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] ${item.metric.includes("pcs / day") || item.metric.includes("gain") ? "border-emerald-100 bg-emerald-50 text-emerald-700" : item.metric.includes("Idle") ? "border-amber-100 bg-amber-50 text-amber-700" : "border-slate-100 bg-slate-50 text-slate-600"}`,
75314
+ children: /* @__PURE__ */ jsx("span", { className: "font-semibold", children: item.metric })
75315
+ }
75316
+ ) })
75317
+ ]
75318
+ },
75319
+ item.id
75320
+ )) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: "No open improvement issues" }) })
75321
+ ] });
75322
+ });
75323
+ TopImprovementsCard.displayName = "TopImprovementsCard";
75324
+ var DEBUG_DASHBOARD_LOGS4 = process.env.NEXT_PUBLIC_DEBUG_DASHBOARD === "true";
75325
+ var debugRefreshLog = (message, payload) => {
75326
+ if (!DEBUG_DASHBOARD_LOGS4) return;
75327
+ if (payload) {
75328
+ console.log(`[OperationsOverviewRefresh] ${message}`, payload);
75329
+ return;
75330
+ }
75331
+ console.log(`[OperationsOverviewRefresh] ${message}`);
75332
+ };
75333
+ var isAbortError = (error) => {
75334
+ return error instanceof DOMException && error.name === "AbortError";
75335
+ };
75336
+ var toNumber4 = (value) => {
75337
+ if (typeof value === "number" && Number.isFinite(value)) return value;
75338
+ if (typeof value === "string" && value.trim().length > 0) {
75339
+ const parsed = Number(value);
75340
+ return Number.isFinite(parsed) ? parsed : null;
75341
+ }
75342
+ return null;
75343
+ };
75344
+ var formatImprovementMetric = (recommendation) => {
75345
+ const estimatedGain = toNumber4(recommendation.estimated_gain_pieces);
75346
+ if (estimatedGain !== null && estimatedGain > 0) {
75347
+ return `+${Math.round(estimatedGain).toLocaleString()} pcs / day`;
75348
+ }
75349
+ const idleMinutes = toNumber4(recommendation.metrics?.idle_minutes);
75350
+ if (idleMinutes !== null) {
75351
+ return `-${Math.round(idleMinutes)}m Idle`;
75352
+ }
75353
+ const impactText = recommendation.impact?.trim();
75354
+ if (impactText) {
75355
+ return impactText.length > 22 ? `${impactText.slice(0, 22).trim()}...` : impactText;
75356
+ }
75357
+ return "Review Issue";
75358
+ };
75359
+ var normalizeImprovements2 = (recommendations, lineIds) => {
75360
+ const allowedLineIds = new Set(lineIds);
75361
+ const scopedRecommendations = (recommendations || []).filter((recommendation) => {
75362
+ return !recommendation.line_id || allowedLineIds.has(recommendation.line_id);
75363
+ });
75364
+ return [...scopedRecommendations].sort(compareImprovementRecommendationPriority).slice(0, 3).map((recommendation) => ({
75365
+ id: recommendation.issue_id || recommendation.id,
75366
+ issueId: recommendation.issue_id || recommendation.id,
75367
+ issueNumber: recommendation.issue_number,
75368
+ title: recommendation.title?.trim() || "Untitled issue",
75369
+ metric: formatImprovementMetric(recommendation),
75370
+ location: recommendation.location,
75371
+ line: recommendation.line,
75372
+ lineId: recommendation.line_id,
75373
+ workspaceId: recommendation.workspace_id
75374
+ }));
75375
+ };
75376
+ var useOperationsOverviewRefresh = ({
75377
+ store,
75378
+ supabase,
75379
+ companyId,
75380
+ lineIds,
75381
+ startKey,
75382
+ endKey,
75383
+ trendMode,
75384
+ comparisonStrategy,
75385
+ isLiveScope
75386
+ }) => {
75387
+ const lineIdsKey = React141__default.useMemo(() => lineIds.join(","), [lineIds]);
75388
+ const scopeSignature = React141__default.useMemo(
75389
+ () => [companyId || "", startKey, endKey, trendMode, comparisonStrategy || "", lineIdsKey].join("::"),
75390
+ [companyId, comparisonStrategy, endKey, lineIdsKey, startKey, trendMode]
75391
+ );
75392
+ const controllersRef = React141__default.useRef({});
75393
+ const requestIdsRef = React141__default.useRef({
75394
+ snapshot: 0,
75395
+ trend: 0,
75396
+ idle: 0,
75397
+ improvements: 0
75398
+ });
75399
+ const intervalRef = React141__default.useRef(null);
75400
+ const isPageActiveRef = React141__default.useRef(true);
75401
+ const lastResumeRefreshAtRef = React141__default.useRef(0);
75402
+ const abortAll = React141__default.useCallback(() => {
75403
+ Object.values(controllersRef.current).forEach((controller) => {
75404
+ controller?.abort();
75405
+ });
75406
+ controllersRef.current = {};
75407
+ }, []);
75408
+ React141__default.useEffect(() => {
75409
+ return () => {
75410
+ abortAll();
75411
+ };
75412
+ }, [abortAll]);
75413
+ const getIsPageActive = React141__default.useCallback(() => {
75414
+ if (typeof document === "undefined") {
75415
+ return true;
73181
75416
  }
73182
- return `${format(parseDateKeyToDate(dateRange.startKey), "do MMM")} - ${format(parseDateKeyToDate(dateRange.endKey), "do MMM, yyyy")}`;
73183
- }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
73184
- const desktopSubtitle = React141__default.useMemo(() => {
73185
- if (isCurrentWeekToDateRange) {
73186
- return `Week of ${format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")}`;
75417
+ const isVisible = document.visibilityState === "visible";
75418
+ const hasFocus = typeof document.hasFocus === "function" ? document.hasFocus() : true;
75419
+ return isVisible && hasFocus;
75420
+ }, []);
75421
+ const stopPolling = React141__default.useCallback((reason) => {
75422
+ if (intervalRef.current === null) {
75423
+ return;
73187
75424
  }
73188
- return `${format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")} - ${format(parseDateKeyToDate(dateRange.endKey), "do MMMM, yyyy")}`;
73189
- }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
73190
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-h-screen bg-slate-50 w-full font-sans", children: [
73191
- /* @__PURE__ */ jsx("header", { className: "sticky top-0 z-10 bg-white border-b flex-shrink-0 shadow-sm", children: /* @__PURE__ */ jsxs("div", { className: "px-3 sm:px-4 md:px-6 py-2 sm:py-3 relative", children: [
73192
- /* @__PURE__ */ jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
73193
- mobileMenuContext ? /* @__PURE__ */ jsx(
73194
- HamburgerButton,
73195
- {
73196
- onClick: mobileMenuContext.onMobileMenuOpen,
73197
- className: "flex-shrink-0 -ml-1"
75425
+ window.clearInterval(intervalRef.current);
75426
+ intervalRef.current = null;
75427
+ debugRefreshLog("poll stopped", { reason });
75428
+ }, []);
75429
+ const runRefresh = React141__default.useCallback(
75430
+ async (section, begin, onSuccess, onError, request, reason) => {
75431
+ if (!supabase || !companyId || lineIds.length === 0) return;
75432
+ const requestId = requestIdsRef.current[section] + 1;
75433
+ requestIdsRef.current[section] = requestId;
75434
+ controllersRef.current[section]?.abort();
75435
+ const controller = new AbortController();
75436
+ controllersRef.current[section] = controller;
75437
+ begin();
75438
+ try {
75439
+ const response = await request(controller.signal, requestId);
75440
+ if (controller.signal.aborted || requestIdsRef.current[section] !== requestId) {
75441
+ return;
75442
+ }
75443
+ onSuccess(response, Date.now(), reason === "live_refresh" ? "transition" : "default");
75444
+ } catch (error) {
75445
+ if (controller.signal.aborted || requestIdsRef.current[section] !== requestId || isAbortError(error)) {
75446
+ return;
75447
+ }
75448
+ onError(error instanceof Error ? error.message : `Failed to refresh ${section}`);
75449
+ }
75450
+ },
75451
+ [companyId, lineIds.length, supabase]
75452
+ );
75453
+ const refreshSnapshot = React141__default.useCallback(
75454
+ async (reason) => {
75455
+ await runRefresh(
75456
+ "snapshot",
75457
+ store.beginSnapshotLoad,
75458
+ store.applySnapshotResponse,
75459
+ store.failSnapshotLoad,
75460
+ (signal, requestId) => {
75461
+ const params = new URLSearchParams({
75462
+ company_id: companyId || "",
75463
+ start_date: startKey,
75464
+ end_date: endKey,
75465
+ trend_shift_mode: trendMode,
75466
+ line_ids: lineIdsKey
75467
+ });
75468
+ if (comparisonStrategy) {
75469
+ params.set("comparison_strategy", comparisonStrategy);
73198
75470
  }
73199
- ) : /* @__PURE__ */ jsx("div", { className: "w-8 flex-shrink-0" }),
73200
- /* @__PURE__ */ jsxs("div", { className: "flex-1 flex flex-col items-center justify-center", children: [
73201
- /* @__PURE__ */ jsx("h1", { className: "text-lg font-semibold text-gray-900 text-center px-1 truncate max-w-[200px]", children: "Operations Overview" }),
73202
- /* @__PURE__ */ jsx("span", { className: "text-[10px] font-medium text-slate-500 text-center mt-0.5", children: mobileSubtitle })
73203
- ] }),
73204
- /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 flex items-center gap-1.5", children: [
73205
- /* @__PURE__ */ jsx(
73206
- MonthlyRangeFilter_default,
75471
+ return fetchBackendJson(
75472
+ supabase,
75473
+ `/api/dashboard/operations-overview/snapshot?${params.toString()}`,
73207
75474
  {
73208
- month: parseDateKeyToDate(dateRange.startKey).getMonth(),
73209
- year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
73210
- timezone: appTimezone,
73211
- value: dateRange,
73212
- onChange: handleDateRangeChange,
73213
- showLabel: false
75475
+ signal,
75476
+ dedupeKey: `operations-overview:snapshot:${scopeSignature}:${requestId}`
73214
75477
  }
73215
- ),
73216
- /* @__PURE__ */ jsxs(
73217
- "button",
73218
- {
73219
- ref: mobileFilterButtonRef,
73220
- onClick: handleFilterToggle,
73221
- className: `p-2 rounded-full transition-colors relative ${isFilterOpen || trendMode !== "all" ? "bg-blue-50" : "active:bg-gray-100"}`,
73222
- "aria-label": "Open filters",
73223
- children: [
73224
- /* @__PURE__ */ jsx(Filter, { className: `w-5 h-5 ${trendMode !== "all" ? "text-blue-600" : "text-gray-700"}` }),
73225
- trendMode !== "all" && /* @__PURE__ */ jsx("span", { className: "absolute -top-1 -right-1 flex items-center justify-center w-4 h-4 bg-blue-600 text-white text-[10px] rounded-full font-bold", children: "1" })
73226
- ]
73227
- }
73228
- )
73229
- ] })
73230
- ] }) }),
73231
- /* @__PURE__ */ jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center relative min-h-[56px]", children: [
73232
- /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 -translate-x-1/2 flex flex-col items-center pointer-events-none", children: [
73233
- /* @__PURE__ */ jsx("h1", { className: "text-2xl md:text-3xl lg:text-4xl font-semibold text-gray-900 tracking-tight text-center pointer-events-auto leading-tight mb-0.5", children: "Operations Overview" }),
73234
- /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium text-slate-500 text-center pointer-events-auto", children: desktopSubtitle })
73235
- ] }),
73236
- /* @__PURE__ */ jsxs("div", { className: "absolute right-0 flex items-center gap-3", children: [
73237
- /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsx(
73238
- MonthlyRangeFilter_default,
73239
- {
73240
- month: parseDateKeyToDate(dateRange.startKey).getMonth(),
73241
- year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
73242
- timezone: appTimezone,
73243
- value: dateRange,
73244
- onChange: handleDateRangeChange,
73245
- showLabel: false
73246
- }
73247
- ) }),
73248
- /* @__PURE__ */ jsxs(
73249
- "button",
75478
+ );
75479
+ },
75480
+ reason
75481
+ );
75482
+ },
75483
+ [companyId, comparisonStrategy, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75484
+ );
75485
+ const refreshTrend = React141__default.useCallback(
75486
+ async (reason) => {
75487
+ await runRefresh(
75488
+ "trend",
75489
+ store.beginTrendLoad,
75490
+ store.applyTrendResponse,
75491
+ store.failTrendLoad,
75492
+ (signal, requestId) => {
75493
+ const params = new URLSearchParams({
75494
+ company_id: companyId || "",
75495
+ start_date: startKey,
75496
+ end_date: endKey,
75497
+ trend_shift_mode: trendMode,
75498
+ line_ids: lineIdsKey
75499
+ });
75500
+ return fetchBackendJson(
75501
+ supabase,
75502
+ `/api/dashboard/operations-overview/trend?${params.toString()}`,
73250
75503
  {
73251
- ref: filterButtonRef,
73252
- onClick: handleFilterToggle,
73253
- className: `flex items-center gap-2 px-3 py-1.5 rounded-lg border text-sm font-medium transition-all shadow-sm ${isFilterOpen || trendMode !== "all" ? "border-blue-500 bg-blue-50 text-blue-700 ring-1 ring-blue-500" : "border-slate-200 bg-white text-slate-700 hover:bg-slate-50"}`,
73254
- "aria-label": "Open filters",
73255
- children: [
73256
- /* @__PURE__ */ jsx(Filter, { className: `w-[18px] h-[18px] ${trendMode !== "all" ? "text-blue-600" : "text-slate-500"}` }),
73257
- "Filters",
73258
- /* @__PURE__ */ jsx(ChevronDown, { className: `w-4 h-4 ml-0.5 transition-transform duration-200 ${isFilterOpen ? "rotate-180" : ""}` })
73259
- ]
75504
+ signal,
75505
+ dedupeKey: `operations-overview:trend:${scopeSignature}:${requestId}`
73260
75506
  }
73261
- )
73262
- ] })
73263
- ] }) }),
73264
- isFilterOpen && /* @__PURE__ */ jsxs("div", { ref: filterRef, className: "absolute right-3 sm:right-4 md:right-5 lg:right-6 top-full mt-2 w-72 bg-white rounded-xl shadow-xl border border-gray-100 p-4 z-50", children: [
73265
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between mb-3", children: [
73266
- /* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold text-gray-900", children: "Filter View" }),
73267
- trendMode !== "all" && /* @__PURE__ */ jsx(
73268
- "button",
75507
+ );
75508
+ },
75509
+ reason
75510
+ );
75511
+ },
75512
+ [companyId, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75513
+ );
75514
+ const refreshIdle = React141__default.useCallback(
75515
+ async (reason) => {
75516
+ await runRefresh(
75517
+ "idle",
75518
+ store.beginIdleLoad,
75519
+ store.applyIdleResponse,
75520
+ store.failIdleLoad,
75521
+ (signal, requestId) => {
75522
+ const params = new URLSearchParams({
75523
+ company_id: companyId || "",
75524
+ start_date: startKey,
75525
+ end_date: endKey,
75526
+ trend_shift_mode: trendMode,
75527
+ line_ids: lineIdsKey
75528
+ });
75529
+ return fetchBackendJson(
75530
+ supabase,
75531
+ `/api/dashboard/operations-overview/idle-reason-breakdown?${params.toString()}`,
73269
75532
  {
73270
- onClick: () => {
73271
- setTrendMode("all");
73272
- setIsFilterOpen(false);
73273
- },
73274
- className: "text-xs text-red-600 hover:text-red-700 font-medium",
73275
- children: "Clear all"
75533
+ signal,
75534
+ dedupeKey: `operations-overview:idle:${scopeSignature}:${requestId}`
73276
75535
  }
73277
- )
73278
- ] }),
73279
- /* @__PURE__ */ jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
73280
- /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide ml-1", children: "Shift" }),
73281
- /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs(
73282
- "select",
75536
+ );
75537
+ },
75538
+ reason
75539
+ );
75540
+ },
75541
+ [companyId, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75542
+ );
75543
+ const refreshImprovements = React141__default.useCallback(
75544
+ async (reason) => {
75545
+ await runRefresh(
75546
+ "improvements",
75547
+ store.beginImprovementsLoad,
75548
+ (response, updatedAt, mode) => {
75549
+ store.applyImprovements(normalizeImprovements2(response.recommendations, lineIds), updatedAt, mode);
75550
+ },
75551
+ store.failImprovementsLoad,
75552
+ (signal, requestId) => {
75553
+ const params = new URLSearchParams({
75554
+ company_id: companyId || "",
75555
+ status: "open",
75556
+ limit: "200",
75557
+ line_ids: lineIdsKey
75558
+ });
75559
+ return fetchBackendJson(
75560
+ supabase,
75561
+ `/api/improvement-center/recommendations?${params.toString()}`,
73283
75562
  {
73284
- value: trendMode,
73285
- onChange: handleTrendModeChange,
73286
- className: "w-full appearance-none pl-3 pr-8 py-2 text-sm bg-gray-50 border border-gray-200 hover:border-gray-300 rounded-lg text-gray-900 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:bg-white transition-all cursor-pointer",
73287
- style: { backgroundImage: `url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e")`, backgroundPosition: `right 0.75rem center`, backgroundRepeat: `no-repeat`, backgroundSize: `1.2em 1.2em` },
73288
- children: [
73289
- /* @__PURE__ */ jsx("option", { value: "all", children: "All Shifts" }),
73290
- /* @__PURE__ */ jsx("option", { value: "day", children: "Day Shift" }),
73291
- /* @__PURE__ */ jsx("option", { value: "night", children: "Night Shift" })
73292
- ]
75563
+ signal,
75564
+ dedupeKey: `operations-overview:improvements:${scopeSignature}:${requestId}`
73293
75565
  }
73294
- ) })
73295
- ] }) })
73296
- ] })
73297
- ] }) }),
75566
+ );
75567
+ },
75568
+ reason
75569
+ );
75570
+ },
75571
+ [companyId, lineIds, lineIdsKey, runRefresh, scopeSignature, store, supabase]
75572
+ );
75573
+ const refreshAll = React141__default.useCallback(
75574
+ async (reason) => {
75575
+ await Promise.allSettled([
75576
+ refreshSnapshot(reason),
75577
+ refreshTrend(reason),
75578
+ refreshIdle(reason),
75579
+ refreshImprovements(reason)
75580
+ ]);
75581
+ },
75582
+ [refreshIdle, refreshImprovements, refreshSnapshot, refreshTrend]
75583
+ );
75584
+ const startPolling = React141__default.useCallback((reason) => {
75585
+ if (!isLiveScope || !supabase || !companyId || lineIds.length === 0) {
75586
+ return;
75587
+ }
75588
+ if (intervalRef.current !== null) {
75589
+ return;
75590
+ }
75591
+ intervalRef.current = window.setInterval(() => {
75592
+ if (!isPageActiveRef.current) {
75593
+ debugRefreshLog("poll skipped because hidden/unfocused", {
75594
+ reason: "interval_tick",
75595
+ visibilityState: typeof document !== "undefined" ? document.visibilityState : "unknown",
75596
+ hasFocus: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : true
75597
+ });
75598
+ stopPolling("inactive_during_tick");
75599
+ return;
75600
+ }
75601
+ void refreshAll("live_refresh");
75602
+ }, LIVE_REFRESH_INTERVAL_MS);
75603
+ debugRefreshLog("poll started", { reason, intervalMs: LIVE_REFRESH_INTERVAL_MS });
75604
+ }, [companyId, isLiveScope, lineIds.length, refreshAll, stopPolling, supabase]);
75605
+ const refreshFromResume = React141__default.useCallback((reason) => {
75606
+ const now4 = Date.now();
75607
+ if (now4 - lastResumeRefreshAtRef.current < 1e3) {
75608
+ debugRefreshLog("resume refresh suppressed", { reason });
75609
+ return;
75610
+ }
75611
+ lastResumeRefreshAtRef.current = now4;
75612
+ stopPolling("resume_refresh");
75613
+ debugRefreshLog("resume refresh fired", { reason });
75614
+ void refreshAll("live_refresh").finally(() => {
75615
+ if (isPageActiveRef.current) {
75616
+ startPolling("resume");
75617
+ }
75618
+ });
75619
+ }, [refreshAll, startPolling, stopPolling]);
75620
+ React141__default.useEffect(() => {
75621
+ if (!supabase || !companyId || lineIds.length === 0) {
75622
+ stopPolling("scope_invalid");
75623
+ abortAll();
75624
+ store.reset();
75625
+ return;
75626
+ }
75627
+ void refreshAll("scope_change");
75628
+ }, [abortAll, companyId, lineIds.length, refreshAll, scopeSignature, stopPolling, store, supabase]);
75629
+ React141__default.useEffect(() => {
75630
+ if (!isLiveScope || !supabase || !companyId || lineIds.length === 0) {
75631
+ isPageActiveRef.current = false;
75632
+ stopPolling("live_scope_disabled");
75633
+ return;
75634
+ }
75635
+ const logInactive = (reason) => {
75636
+ debugRefreshLog("poll skipped because hidden/unfocused", {
75637
+ reason,
75638
+ visibilityState: typeof document !== "undefined" ? document.visibilityState : "unknown",
75639
+ hasFocus: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : true
75640
+ });
75641
+ };
75642
+ const markInactive = (reason) => {
75643
+ isPageActiveRef.current = false;
75644
+ logInactive(reason);
75645
+ stopPolling(reason);
75646
+ };
75647
+ const syncActivity = (reason) => {
75648
+ const nextIsActive = getIsPageActive();
75649
+ const wasActive = isPageActiveRef.current;
75650
+ isPageActiveRef.current = nextIsActive;
75651
+ if (!nextIsActive) {
75652
+ logInactive(reason);
75653
+ stopPolling(reason);
75654
+ return;
75655
+ }
75656
+ if (!wasActive) {
75657
+ refreshFromResume(reason);
75658
+ return;
75659
+ }
75660
+ startPolling(reason);
75661
+ };
75662
+ isPageActiveRef.current = getIsPageActive();
75663
+ if (isPageActiveRef.current) {
75664
+ startPolling("effect_mount");
75665
+ } else {
75666
+ logInactive("effect_mount");
75667
+ }
75668
+ const handleVisibilityChange = () => syncActivity("visibilitychange");
75669
+ const handleFocus = () => syncActivity("focus");
75670
+ const handleBlur = () => markInactive("blur");
75671
+ const handlePageShow = () => syncActivity("pageshow");
75672
+ const handlePageHide = () => markInactive("pagehide");
75673
+ document.addEventListener("visibilitychange", handleVisibilityChange);
75674
+ window.addEventListener("focus", handleFocus);
75675
+ window.addEventListener("blur", handleBlur);
75676
+ window.addEventListener("pageshow", handlePageShow);
75677
+ window.addEventListener("pagehide", handlePageHide);
75678
+ return () => {
75679
+ stopPolling("cleanup");
75680
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
75681
+ window.removeEventListener("focus", handleFocus);
75682
+ window.removeEventListener("blur", handleBlur);
75683
+ window.removeEventListener("pageshow", handlePageShow);
75684
+ window.removeEventListener("pagehide", handlePageHide);
75685
+ };
75686
+ }, [companyId, getIsPageActive, isLiveScope, lineIds.length, refreshFromResume, startPolling, stopPolling, supabase]);
75687
+ };
75688
+ var PlantHeadView = () => {
75689
+ const supabase = useSupabase();
75690
+ const entityConfig = useEntityConfig();
75691
+ const appTimezone = useAppTimezone() || "UTC";
75692
+ const { navigate } = useNavigation();
75693
+ const { accessibleLineIds } = useUserLineAccess();
75694
+ const mobileMenuContext = useMobileMenu();
75695
+ useHideMobileHeader(!!mobileMenuContext);
75696
+ const storeRef = React141__default.useRef(createOperationsOverviewStore());
75697
+ const store = storeRef.current;
75698
+ const [dateRange, setDateRange] = React141__default.useState(() => getCurrentWeekToDateRange(appTimezone));
75699
+ const [usesThisWeekComparison, setUsesThisWeekComparison] = React141__default.useState(true);
75700
+ const [trendMode, setTrendMode] = React141__default.useState("all");
75701
+ React141__default.useEffect(() => {
75702
+ trackCorePageView("Operations Overview", {
75703
+ dashboard_surface: "operations_overview"
75704
+ });
75705
+ }, []);
75706
+ const currentWeekRange = React141__default.useMemo(
75707
+ () => getCurrentWeekToDateRange(appTimezone),
75708
+ [appTimezone]
75709
+ );
75710
+ const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
75711
+ const normalizedLineIds = React141__default.useMemo(
75712
+ () => Array.from(new Set((accessibleLineIds || []).filter(Boolean))).sort(),
75713
+ [accessibleLineIds]
75714
+ );
75715
+ const lineIdsKey = React141__default.useMemo(
75716
+ () => normalizedLineIds.join(","),
75717
+ [normalizedLineIds]
75718
+ );
75719
+ const scopedLineIds = React141__default.useMemo(
75720
+ () => lineIdsKey ? lineIdsKey.split(",") : [],
75721
+ [lineIdsKey]
75722
+ );
75723
+ const initializedTimezoneRef = React141__default.useRef(appTimezone);
75724
+ React141__default.useEffect(() => {
75725
+ if (initializedTimezoneRef.current === appTimezone) return;
75726
+ setDateRange(getCurrentWeekToDateRange(appTimezone));
75727
+ setUsesThisWeekComparison(true);
75728
+ initializedTimezoneRef.current = appTimezone;
75729
+ }, [appTimezone]);
75730
+ const handleDateRangeChange = React141__default.useCallback((range, meta) => {
75731
+ trackCoreEvent("Operations Overview Date Range Changed", {
75732
+ start_date: range.startKey,
75733
+ end_date: range.endKey
75734
+ });
75735
+ setDateRange(range);
75736
+ setUsesThisWeekComparison((previous) => {
75737
+ if (meta?.source === "preset") {
75738
+ return meta.presetLabel === "This Week";
75739
+ }
75740
+ if (meta?.source === "custom") {
75741
+ return false;
75742
+ }
75743
+ return previous;
75744
+ });
75745
+ }, []);
75746
+ const handleTrendModeChange = React141__default.useCallback((mode) => {
75747
+ setTrendMode(mode);
75748
+ }, []);
75749
+ const buildLineMonthlyHistoryUrl = React141__default.useCallback((lineId) => {
75750
+ const rangeStartDate = parseDateKeyToDate(dateRange.startKey);
75751
+ const params = new URLSearchParams();
75752
+ params.set("tab", "monthly_history");
75753
+ params.set("month", rangeStartDate.getMonth().toString());
75754
+ params.set("year", rangeStartDate.getFullYear().toString());
75755
+ params.set("rangeStart", dateRange.startKey);
75756
+ params.set("rangeEnd", dateRange.endKey);
75757
+ return `/kpis/${lineId}?${params.toString()}`;
75758
+ }, [dateRange.endKey, dateRange.startKey]);
75759
+ const handleOpenLineMonthlyHistory = React141__default.useCallback((lineId, lineName) => {
75760
+ trackCoreEvent("Operations Overview Line Clicked", {
75761
+ line_id: lineId,
75762
+ line_name: lineName,
75763
+ range_start: dateRange.startKey,
75764
+ range_end: dateRange.endKey
75765
+ });
75766
+ navigate(buildLineMonthlyHistoryUrl(lineId));
75767
+ }, [buildLineMonthlyHistoryUrl, dateRange.endKey, dateRange.startKey, navigate]);
75768
+ const handleViewAllPoorestPerformers = React141__default.useCallback(() => {
75769
+ trackCoreEvent("Operations Overview View All Clicked", { section: "poorest_performers" });
75770
+ navigate("/kpis?tab=leaderboard");
75771
+ }, [navigate]);
75772
+ const handleViewAllImprovements = React141__default.useCallback(() => {
75773
+ trackCoreEvent("Operations Overview View All Clicked", { section: "improvements" });
75774
+ navigate("/improvement-center");
75775
+ }, [navigate]);
75776
+ const handleOpenImprovement = React141__default.useCallback((item) => {
75777
+ trackCoreEvent("Operations Overview Improvement Clicked", {
75778
+ issue_id: item.issueId,
75779
+ issue_number: item.issueNumber,
75780
+ title: item.title
75781
+ });
75782
+ const params = new URLSearchParams({
75783
+ focusIssueId: item.issueId
75784
+ });
75785
+ navigate(`/improvement-center?${params.toString()}`);
75786
+ }, [navigate]);
75787
+ const comparisonStrategy = React141__default.useMemo(() => {
75788
+ if (usesThisWeekComparison && isCurrentWeekToDateRange) {
75789
+ return "previous_full_week";
75790
+ }
75791
+ return void 0;
75792
+ }, [isCurrentWeekToDateRange, usesThisWeekComparison]);
75793
+ useOperationsOverviewRefresh({
75794
+ store,
75795
+ supabase,
75796
+ companyId: entityConfig.companyId,
75797
+ lineIds: scopedLineIds,
75798
+ startKey: dateRange.startKey,
75799
+ endKey: dateRange.endKey,
75800
+ trendMode,
75801
+ comparisonStrategy,
75802
+ isLiveScope: isCurrentWeekToDateRange
75803
+ });
75804
+ const { supervisorsByLineId } = useSupervisorsByLineIds(scopedLineIds, {
75805
+ enabled: !!entityConfig.companyId && scopedLineIds.length > 0,
75806
+ companyId: entityConfig.companyId,
75807
+ useBackend: true
75808
+ });
75809
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col min-h-screen bg-slate-50 w-full font-sans", children: [
75810
+ /* @__PURE__ */ jsx(
75811
+ OperationsOverviewHeader,
75812
+ {
75813
+ dateRange,
75814
+ trendMode,
75815
+ appTimezone,
75816
+ mobileMenuContext,
75817
+ onDateRangeChange: handleDateRangeChange,
75818
+ onTrendModeChange: handleTrendModeChange
75819
+ }
75820
+ ),
73298
75821
  /* @__PURE__ */ jsxs("div", { className: "p-4 sm:p-6 pb-6 max-w-[1800px] mx-auto w-full flex-1 min-h-0 overflow-y-auto flex flex-col gap-5", children: [
73299
- /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
73300
- /* @__PURE__ */ jsxs(
73301
- "div",
73302
- {
73303
- className: "bg-white rounded-xl shadow-sm border border-slate-100 p-4 md:p-5 flex flex-col justify-center min-h-[100px] text-left",
73304
- children: [
73305
- /* @__PURE__ */ jsx("div", { className: "flex justify-between items-center mb-1", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Overall Efficiency" }) }),
73306
- isSnapshotLoading ? /* @__PURE__ */ jsx(OverviewMetricCardSkeleton, {}) : overview.summary?.plant_efficiency?.current !== null && overview.summary?.plant_efficiency?.current !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
73307
- /* @__PURE__ */ jsxs("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: [
73308
- roundOne(overview.summary.plant_efficiency.current),
73309
- "%"
73310
- ] }),
73311
- /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${plantEfficiencyBadge.className}`, children: [
73312
- plantEfficiencyBadge.icon === "up" ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : plantEfficiencyBadge.icon === "down" ? /* @__PURE__ */ jsx(ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
73313
- /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium", children: plantEfficiencyBadge.text })
73314
- ] })
73315
- ] }) : /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No efficiency data available" })
73316
- ]
73317
- }
73318
- ),
73319
- /* @__PURE__ */ jsxs(
73320
- "div",
73321
- {
73322
- ref: idleContributorsRef,
73323
- "data-testid": "idle-kpi-card-region",
73324
- className: "relative",
73325
- onMouseEnter: () => {
73326
- if (canInspectIdleContributors) {
73327
- setIsIdleContributorsOpen(true);
73328
- }
73329
- },
73330
- onMouseLeave: () => {
73331
- if (!isIdleContributorsPinned) {
73332
- setIsIdleContributorsOpen(false);
73333
- }
73334
- },
73335
- onFocus: () => {
73336
- if (canInspectIdleContributors) {
73337
- setIsIdleContributorsOpen(true);
73338
- }
73339
- },
73340
- onBlur: (event) => {
73341
- if (isIdleContributorsPinned) return;
73342
- const nextTarget = event.relatedTarget;
73343
- if (nextTarget && idleContributorsRef.current?.contains(nextTarget)) return;
73344
- setIsIdleContributorsOpen(false);
73345
- },
73346
- children: [
73347
- /* @__PURE__ */ jsxs(
73348
- "div",
73349
- {
73350
- "data-testid": "idle-kpi-card",
73351
- role: canInspectIdleContributors ? "button" : void 0,
73352
- tabIndex: canInspectIdleContributors ? 0 : -1,
73353
- "aria-controls": canInspectIdleContributors ? "idle-kpi-popover" : void 0,
73354
- "aria-expanded": canInspectIdleContributors ? isIdleContributorsOpen : void 0,
73355
- className: `bg-white rounded-xl border p-4 md:p-5 flex flex-col justify-center min-h-[100px] text-left transition-all ${canInspectIdleContributors ? "cursor-pointer hover:shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-200" : ""} ${isIdleContributorsOpen ? "shadow-md border-indigo-100" : "shadow-sm border-slate-100"}`,
73356
- onClick: handleIdleContributorsToggle,
73357
- onKeyDown: handleIdleContributorsKeyDown,
73358
- children: [
73359
- /* @__PURE__ */ jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time per Workstation" }) }),
73360
- isSnapshotLoading ? /* @__PURE__ */ jsx(OverviewMetricCardSkeleton, {}) : overview.summary?.avg_idle_per_workstation?.current_seconds !== null && overview.summary?.avg_idle_per_workstation?.current_seconds !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
73361
- /* @__PURE__ */ jsx("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: formatIdleDuration(overview.summary.avg_idle_per_workstation.current_seconds) }),
73362
- /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${idleBadge.className}`, children: [
73363
- idleBadge.icon === "up" ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : idleBadge.icon === "down" ? /* @__PURE__ */ jsx(ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
73364
- /* @__PURE__ */ jsx("span", { className: "text-xs sm:text-sm font-medium", children: idleBadge.text })
73365
- ] })
73366
- ] }) : /* @__PURE__ */ jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No idle time data available" })
73367
- ]
73368
- }
73369
- ),
73370
- canInspectIdleContributors && isIdleContributorsOpen ? /* @__PURE__ */ jsxs(
73371
- "div",
73372
- {
73373
- id: "idle-kpi-popover",
73374
- "data-testid": "idle-kpi-popover",
73375
- className: "absolute left-0 right-0 top-full z-20 mt-2 bg-white p-4 border border-gray-100 shadow-xl rounded-xl sm:left-auto sm:right-0 sm:w-[320px] min-w-[280px]",
73376
- children: [
73377
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pb-3 mb-3 border-b border-slate-100", children: [
73378
- /* @__PURE__ */ jsx("div", { className: "w-2.5 h-2.5 rounded-full flex-shrink-0 bg-red-500" }),
73379
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-slate-800 text-[15px]", children: "Idle Time per Workstation" })
73380
- ] }),
73381
- /* @__PURE__ */ jsxs("div", { children: [
73382
- /* @__PURE__ */ jsx("p", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400 mb-3", children: "TOP CONTRIBUTORS" }),
73383
- idleTopContributors.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-2.5", children: idleTopContributors.map((contributor, index) => /* @__PURE__ */ jsxs(
73384
- "div",
73385
- {
73386
- className: "flex items-start justify-between gap-3",
73387
- children: [
73388
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
73389
- /* @__PURE__ */ jsx(
73390
- "div",
73391
- {
73392
- className: "text-slate-600 text-[13px] truncate",
73393
- title: contributor.workspaceName,
73394
- children: contributor.workspaceName
73395
- }
73396
- ),
73397
- showIdleContributorLineNames && contributor.lineName ? /* @__PURE__ */ jsx("div", { className: "text-[11px] font-medium text-slate-400 truncate", title: contributor.lineName, children: contributor.lineName }) : null
73398
- ] }),
73399
- /* @__PURE__ */ jsx("div", { className: "text-slate-500 text-[13px] text-right whitespace-nowrap", children: formatIdleDuration(contributor.avgIdleSeconds) })
73400
- ]
73401
- },
73402
- `${contributor.workspaceId || contributor.workspaceName}-${index}`
73403
- )) }) : /* @__PURE__ */ jsx("div", { className: "rounded-lg border border-dashed border-slate-200 bg-slate-50 px-3 py-2 text-xs text-slate-500", children: "No workstation idle averages available for this range." })
73404
- ] })
73405
- ]
73406
- }
73407
- ) : null
73408
- ]
73409
- }
73410
- )
73411
- ] }),
75822
+ /* @__PURE__ */ jsx(OverviewSummaryCards, { store }),
73412
75823
  /* @__PURE__ */ jsxs("div", { className: "flex-1 min-h-0 grid grid-cols-1 xl:grid-cols-2 gap-5 auto-rows-fr", children: [
73413
75824
  /* @__PURE__ */ jsxs("div", { className: "grid grid-rows-1 xl:grid-rows-2 gap-5 min-h-0", children: [
73414
- /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
73415
- /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 border-b border-slate-50 flex justify-between items-center gap-3 flex-wrap", children: [
73416
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
73417
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Poorest Performers" }),
73418
- showPoorestModeToggle && /* @__PURE__ */ jsxs("div", { className: "flex bg-slate-100 p-0.5 rounded-lg", children: [
73419
- /* @__PURE__ */ jsx(
73420
- "button",
73421
- {
73422
- type: "button",
73423
- onClick: () => handlePoorestLineModeChange("output"),
73424
- className: `px-3 py-1 text-[11px] font-bold rounded-md ${poorestLineMode === "output" ? "bg-white text-slate-800 shadow-sm" : "text-slate-500 hover:text-slate-800"}`,
73425
- children: "Output"
73426
- }
73427
- ),
73428
- /* @__PURE__ */ jsx(
73429
- "button",
73430
- {
73431
- type: "button",
73432
- onClick: () => handlePoorestLineModeChange("uptime"),
73433
- className: `px-3 py-1 text-[11px] font-bold rounded-md ${poorestLineMode === "uptime" ? "bg-white text-slate-800 shadow-sm" : "text-slate-500 hover:text-slate-800"}`,
73434
- children: "Uptime"
73435
- }
73436
- )
73437
- ] })
73438
- ] }),
73439
- /* @__PURE__ */ jsx(
73440
- "button",
73441
- {
73442
- type: "button",
73443
- onClick: () => {
73444
- trackCoreEvent("Operations Overview View All Clicked", { section: "poorest_performers" });
73445
- navigate("/kpis?tab=leaderboard");
73446
- },
73447
- className: "text-[11px] font-bold text-slate-500 hover:text-slate-800 transition-colors",
73448
- children: "View All"
73449
- }
73450
- )
73451
- ] }),
73452
- /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col p-0 overflow-auto", children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-slate-50 flex-1 px-5", children: [
73453
- /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between py-2", children: [
73454
- /* @__PURE__ */ jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider min-w-[120px]", children: "Line" }),
73455
- /* @__PURE__ */ jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider text-left shrink-0 min-w-[110px] flex items-center gap-2", children: poorestMetricLabel })
73456
- ] }),
73457
- isSnapshotLoading ? /* @__PURE__ */ jsx(OverviewListSkeleton, {}) : mergedPoorestLines.length > 0 ? mergedPoorestLines.map((line) => {
73458
- const lineDelta = buildLineDeltaTone(line.delta, comparisonLabel);
73459
- return /* @__PURE__ */ jsx(
73460
- "div",
73461
- {
73462
- onClick: () => {
73463
- trackCoreEvent("Operations Overview Line Clicked", { line_id: line.id, line_name: line.name });
73464
- navigate(`/kpis/${line.id}`);
73465
- },
73466
- className: "block py-3 hover:bg-slate-50/50 transition-colors cursor-pointer group relative",
73467
- children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
73468
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
73469
- /* @__PURE__ */ jsx("div", { className: "w-8 h-8 rounded-full bg-slate-100 border border-slate-200 overflow-hidden flex-shrink-0", children: line.supervisorImage ? /* @__PURE__ */ jsx(
73470
- "img",
73471
- {
73472
- src: line.supervisorImage,
73473
- alt: line.supervisor,
73474
- className: "w-full h-full object-cover"
73475
- }
73476
- ) : /* @__PURE__ */ jsx("div", { className: "w-full h-full flex items-center justify-center text-[10px] font-bold text-slate-500", children: line.supervisor.split(" ").map((part) => part[0]).join("").slice(0, 2) }) }),
73477
- /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
73478
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "font-bold text-slate-800 text-[13px] truncate group-hover:text-indigo-600 transition-colors", children: line.name }) }),
73479
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 mt-0.5 flex-wrap", children: /* @__PURE__ */ jsx("span", { className: "text-[10px] text-slate-400 font-medium", children: line.supervisor }) })
73480
- ] })
73481
- ] }),
73482
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 shrink-0 justify-start min-w-[110px]", children: [
73483
- /* @__PURE__ */ jsxs("div", { className: "text-[15px] font-bold text-slate-800", children: [
73484
- line.efficiency,
73485
- "%"
73486
- ] }),
73487
- line.delta !== null && line.delta !== void 0 && Number.isFinite(line.delta) ? /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-0.5 px-2 py-0.5 rounded-full ${line.delta >= 0 ? "bg-[#ecfdf5] text-[#059669]" : "bg-[#FEF2F2] text-[#DC2626]"}`, children: [
73488
- line.delta >= 0 ? /* @__PURE__ */ jsx(ArrowUp, { className: "w-3 h-3", strokeWidth: 2.5 }) : /* @__PURE__ */ jsx(ArrowDown, { className: "w-3 h-3", strokeWidth: 2.5 }),
73489
- /* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold", children: lineDelta.text.split(" vs ")[0].replace("+", "") })
73490
- ] }) : /* @__PURE__ */ jsx("div", { className: "flex items-center gap-0.5 px-2 py-0.5 rounded-full bg-slate-50 text-slate-400", children: /* @__PURE__ */ jsx("span", { className: "text-[11px] font-bold", children: "\u2014" }) })
73491
- ] })
73492
- ] })
73493
- },
73494
- line.id
73495
- );
73496
- }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: `No ${poorestLineMode} line data available` })
73497
- ] }) })
73498
- ] }),
73499
- /* @__PURE__ */ jsxs(
73500
- "div",
75825
+ /* @__PURE__ */ jsx(
75826
+ PoorestPerformersCard,
73501
75827
  {
73502
- className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden text-left",
73503
- children: [
73504
- /* @__PURE__ */ jsx("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50 relative", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time Breakdown" }) }),
73505
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 p-4 pt-2 relative", children: isIdleReasonBreakdownLoading ? /* @__PURE__ */ jsx(OverviewIdleBreakdownSkeleton, {}) : showIdleModuleNotEnabledState ? /* @__PURE__ */ jsx("div", { className: "h-full flex items-center justify-center rounded-xl border border-dashed border-slate-200 bg-slate-50/80 px-6 text-center", children: /* @__PURE__ */ jsxs("div", { children: [
73506
- /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-slate-700", children: "Module not enabled" }),
73507
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-slate-500", children: "Enable idle-time classification on at least one line to view this breakdown." })
73508
- ] }) }) : /* @__PURE__ */ jsx(
73509
- IdleTimeReasonChart,
73510
- {
73511
- data: idleBreakdown,
73512
- isLoading: false,
73513
- hideTotalDuration: true
73514
- }
73515
- ) })
73516
- ]
75828
+ store,
75829
+ supervisorsByLineId,
75830
+ onViewAll: handleViewAllPoorestPerformers,
75831
+ onLineClick: handleOpenLineMonthlyHistory
75832
+ }
75833
+ ),
75834
+ /* @__PURE__ */ jsx(
75835
+ IdleBreakdownCard,
75836
+ {
75837
+ store,
75838
+ scopedLineCount: scopedLineIds.length
73517
75839
  }
73518
75840
  )
73519
75841
  ] }),
73520
75842
  /* @__PURE__ */ jsxs("div", { className: "grid grid-rows-1 xl:grid-rows-2 gap-5 min-h-0", children: [
73521
- /* @__PURE__ */ jsxs(
73522
- "div",
75843
+ /* @__PURE__ */ jsx(
75844
+ EfficiencyTrendCard,
73523
75845
  {
73524
- className: "bg-white rounded-xl shadow-[0_2px_10px_-3px_rgba(6,81,237,0.1)] border border-slate-100 flex flex-col overflow-hidden text-left",
73525
- children: [
73526
- /* @__PURE__ */ jsx("div", { className: "px-6 py-5 flex-none flex justify-between items-center border-b border-slate-50/50", children: /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Efficiency Trend" }) }),
73527
- /* @__PURE__ */ jsx("div", { className: "flex-1 min-h-0 w-full p-4 pt-4 relative", children: isTrendLoading ? /* @__PURE__ */ jsx(OverviewChartSkeleton, {}) : /* @__PURE__ */ jsx("div", { className: "absolute inset-0 pb-2 pr-4 pl-1", children: /* @__PURE__ */ jsx(
73528
- LineChart,
73529
- {
73530
- data: trendData,
73531
- lines: efficiencyLineConfig,
73532
- xAxisDataKey: "name",
73533
- yAxisUnit: "%",
73534
- yAxisDomain: [0, 100],
73535
- showLegend: false,
73536
- showGrid: true,
73537
- fillContainer: true,
73538
- tooltipLabelFormatter: trendTooltipLabelFormatter
73539
- },
73540
- trendPlayKey
73541
- ) }) })
73542
- ]
75846
+ store,
75847
+ dateRange,
75848
+ appTimezone
73543
75849
  }
73544
75850
  ),
73545
- /* @__PURE__ */ jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
73546
- /* @__PURE__ */ jsxs("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50", children: [
73547
- /* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Improvements" }),
73548
- /* @__PURE__ */ jsx(
73549
- "button",
73550
- {
73551
- type: "button",
73552
- onClick: () => {
73553
- trackCoreEvent("Operations Overview View All Clicked", { section: "improvements" });
73554
- navigate("/improvement-center");
73555
- },
73556
- className: "text-[11px] font-bold text-slate-500 hover:text-slate-800 transition-colors",
73557
- children: "View All"
73558
- }
73559
- )
73560
- ] }),
73561
- /* @__PURE__ */ jsx("div", { className: "flex-1 p-0 flex flex-col px-5 py-2 justify-start overflow-auto", children: isImprovementsLoading ? /* @__PURE__ */ jsx(OverviewImprovementsSkeleton, {}) : displayImprovements.length > 0 ? displayImprovements.map((item) => /* @__PURE__ */ jsxs(
73562
- "div",
73563
- {
73564
- "data-testid": `plant-head-improvement-${item.issueId}`,
73565
- onClick: () => {
73566
- trackCoreEvent("Operations Overview Improvement Clicked", {
73567
- issue_id: item.issueId,
73568
- issue_number: item.issueNumber,
73569
- title: item.title
73570
- });
73571
- const params = new URLSearchParams({
73572
- focusIssueId: item.issueId
73573
- });
73574
- navigate(`/improvement-center?${params.toString()}`);
73575
- },
73576
- className: "flex items-center justify-between py-3 border-b border-slate-50 last:border-0 group cursor-pointer",
73577
- children: [
73578
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0 pr-4", children: [
73579
- item.ticketLabel && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsx("span", { className: "inline-flex items-center rounded-full border border-indigo-100 bg-indigo-50 px-2 py-0.5 text-[10px] font-semibold text-indigo-600", children: item.ticketLabel }) }),
73580
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
73581
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 min-w-0 mb-0.5", children: /* @__PURE__ */ jsx("h4", { className: "text-[13px] font-semibold text-slate-800 truncate transition-colors group-hover:text-indigo-600", children: item.title }) }),
73582
- /* @__PURE__ */ jsx(
73583
- "p",
73584
- {
73585
- className: "text-[10px] font-medium text-slate-400 truncate",
73586
- title: item.metadataLabel,
73587
- children: item.metadataLabel
73588
- }
73589
- )
73590
- ] })
73591
- ] }),
73592
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsxs(
73593
- "span",
73594
- {
73595
- className: `inline-flex items-center gap-1 rounded-full border px-2.5 py-0.5 text-[11px] ${item.metric.includes("pcs / day") || item.metric.includes("gain") ? "border-emerald-100 bg-emerald-50 text-emerald-700" : item.metric.includes("Idle") ? "border-amber-100 bg-amber-50 text-amber-700" : "border-slate-100 bg-slate-50 text-slate-600"}`,
73596
- children: [
73597
- (item.metric.includes("pcs / day") || item.metric.includes("gain")) && /* @__PURE__ */ jsx(TrendingUp, { className: "h-3 w-3" }),
73598
- /* @__PURE__ */ jsx("span", { className: "font-semibold", children: item.metric })
73599
- ]
73600
- }
73601
- ) })
73602
- ]
73603
- },
73604
- item.id
73605
- )) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: "No open improvement issues" }) })
73606
- ] })
75851
+ /* @__PURE__ */ jsx(
75852
+ TopImprovementsCard,
75853
+ {
75854
+ store,
75855
+ supervisorsByLineId,
75856
+ onViewAll: handleViewAllImprovements,
75857
+ onItemClick: handleOpenImprovement
75858
+ }
75859
+ )
73607
75860
  ] })
73608
75861
  ] })
73609
75862
  ] })
@@ -74086,4 +76339,4 @@ var streamProxyConfig = {
74086
76339
  }
74087
76340
  };
74088
76341
 
74089
- export { ACTION_NAMES, AIAgentView_default as AIAgentView, AcceptInvite, AcceptInviteView_default as AcceptInviteView, AdvancedFilterDialog, AdvancedFilterPanel, AudioService, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthService, AuthenticatedBottleneckClipsView, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedShiftsView, AuthenticatedTargetsView, AuthenticatedTicketsView, AuthenticatedWorkspaceHealthView, AvatarUpload, AxelNotificationPopup, AxelOrb, BackButton, BackButtonMinimal, BarChart, BaseHistoryCalendar, BottleneckClipsModal, BottleneckClipsView_default as BottleneckClipsView, BottlenecksContent, BreakNotificationPopup, CachePrefetchStatus, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, ChangeRoleDialog, ClipFilterProvider, ClipsCostView_default as ClipsCostView, CompactWorkspaceHealthCard, ConfirmRemoveUserDialog, CongratulationsOverlay, CroppedHlsVideoPlayer, CroppedVideoPlayer, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_HOME_VIEW_CONFIG, DEFAULT_MAP_VIEW_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_SHIFT_DATA, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, DetailedHealthStatus, DiagnosisVideoModal, EFFICIENCY_ON_TRACK_THRESHOLD, EmptyStateMessage, EncouragementOverlay, FactoryAssignmentDropdown, FactoryView_default as FactoryView, FileManagerFilters, FilterDialogTrigger, FirstTimeLoginDebug, FirstTimeLoginHandler, FittingTitle, GaugeChart, GridComponentsPlaceholder, HamburgerButton, Header, HealthDateShiftSelector, HealthStatusGrid, HealthStatusIndicator, HelpView_default as HelpView, HlsVideoPlayer, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, HourlyUptimeChart, ISTTimer_default as ISTTimer, IdleTimeVlmConfigProvider, ImprovementCenterView_default as ImprovementCenterView, InlineEditableText, InteractiveOnboardingTour, InvitationService, InvitationsTable, InviteUserDialog, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineAssignmentDropdown, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LinesService, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingState, LoginPage, LoginView_default as LoginView, Logo, MainLayout, MapGridView, MetricCard_default as MetricCard, MinimalOnboardingPopup, MobileMenuProvider, NewClipsNotification, NoWorkspaceData, OnboardingDemo, OnboardingTour, OptifyeAgentClient, OptifyeLogoLoader_default as OptifyeLogoLoader, OutputProgressChart, PageHeader, PieChart4 as PieChart, PlantHeadView_default as PlantHeadView, PlayPauseIndicator, PrefetchConfigurationError, PrefetchError, PrefetchEvents, PrefetchStatus, PrefetchTimeoutError, ProfileView_default as ProfileView, RegistryProvider, RoleBadge, S3ClipsSupabaseService as S3ClipsService, S3Service, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SessionTracker, SessionTrackingContext, SessionTrackingProvider, SettingsPopup, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SignupWithInvitation, SilentErrorBoundary, SimpleOnboardingPopup, SingleVideoStream_default as SingleVideoStream, Skeleton, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, SupervisorDropdown_default as SupervisorDropdown, SupervisorManagementView_default as SupervisorManagementView, SupervisorService, TargetWorkspaceGrid, TargetsView_default as TargetsView, TeamManagementView_default as TeamManagementView, ThreadSidebar, TicketHistory_default as TicketHistory, TicketHistoryService, TicketsView_default as TicketsView, TimeDisplay_default as TimeDisplay, TimePickerDropdown, Timer_default as Timer, TimezoneProvider, TimezoneService, UptimeDonutChart, UptimeLineChart, UptimeMetricCards, UserAvatar, UserManagementService, UserManagementTable, UserService, UserUsageDetailModal, UserUsageStats, VideoCard, VideoGridView, VideoPlayer, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHealthCard, WorkspaceHealthView_default as WorkspaceHealthView, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMetricCardsImpl, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyHistory, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, aggregateKPIsFromLineMetricsRows, alertsService, apiUtils, areAllLinesOnSameShift, authCoreService, authOTPService, authRateLimitService, awardsService, buildDateKey, buildKPIsFromLineMetricsRow, buildShiftGroupsKey, captureSentryException, captureSentryMessage, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearSentryContext, clearWorkspaceDisplayNamesCache, cn, createDefaultKPIs, createInvitationService, createLinesService, createSessionTracker, createStorageService, createStreamProxyHandler, createSupabaseClient, createSupervisorService, createThrottledReload, createUserManagementService, createUserService, dashboardService, deleteThread, fetchIdleTimeReasons, filterDataByDateKeyRange, forceRefreshWorkspaceDisplayNames, formatAwardMonth, formatDateInZone, formatDateKeyForDisplay, formatDateTimeInZone, formatDuration2 as formatDuration, formatISTDate, formatIdleTime, formatRangeLabel, formatReasonLabel, formatRelativeTime, formatTimeInZone, fromUrlFriendlyName, getAllLineDisplayNames, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAllWorkspaceDisplayNamesSnapshot, getAnonClient, getAvailableShiftIds, getAwardBadgeType, getAwardDescription, getAwardTitle, getBrowserName, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getConfiguredLineIds, getCoreSessionRecordingProperties, getCoreSessionReplayUrl, getCurrentShift, getCurrentShiftForLine, getCurrentTimeInZone, getCurrentWeekToDateRange, getDashboardHeaderTimeInZone, getDateKeyFromDate, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultLineId, getDefaultTabForWorkspace, getInitials, getLineDisplayName, getManufacturingInsights, getMetricsTablePrefix, getMonthKeyBounds, getMonthWeekRanges, getNextUpdateInterval, getOperationalDate, getReasonColor, getS3SignedUrl, getS3VideoSrc, getShiftData, getShiftNameById, getShiftWorkDurationSeconds, getShortShiftName, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUniformShiftGroup, getUserThreads, getUserThreadsPaginated, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, groupLinesByShift, hasAnyShiftData, identifyCoreUser, initializeCoreMixpanel, isEfficiencyOnTrack, isFullMonthRange, isLegacyConfiguration, isPrefetchError, isSafari, isTransitionPeriod, isUrlPermanentlyFailed, isValidFactoryViewConfiguration, isValidLineInfoPayload, isValidPrefetchParams, isValidPrefetchStatus, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, lineLeaderboardService, linesService, mergeWithDefaultConfig, migrateLegacyConfiguration, normalizeDateKeyRange, optifyeAgentClient, parseDateKeyToDate, parseS3Uri, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetFailedUrl, resetSubscriptionManager, s3VideoPreloader, setSentryUserContext, setSentryWorkspaceContext, shuffleArray, simulateApiDelay, skuService, startCoreSessionRecording, stopCoreSessionRecording, storeWorkspaceMapping, streamProxyConfig, subscribeWorkspaceDisplayNames, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, transformToChartData, updateThreadTitle, upsertWorkspaceDisplayNameInCache, useAccessControl, useActiveBreaks, useActiveLineId, useAllWorkspaceMetrics, useAnalyticsConfig, useAppTimezone, useAudioService, useAuth, useAuthConfig, useAxelNotifications, useCanSaveTargets, useClipFilter, useClipTypes, useClipTypesWithCounts, useClipsInit, useCompanyClipsCost, useCompanyUsersUsage, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useDynamicShiftConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHasLineAccess, useHideMobileHeader, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useHourEndTimer, useHourlyTargetAchievements, useHourlyTargetMisses, useIdleTimeClipClassifications, useIdleTimeReasons, useIdleTimeVlmConfig, useKpiTrends, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineShiftConfig, useLineSupervisor, useLineWorkspaceMetrics, useLines, useMessages, useMetrics, useMobileMenu, useMonthlyTrend, useMultiLineShiftConfigs, useNavigation, useOperationalShiftKey, useOptionalSupabase, useOverrides, usePageOverride, usePrefetchClipCounts, useRealtimeLineMetrics, useRegistry, useSKUs, useSessionKeepAlive, useSessionTracking, useSessionTrackingContext, useShiftConfig, useShiftGroups, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useSupervisorsByLineIds, useTargets, useTeamManagementPermissions, useTheme, useThemeConfig, useThreads, useTicketHistory, useTimezoneContext, useUserLineAccess, useUserUsage, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceHealthById, useWorkspaceHealthLastSeen, useWorkspaceHealthStatus, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, useWorkspaceUptimeTimeline, useWorkspaceVideoStreams, userService, videoPrefetchManager, videoPreloader, weeklyTopPerformerService, whatsappService, withAccessControl, withAuth, withRegistry, withTimezone, workspaceHealthService, workspaceService };
76342
+ export { ACTION_NAMES, AIAgentView_default as AIAgentView, AcceptInvite, AcceptInviteView_default as AcceptInviteView, AdvancedFilterDialog, AdvancedFilterPanel, AudioService, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthService, AuthenticatedBottleneckClipsView, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedShiftsView, AuthenticatedTargetsView, AuthenticatedTicketsView, AuthenticatedWorkspaceHealthView, AvatarUpload, AxelNotificationPopup, AxelOrb, BackButton, BackButtonMinimal, BarChart, BaseHistoryCalendar, BottleneckClipsModal, BottleneckClipsView_default as BottleneckClipsView, BottlenecksContent, BreakNotificationPopup, CachePrefetchStatus, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, ChangeRoleDialog, ClipFilterProvider, ClipsCostView_default as ClipsCostView, CompactWorkspaceHealthCard, ConfirmRemoveUserDialog, CongratulationsOverlay, CroppedHlsVideoPlayer, CroppedVideoPlayer, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_HOME_VIEW_CONFIG, DEFAULT_MAP_VIEW_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_SHIFT_DATA, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, DetailedHealthStatus, DiagnosisVideoModal, EFFICIENCY_ON_TRACK_THRESHOLD, EmptyStateMessage, EncouragementOverlay, FactoryAssignmentDropdown, FactoryView_default as FactoryView, FileManagerFilters, FilterDialogTrigger, FirstTimeLoginDebug, FirstTimeLoginHandler, FittingTitle, GaugeChart, GridComponentsPlaceholder, HamburgerButton, Header, HealthDateShiftSelector, HealthStatusGrid, HealthStatusIndicator, HelpView_default as HelpView, HlsVideoPlayer, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, HourlyUptimeChart, ISTTimer_default as ISTTimer, IdleTimeVlmConfigProvider, ImprovementCenterView_default as ImprovementCenterView, InlineEditableText, InteractiveOnboardingTour, InvitationService, InvitationsTable, InviteUserDialog, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend6 as Legend, LineAssignmentDropdown, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LinesService, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingState, LoginPage, LoginView_default as LoginView, Logo, MainLayout, MapGridView, MetricCard_default as MetricCard, MinimalOnboardingPopup, MobileMenuProvider, NewClipsNotification, NoWorkspaceData, OnboardingDemo, OnboardingTour, OptifyeAgentClient, OptifyeLogoLoader_default as OptifyeLogoLoader, OutputProgressChart, PageHeader, PieChart4 as PieChart, PlantHeadView_default as PlantHeadView, PlayPauseIndicator, PrefetchConfigurationError, PrefetchError, PrefetchEvents, PrefetchStatus, PrefetchTimeoutError, ProfileView_default as ProfileView, RegistryProvider, RoleBadge, S3ClipsSupabaseService as S3ClipsService, S3Service, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SessionTracker, SessionTrackingContext, SessionTrackingProvider, SettingsPopup, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SignupWithInvitation, SilentErrorBoundary, SimpleOnboardingPopup, SingleVideoStream_default as SingleVideoStream, Skeleton, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, SupervisorDropdown_default as SupervisorDropdown, SupervisorManagementView_default as SupervisorManagementView, SupervisorService, TargetWorkspaceGrid, TargetsView_default as TargetsView, TeamManagementView_default as TeamManagementView, ThreadSidebar, TicketHistory_default as TicketHistory, TicketHistoryService, TicketsView_default as TicketsView, TimeDisplay_default as TimeDisplay, TimePickerDropdown, Timer_default as Timer, TimezoneProvider, TimezoneService, UptimeDonutChart, UptimeLineChart, UptimeMetricCards, UserAvatar, UserManagementService, UserManagementTable, UserService, UserUsageDetailModal, UserUsageStats, VideoCard, VideoGridView, VideoPlayer, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHealthCard, WorkspaceHealthView_default as WorkspaceHealthView, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMetricCardsImpl, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyHistory, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, aggregateKPIsFromLineMetricsRows, alertsService, apiUtils, areAllLinesOnSameShift, authCoreService, authOTPService, authRateLimitService, awardsService, buildDateKey, buildKPIsFromLineMetricsRow, buildShiftGroupsKey, canRoleAccessDashboardPath, canRoleAccessTeamManagement, canRoleAssignFactories, canRoleAssignLines, canRoleChangeRole, canRoleInviteRole, canRoleManageCompany, canRoleManageTargets, canRoleManageUsers, canRoleRemoveUser, canRoleViewClipsCost, canRoleViewUsageStats, captureSentryException, captureSentryMessage, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearSentryContext, clearWorkspaceDisplayNamesCache, cn, createDefaultKPIs, createInvitationService, createLinesService, createSessionTracker, createStorageService, createStreamProxyHandler, createSupabaseClient, createSupervisorService, createThrottledReload, createUserManagementService, createUserService, dashboardService, deleteThread, fetchIdleTimeReasons, filterDataByDateKeyRange, forceRefreshWorkspaceDisplayNames, formatAwardMonth, formatDateInZone, formatDateKeyForDisplay, formatDateTimeInZone, formatDuration2 as formatDuration, formatISTDate, formatIdleTime, formatRangeLabel, formatReasonLabel, formatRelativeTime, formatTimeInZone, fromUrlFriendlyName, getAllLineDisplayNames, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAllWorkspaceDisplayNamesSnapshot, getAnonClient, getAssignableRoles, getAssignmentColumnLabel, getAvailableShiftIds, getAwardBadgeType, getAwardDescription, getAwardTitle, getBrowserName, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getConfiguredLineIds, getCoreSessionRecordingProperties, getCoreSessionReplayUrl, getCurrentShift, getCurrentShiftForLine, getCurrentTimeInZone, getCurrentWeekToDateRange, getDashboardHeaderTimeInZone, getDateKeyFromDate, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultLineId, getDefaultTabForWorkspace, getInitials, getLineDisplayName, getManufacturingInsights, getMetricsTablePrefix, getMonthKeyBounds, getMonthWeekRanges, getNextUpdateInterval, getOperationalDate, getReasonColor, getRoleAssignmentKind, getRoleDescription, getRoleLabel, getRoleMetadata, getRoleNavPaths, getS3SignedUrl, getS3VideoSrc, getShiftData, getShiftNameById, getShiftWorkDurationSeconds, getShortShiftName, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUniformShiftGroup, getUserThreads, getUserThreadsPaginated, getVisibleRolesForCurrentUser, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, groupLinesByShift, hasAnyShiftData, identifyCoreUser, initializeCoreMixpanel, isEfficiencyOnTrack, isFactoryScopedRole, isFullMonthRange, isLegacyConfiguration, isPrefetchError, isSafari, isSupervisorRole, isTransitionPeriod, isUrlPermanentlyFailed, isValidFactoryViewConfiguration, isValidLineInfoPayload, isValidPrefetchParams, isValidPrefetchStatus, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, lineLeaderboardService, linesService, mergeWithDefaultConfig, migrateLegacyConfiguration, normalizeDateKeyRange, normalizeRoleLevel, optifyeAgentClient, parseDateKeyToDate, parseS3Uri, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetFailedUrl, resetSubscriptionManager, s3VideoPreloader, setSentryUserContext, setSentryWorkspaceContext, shuffleArray, simulateApiDelay, skuService, startCoreSessionRecording, stopCoreSessionRecording, storeWorkspaceMapping, streamProxyConfig, subscribeWorkspaceDisplayNames, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, transformToChartData, updateThreadTitle, upsertWorkspaceDisplayNameInCache, useAccessControl, useActiveBreaks, useActiveLineId, useAllWorkspaceMetrics, useAnalyticsConfig, useAppTimezone, useAudioService, useAuth, useAuthConfig, useAxelNotifications, useCanSaveTargets, useClipFilter, useClipTypes, useClipTypesWithCounts, useClipsInit, useCompanyClipsCost, useCompanyUsersUsage, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useDynamicShiftConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHasLineAccess, useHideMobileHeader, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useHourEndTimer, useHourlyTargetAchievements, useHourlyTargetMisses, useIdleTimeClipClassifications, useIdleTimeReasons, useIdleTimeVlmConfig, useKpiTrends, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineShiftConfig, useLineSupervisor, useLineWorkspaceMetrics, useLines, useMessages, useMetrics, useMobileMenu, useMonthlyTrend, useMultiLineShiftConfigs, useNavigation, useOperationalShiftKey, useOptionalSupabase, useOverrides, usePageOverride, usePrefetchClipCounts, useRealtimeLineMetrics, useRegistry, useSKUs, useSessionKeepAlive, useSessionTracking, useSessionTrackingContext, useShiftConfig, useShiftGroups, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useSupervisorsByLineIds, useTargets, useTeamManagementPermissions, useTheme, useThemeConfig, useThreads, useTicketHistory, useTimezoneContext, useUserLineAccess, useUserUsage, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceHealthById, useWorkspaceHealthLastSeen, useWorkspaceHealthStatus, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, useWorkspaceUptimeTimeline, useWorkspaceVideoStreams, userService, videoPrefetchManager, videoPreloader, weeklyTopPerformerService, whatsappService, withAccessControl, withAuth, withRegistry, withTimezone, workspaceHealthService, workspaceService };