@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.js CHANGED
@@ -54,12 +54,1550 @@ var SelectPrimitive__namespace = /*#__PURE__*/_interopNamespace(SelectPrimitive)
54
54
  var html2canvas__default = /*#__PURE__*/_interopDefault(html2canvas);
55
55
  var jsPDF__default = /*#__PURE__*/_interopDefault(jsPDF);
56
56
 
57
+ var __create = Object.create;
58
+ var __defProp = Object.defineProperty;
59
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
60
+ var __getOwnPropNames = Object.getOwnPropertyNames;
61
+ var __getProtoOf = Object.getPrototypeOf;
62
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
57
63
  var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
58
64
  get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
59
65
  }) : x)(function(x) {
60
66
  if (typeof require !== "undefined") return require.apply(this, arguments);
61
67
  throw Error('Dynamic require of "' + x + '" is not supported');
62
68
  });
69
+ var __commonJS = (cb, mod) => function __require2() {
70
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
71
+ };
72
+ var __copyProps = (to, from, except, desc) => {
73
+ if (from && typeof from === "object" || typeof from === "function") {
74
+ for (let key of __getOwnPropNames(from))
75
+ if (!__hasOwnProp.call(to, key) && key !== except)
76
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
77
+ }
78
+ return to;
79
+ };
80
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
81
+ // If the importer is in node compatibility mode or this is not an ESM
82
+ // file that has been converted to a CommonJS file using a Babel-
83
+ // compatible transform (i.e. "__esModule" has not been set), then set
84
+ // "default" to the CommonJS "module.exports" for node compatibility.
85
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
86
+ mod
87
+ ));
88
+
89
+ // ../../node_modules/lodash/_listCacheClear.js
90
+ var require_listCacheClear = __commonJS({
91
+ "../../node_modules/lodash/_listCacheClear.js"(exports, module) {
92
+ function listCacheClear() {
93
+ this.__data__ = [];
94
+ this.size = 0;
95
+ }
96
+ module.exports = listCacheClear;
97
+ }
98
+ });
99
+
100
+ // ../../node_modules/lodash/eq.js
101
+ var require_eq = __commonJS({
102
+ "../../node_modules/lodash/eq.js"(exports, module) {
103
+ function eq(value, other) {
104
+ return value === other || value !== value && other !== other;
105
+ }
106
+ module.exports = eq;
107
+ }
108
+ });
109
+
110
+ // ../../node_modules/lodash/_assocIndexOf.js
111
+ var require_assocIndexOf = __commonJS({
112
+ "../../node_modules/lodash/_assocIndexOf.js"(exports, module) {
113
+ var eq = require_eq();
114
+ function assocIndexOf(array, key) {
115
+ var length = array.length;
116
+ while (length--) {
117
+ if (eq(array[length][0], key)) {
118
+ return length;
119
+ }
120
+ }
121
+ return -1;
122
+ }
123
+ module.exports = assocIndexOf;
124
+ }
125
+ });
126
+
127
+ // ../../node_modules/lodash/_listCacheDelete.js
128
+ var require_listCacheDelete = __commonJS({
129
+ "../../node_modules/lodash/_listCacheDelete.js"(exports, module) {
130
+ var assocIndexOf = require_assocIndexOf();
131
+ var arrayProto = Array.prototype;
132
+ var splice = arrayProto.splice;
133
+ function listCacheDelete(key) {
134
+ var data = this.__data__, index = assocIndexOf(data, key);
135
+ if (index < 0) {
136
+ return false;
137
+ }
138
+ var lastIndex = data.length - 1;
139
+ if (index == lastIndex) {
140
+ data.pop();
141
+ } else {
142
+ splice.call(data, index, 1);
143
+ }
144
+ --this.size;
145
+ return true;
146
+ }
147
+ module.exports = listCacheDelete;
148
+ }
149
+ });
150
+
151
+ // ../../node_modules/lodash/_listCacheGet.js
152
+ var require_listCacheGet = __commonJS({
153
+ "../../node_modules/lodash/_listCacheGet.js"(exports, module) {
154
+ var assocIndexOf = require_assocIndexOf();
155
+ function listCacheGet(key) {
156
+ var data = this.__data__, index = assocIndexOf(data, key);
157
+ return index < 0 ? void 0 : data[index][1];
158
+ }
159
+ module.exports = listCacheGet;
160
+ }
161
+ });
162
+
163
+ // ../../node_modules/lodash/_listCacheHas.js
164
+ var require_listCacheHas = __commonJS({
165
+ "../../node_modules/lodash/_listCacheHas.js"(exports, module) {
166
+ var assocIndexOf = require_assocIndexOf();
167
+ function listCacheHas(key) {
168
+ return assocIndexOf(this.__data__, key) > -1;
169
+ }
170
+ module.exports = listCacheHas;
171
+ }
172
+ });
173
+
174
+ // ../../node_modules/lodash/_listCacheSet.js
175
+ var require_listCacheSet = __commonJS({
176
+ "../../node_modules/lodash/_listCacheSet.js"(exports, module) {
177
+ var assocIndexOf = require_assocIndexOf();
178
+ function listCacheSet(key, value) {
179
+ var data = this.__data__, index = assocIndexOf(data, key);
180
+ if (index < 0) {
181
+ ++this.size;
182
+ data.push([key, value]);
183
+ } else {
184
+ data[index][1] = value;
185
+ }
186
+ return this;
187
+ }
188
+ module.exports = listCacheSet;
189
+ }
190
+ });
191
+
192
+ // ../../node_modules/lodash/_ListCache.js
193
+ var require_ListCache = __commonJS({
194
+ "../../node_modules/lodash/_ListCache.js"(exports, module) {
195
+ var listCacheClear = require_listCacheClear();
196
+ var listCacheDelete = require_listCacheDelete();
197
+ var listCacheGet = require_listCacheGet();
198
+ var listCacheHas = require_listCacheHas();
199
+ var listCacheSet = require_listCacheSet();
200
+ function ListCache(entries) {
201
+ var index = -1, length = entries == null ? 0 : entries.length;
202
+ this.clear();
203
+ while (++index < length) {
204
+ var entry = entries[index];
205
+ this.set(entry[0], entry[1]);
206
+ }
207
+ }
208
+ ListCache.prototype.clear = listCacheClear;
209
+ ListCache.prototype["delete"] = listCacheDelete;
210
+ ListCache.prototype.get = listCacheGet;
211
+ ListCache.prototype.has = listCacheHas;
212
+ ListCache.prototype.set = listCacheSet;
213
+ module.exports = ListCache;
214
+ }
215
+ });
216
+
217
+ // ../../node_modules/lodash/_stackClear.js
218
+ var require_stackClear = __commonJS({
219
+ "../../node_modules/lodash/_stackClear.js"(exports, module) {
220
+ var ListCache = require_ListCache();
221
+ function stackClear() {
222
+ this.__data__ = new ListCache();
223
+ this.size = 0;
224
+ }
225
+ module.exports = stackClear;
226
+ }
227
+ });
228
+
229
+ // ../../node_modules/lodash/_stackDelete.js
230
+ var require_stackDelete = __commonJS({
231
+ "../../node_modules/lodash/_stackDelete.js"(exports, module) {
232
+ function stackDelete(key) {
233
+ var data = this.__data__, result = data["delete"](key);
234
+ this.size = data.size;
235
+ return result;
236
+ }
237
+ module.exports = stackDelete;
238
+ }
239
+ });
240
+
241
+ // ../../node_modules/lodash/_stackGet.js
242
+ var require_stackGet = __commonJS({
243
+ "../../node_modules/lodash/_stackGet.js"(exports, module) {
244
+ function stackGet(key) {
245
+ return this.__data__.get(key);
246
+ }
247
+ module.exports = stackGet;
248
+ }
249
+ });
250
+
251
+ // ../../node_modules/lodash/_stackHas.js
252
+ var require_stackHas = __commonJS({
253
+ "../../node_modules/lodash/_stackHas.js"(exports, module) {
254
+ function stackHas(key) {
255
+ return this.__data__.has(key);
256
+ }
257
+ module.exports = stackHas;
258
+ }
259
+ });
260
+
261
+ // ../../node_modules/lodash/_freeGlobal.js
262
+ var require_freeGlobal = __commonJS({
263
+ "../../node_modules/lodash/_freeGlobal.js"(exports, module) {
264
+ var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
265
+ module.exports = freeGlobal;
266
+ }
267
+ });
268
+
269
+ // ../../node_modules/lodash/_root.js
270
+ var require_root = __commonJS({
271
+ "../../node_modules/lodash/_root.js"(exports, module) {
272
+ var freeGlobal = require_freeGlobal();
273
+ var freeSelf = typeof self == "object" && self && self.Object === Object && self;
274
+ var root = freeGlobal || freeSelf || Function("return this")();
275
+ module.exports = root;
276
+ }
277
+ });
278
+
279
+ // ../../node_modules/lodash/_Symbol.js
280
+ var require_Symbol = __commonJS({
281
+ "../../node_modules/lodash/_Symbol.js"(exports, module) {
282
+ var root = require_root();
283
+ var Symbol2 = root.Symbol;
284
+ module.exports = Symbol2;
285
+ }
286
+ });
287
+
288
+ // ../../node_modules/lodash/_getRawTag.js
289
+ var require_getRawTag = __commonJS({
290
+ "../../node_modules/lodash/_getRawTag.js"(exports, module) {
291
+ var Symbol2 = require_Symbol();
292
+ var objectProto = Object.prototype;
293
+ var hasOwnProperty = objectProto.hasOwnProperty;
294
+ var nativeObjectToString = objectProto.toString;
295
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
296
+ function getRawTag(value) {
297
+ var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag];
298
+ try {
299
+ value[symToStringTag] = void 0;
300
+ var unmasked = true;
301
+ } catch (e) {
302
+ }
303
+ var result = nativeObjectToString.call(value);
304
+ if (unmasked) {
305
+ if (isOwn) {
306
+ value[symToStringTag] = tag;
307
+ } else {
308
+ delete value[symToStringTag];
309
+ }
310
+ }
311
+ return result;
312
+ }
313
+ module.exports = getRawTag;
314
+ }
315
+ });
316
+
317
+ // ../../node_modules/lodash/_objectToString.js
318
+ var require_objectToString = __commonJS({
319
+ "../../node_modules/lodash/_objectToString.js"(exports, module) {
320
+ var objectProto = Object.prototype;
321
+ var nativeObjectToString = objectProto.toString;
322
+ function objectToString(value) {
323
+ return nativeObjectToString.call(value);
324
+ }
325
+ module.exports = objectToString;
326
+ }
327
+ });
328
+
329
+ // ../../node_modules/lodash/_baseGetTag.js
330
+ var require_baseGetTag = __commonJS({
331
+ "../../node_modules/lodash/_baseGetTag.js"(exports, module) {
332
+ var Symbol2 = require_Symbol();
333
+ var getRawTag = require_getRawTag();
334
+ var objectToString = require_objectToString();
335
+ var nullTag = "[object Null]";
336
+ var undefinedTag = "[object Undefined]";
337
+ var symToStringTag = Symbol2 ? Symbol2.toStringTag : void 0;
338
+ function baseGetTag(value) {
339
+ if (value == null) {
340
+ return value === void 0 ? undefinedTag : nullTag;
341
+ }
342
+ return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
343
+ }
344
+ module.exports = baseGetTag;
345
+ }
346
+ });
347
+
348
+ // ../../node_modules/lodash/isObject.js
349
+ var require_isObject = __commonJS({
350
+ "../../node_modules/lodash/isObject.js"(exports, module) {
351
+ function isObject2(value) {
352
+ var type = typeof value;
353
+ return value != null && (type == "object" || type == "function");
354
+ }
355
+ module.exports = isObject2;
356
+ }
357
+ });
358
+
359
+ // ../../node_modules/lodash/isFunction.js
360
+ var require_isFunction = __commonJS({
361
+ "../../node_modules/lodash/isFunction.js"(exports, module) {
362
+ var baseGetTag = require_baseGetTag();
363
+ var isObject2 = require_isObject();
364
+ var asyncTag = "[object AsyncFunction]";
365
+ var funcTag = "[object Function]";
366
+ var genTag = "[object GeneratorFunction]";
367
+ var proxyTag = "[object Proxy]";
368
+ function isFunction(value) {
369
+ if (!isObject2(value)) {
370
+ return false;
371
+ }
372
+ var tag = baseGetTag(value);
373
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
374
+ }
375
+ module.exports = isFunction;
376
+ }
377
+ });
378
+
379
+ // ../../node_modules/lodash/_coreJsData.js
380
+ var require_coreJsData = __commonJS({
381
+ "../../node_modules/lodash/_coreJsData.js"(exports, module) {
382
+ var root = require_root();
383
+ var coreJsData = root["__core-js_shared__"];
384
+ module.exports = coreJsData;
385
+ }
386
+ });
387
+
388
+ // ../../node_modules/lodash/_isMasked.js
389
+ var require_isMasked = __commonJS({
390
+ "../../node_modules/lodash/_isMasked.js"(exports, module) {
391
+ var coreJsData = require_coreJsData();
392
+ var maskSrcKey = function() {
393
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
394
+ return uid ? "Symbol(src)_1." + uid : "";
395
+ }();
396
+ function isMasked(func) {
397
+ return !!maskSrcKey && maskSrcKey in func;
398
+ }
399
+ module.exports = isMasked;
400
+ }
401
+ });
402
+
403
+ // ../../node_modules/lodash/_toSource.js
404
+ var require_toSource = __commonJS({
405
+ "../../node_modules/lodash/_toSource.js"(exports, module) {
406
+ var funcProto = Function.prototype;
407
+ var funcToString = funcProto.toString;
408
+ function toSource(func) {
409
+ if (func != null) {
410
+ try {
411
+ return funcToString.call(func);
412
+ } catch (e) {
413
+ }
414
+ try {
415
+ return func + "";
416
+ } catch (e) {
417
+ }
418
+ }
419
+ return "";
420
+ }
421
+ module.exports = toSource;
422
+ }
423
+ });
424
+
425
+ // ../../node_modules/lodash/_baseIsNative.js
426
+ var require_baseIsNative = __commonJS({
427
+ "../../node_modules/lodash/_baseIsNative.js"(exports, module) {
428
+ var isFunction = require_isFunction();
429
+ var isMasked = require_isMasked();
430
+ var isObject2 = require_isObject();
431
+ var toSource = require_toSource();
432
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
433
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
434
+ var funcProto = Function.prototype;
435
+ var objectProto = Object.prototype;
436
+ var funcToString = funcProto.toString;
437
+ var hasOwnProperty = objectProto.hasOwnProperty;
438
+ var reIsNative = RegExp(
439
+ "^" + funcToString.call(hasOwnProperty).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
440
+ );
441
+ function baseIsNative(value) {
442
+ if (!isObject2(value) || isMasked(value)) {
443
+ return false;
444
+ }
445
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
446
+ return pattern.test(toSource(value));
447
+ }
448
+ module.exports = baseIsNative;
449
+ }
450
+ });
451
+
452
+ // ../../node_modules/lodash/_getValue.js
453
+ var require_getValue = __commonJS({
454
+ "../../node_modules/lodash/_getValue.js"(exports, module) {
455
+ function getValue(object, key) {
456
+ return object == null ? void 0 : object[key];
457
+ }
458
+ module.exports = getValue;
459
+ }
460
+ });
461
+
462
+ // ../../node_modules/lodash/_getNative.js
463
+ var require_getNative = __commonJS({
464
+ "../../node_modules/lodash/_getNative.js"(exports, module) {
465
+ var baseIsNative = require_baseIsNative();
466
+ var getValue = require_getValue();
467
+ function getNative(object, key) {
468
+ var value = getValue(object, key);
469
+ return baseIsNative(value) ? value : void 0;
470
+ }
471
+ module.exports = getNative;
472
+ }
473
+ });
474
+
475
+ // ../../node_modules/lodash/_Map.js
476
+ var require_Map = __commonJS({
477
+ "../../node_modules/lodash/_Map.js"(exports, module) {
478
+ var getNative = require_getNative();
479
+ var root = require_root();
480
+ var Map2 = getNative(root, "Map");
481
+ module.exports = Map2;
482
+ }
483
+ });
484
+
485
+ // ../../node_modules/lodash/_nativeCreate.js
486
+ var require_nativeCreate = __commonJS({
487
+ "../../node_modules/lodash/_nativeCreate.js"(exports, module) {
488
+ var getNative = require_getNative();
489
+ var nativeCreate = getNative(Object, "create");
490
+ module.exports = nativeCreate;
491
+ }
492
+ });
493
+
494
+ // ../../node_modules/lodash/_hashClear.js
495
+ var require_hashClear = __commonJS({
496
+ "../../node_modules/lodash/_hashClear.js"(exports, module) {
497
+ var nativeCreate = require_nativeCreate();
498
+ function hashClear() {
499
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
500
+ this.size = 0;
501
+ }
502
+ module.exports = hashClear;
503
+ }
504
+ });
505
+
506
+ // ../../node_modules/lodash/_hashDelete.js
507
+ var require_hashDelete = __commonJS({
508
+ "../../node_modules/lodash/_hashDelete.js"(exports, module) {
509
+ function hashDelete(key) {
510
+ var result = this.has(key) && delete this.__data__[key];
511
+ this.size -= result ? 1 : 0;
512
+ return result;
513
+ }
514
+ module.exports = hashDelete;
515
+ }
516
+ });
517
+
518
+ // ../../node_modules/lodash/_hashGet.js
519
+ var require_hashGet = __commonJS({
520
+ "../../node_modules/lodash/_hashGet.js"(exports, module) {
521
+ var nativeCreate = require_nativeCreate();
522
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
523
+ var objectProto = Object.prototype;
524
+ var hasOwnProperty = objectProto.hasOwnProperty;
525
+ function hashGet(key) {
526
+ var data = this.__data__;
527
+ if (nativeCreate) {
528
+ var result = data[key];
529
+ return result === HASH_UNDEFINED ? void 0 : result;
530
+ }
531
+ return hasOwnProperty.call(data, key) ? data[key] : void 0;
532
+ }
533
+ module.exports = hashGet;
534
+ }
535
+ });
536
+
537
+ // ../../node_modules/lodash/_hashHas.js
538
+ var require_hashHas = __commonJS({
539
+ "../../node_modules/lodash/_hashHas.js"(exports, module) {
540
+ var nativeCreate = require_nativeCreate();
541
+ var objectProto = Object.prototype;
542
+ var hasOwnProperty = objectProto.hasOwnProperty;
543
+ function hashHas(key) {
544
+ var data = this.__data__;
545
+ return nativeCreate ? data[key] !== void 0 : hasOwnProperty.call(data, key);
546
+ }
547
+ module.exports = hashHas;
548
+ }
549
+ });
550
+
551
+ // ../../node_modules/lodash/_hashSet.js
552
+ var require_hashSet = __commonJS({
553
+ "../../node_modules/lodash/_hashSet.js"(exports, module) {
554
+ var nativeCreate = require_nativeCreate();
555
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
556
+ function hashSet(key, value) {
557
+ var data = this.__data__;
558
+ this.size += this.has(key) ? 0 : 1;
559
+ data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
560
+ return this;
561
+ }
562
+ module.exports = hashSet;
563
+ }
564
+ });
565
+
566
+ // ../../node_modules/lodash/_Hash.js
567
+ var require_Hash = __commonJS({
568
+ "../../node_modules/lodash/_Hash.js"(exports, module) {
569
+ var hashClear = require_hashClear();
570
+ var hashDelete = require_hashDelete();
571
+ var hashGet = require_hashGet();
572
+ var hashHas = require_hashHas();
573
+ var hashSet = require_hashSet();
574
+ function Hash(entries) {
575
+ var index = -1, length = entries == null ? 0 : entries.length;
576
+ this.clear();
577
+ while (++index < length) {
578
+ var entry = entries[index];
579
+ this.set(entry[0], entry[1]);
580
+ }
581
+ }
582
+ Hash.prototype.clear = hashClear;
583
+ Hash.prototype["delete"] = hashDelete;
584
+ Hash.prototype.get = hashGet;
585
+ Hash.prototype.has = hashHas;
586
+ Hash.prototype.set = hashSet;
587
+ module.exports = Hash;
588
+ }
589
+ });
590
+
591
+ // ../../node_modules/lodash/_mapCacheClear.js
592
+ var require_mapCacheClear = __commonJS({
593
+ "../../node_modules/lodash/_mapCacheClear.js"(exports, module) {
594
+ var Hash = require_Hash();
595
+ var ListCache = require_ListCache();
596
+ var Map2 = require_Map();
597
+ function mapCacheClear() {
598
+ this.size = 0;
599
+ this.__data__ = {
600
+ "hash": new Hash(),
601
+ "map": new (Map2 || ListCache)(),
602
+ "string": new Hash()
603
+ };
604
+ }
605
+ module.exports = mapCacheClear;
606
+ }
607
+ });
608
+
609
+ // ../../node_modules/lodash/_isKeyable.js
610
+ var require_isKeyable = __commonJS({
611
+ "../../node_modules/lodash/_isKeyable.js"(exports, module) {
612
+ function isKeyable(value) {
613
+ var type = typeof value;
614
+ return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
615
+ }
616
+ module.exports = isKeyable;
617
+ }
618
+ });
619
+
620
+ // ../../node_modules/lodash/_getMapData.js
621
+ var require_getMapData = __commonJS({
622
+ "../../node_modules/lodash/_getMapData.js"(exports, module) {
623
+ var isKeyable = require_isKeyable();
624
+ function getMapData(map, key) {
625
+ var data = map.__data__;
626
+ return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
627
+ }
628
+ module.exports = getMapData;
629
+ }
630
+ });
631
+
632
+ // ../../node_modules/lodash/_mapCacheDelete.js
633
+ var require_mapCacheDelete = __commonJS({
634
+ "../../node_modules/lodash/_mapCacheDelete.js"(exports, module) {
635
+ var getMapData = require_getMapData();
636
+ function mapCacheDelete(key) {
637
+ var result = getMapData(this, key)["delete"](key);
638
+ this.size -= result ? 1 : 0;
639
+ return result;
640
+ }
641
+ module.exports = mapCacheDelete;
642
+ }
643
+ });
644
+
645
+ // ../../node_modules/lodash/_mapCacheGet.js
646
+ var require_mapCacheGet = __commonJS({
647
+ "../../node_modules/lodash/_mapCacheGet.js"(exports, module) {
648
+ var getMapData = require_getMapData();
649
+ function mapCacheGet(key) {
650
+ return getMapData(this, key).get(key);
651
+ }
652
+ module.exports = mapCacheGet;
653
+ }
654
+ });
655
+
656
+ // ../../node_modules/lodash/_mapCacheHas.js
657
+ var require_mapCacheHas = __commonJS({
658
+ "../../node_modules/lodash/_mapCacheHas.js"(exports, module) {
659
+ var getMapData = require_getMapData();
660
+ function mapCacheHas(key) {
661
+ return getMapData(this, key).has(key);
662
+ }
663
+ module.exports = mapCacheHas;
664
+ }
665
+ });
666
+
667
+ // ../../node_modules/lodash/_mapCacheSet.js
668
+ var require_mapCacheSet = __commonJS({
669
+ "../../node_modules/lodash/_mapCacheSet.js"(exports, module) {
670
+ var getMapData = require_getMapData();
671
+ function mapCacheSet(key, value) {
672
+ var data = getMapData(this, key), size = data.size;
673
+ data.set(key, value);
674
+ this.size += data.size == size ? 0 : 1;
675
+ return this;
676
+ }
677
+ module.exports = mapCacheSet;
678
+ }
679
+ });
680
+
681
+ // ../../node_modules/lodash/_MapCache.js
682
+ var require_MapCache = __commonJS({
683
+ "../../node_modules/lodash/_MapCache.js"(exports, module) {
684
+ var mapCacheClear = require_mapCacheClear();
685
+ var mapCacheDelete = require_mapCacheDelete();
686
+ var mapCacheGet = require_mapCacheGet();
687
+ var mapCacheHas = require_mapCacheHas();
688
+ var mapCacheSet = require_mapCacheSet();
689
+ function MapCache(entries) {
690
+ var index = -1, length = entries == null ? 0 : entries.length;
691
+ this.clear();
692
+ while (++index < length) {
693
+ var entry = entries[index];
694
+ this.set(entry[0], entry[1]);
695
+ }
696
+ }
697
+ MapCache.prototype.clear = mapCacheClear;
698
+ MapCache.prototype["delete"] = mapCacheDelete;
699
+ MapCache.prototype.get = mapCacheGet;
700
+ MapCache.prototype.has = mapCacheHas;
701
+ MapCache.prototype.set = mapCacheSet;
702
+ module.exports = MapCache;
703
+ }
704
+ });
705
+
706
+ // ../../node_modules/lodash/_stackSet.js
707
+ var require_stackSet = __commonJS({
708
+ "../../node_modules/lodash/_stackSet.js"(exports, module) {
709
+ var ListCache = require_ListCache();
710
+ var Map2 = require_Map();
711
+ var MapCache = require_MapCache();
712
+ var LARGE_ARRAY_SIZE = 200;
713
+ function stackSet(key, value) {
714
+ var data = this.__data__;
715
+ if (data instanceof ListCache) {
716
+ var pairs = data.__data__;
717
+ if (!Map2 || pairs.length < LARGE_ARRAY_SIZE - 1) {
718
+ pairs.push([key, value]);
719
+ this.size = ++data.size;
720
+ return this;
721
+ }
722
+ data = this.__data__ = new MapCache(pairs);
723
+ }
724
+ data.set(key, value);
725
+ this.size = data.size;
726
+ return this;
727
+ }
728
+ module.exports = stackSet;
729
+ }
730
+ });
731
+
732
+ // ../../node_modules/lodash/_Stack.js
733
+ var require_Stack = __commonJS({
734
+ "../../node_modules/lodash/_Stack.js"(exports, module) {
735
+ var ListCache = require_ListCache();
736
+ var stackClear = require_stackClear();
737
+ var stackDelete = require_stackDelete();
738
+ var stackGet = require_stackGet();
739
+ var stackHas = require_stackHas();
740
+ var stackSet = require_stackSet();
741
+ function Stack(entries) {
742
+ var data = this.__data__ = new ListCache(entries);
743
+ this.size = data.size;
744
+ }
745
+ Stack.prototype.clear = stackClear;
746
+ Stack.prototype["delete"] = stackDelete;
747
+ Stack.prototype.get = stackGet;
748
+ Stack.prototype.has = stackHas;
749
+ Stack.prototype.set = stackSet;
750
+ module.exports = Stack;
751
+ }
752
+ });
753
+
754
+ // ../../node_modules/lodash/_setCacheAdd.js
755
+ var require_setCacheAdd = __commonJS({
756
+ "../../node_modules/lodash/_setCacheAdd.js"(exports, module) {
757
+ var HASH_UNDEFINED = "__lodash_hash_undefined__";
758
+ function setCacheAdd(value) {
759
+ this.__data__.set(value, HASH_UNDEFINED);
760
+ return this;
761
+ }
762
+ module.exports = setCacheAdd;
763
+ }
764
+ });
765
+
766
+ // ../../node_modules/lodash/_setCacheHas.js
767
+ var require_setCacheHas = __commonJS({
768
+ "../../node_modules/lodash/_setCacheHas.js"(exports, module) {
769
+ function setCacheHas(value) {
770
+ return this.__data__.has(value);
771
+ }
772
+ module.exports = setCacheHas;
773
+ }
774
+ });
775
+
776
+ // ../../node_modules/lodash/_SetCache.js
777
+ var require_SetCache = __commonJS({
778
+ "../../node_modules/lodash/_SetCache.js"(exports, module) {
779
+ var MapCache = require_MapCache();
780
+ var setCacheAdd = require_setCacheAdd();
781
+ var setCacheHas = require_setCacheHas();
782
+ function SetCache(values) {
783
+ var index = -1, length = values == null ? 0 : values.length;
784
+ this.__data__ = new MapCache();
785
+ while (++index < length) {
786
+ this.add(values[index]);
787
+ }
788
+ }
789
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
790
+ SetCache.prototype.has = setCacheHas;
791
+ module.exports = SetCache;
792
+ }
793
+ });
794
+
795
+ // ../../node_modules/lodash/_arraySome.js
796
+ var require_arraySome = __commonJS({
797
+ "../../node_modules/lodash/_arraySome.js"(exports, module) {
798
+ function arraySome(array, predicate) {
799
+ var index = -1, length = array == null ? 0 : array.length;
800
+ while (++index < length) {
801
+ if (predicate(array[index], index, array)) {
802
+ return true;
803
+ }
804
+ }
805
+ return false;
806
+ }
807
+ module.exports = arraySome;
808
+ }
809
+ });
810
+
811
+ // ../../node_modules/lodash/_cacheHas.js
812
+ var require_cacheHas = __commonJS({
813
+ "../../node_modules/lodash/_cacheHas.js"(exports, module) {
814
+ function cacheHas(cache, key) {
815
+ return cache.has(key);
816
+ }
817
+ module.exports = cacheHas;
818
+ }
819
+ });
820
+
821
+ // ../../node_modules/lodash/_equalArrays.js
822
+ var require_equalArrays = __commonJS({
823
+ "../../node_modules/lodash/_equalArrays.js"(exports, module) {
824
+ var SetCache = require_SetCache();
825
+ var arraySome = require_arraySome();
826
+ var cacheHas = require_cacheHas();
827
+ var COMPARE_PARTIAL_FLAG = 1;
828
+ var COMPARE_UNORDERED_FLAG = 2;
829
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
830
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array.length, othLength = other.length;
831
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
832
+ return false;
833
+ }
834
+ var arrStacked = stack.get(array);
835
+ var othStacked = stack.get(other);
836
+ if (arrStacked && othStacked) {
837
+ return arrStacked == other && othStacked == array;
838
+ }
839
+ var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache() : void 0;
840
+ stack.set(array, other);
841
+ stack.set(other, array);
842
+ while (++index < arrLength) {
843
+ var arrValue = array[index], othValue = other[index];
844
+ if (customizer) {
845
+ var compared = isPartial ? customizer(othValue, arrValue, index, other, array, stack) : customizer(arrValue, othValue, index, array, other, stack);
846
+ }
847
+ if (compared !== void 0) {
848
+ if (compared) {
849
+ continue;
850
+ }
851
+ result = false;
852
+ break;
853
+ }
854
+ if (seen) {
855
+ if (!arraySome(other, function(othValue2, othIndex) {
856
+ if (!cacheHas(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
857
+ return seen.push(othIndex);
858
+ }
859
+ })) {
860
+ result = false;
861
+ break;
862
+ }
863
+ } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
864
+ result = false;
865
+ break;
866
+ }
867
+ }
868
+ stack["delete"](array);
869
+ stack["delete"](other);
870
+ return result;
871
+ }
872
+ module.exports = equalArrays;
873
+ }
874
+ });
875
+
876
+ // ../../node_modules/lodash/_Uint8Array.js
877
+ var require_Uint8Array = __commonJS({
878
+ "../../node_modules/lodash/_Uint8Array.js"(exports, module) {
879
+ var root = require_root();
880
+ var Uint8Array2 = root.Uint8Array;
881
+ module.exports = Uint8Array2;
882
+ }
883
+ });
884
+
885
+ // ../../node_modules/lodash/_mapToArray.js
886
+ var require_mapToArray = __commonJS({
887
+ "../../node_modules/lodash/_mapToArray.js"(exports, module) {
888
+ function mapToArray(map) {
889
+ var index = -1, result = Array(map.size);
890
+ map.forEach(function(value, key) {
891
+ result[++index] = [key, value];
892
+ });
893
+ return result;
894
+ }
895
+ module.exports = mapToArray;
896
+ }
897
+ });
898
+
899
+ // ../../node_modules/lodash/_setToArray.js
900
+ var require_setToArray = __commonJS({
901
+ "../../node_modules/lodash/_setToArray.js"(exports, module) {
902
+ function setToArray(set) {
903
+ var index = -1, result = Array(set.size);
904
+ set.forEach(function(value) {
905
+ result[++index] = value;
906
+ });
907
+ return result;
908
+ }
909
+ module.exports = setToArray;
910
+ }
911
+ });
912
+
913
+ // ../../node_modules/lodash/_equalByTag.js
914
+ var require_equalByTag = __commonJS({
915
+ "../../node_modules/lodash/_equalByTag.js"(exports, module) {
916
+ var Symbol2 = require_Symbol();
917
+ var Uint8Array2 = require_Uint8Array();
918
+ var eq = require_eq();
919
+ var equalArrays = require_equalArrays();
920
+ var mapToArray = require_mapToArray();
921
+ var setToArray = require_setToArray();
922
+ var COMPARE_PARTIAL_FLAG = 1;
923
+ var COMPARE_UNORDERED_FLAG = 2;
924
+ var boolTag = "[object Boolean]";
925
+ var dateTag = "[object Date]";
926
+ var errorTag = "[object Error]";
927
+ var mapTag = "[object Map]";
928
+ var numberTag = "[object Number]";
929
+ var regexpTag = "[object RegExp]";
930
+ var setTag = "[object Set]";
931
+ var stringTag = "[object String]";
932
+ var symbolTag = "[object Symbol]";
933
+ var arrayBufferTag = "[object ArrayBuffer]";
934
+ var dataViewTag = "[object DataView]";
935
+ var symbolProto = Symbol2 ? Symbol2.prototype : void 0;
936
+ var symbolValueOf = symbolProto ? symbolProto.valueOf : void 0;
937
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
938
+ switch (tag) {
939
+ case dataViewTag:
940
+ if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
941
+ return false;
942
+ }
943
+ object = object.buffer;
944
+ other = other.buffer;
945
+ case arrayBufferTag:
946
+ if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array2(object), new Uint8Array2(other))) {
947
+ return false;
948
+ }
949
+ return true;
950
+ case boolTag:
951
+ case dateTag:
952
+ case numberTag:
953
+ return eq(+object, +other);
954
+ case errorTag:
955
+ return object.name == other.name && object.message == other.message;
956
+ case regexpTag:
957
+ case stringTag:
958
+ return object == other + "";
959
+ case mapTag:
960
+ var convert = mapToArray;
961
+ case setTag:
962
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
963
+ convert || (convert = setToArray);
964
+ if (object.size != other.size && !isPartial) {
965
+ return false;
966
+ }
967
+ var stacked = stack.get(object);
968
+ if (stacked) {
969
+ return stacked == other;
970
+ }
971
+ bitmask |= COMPARE_UNORDERED_FLAG;
972
+ stack.set(object, other);
973
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
974
+ stack["delete"](object);
975
+ return result;
976
+ case symbolTag:
977
+ if (symbolValueOf) {
978
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
979
+ }
980
+ }
981
+ return false;
982
+ }
983
+ module.exports = equalByTag;
984
+ }
985
+ });
986
+
987
+ // ../../node_modules/lodash/_arrayPush.js
988
+ var require_arrayPush = __commonJS({
989
+ "../../node_modules/lodash/_arrayPush.js"(exports, module) {
990
+ function arrayPush(array, values) {
991
+ var index = -1, length = values.length, offset = array.length;
992
+ while (++index < length) {
993
+ array[offset + index] = values[index];
994
+ }
995
+ return array;
996
+ }
997
+ module.exports = arrayPush;
998
+ }
999
+ });
1000
+
1001
+ // ../../node_modules/lodash/isArray.js
1002
+ var require_isArray = __commonJS({
1003
+ "../../node_modules/lodash/isArray.js"(exports, module) {
1004
+ var isArray = Array.isArray;
1005
+ module.exports = isArray;
1006
+ }
1007
+ });
1008
+
1009
+ // ../../node_modules/lodash/_baseGetAllKeys.js
1010
+ var require_baseGetAllKeys = __commonJS({
1011
+ "../../node_modules/lodash/_baseGetAllKeys.js"(exports, module) {
1012
+ var arrayPush = require_arrayPush();
1013
+ var isArray = require_isArray();
1014
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1015
+ var result = keysFunc(object);
1016
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1017
+ }
1018
+ module.exports = baseGetAllKeys;
1019
+ }
1020
+ });
1021
+
1022
+ // ../../node_modules/lodash/_arrayFilter.js
1023
+ var require_arrayFilter = __commonJS({
1024
+ "../../node_modules/lodash/_arrayFilter.js"(exports, module) {
1025
+ function arrayFilter(array, predicate) {
1026
+ var index = -1, length = array == null ? 0 : array.length, resIndex = 0, result = [];
1027
+ while (++index < length) {
1028
+ var value = array[index];
1029
+ if (predicate(value, index, array)) {
1030
+ result[resIndex++] = value;
1031
+ }
1032
+ }
1033
+ return result;
1034
+ }
1035
+ module.exports = arrayFilter;
1036
+ }
1037
+ });
1038
+
1039
+ // ../../node_modules/lodash/stubArray.js
1040
+ var require_stubArray = __commonJS({
1041
+ "../../node_modules/lodash/stubArray.js"(exports, module) {
1042
+ function stubArray() {
1043
+ return [];
1044
+ }
1045
+ module.exports = stubArray;
1046
+ }
1047
+ });
1048
+
1049
+ // ../../node_modules/lodash/_getSymbols.js
1050
+ var require_getSymbols = __commonJS({
1051
+ "../../node_modules/lodash/_getSymbols.js"(exports, module) {
1052
+ var arrayFilter = require_arrayFilter();
1053
+ var stubArray = require_stubArray();
1054
+ var objectProto = Object.prototype;
1055
+ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1056
+ var nativeGetSymbols = Object.getOwnPropertySymbols;
1057
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1058
+ if (object == null) {
1059
+ return [];
1060
+ }
1061
+ object = Object(object);
1062
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1063
+ return propertyIsEnumerable.call(object, symbol);
1064
+ });
1065
+ };
1066
+ module.exports = getSymbols;
1067
+ }
1068
+ });
1069
+
1070
+ // ../../node_modules/lodash/_baseTimes.js
1071
+ var require_baseTimes = __commonJS({
1072
+ "../../node_modules/lodash/_baseTimes.js"(exports, module) {
1073
+ function baseTimes(n, iteratee) {
1074
+ var index = -1, result = Array(n);
1075
+ while (++index < n) {
1076
+ result[index] = iteratee(index);
1077
+ }
1078
+ return result;
1079
+ }
1080
+ module.exports = baseTimes;
1081
+ }
1082
+ });
1083
+
1084
+ // ../../node_modules/lodash/isObjectLike.js
1085
+ var require_isObjectLike = __commonJS({
1086
+ "../../node_modules/lodash/isObjectLike.js"(exports, module) {
1087
+ function isObjectLike(value) {
1088
+ return value != null && typeof value == "object";
1089
+ }
1090
+ module.exports = isObjectLike;
1091
+ }
1092
+ });
1093
+
1094
+ // ../../node_modules/lodash/_baseIsArguments.js
1095
+ var require_baseIsArguments = __commonJS({
1096
+ "../../node_modules/lodash/_baseIsArguments.js"(exports, module) {
1097
+ var baseGetTag = require_baseGetTag();
1098
+ var isObjectLike = require_isObjectLike();
1099
+ var argsTag = "[object Arguments]";
1100
+ function baseIsArguments(value) {
1101
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
1102
+ }
1103
+ module.exports = baseIsArguments;
1104
+ }
1105
+ });
1106
+
1107
+ // ../../node_modules/lodash/isArguments.js
1108
+ var require_isArguments = __commonJS({
1109
+ "../../node_modules/lodash/isArguments.js"(exports, module) {
1110
+ var baseIsArguments = require_baseIsArguments();
1111
+ var isObjectLike = require_isObjectLike();
1112
+ var objectProto = Object.prototype;
1113
+ var hasOwnProperty = objectProto.hasOwnProperty;
1114
+ var propertyIsEnumerable = objectProto.propertyIsEnumerable;
1115
+ var isArguments = baseIsArguments(/* @__PURE__ */ function() {
1116
+ return arguments;
1117
+ }()) ? baseIsArguments : function(value) {
1118
+ return isObjectLike(value) && hasOwnProperty.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
1119
+ };
1120
+ module.exports = isArguments;
1121
+ }
1122
+ });
1123
+
1124
+ // ../../node_modules/lodash/stubFalse.js
1125
+ var require_stubFalse = __commonJS({
1126
+ "../../node_modules/lodash/stubFalse.js"(exports, module) {
1127
+ function stubFalse() {
1128
+ return false;
1129
+ }
1130
+ module.exports = stubFalse;
1131
+ }
1132
+ });
1133
+
1134
+ // ../../node_modules/lodash/isBuffer.js
1135
+ var require_isBuffer = __commonJS({
1136
+ "../../node_modules/lodash/isBuffer.js"(exports, module) {
1137
+ var root = require_root();
1138
+ var stubFalse = require_stubFalse();
1139
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1140
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1141
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1142
+ var Buffer2 = moduleExports ? root.Buffer : void 0;
1143
+ var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
1144
+ var isBuffer = nativeIsBuffer || stubFalse;
1145
+ module.exports = isBuffer;
1146
+ }
1147
+ });
1148
+
1149
+ // ../../node_modules/lodash/_isIndex.js
1150
+ var require_isIndex = __commonJS({
1151
+ "../../node_modules/lodash/_isIndex.js"(exports, module) {
1152
+ var MAX_SAFE_INTEGER = 9007199254740991;
1153
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
1154
+ function isIndex(value, length) {
1155
+ var type = typeof value;
1156
+ length = length == null ? MAX_SAFE_INTEGER : length;
1157
+ return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
1158
+ }
1159
+ module.exports = isIndex;
1160
+ }
1161
+ });
1162
+
1163
+ // ../../node_modules/lodash/isLength.js
1164
+ var require_isLength = __commonJS({
1165
+ "../../node_modules/lodash/isLength.js"(exports, module) {
1166
+ var MAX_SAFE_INTEGER = 9007199254740991;
1167
+ function isLength2(value) {
1168
+ return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1169
+ }
1170
+ module.exports = isLength2;
1171
+ }
1172
+ });
1173
+
1174
+ // ../../node_modules/lodash/_baseIsTypedArray.js
1175
+ var require_baseIsTypedArray = __commonJS({
1176
+ "../../node_modules/lodash/_baseIsTypedArray.js"(exports, module) {
1177
+ var baseGetTag = require_baseGetTag();
1178
+ var isLength2 = require_isLength();
1179
+ var isObjectLike = require_isObjectLike();
1180
+ var argsTag = "[object Arguments]";
1181
+ var arrayTag = "[object Array]";
1182
+ var boolTag = "[object Boolean]";
1183
+ var dateTag = "[object Date]";
1184
+ var errorTag = "[object Error]";
1185
+ var funcTag = "[object Function]";
1186
+ var mapTag = "[object Map]";
1187
+ var numberTag = "[object Number]";
1188
+ var objectTag = "[object Object]";
1189
+ var regexpTag = "[object RegExp]";
1190
+ var setTag = "[object Set]";
1191
+ var stringTag = "[object String]";
1192
+ var weakMapTag = "[object WeakMap]";
1193
+ var arrayBufferTag = "[object ArrayBuffer]";
1194
+ var dataViewTag = "[object DataView]";
1195
+ var float32Tag = "[object Float32Array]";
1196
+ var float64Tag = "[object Float64Array]";
1197
+ var int8Tag = "[object Int8Array]";
1198
+ var int16Tag = "[object Int16Array]";
1199
+ var int32Tag = "[object Int32Array]";
1200
+ var uint8Tag = "[object Uint8Array]";
1201
+ var uint8ClampedTag = "[object Uint8ClampedArray]";
1202
+ var uint16Tag = "[object Uint16Array]";
1203
+ var uint32Tag = "[object Uint32Array]";
1204
+ var typedArrayTags = {};
1205
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
1206
+ 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;
1207
+ function baseIsTypedArray(value) {
1208
+ return isObjectLike(value) && isLength2(value.length) && !!typedArrayTags[baseGetTag(value)];
1209
+ }
1210
+ module.exports = baseIsTypedArray;
1211
+ }
1212
+ });
1213
+
1214
+ // ../../node_modules/lodash/_baseUnary.js
1215
+ var require_baseUnary = __commonJS({
1216
+ "../../node_modules/lodash/_baseUnary.js"(exports, module) {
1217
+ function baseUnary(func) {
1218
+ return function(value) {
1219
+ return func(value);
1220
+ };
1221
+ }
1222
+ module.exports = baseUnary;
1223
+ }
1224
+ });
1225
+
1226
+ // ../../node_modules/lodash/_nodeUtil.js
1227
+ var require_nodeUtil = __commonJS({
1228
+ "../../node_modules/lodash/_nodeUtil.js"(exports, module) {
1229
+ var freeGlobal = require_freeGlobal();
1230
+ var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
1231
+ var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
1232
+ var moduleExports = freeModule && freeModule.exports === freeExports;
1233
+ var freeProcess = moduleExports && freeGlobal.process;
1234
+ var nodeUtil = function() {
1235
+ try {
1236
+ var types = freeModule && freeModule.require && freeModule.require("util").types;
1237
+ if (types) {
1238
+ return types;
1239
+ }
1240
+ return freeProcess && freeProcess.binding && freeProcess.binding("util");
1241
+ } catch (e) {
1242
+ }
1243
+ }();
1244
+ module.exports = nodeUtil;
1245
+ }
1246
+ });
1247
+
1248
+ // ../../node_modules/lodash/isTypedArray.js
1249
+ var require_isTypedArray = __commonJS({
1250
+ "../../node_modules/lodash/isTypedArray.js"(exports, module) {
1251
+ var baseIsTypedArray = require_baseIsTypedArray();
1252
+ var baseUnary = require_baseUnary();
1253
+ var nodeUtil = require_nodeUtil();
1254
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1255
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1256
+ module.exports = isTypedArray;
1257
+ }
1258
+ });
1259
+
1260
+ // ../../node_modules/lodash/_arrayLikeKeys.js
1261
+ var require_arrayLikeKeys = __commonJS({
1262
+ "../../node_modules/lodash/_arrayLikeKeys.js"(exports, module) {
1263
+ var baseTimes = require_baseTimes();
1264
+ var isArguments = require_isArguments();
1265
+ var isArray = require_isArray();
1266
+ var isBuffer = require_isBuffer();
1267
+ var isIndex = require_isIndex();
1268
+ var isTypedArray = require_isTypedArray();
1269
+ var objectProto = Object.prototype;
1270
+ var hasOwnProperty = objectProto.hasOwnProperty;
1271
+ function arrayLikeKeys(value, inherited) {
1272
+ 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;
1273
+ for (var key in value) {
1274
+ if ((inherited || hasOwnProperty.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
1275
+ (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
1276
+ isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
1277
+ isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
1278
+ isIndex(key, length)))) {
1279
+ result.push(key);
1280
+ }
1281
+ }
1282
+ return result;
1283
+ }
1284
+ module.exports = arrayLikeKeys;
1285
+ }
1286
+ });
1287
+
1288
+ // ../../node_modules/lodash/_isPrototype.js
1289
+ var require_isPrototype = __commonJS({
1290
+ "../../node_modules/lodash/_isPrototype.js"(exports, module) {
1291
+ var objectProto = Object.prototype;
1292
+ function isPrototype(value) {
1293
+ var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto;
1294
+ return value === proto;
1295
+ }
1296
+ module.exports = isPrototype;
1297
+ }
1298
+ });
1299
+
1300
+ // ../../node_modules/lodash/_overArg.js
1301
+ var require_overArg = __commonJS({
1302
+ "../../node_modules/lodash/_overArg.js"(exports, module) {
1303
+ function overArg(func, transform) {
1304
+ return function(arg) {
1305
+ return func(transform(arg));
1306
+ };
1307
+ }
1308
+ module.exports = overArg;
1309
+ }
1310
+ });
1311
+
1312
+ // ../../node_modules/lodash/_nativeKeys.js
1313
+ var require_nativeKeys = __commonJS({
1314
+ "../../node_modules/lodash/_nativeKeys.js"(exports, module) {
1315
+ var overArg = require_overArg();
1316
+ var nativeKeys = overArg(Object.keys, Object);
1317
+ module.exports = nativeKeys;
1318
+ }
1319
+ });
1320
+
1321
+ // ../../node_modules/lodash/_baseKeys.js
1322
+ var require_baseKeys = __commonJS({
1323
+ "../../node_modules/lodash/_baseKeys.js"(exports, module) {
1324
+ var isPrototype = require_isPrototype();
1325
+ var nativeKeys = require_nativeKeys();
1326
+ var objectProto = Object.prototype;
1327
+ var hasOwnProperty = objectProto.hasOwnProperty;
1328
+ function baseKeys(object) {
1329
+ if (!isPrototype(object)) {
1330
+ return nativeKeys(object);
1331
+ }
1332
+ var result = [];
1333
+ for (var key in Object(object)) {
1334
+ if (hasOwnProperty.call(object, key) && key != "constructor") {
1335
+ result.push(key);
1336
+ }
1337
+ }
1338
+ return result;
1339
+ }
1340
+ module.exports = baseKeys;
1341
+ }
1342
+ });
1343
+
1344
+ // ../../node_modules/lodash/isArrayLike.js
1345
+ var require_isArrayLike = __commonJS({
1346
+ "../../node_modules/lodash/isArrayLike.js"(exports, module) {
1347
+ var isFunction = require_isFunction();
1348
+ var isLength2 = require_isLength();
1349
+ function isArrayLike(value) {
1350
+ return value != null && isLength2(value.length) && !isFunction(value);
1351
+ }
1352
+ module.exports = isArrayLike;
1353
+ }
1354
+ });
1355
+
1356
+ // ../../node_modules/lodash/keys.js
1357
+ var require_keys = __commonJS({
1358
+ "../../node_modules/lodash/keys.js"(exports, module) {
1359
+ var arrayLikeKeys = require_arrayLikeKeys();
1360
+ var baseKeys = require_baseKeys();
1361
+ var isArrayLike = require_isArrayLike();
1362
+ function keys(object) {
1363
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1364
+ }
1365
+ module.exports = keys;
1366
+ }
1367
+ });
1368
+
1369
+ // ../../node_modules/lodash/_getAllKeys.js
1370
+ var require_getAllKeys = __commonJS({
1371
+ "../../node_modules/lodash/_getAllKeys.js"(exports, module) {
1372
+ var baseGetAllKeys = require_baseGetAllKeys();
1373
+ var getSymbols = require_getSymbols();
1374
+ var keys = require_keys();
1375
+ function getAllKeys(object) {
1376
+ return baseGetAllKeys(object, keys, getSymbols);
1377
+ }
1378
+ module.exports = getAllKeys;
1379
+ }
1380
+ });
1381
+
1382
+ // ../../node_modules/lodash/_equalObjects.js
1383
+ var require_equalObjects = __commonJS({
1384
+ "../../node_modules/lodash/_equalObjects.js"(exports, module) {
1385
+ var getAllKeys = require_getAllKeys();
1386
+ var COMPARE_PARTIAL_FLAG = 1;
1387
+ var objectProto = Object.prototype;
1388
+ var hasOwnProperty = objectProto.hasOwnProperty;
1389
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1390
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG, objProps = getAllKeys(object), objLength = objProps.length, othProps = getAllKeys(other), othLength = othProps.length;
1391
+ if (objLength != othLength && !isPartial) {
1392
+ return false;
1393
+ }
1394
+ var index = objLength;
1395
+ while (index--) {
1396
+ var key = objProps[index];
1397
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1398
+ return false;
1399
+ }
1400
+ }
1401
+ var objStacked = stack.get(object);
1402
+ var othStacked = stack.get(other);
1403
+ if (objStacked && othStacked) {
1404
+ return objStacked == other && othStacked == object;
1405
+ }
1406
+ var result = true;
1407
+ stack.set(object, other);
1408
+ stack.set(other, object);
1409
+ var skipCtor = isPartial;
1410
+ while (++index < objLength) {
1411
+ key = objProps[index];
1412
+ var objValue = object[key], othValue = other[key];
1413
+ if (customizer) {
1414
+ var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
1415
+ }
1416
+ if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
1417
+ result = false;
1418
+ break;
1419
+ }
1420
+ skipCtor || (skipCtor = key == "constructor");
1421
+ }
1422
+ if (result && !skipCtor) {
1423
+ var objCtor = object.constructor, othCtor = other.constructor;
1424
+ if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
1425
+ result = false;
1426
+ }
1427
+ }
1428
+ stack["delete"](object);
1429
+ stack["delete"](other);
1430
+ return result;
1431
+ }
1432
+ module.exports = equalObjects;
1433
+ }
1434
+ });
1435
+
1436
+ // ../../node_modules/lodash/_DataView.js
1437
+ var require_DataView = __commonJS({
1438
+ "../../node_modules/lodash/_DataView.js"(exports, module) {
1439
+ var getNative = require_getNative();
1440
+ var root = require_root();
1441
+ var DataView = getNative(root, "DataView");
1442
+ module.exports = DataView;
1443
+ }
1444
+ });
1445
+
1446
+ // ../../node_modules/lodash/_Promise.js
1447
+ var require_Promise = __commonJS({
1448
+ "../../node_modules/lodash/_Promise.js"(exports, module) {
1449
+ var getNative = require_getNative();
1450
+ var root = require_root();
1451
+ var Promise2 = getNative(root, "Promise");
1452
+ module.exports = Promise2;
1453
+ }
1454
+ });
1455
+
1456
+ // ../../node_modules/lodash/_Set.js
1457
+ var require_Set = __commonJS({
1458
+ "../../node_modules/lodash/_Set.js"(exports, module) {
1459
+ var getNative = require_getNative();
1460
+ var root = require_root();
1461
+ var Set2 = getNative(root, "Set");
1462
+ module.exports = Set2;
1463
+ }
1464
+ });
1465
+
1466
+ // ../../node_modules/lodash/_WeakMap.js
1467
+ var require_WeakMap = __commonJS({
1468
+ "../../node_modules/lodash/_WeakMap.js"(exports, module) {
1469
+ var getNative = require_getNative();
1470
+ var root = require_root();
1471
+ var WeakMap2 = getNative(root, "WeakMap");
1472
+ module.exports = WeakMap2;
1473
+ }
1474
+ });
1475
+
1476
+ // ../../node_modules/lodash/_getTag.js
1477
+ var require_getTag = __commonJS({
1478
+ "../../node_modules/lodash/_getTag.js"(exports, module) {
1479
+ var DataView = require_DataView();
1480
+ var Map2 = require_Map();
1481
+ var Promise2 = require_Promise();
1482
+ var Set2 = require_Set();
1483
+ var WeakMap2 = require_WeakMap();
1484
+ var baseGetTag = require_baseGetTag();
1485
+ var toSource = require_toSource();
1486
+ var mapTag = "[object Map]";
1487
+ var objectTag = "[object Object]";
1488
+ var promiseTag = "[object Promise]";
1489
+ var setTag = "[object Set]";
1490
+ var weakMapTag = "[object WeakMap]";
1491
+ var dataViewTag = "[object DataView]";
1492
+ var dataViewCtorString = toSource(DataView);
1493
+ var mapCtorString = toSource(Map2);
1494
+ var promiseCtorString = toSource(Promise2);
1495
+ var setCtorString = toSource(Set2);
1496
+ var weakMapCtorString = toSource(WeakMap2);
1497
+ var getTag = baseGetTag;
1498
+ 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) {
1499
+ getTag = function(value) {
1500
+ var result = baseGetTag(value), Ctor = result == objectTag ? value.constructor : void 0, ctorString = Ctor ? toSource(Ctor) : "";
1501
+ if (ctorString) {
1502
+ switch (ctorString) {
1503
+ case dataViewCtorString:
1504
+ return dataViewTag;
1505
+ case mapCtorString:
1506
+ return mapTag;
1507
+ case promiseCtorString:
1508
+ return promiseTag;
1509
+ case setCtorString:
1510
+ return setTag;
1511
+ case weakMapCtorString:
1512
+ return weakMapTag;
1513
+ }
1514
+ }
1515
+ return result;
1516
+ };
1517
+ }
1518
+ module.exports = getTag;
1519
+ }
1520
+ });
1521
+
1522
+ // ../../node_modules/lodash/_baseIsEqualDeep.js
1523
+ var require_baseIsEqualDeep = __commonJS({
1524
+ "../../node_modules/lodash/_baseIsEqualDeep.js"(exports, module) {
1525
+ var Stack = require_Stack();
1526
+ var equalArrays = require_equalArrays();
1527
+ var equalByTag = require_equalByTag();
1528
+ var equalObjects = require_equalObjects();
1529
+ var getTag = require_getTag();
1530
+ var isArray = require_isArray();
1531
+ var isBuffer = require_isBuffer();
1532
+ var isTypedArray = require_isTypedArray();
1533
+ var COMPARE_PARTIAL_FLAG = 1;
1534
+ var argsTag = "[object Arguments]";
1535
+ var arrayTag = "[object Array]";
1536
+ var objectTag = "[object Object]";
1537
+ var objectProto = Object.prototype;
1538
+ var hasOwnProperty = objectProto.hasOwnProperty;
1539
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1540
+ var objIsArr = isArray(object), othIsArr = isArray(other), objTag = objIsArr ? arrayTag : getTag(object), othTag = othIsArr ? arrayTag : getTag(other);
1541
+ objTag = objTag == argsTag ? objectTag : objTag;
1542
+ othTag = othTag == argsTag ? objectTag : othTag;
1543
+ var objIsObj = objTag == objectTag, othIsObj = othTag == objectTag, isSameTag = objTag == othTag;
1544
+ if (isSameTag && isBuffer(object)) {
1545
+ if (!isBuffer(other)) {
1546
+ return false;
1547
+ }
1548
+ objIsArr = true;
1549
+ objIsObj = false;
1550
+ }
1551
+ if (isSameTag && !objIsObj) {
1552
+ stack || (stack = new Stack());
1553
+ return objIsArr || isTypedArray(object) ? equalArrays(object, other, bitmask, customizer, equalFunc, stack) : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1554
+ }
1555
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
1556
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty.call(other, "__wrapped__");
1557
+ if (objIsWrapped || othIsWrapped) {
1558
+ var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
1559
+ stack || (stack = new Stack());
1560
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1561
+ }
1562
+ }
1563
+ if (!isSameTag) {
1564
+ return false;
1565
+ }
1566
+ stack || (stack = new Stack());
1567
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1568
+ }
1569
+ module.exports = baseIsEqualDeep;
1570
+ }
1571
+ });
1572
+
1573
+ // ../../node_modules/lodash/_baseIsEqual.js
1574
+ var require_baseIsEqual = __commonJS({
1575
+ "../../node_modules/lodash/_baseIsEqual.js"(exports, module) {
1576
+ var baseIsEqualDeep = require_baseIsEqualDeep();
1577
+ var isObjectLike = require_isObjectLike();
1578
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
1579
+ if (value === other) {
1580
+ return true;
1581
+ }
1582
+ if (value == null || other == null || !isObjectLike(value) && !isObjectLike(other)) {
1583
+ return value !== value && other !== other;
1584
+ }
1585
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1586
+ }
1587
+ module.exports = baseIsEqual;
1588
+ }
1589
+ });
1590
+
1591
+ // ../../node_modules/lodash/isEqual.js
1592
+ var require_isEqual = __commonJS({
1593
+ "../../node_modules/lodash/isEqual.js"(exports, module) {
1594
+ var baseIsEqual = require_baseIsEqual();
1595
+ function isEqual2(value, other) {
1596
+ return baseIsEqual(value, other);
1597
+ }
1598
+ module.exports = isEqual2;
1599
+ }
1600
+ });
63
1601
 
64
1602
  // src/lib/types/ISTDate.ts
65
1603
  function formatISTDate(date, options) {
@@ -4055,11 +5593,18 @@ var getRoleLabel = (role) => {
4055
5593
  var getRoleDescription = (role) => {
4056
5594
  return getRoleMetadata(role)?.description || "";
4057
5595
  };
5596
+ var getRoleAssignmentKind = (role) => {
5597
+ return getRoleMetadata(role)?.assignmentKind || null;
5598
+ };
4058
5599
  var isFactoryScopedRole = (role) => {
4059
5600
  const normalizedRole = normalizeRoleLevel(role);
4060
5601
  return normalizedRole ? FACTORY_SCOPED_ROLE_SET.has(normalizedRole) : false;
4061
5602
  };
4062
5603
  var isSupervisorRole = (role) => normalizeRoleLevel(role) === "supervisor";
5604
+ var canRoleManageCompany = (role) => {
5605
+ const normalizedRole = normalizeRoleLevel(role);
5606
+ return normalizedRole === "owner" || normalizedRole === "it";
5607
+ };
4063
5608
  var canRoleManageUsers = (role) => {
4064
5609
  const normalizedRole = normalizeRoleLevel(role);
4065
5610
  return normalizedRole === "optifye" || normalizedRole === "owner" || normalizedRole === "it" || isFactoryScopedRole(normalizedRole);
@@ -4072,12 +5617,23 @@ var canRoleViewUsageStats = (role) => {
4072
5617
  const normalizedRole = normalizeRoleLevel(role);
4073
5618
  return normalizedRole === "optifye" || normalizedRole === "owner" || normalizedRole === "it";
4074
5619
  };
5620
+ var canRoleViewClipsCost = (role) => {
5621
+ const normalizedRole = normalizeRoleLevel(role);
5622
+ return normalizedRole === "optifye" || normalizedRole === "owner";
5623
+ };
4075
5624
  var canRoleAccessTeamManagement = (role) => {
4076
5625
  return canRoleManageUsers(role);
4077
5626
  };
4078
5627
  var getRoleNavPaths = (role) => {
4079
5628
  return getRoleMetadata(role)?.navPaths || [];
4080
5629
  };
5630
+ var canRoleAccessDashboardPath = (path, role) => {
5631
+ const basePath = `/${path.split("?")[0].split("/").filter(Boolean)[0] || ""}`.replace(/\/$/, "") || "/";
5632
+ if (basePath === "/clips-cost") {
5633
+ return canRoleViewClipsCost(role);
5634
+ }
5635
+ return getRoleNavPaths(role).includes(basePath);
5636
+ };
4081
5637
  var getVisibleRolesForCurrentUser = (currentRole) => {
4082
5638
  const normalizedRole = normalizeRoleLevel(currentRole);
4083
5639
  const visibleRolesByCurrentRole = {
@@ -5882,6 +7438,16 @@ var getClipCycleTimeFrames = (metadata) => {
5882
7438
  }
5883
7439
  return parseFiniteNumber(metadata?.request?.metadata?.cycle_time);
5884
7440
  };
7441
+ var getClipCaptureFps = (clip) => {
7442
+ return parseFiniteNumber(clip?.capture_fps) ?? parseFiniteNumber(clip?.metadata?.playlist?.fps) ?? 20;
7443
+ };
7444
+ var getClipCycleTimeSeconds = (clip) => {
7445
+ const cycleTimeFrames = getClipCycleTimeFrames(clip?.metadata);
7446
+ if (cycleTimeFrames === void 0) {
7447
+ return void 0;
7448
+ }
7449
+ return cycleTimeFrames / getClipCaptureFps(clip);
7450
+ };
5885
7451
  var getSupabaseClient = () => {
5886
7452
  const existing = _getSupabaseInstanceOptional();
5887
7453
  if (existing) {
@@ -6394,10 +7960,10 @@ var S3ClipsSupabaseService = class {
6394
7960
  const transformedClips = (response.clips || []).map((clip) => {
6395
7961
  const clipId = clip.id ?? clip.clip_id;
6396
7962
  const clipType = clip.type ?? clip.clip_type_name;
6397
- const cycleTimeSeconds = parseFiniteNumber(clip.cycle_time_seconds) ?? (() => {
6398
- const cycleTimeFrames = getClipCycleTimeFrames(clip.metadata);
6399
- return cycleTimeFrames !== void 0 ? cycleTimeFrames / (clip.metadata?.playlist?.fps || 20) : void 0;
6400
- })();
7963
+ const cycleTimeSeconds = parseFiniteNumber(clip.cycle_time_seconds) ?? getClipCycleTimeSeconds({
7964
+ capture_fps: clip.capture_fps,
7965
+ metadata: clip.metadata
7966
+ });
6401
7967
  return {
6402
7968
  id: clipId,
6403
7969
  src: clip.src ?? clip.playlist,
@@ -37947,7 +39513,7 @@ var FileManagerFilters = ({
37947
39513
  ] }) })
37948
39514
  ] }, node.id);
37949
39515
  };
37950
- return /* @__PURE__ */ jsxRuntime.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: [
39516
+ return /* @__PURE__ */ jsxRuntime.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: [
37951
39517
  /* @__PURE__ */ jsxRuntime.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: [
37952
39518
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
37953
39519
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
@@ -38029,7 +39595,7 @@ var FileManagerFilters = ({
38029
39595
  /* @__PURE__ */ jsxRuntime.jsxs(
38030
39596
  "div",
38031
39597
  {
38032
- 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",
39598
+ 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",
38033
39599
  onClick: (e) => e.stopPropagation(),
38034
39600
  children: [
38035
39601
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-3 flex items-center justify-between border-b border-slate-200", children: [
@@ -38086,7 +39652,7 @@ var FileManagerFilters = ({
38086
39652
  /* @__PURE__ */ jsxRuntime.jsxs(
38087
39653
  "div",
38088
39654
  {
38089
- 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",
39655
+ 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",
38090
39656
  onClick: (e) => e.stopPropagation(),
38091
39657
  children: [
38092
39658
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-3 flex items-center justify-between border-b border-slate-200", children: [
@@ -38203,7 +39769,7 @@ var FileManagerFilters = ({
38203
39769
  }
38204
39770
  )
38205
39771
  ] }),
38206
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-3 h-[calc(100%-8rem)] overflow-y-auto scrollbar-thin", children: [
39772
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-3 flex-1 min-h-0 overflow-y-auto scrollbar-thin", children: [
38207
39773
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2", children: filterTree.map((node) => renderNode(node)) }),
38208
39774
  filterTree.length === 0 && isTimeFilterActive && (startTime || endTime) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center py-12", children: [
38209
39775
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-slate-300 mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock, { className: "h-12 w-12 mx-auto" }) }),
@@ -40314,17 +41880,17 @@ var BottlenecksContent = ({
40314
41880
  }
40315
41881
  }, [workspaceTargetCycleTime]);
40316
41882
  if (!dashboardConfig?.s3Config) {
40317
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center h-[calc(100vh-12rem)] text-center", children: [
41883
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center min-h-[calc(100dvh-12rem)] text-center", children: [
40318
41884
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "w-12 h-12 text-red-400 mb-3" }),
40319
41885
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-red-700 mb-1", children: "S3 Configuration Missing" }),
40320
41886
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600 max-w-md", children: "S3 configuration is required to load video clips. Please check your dashboard configuration." })
40321
41887
  ] });
40322
41888
  }
40323
41889
  if (clipTypesLoading && allVideos.length === 0 && Object.keys(mergedCounts).length === 0) {
40324
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow p-4 flex items-center justify-center h-[calc(100vh-12rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading clips..." }) });
41890
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow p-4 flex items-center justify-center min-h-[calc(100dvh-12rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading clips..." }) });
40325
41891
  }
40326
41892
  if (error && error.type === "fatal" && !hasInitialLoad || clipTypesError) {
40327
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center h-[calc(100vh-12rem)] text-center", children: [
41893
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center min-h-[calc(100dvh-12rem)] text-center", children: [
40328
41894
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.XCircle, { className: "w-12 h-12 text-red-400 mb-3" }),
40329
41895
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-red-700 mb-1", children: "Error Loading Clips" }),
40330
41896
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600 max-w-md", children: error?.message || clipTypesError })
@@ -40339,7 +41905,7 @@ var BottlenecksContent = ({
40339
41905
  clipTypesError,
40340
41906
  mergedCounts
40341
41907
  });
40342
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-1.5 sm:p-2 lg:p-4 h-[calc(100vh-12rem)] relative", children: [
41908
+ return /* @__PURE__ */ jsxRuntime.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: [
40343
41909
  hasNewClips && newClipsNotification && /* @__PURE__ */ jsxRuntime.jsx(
40344
41910
  NewClipsNotification,
40345
41911
  {
@@ -40348,8 +41914,8 @@ var BottlenecksContent = ({
40348
41914
  onDismiss: clearNotification
40349
41915
  }
40350
41916
  ),
40351
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col lg:flex-row gap-4 h-full", children: [
40352
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-w-0 lg:flex-[3]", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white rounded-lg shadow-sm overflow-hidden h-full", children: filteredVideos.length > 0 && currentVideo && !isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative h-full group", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full h-full overflow-hidden rounded-md shadow-inner bg-gray-900", children: [
41917
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 lg:flex-row lg:h-full", children: [
41918
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-0 w-full lg:flex-[3] lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white rounded-lg shadow-sm overflow-hidden lg:h-full", children: filteredVideos.length > 0 && currentVideo && !isFullscreen ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative group lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative w-full aspect-video lg:aspect-auto lg:h-full overflow-hidden rounded-md shadow-inner bg-gray-900", children: [
40353
41919
  /* @__PURE__ */ jsxRuntime.jsx(
40354
41920
  "div",
40355
41921
  {
@@ -40499,23 +42065,23 @@ var BottlenecksContent = ({
40499
42065
  )
40500
42066
  ] }) }) }) : (
40501
42067
  /* Priority 5: Show "no clips found" only if we have counts and there are truly no clips for workspace */
40502
- hasInitialLoad && Object.keys(mergedCounts).length > 0 && Object.values(mergedCounts).every((count) => count === 0) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
42068
+ hasInitialLoad && Object.keys(mergedCounts).length > 0 && Object.values(mergedCounts).every((count) => count === 0) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-[220px] sm:min-h-[320px] lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
40503
42069
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.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" }) }),
40504
42070
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-medium text-gray-700 mb-2", children: "No Clips Found" }),
40505
42071
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500", children: "There were no video clips found for this workspace today." })
40506
42072
  ] }) }) : (
40507
42073
  /* Priority 6: Show "no matching clips" only if we have data loaded and specifically no clips for this filter */
40508
- hasInitialLoad && (mergedCounts[activeFilter] || 0) === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
42074
+ hasInitialLoad && (mergedCounts[activeFilter] || 0) === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-[220px] sm:min-h-[320px] lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
40509
42075
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.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" }) }),
40510
42076
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-medium text-gray-700 mb-2", children: "No Matching Clips" }),
40511
42077
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500", children: "There are no clips matching the selected filter." })
40512
42078
  ] }) }) : (
40513
42079
  /* Priority 7: Default loading state for any other case */
40514
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full h-full overflow-hidden rounded-md shadow-inner bg-gray-900 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading..." }) }) }) })
42080
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 lg:h-full", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative lg:h-full", children: /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading..." }) }) }) })
40515
42081
  )
40516
42082
  )
40517
42083
  ) }) }),
40518
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0 lg:flex-[1] lg:min-w-[280px] lg:max-w-[320px]", children: triageMode ? (
42084
+ /* @__PURE__ */ jsxRuntime.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 ? (
40519
42085
  /* Triage Mode - Direct tile view for cycle completions and idle time */
40520
42086
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-lg shadow-sm h-full overflow-hidden flex flex-col", children: [
40521
42087
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-4 py-3 border-b border-gray-100", children: [
@@ -42826,10 +44392,15 @@ var IdleTimeReasonChartComponent = ({
42826
44392
  data,
42827
44393
  isLoading = false,
42828
44394
  error = null,
42829
- hideTotalDuration = false
44395
+ hideTotalDuration = false,
44396
+ updateAnimation = "replay"
42830
44397
  }) => {
42831
44398
  const [activeData, setActiveData] = React141__namespace.default.useState([]);
42832
44399
  React141__namespace.default.useEffect(() => {
44400
+ if (updateAnimation === "smooth") {
44401
+ setActiveData(data && data.length > 0 ? data : []);
44402
+ return;
44403
+ }
42833
44404
  if (activeData.length > 0) {
42834
44405
  setActiveData([]);
42835
44406
  }
@@ -42843,7 +44414,7 @@ var IdleTimeReasonChartComponent = ({
42843
44414
  } else {
42844
44415
  setActiveData([]);
42845
44416
  }
42846
- }, [data]);
44417
+ }, [data, updateAnimation]);
42847
44418
  React141__namespace.default.useEffect(() => {
42848
44419
  if (!data || data.length === 0) return;
42849
44420
  data.forEach((entry, index) => {
@@ -42853,8 +44424,11 @@ var IdleTimeReasonChartComponent = ({
42853
44424
  });
42854
44425
  }, [data]);
42855
44426
  const pieKey = React141__namespace.default.useMemo(() => {
44427
+ if (updateAnimation === "smooth") {
44428
+ return "smooth";
44429
+ }
42856
44430
  return activeData.map((d) => `${d.name}-${d.value}`).join("|");
42857
- }, [activeData]);
44431
+ }, [activeData, updateAnimation]);
42858
44432
  if (isLoading) {
42859
44433
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-full" });
42860
44434
  }
@@ -49405,7 +50979,6 @@ var SettingsPopup = ({
49405
50979
  document.body
49406
50980
  );
49407
50981
  };
49408
- var formatPercent = (value) => typeof value === "number" && Number.isFinite(value) ? `${value.toFixed(1)}%` : "N/A";
49409
50982
  var formatRelativeTime2 = (value) => {
49410
50983
  const parsed = new Date(value);
49411
50984
  if (Number.isNaN(parsed.getTime())) return "Just now";
@@ -49571,8 +51144,7 @@ var AlertsPopup = ({
49571
51144
  !isLoading && error && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-10 text-sm text-red-600", children: error }),
49572
51145
  !isLoading && !error && alerts.length === 0 && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-10 text-sm text-gray-500", children: "No alerts right now." }),
49573
51146
  !isLoading && !error && alerts.map((alert2, index) => {
49574
- const isCritical = typeof alert2.delta_efficiency === "number" && alert2.delta_efficiency <= -10;
49575
- const description = `Now: ${formatPercent(alert2.current_efficiency)}. Usual for this shift: ${formatPercent(alert2.baseline_efficiency)}.`;
51147
+ const isCritical = alert2.alert_type === "recent_output_drop";
49576
51148
  return /* @__PURE__ */ jsxRuntime.jsx(
49577
51149
  motion.div,
49578
51150
  {
@@ -49594,8 +51166,8 @@ var AlertsPopup = ({
49594
51166
  formatRelativeTime2(alert2.evaluated_at)
49595
51167
  ] })
49596
51168
  ] }),
49597
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[12px] font-medium text-[#475569] uppercase tracking-wide", children: alert2.monitoring_mode === "uptime" ? "Machine Utilization is low" : "Output is low" }),
49598
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13.5px] text-[#64748b] leading-[1.45] mt-1", children: description })
51169
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[12px] font-medium text-[#475569] uppercase tracking-wide", children: alert2.title }),
51170
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[13.5px] text-[#64748b] leading-[1.45] mt-1", children: alert2.message })
49599
51171
  ] })
49600
51172
  ] })
49601
51173
  },
@@ -49629,6 +51201,7 @@ var SideNavBar = React141.memo(({
49629
51201
  const role = user?.role_level;
49630
51202
  const roleNavPaths = React141.useMemo(() => getRoleNavPaths(role), [role]);
49631
51203
  const showLiveMonitorLink = roleNavPaths.includes("/live-monitor");
51204
+ const rootDashboardSurface = React141.useMemo(() => role === "owner" || role === "plant_head" || role === "optifye" ? "operations_overview" : "monitor", [role]);
49632
51205
  const getBasePath = React141.useCallback((path) => {
49633
51206
  const firstSegment = path.split("?")[0].split("/").filter(Boolean)[0];
49634
51207
  return firstSegment ? `/${firstSegment}` : "/";
@@ -49639,12 +51212,11 @@ var SideNavBar = React141.memo(({
49639
51212
  const basePath = getBasePath(path);
49640
51213
  return roleNavPaths.includes(basePath);
49641
51214
  }, [role, isSuperAdmin, getBasePath, roleNavPaths]);
49642
- const lineId = entityConfig.defaultLineId || LINE_1_UUID;
49643
51215
  const skuEnabled = dashboardConfig?.skuConfig?.enabled || false;
49644
51216
  dashboardConfig?.supervisorConfig?.enabled || false;
49645
51217
  const showSupervisorManagement = false;
49646
51218
  const ticketsEnabled = dashboardConfig?.ticketsConfig?.enabled ?? true;
49647
- const { hasData: hasClipsCostData } = useCompanyClipsCost();
51219
+ const showBillingLink = canRoleViewClipsCost(role);
49648
51220
  console.log("\u{1F50D} [SideNavBar] dashboardConfig:", dashboardConfig);
49649
51221
  console.log("\u{1F50D} [SideNavBar] ticketsConfig:", dashboardConfig?.ticketsConfig);
49650
51222
  console.log("\u{1F50D} [SideNavBar] ticketsEnabled:", ticketsEnabled);
@@ -49655,19 +51227,20 @@ var SideNavBar = React141.memo(({
49655
51227
  ${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"}
49656
51228
  transition-all duration-200 ease-out focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-500 focus-visible:ring-offset-2`;
49657
51229
  }, [pathname]);
51230
+ const buildDashboardSurfaceTrackingEvent = React141.useCallback((source, destinationPath, dashboardSurface) => ({
51231
+ name: dashboardSurface === "operations_overview" ? "Operations Overview clicked" : "monitor page clicked",
51232
+ properties: {
51233
+ source,
51234
+ destination_path: destinationPath,
51235
+ dashboard_surface: dashboardSurface
51236
+ }
51237
+ }), []);
49658
51238
  const handleHomeClick = React141.useCallback(() => {
49659
51239
  navigate("/", {
49660
- trackingEvent: {
49661
- name: "Operations Overview Page Clicked",
49662
- properties: {
49663
- source: "side_nav",
49664
- line_id: lineId,
49665
- line_name: "Line 1"
49666
- }
49667
- }
51240
+ trackingEvent: buildDashboardSurfaceTrackingEvent("side_nav", "/", rootDashboardSurface)
49668
51241
  });
49669
51242
  onMobileMenuClose?.();
49670
- }, [navigate, lineId, onMobileMenuClose]);
51243
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent, rootDashboardSurface]);
49671
51244
  const handleLeaderboardClick = React141.useCallback(() => {
49672
51245
  navigate(`/leaderboard`, {
49673
51246
  trackingEvent: {
@@ -49681,15 +51254,10 @@ var SideNavBar = React141.memo(({
49681
51254
  }, [navigate, onMobileMenuClose]);
49682
51255
  const handleLiveClick = React141.useCallback(() => {
49683
51256
  navigate("/live-monitor", {
49684
- trackingEvent: {
49685
- name: "Live Monitor Clicked",
49686
- properties: {
49687
- source: "side_nav"
49688
- }
49689
- }
51257
+ trackingEvent: buildDashboardSurfaceTrackingEvent("side_nav", "/live-monitor", "monitor")
49690
51258
  });
49691
51259
  onMobileMenuClose?.();
49692
- }, [navigate, onMobileMenuClose]);
51260
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent]);
49693
51261
  const handleKPIsClick = React141.useCallback(() => {
49694
51262
  navigate(`/kpis`, {
49695
51263
  trackingEvent: {
@@ -49932,7 +51500,7 @@ var SideNavBar = React141.memo(({
49932
51500
  isActive: pathname === "/tickets" || pathname.startsWith("/tickets/")
49933
51501
  });
49934
51502
  }
49935
- if (hasClipsCostData) {
51503
+ if (showBillingLink) {
49936
51504
  items.push({
49937
51505
  key: "clips-analysis",
49938
51506
  label: "Billing",
@@ -49957,7 +51525,7 @@ var SideNavBar = React141.memo(({
49957
51525
  });
49958
51526
  }
49959
51527
  return items;
49960
- }, [handleTargetsClick, handleShiftsClick, handleTeamManagementClick, handleProfileClick, handleTicketsClick, handleClipsCostClick, handleHelpClick, pathname, ticketsEnabled, hasClipsCostData, canAccessPath]);
51528
+ }, [handleTargetsClick, handleShiftsClick, handleTeamManagementClick, handleProfileClick, handleTicketsClick, handleClipsCostClick, handleHelpClick, pathname, ticketsEnabled, showBillingLink, canAccessPath]);
49961
51529
  const handleLogout = React141.useCallback(async () => {
49962
51530
  setIsSettingsOpen(false);
49963
51531
  try {
@@ -49967,10 +51535,11 @@ var SideNavBar = React141.memo(({
49967
51535
  }
49968
51536
  }, [signOut]);
49969
51537
  const handleLogoClick = React141.useCallback(() => {
49970
- trackCoreEvent("Operations Overview Page Clicked", { source: "logo" });
49971
- navigate("/");
51538
+ navigate("/", {
51539
+ trackingEvent: buildDashboardSurfaceTrackingEvent("logo", "/", rootDashboardSurface)
51540
+ });
49972
51541
  onMobileMenuClose?.();
49973
- }, [navigate, onMobileMenuClose]);
51542
+ }, [navigate, onMobileMenuClose, buildDashboardSurfaceTrackingEvent, rootDashboardSurface]);
49974
51543
  const homeButtonClasses = React141.useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
49975
51544
  const liveButtonClasses = React141.useMemo(() => getButtonClasses("/live-monitor"), [getButtonClasses, pathname]);
49976
51545
  const leaderboardButtonClasses = React141.useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
@@ -50354,6 +51923,18 @@ var SideNavBar = React141.memo(({
50354
51923
  ]
50355
51924
  }
50356
51925
  ),
51926
+ showBillingLink && /* @__PURE__ */ jsxRuntime.jsxs(
51927
+ "button",
51928
+ {
51929
+ onClick: handleMobileNavClick(handleClipsCostClick),
51930
+ className: getMobileButtonClass("/clips-cost"),
51931
+ "aria-label": "Billing",
51932
+ children: [
51933
+ /* @__PURE__ */ jsxRuntime.jsx(outline.CurrencyDollarIcon, { className: getIconClass("/clips-cost") }),
51934
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-base font-medium", children: "Billing" })
51935
+ ]
51936
+ }
51937
+ ),
50357
51938
  canAccessPath("/help") && /* @__PURE__ */ jsxRuntime.jsxs(
50358
51939
  "button",
50359
51940
  {
@@ -56811,6 +58392,11 @@ function HomeView({
56811
58392
  React141.useEffect(() => {
56812
58393
  setIsHydrated(true);
56813
58394
  }, []);
58395
+ React141.useEffect(() => {
58396
+ trackCorePageView("Monitor", {
58397
+ dashboard_surface: "monitor"
58398
+ });
58399
+ }, []);
56814
58400
  React141.useEffect(() => {
56815
58401
  if (metricsError) {
56816
58402
  setErrorMessage(metricsError.message);
@@ -56821,7 +58407,7 @@ function HomeView({
56821
58407
  const handleLineChange = React141.useCallback((value) => {
56822
58408
  setIsChangingFilter(true);
56823
58409
  setSelectedLineId(value);
56824
- trackCoreEvent("Home Line Filter Changed", {
58410
+ trackCoreEvent("monitor line filter changed", {
56825
58411
  previous_line_id: selectedLineId,
56826
58412
  new_line_id: value,
56827
58413
  line_name: mergedLineNames[value] || (value === factoryViewId ? "All Lines" : `Line ${value.substring(0, 4)}`)
@@ -56842,10 +58428,11 @@ function HomeView({
56842
58428
  React141.useEffect(() => {
56843
58429
  if (!metricsLoading && !hasInitialDataLoaded) {
56844
58430
  setHasInitialDataLoaded(true);
56845
- trackCoreEvent("Home View Loaded", {
58431
+ trackCoreEvent("monitor page loaded", {
56846
58432
  default_line_id: defaultLineId,
56847
58433
  factory_view_id: factoryViewId,
56848
- is_supervisor: isSupervisor
58434
+ is_supervisor: isSupervisor,
58435
+ dashboard_surface: "monitor"
56849
58436
  });
56850
58437
  }
56851
58438
  }, [metricsLoading, hasInitialDataLoaded, defaultLineId, factoryViewId, isSupervisor]);
@@ -57521,6 +59108,7 @@ var MonthlyRangeFilter = ({
57521
59108
  const [rangeEnd, setRangeEnd] = React141.useState(parseDateKeyToDate(normalizedRange.endKey));
57522
59109
  const [selecting, setSelecting] = React141.useState(false);
57523
59110
  const [activePreset, setActivePreset] = React141.useState(null);
59111
+ const [pendingChangeMeta, setPendingChangeMeta] = React141.useState(null);
57524
59112
  const today = React141.useMemo(() => dateFns.endOfDay(todayDate), [todayDate]);
57525
59113
  React141.useEffect(() => {
57526
59114
  setCalendarMonth(month);
@@ -57540,6 +59128,7 @@ var MonthlyRangeFilter = ({
57540
59128
  return val.startKey === value.startKey && val.endKey === value.endKey;
57541
59129
  });
57542
59130
  setActivePreset(match ? match.label : "Custom");
59131
+ setPendingChangeMeta(null);
57543
59132
  }
57544
59133
  }, [isOpen, month, presets, value.endKey, value.startKey, year]);
57545
59134
  React141.useEffect(() => {
@@ -57556,6 +59145,7 @@ var MonthlyRangeFilter = ({
57556
59145
  return;
57557
59146
  }
57558
59147
  setActivePreset("Custom");
59148
+ setPendingChangeMeta({ source: "custom" });
57559
59149
  if (!selecting || !rangeStart) {
57560
59150
  setRangeStart(day);
57561
59151
  setRangeEnd(null);
@@ -57578,6 +59168,7 @@ var MonthlyRangeFilter = ({
57578
59168
  setRangeEnd(end);
57579
59169
  setSelecting(false);
57580
59170
  setActivePreset(preset.label);
59171
+ setPendingChangeMeta({ source: "preset", presetLabel: preset.label });
57581
59172
  setCalendarMonth(start.getMonth());
57582
59173
  setCalendarYear(start.getFullYear());
57583
59174
  };
@@ -57596,7 +59187,7 @@ var MonthlyRangeFilter = ({
57596
59187
  const end = boundedStart <= boundedEnd ? boundedEnd : boundedStart;
57597
59188
  const startKey = dateFns.format(start, "yyyy-MM-dd");
57598
59189
  const endKey = dateFns.format(end, "yyyy-MM-dd");
57599
- onChange({ startKey, endKey });
59190
+ onChange({ startKey, endKey }, pendingChangeMeta || void 0);
57600
59191
  setIsOpen(false);
57601
59192
  }
57602
59193
  };
@@ -67534,13 +69125,7 @@ var WorkspaceHealthView = ({
67534
69125
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: clsx("text-3xl font-bold", getUptimeColor(summary.uptimePercentage)), children: summary.uptimePercentage === null ? "No data" : `${summary.uptimePercentage.toFixed(1)}%` }),
67535
69126
  summary.uptimePercentage === null ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "h-5 w-5 text-gray-400" }) : summary.uptimePercentage >= 97 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { className: "h-5 w-5 text-green-500" }) : summary.uptimePercentage >= 90 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Activity, { className: "h-5 w-5 text-yellow-500" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingDown, { className: "h-5 w-5 text-red-500" })
67536
69127
  ] }),
67537
- /* @__PURE__ */ jsxRuntime.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" }),
67538
- summary.workspacesWithoutUptimeData > 0 && /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-xs text-amber-600 mt-1", children: [
67539
- summary.workspacesWithoutUptimeData,
67540
- " workspace",
67541
- summary.workspacesWithoutUptimeData === 1 ? "" : "s",
67542
- " missing uptime data"
67543
- ] })
69128
+ /* @__PURE__ */ jsxRuntime.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" })
67544
69129
  ] })
67545
69130
  ] }),
67546
69131
  /* @__PURE__ */ jsxRuntime.jsxs(Card2, { className: "bg-white", children: [
@@ -69235,6 +70820,12 @@ var getPositiveImprovementGain = ({
69235
70820
  pcsGain: issueGain !== null && issueGain > 0 ? issueGain : null
69236
70821
  };
69237
70822
  };
70823
+ var getImprovementPcsGainSortValue = (input) => {
70824
+ const { pcsGain } = getPositiveImprovementGain(input);
70825
+ if (pcsGain !== null) return pcsGain;
70826
+ const raw = toFiniteNumber(input.estimated_gain_pieces);
70827
+ return raw ?? null;
70828
+ };
69238
70829
  var getImprovementDisplayMetadata = ({
69239
70830
  location,
69240
70831
  line,
@@ -69298,26 +70889,21 @@ var compareImprovementRecommendationPriority = (left, right) => {
69298
70889
  };
69299
70890
  var ImprovementRecommendationSignals = ({
69300
70891
  recommendation,
69301
- className
70892
+ className,
70893
+ hideTargetsReadjustment = false
69302
70894
  }) => {
69303
70895
  const gainSummary = getImprovementGainSummary(recommendation);
69304
- const showTargetReadjustment = needsTargetReadjustment(recommendation);
70896
+ const showTargetReadjustment = !hideTargetsReadjustment && needsTargetReadjustment(recommendation);
69305
70897
  if (!gainSummary && !showTargetReadjustment) {
69306
70898
  return null;
69307
70899
  }
69308
70900
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: className || "flex flex-wrap items-center gap-x-4 gap-y-3", children: [
69309
- gainSummary && /* @__PURE__ */ jsxRuntime.jsxs(
70901
+ gainSummary && /* @__PURE__ */ jsxRuntime.jsx(
69310
70902
  "span",
69311
70903
  {
69312
70904
  "data-testid": "improvement-gain-chip",
69313
- 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",
69314
- children: [
69315
- /* @__PURE__ */ jsxRuntime.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: [
69316
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "22 7 13.5 15.5 8.5 10.5 2 17" }),
69317
- /* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16 7 22 7 22 13" })
69318
- ] }),
69319
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: gainSummary.primary })
69320
- ]
70905
+ 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",
70906
+ children: gainSummary.primary
69321
70907
  }
69322
70908
  ),
69323
70909
  showTargetReadjustment && /* @__PURE__ */ jsxRuntime.jsxs(
@@ -70118,6 +71704,7 @@ var ImprovementCenterView = () => {
70118
71704
  });
70119
71705
  }, [supervisorsByLineId]);
70120
71706
  const filteredRecommendations = React141.useMemo(() => {
71707
+ const hasActiveFilters = selectedLineId !== "all" || selectedStatus !== "all" || selectedShift !== "all" || selectedWeeksRange !== "all" || selectedMemberId !== "all" || selectedSortBy !== "all";
70121
71708
  const sortedRecommendations = recommendations.filter((rec) => {
70122
71709
  if (selectedLineId !== "all" && rec.line_id !== selectedLineId) return false;
70123
71710
  if (selectedStatus === "resolved" && rec.ticket_status !== "solved") return false;
@@ -70132,22 +71719,22 @@ var ImprovementCenterView = () => {
70132
71719
  if (selectedMemberId !== "all" && !(rec.assigned_user_ids?.includes(selectedMemberId) || rec.assigned_to_user_id === selectedMemberId)) return false;
70133
71720
  return true;
70134
71721
  }).sort((a, b) => {
70135
- if (selectedSortBy === "highest_to_lowest") {
70136
- const gainA = toFiniteNumber2(a.estimated_gain_pieces) || 0;
70137
- const gainB = toFiniteNumber2(b.estimated_gain_pieces) || 0;
70138
- if (gainA !== gainB) {
70139
- return gainB - gainA;
70140
- }
70141
- } else if (selectedSortBy === "lowest_to_highest") {
70142
- const gainA = toFiniteNumber2(a.estimated_gain_pieces) || 0;
70143
- const gainB = toFiniteNumber2(b.estimated_gain_pieces) || 0;
70144
- if (gainA !== gainB) {
70145
- return gainA - gainB;
71722
+ if (selectedSortBy === "highest_to_lowest" || selectedSortBy === "lowest_to_highest") {
71723
+ const gainA = getImprovementPcsGainSortValue(a);
71724
+ const gainB = getImprovementPcsGainSortValue(b);
71725
+ const aMissing = gainA === null;
71726
+ const bMissing = gainB === null;
71727
+ if (aMissing && bMissing) ; else if (aMissing) {
71728
+ return 1;
71729
+ } else if (bMissing) {
71730
+ return -1;
71731
+ } else if (gainA !== gainB) {
71732
+ return selectedSortBy === "highest_to_lowest" ? gainB - gainA : gainA - gainB;
70146
71733
  }
70147
71734
  }
70148
71735
  return compareImprovementRecommendationPriority(a, b);
70149
71736
  });
70150
- if (!focusIssueId) {
71737
+ if (!focusIssueId || hasActiveFilters) {
70151
71738
  return sortedRecommendations;
70152
71739
  }
70153
71740
  const focusedIndex = sortedRecommendations.findIndex((rec) => rec.issue_id === focusIssueId);
@@ -70481,7 +72068,7 @@ var ImprovementCenterView = () => {
70481
72068
  /* @__PURE__ */ jsxRuntime.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))" } })
70482
72069
  ] })
70483
72070
  ] }),
70484
- /* @__PURE__ */ jsxRuntime.jsx(ImprovementRecommendationSignals_default, { recommendation: rec })
72071
+ /* @__PURE__ */ jsxRuntime.jsx(ImprovementRecommendationSignals_default, { recommendation: rec, hideTargetsReadjustment: true })
70485
72072
  ] })
70486
72073
  ] }),
70487
72074
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
@@ -72568,20 +74155,410 @@ var AIAgentView = () => {
72568
74155
  ] });
72569
74156
  };
72570
74157
  var AIAgentView_default = AIAgentView;
72571
- var EMPTY_OVERVIEW = {
72572
- scope: {
72573
- current_range: { day_count: null },
72574
- previous_range: { day_count: null },
72575
- available_line_modes: { has_output: false, has_uptime: false }
74158
+
74159
+ // src/views/operations-overview/store.ts
74160
+ var import_isEqual = __toESM(require_isEqual());
74161
+
74162
+ // src/views/operations-overview/types.ts
74163
+ var EMPTY_OVERVIEW_SCOPE = {
74164
+ current_range: { day_count: null },
74165
+ previous_range: { day_count: null },
74166
+ available_line_modes: { has_output: false, has_uptime: false },
74167
+ idle_time_vlm_enabled_line_count: null,
74168
+ idle_time_vlm_disabled_line_count: null
74169
+ };
74170
+ var EMPTY_OVERVIEW_SUMMARY = {
74171
+ plant_efficiency: { current: null, previous: null, delta_pp: null },
74172
+ avg_idle_per_workstation: {
74173
+ current_seconds: null,
74174
+ previous_seconds: null,
74175
+ delta_seconds: null,
74176
+ top_contributors: []
74177
+ }
74178
+ };
74179
+ var EMPTY_OVERVIEW_POOREST_LINES = {
74180
+ output: [],
74181
+ uptime: []
74182
+ };
74183
+ var EMPTY_OVERVIEW_TREND = {
74184
+ shift_mode: "all",
74185
+ points: []
74186
+ };
74187
+ var EMPTY_IDLE_BREAKDOWN = [];
74188
+ var EMPTY_IMPROVEMENTS = [];
74189
+ var LIVE_REFRESH_INTERVAL_MS = 6e4;
74190
+
74191
+ // src/views/operations-overview/store.ts
74192
+ var normalizeNumber = (value) => {
74193
+ if (typeof value === "number" && Number.isFinite(value)) return value;
74194
+ if (typeof value === "string" && value.trim().length > 0) {
74195
+ const parsed = Number(value);
74196
+ return Number.isFinite(parsed) ? parsed : null;
74197
+ }
74198
+ return null;
74199
+ };
74200
+ var normalizeScope = (value) => ({
74201
+ company_id: value?.company_id,
74202
+ line_ids: Array.isArray(value?.line_ids) ? value.line_ids.filter((lineId) => typeof lineId === "string" && lineId.length > 0) : [],
74203
+ line_count: typeof value?.line_count === "number" ? value.line_count : value?.line_count ?? null,
74204
+ shift_mode: value?.shift_mode,
74205
+ comparison_strategy: value?.comparison_strategy,
74206
+ current_range: {
74207
+ start_date: value?.current_range?.start_date,
74208
+ end_date: value?.current_range?.end_date,
74209
+ day_count: value?.current_range?.day_count ?? null
74210
+ },
74211
+ previous_range: {
74212
+ start_date: value?.previous_range?.start_date,
74213
+ end_date: value?.previous_range?.end_date,
74214
+ day_count: value?.previous_range?.day_count ?? null
74215
+ },
74216
+ available_line_modes: {
74217
+ has_output: !!value?.available_line_modes?.has_output,
74218
+ has_uptime: !!value?.available_line_modes?.has_uptime
72576
74219
  },
72577
- summary: {
72578
- plant_efficiency: { current: null, previous: null, delta_pp: null },
72579
- avg_idle_per_workstation: { current_seconds: null, previous_seconds: null, delta_seconds: null, top_contributors: [] }
74220
+ idle_time_vlm_enabled_line_count: value?.idle_time_vlm_enabled_line_count ?? null,
74221
+ idle_time_vlm_disabled_line_count: value?.idle_time_vlm_disabled_line_count ?? null
74222
+ });
74223
+ var normalizeTopContributor = (value) => ({
74224
+ workspace_id: value?.workspace_id,
74225
+ workspace_name: value?.workspace_name?.trim() || value?.workspace_id || "",
74226
+ line_id: value?.line_id,
74227
+ line_name: value?.line_name?.trim() || "",
74228
+ avg_idle_seconds: normalizeNumber(value?.avg_idle_seconds)
74229
+ });
74230
+ var normalizeIdleMetric = (value) => ({
74231
+ current_seconds: normalizeNumber(value?.current_seconds),
74232
+ previous_seconds: normalizeNumber(value?.previous_seconds),
74233
+ delta_seconds: normalizeNumber(value?.delta_seconds),
74234
+ top_contributors: (value?.top_contributors || []).map((item) => normalizeTopContributor(item))
74235
+ });
74236
+ var normalizeSummary = (value) => ({
74237
+ plant_efficiency: {
74238
+ current: normalizeNumber(value?.plant_efficiency?.current),
74239
+ previous: normalizeNumber(value?.plant_efficiency?.previous),
74240
+ delta_pp: normalizeNumber(value?.plant_efficiency?.delta_pp)
74241
+ },
74242
+ avg_idle_per_workstation: normalizeIdleMetric(value?.avg_idle_per_workstation)
74243
+ });
74244
+ var normalizeLineRow = (value) => ({
74245
+ line_id: value?.line_id,
74246
+ line_name: value?.line_name?.trim() || value?.line_id || "",
74247
+ avg_efficiency: normalizeNumber(value?.avg_efficiency),
74248
+ previous_avg_efficiency: normalizeNumber(value?.previous_avg_efficiency),
74249
+ delta_pp: normalizeNumber(value?.delta_pp)
74250
+ });
74251
+ var normalizePoorestLines = (value) => ({
74252
+ output: (value?.output || []).map((item) => normalizeLineRow(item)),
74253
+ uptime: (value?.uptime || []).map((item) => normalizeLineRow(item))
74254
+ });
74255
+ var normalizeTrend = (value) => ({
74256
+ shift_mode: value?.shift_mode || "all",
74257
+ points: (value?.points || []).map((point) => ({
74258
+ date: point?.date,
74259
+ avg_efficiency: normalizeNumber(point?.avg_efficiency)
74260
+ }))
74261
+ });
74262
+ var normalizeIdleBreakdown = (value) => (value || []).map((item) => ({
74263
+ reason: item?.reason?.trim() || "Unknown",
74264
+ percentage: normalizeNumber(item?.percentage),
74265
+ total_duration_seconds: normalizeNumber(item?.total_duration_seconds),
74266
+ efficiency_loss_percentage: normalizeNumber(item?.efficiency_loss_percentage),
74267
+ contributors: (item?.contributors || []).map((contributor) => ({
74268
+ workspace_id: contributor?.workspace_id,
74269
+ workspace_name: contributor?.workspace_name?.trim() || contributor?.workspace_id || "",
74270
+ total_duration_seconds: normalizeNumber(contributor?.total_duration_seconds),
74271
+ percentage_within_reason: normalizeNumber(contributor?.percentage_within_reason)
74272
+ }))
74273
+ }));
74274
+ var normalizeImprovements = (rows) => rows.map((row) => ({
74275
+ id: row.id,
74276
+ issueId: row.issueId,
74277
+ issueNumber: row.issueNumber,
74278
+ title: row.title,
74279
+ metric: row.metric,
74280
+ location: row.location,
74281
+ line: row.line,
74282
+ lineId: row.lineId,
74283
+ workspaceId: row.workspaceId
74284
+ }));
74285
+ var reuseIfEqual = (previous, next) => (0, import_isEqual.default)(previous, next) ? previous : next;
74286
+ var createInitialState = () => ({
74287
+ scope: EMPTY_OVERVIEW_SCOPE,
74288
+ snapshot: {
74289
+ data: {
74290
+ summary: EMPTY_OVERVIEW_SUMMARY,
74291
+ poorest_lines: EMPTY_OVERVIEW_POOREST_LINES
74292
+ },
74293
+ loading: false,
74294
+ error: null,
74295
+ hasLoadedOnce: false,
74296
+ lastUpdated: null
74297
+ },
74298
+ trend: {
74299
+ data: EMPTY_OVERVIEW_TREND,
74300
+ loading: false,
74301
+ error: null,
74302
+ lastUpdated: null
72580
74303
  },
72581
- poorest_lines: { output: [], uptime: [] },
72582
- trend: { shift_mode: "all", points: [] },
72583
- idle_reason_breakdown: []
74304
+ idle: {
74305
+ scope: EMPTY_OVERVIEW_SCOPE,
74306
+ data: EMPTY_IDLE_BREAKDOWN,
74307
+ loading: false,
74308
+ error: null,
74309
+ lastUpdated: null
74310
+ },
74311
+ improvements: {
74312
+ data: EMPTY_IMPROVEMENTS,
74313
+ loading: false,
74314
+ error: null,
74315
+ lastUpdated: null
74316
+ }
74317
+ });
74318
+ var hasSnapshotPayload = (state) => state.snapshot.hasLoadedOnce;
74319
+ var hasTrendPayload = (state) => state.trend.lastUpdated !== null;
74320
+ var hasIdlePayload = (state) => state.idle.lastUpdated !== null;
74321
+ var hasImprovementsPayload = (state) => state.improvements.lastUpdated !== null;
74322
+ var createOperationsOverviewStore = () => {
74323
+ let state = createInitialState();
74324
+ const listeners2 = /* @__PURE__ */ new Set();
74325
+ const emit = () => {
74326
+ listeners2.forEach((listener) => listener());
74327
+ };
74328
+ const setState = (updater, mode = "default") => {
74329
+ const next = updater(state);
74330
+ if (next === state) return;
74331
+ const commit = () => {
74332
+ state = next;
74333
+ emit();
74334
+ };
74335
+ if (mode === "transition") {
74336
+ React141.startTransition(commit);
74337
+ return;
74338
+ }
74339
+ commit();
74340
+ };
74341
+ const subscribe = (listener) => {
74342
+ listeners2.add(listener);
74343
+ return () => {
74344
+ listeners2.delete(listener);
74345
+ };
74346
+ };
74347
+ const reset = () => {
74348
+ setState(() => createInitialState());
74349
+ };
74350
+ const beginSectionLoad = (section) => {
74351
+ setState((previous) => {
74352
+ if (section === "snapshot") {
74353
+ const showLoading2 = !hasSnapshotPayload(previous);
74354
+ if (previous.snapshot.loading === showLoading2 && previous.snapshot.error === null) {
74355
+ return previous;
74356
+ }
74357
+ return {
74358
+ ...previous,
74359
+ snapshot: {
74360
+ ...previous.snapshot,
74361
+ loading: showLoading2,
74362
+ error: null
74363
+ }
74364
+ };
74365
+ }
74366
+ if (section === "trend") {
74367
+ const showLoading2 = !hasTrendPayload(previous);
74368
+ if (previous.trend.loading === showLoading2 && previous.trend.error === null) {
74369
+ return previous;
74370
+ }
74371
+ return {
74372
+ ...previous,
74373
+ trend: {
74374
+ ...previous.trend,
74375
+ loading: showLoading2,
74376
+ error: null
74377
+ }
74378
+ };
74379
+ }
74380
+ if (section === "idle") {
74381
+ const showLoading2 = !hasIdlePayload(previous);
74382
+ if (previous.idle.loading === showLoading2 && previous.idle.error === null) {
74383
+ return previous;
74384
+ }
74385
+ return {
74386
+ ...previous,
74387
+ idle: {
74388
+ ...previous.idle,
74389
+ loading: showLoading2,
74390
+ error: null
74391
+ }
74392
+ };
74393
+ }
74394
+ const showLoading = !hasImprovementsPayload(previous);
74395
+ if (previous.improvements.loading === showLoading && previous.improvements.error === null) {
74396
+ return previous;
74397
+ }
74398
+ return {
74399
+ ...previous,
74400
+ improvements: {
74401
+ ...previous.improvements,
74402
+ loading: showLoading,
74403
+ error: null
74404
+ }
74405
+ };
74406
+ });
74407
+ };
74408
+ const failSectionLoad = (section, error) => {
74409
+ setState((previous) => {
74410
+ if (section === "snapshot") {
74411
+ if (hasSnapshotPayload(previous)) return previous;
74412
+ return {
74413
+ ...previous,
74414
+ snapshot: {
74415
+ ...previous.snapshot,
74416
+ loading: false,
74417
+ error
74418
+ }
74419
+ };
74420
+ }
74421
+ if (section === "trend") {
74422
+ if (hasTrendPayload(previous)) return previous;
74423
+ return {
74424
+ ...previous,
74425
+ trend: {
74426
+ ...previous.trend,
74427
+ loading: false,
74428
+ error
74429
+ }
74430
+ };
74431
+ }
74432
+ if (section === "idle") {
74433
+ if (hasIdlePayload(previous)) return previous;
74434
+ return {
74435
+ ...previous,
74436
+ idle: {
74437
+ ...previous.idle,
74438
+ loading: false,
74439
+ error
74440
+ }
74441
+ };
74442
+ }
74443
+ if (hasImprovementsPayload(previous)) return previous;
74444
+ return {
74445
+ ...previous,
74446
+ improvements: {
74447
+ ...previous.improvements,
74448
+ loading: false,
74449
+ error
74450
+ }
74451
+ };
74452
+ });
74453
+ };
74454
+ return {
74455
+ getState: () => state,
74456
+ subscribe,
74457
+ reset,
74458
+ beginSnapshotLoad: () => beginSectionLoad("snapshot"),
74459
+ applySnapshotResponse: (response, updatedAt, mode = "default") => {
74460
+ setState((previous) => {
74461
+ const nextScope = reuseIfEqual(previous.scope, normalizeScope(response.scope));
74462
+ const nextSummary = reuseIfEqual(previous.snapshot.data.summary, normalizeSummary(response.summary));
74463
+ const nextPoorestLines = reuseIfEqual(previous.snapshot.data.poorest_lines, normalizePoorestLines(response.poorest_lines));
74464
+ const nextData = nextSummary === previous.snapshot.data.summary && nextPoorestLines === previous.snapshot.data.poorest_lines ? previous.snapshot.data : {
74465
+ summary: nextSummary,
74466
+ poorest_lines: nextPoorestLines
74467
+ };
74468
+ const nextLastUpdated = nextData !== previous.snapshot.data || previous.snapshot.lastUpdated === null ? updatedAt : previous.snapshot.lastUpdated;
74469
+ if (nextScope === previous.scope && nextData === previous.snapshot.data && previous.snapshot.loading === false && previous.snapshot.error === null && previous.snapshot.hasLoadedOnce && nextLastUpdated === previous.snapshot.lastUpdated) {
74470
+ return previous;
74471
+ }
74472
+ return {
74473
+ ...previous,
74474
+ scope: nextScope,
74475
+ snapshot: {
74476
+ data: nextData,
74477
+ loading: false,
74478
+ error: null,
74479
+ hasLoadedOnce: true,
74480
+ lastUpdated: nextLastUpdated
74481
+ }
74482
+ };
74483
+ }, mode);
74484
+ },
74485
+ failSnapshotLoad: (error) => failSectionLoad("snapshot", error),
74486
+ beginTrendLoad: () => beginSectionLoad("trend"),
74487
+ applyTrendResponse: (response, updatedAt, mode = "default") => {
74488
+ setState((previous) => {
74489
+ const nextData = reuseIfEqual(previous.trend.data, normalizeTrend(response.trend));
74490
+ const nextLastUpdated = nextData !== previous.trend.data || previous.trend.lastUpdated === null ? updatedAt : previous.trend.lastUpdated;
74491
+ if (nextData === previous.trend.data && previous.trend.loading === false && previous.trend.error === null && nextLastUpdated === previous.trend.lastUpdated) {
74492
+ return previous;
74493
+ }
74494
+ return {
74495
+ ...previous,
74496
+ trend: {
74497
+ data: nextData,
74498
+ loading: false,
74499
+ error: null,
74500
+ lastUpdated: nextLastUpdated
74501
+ }
74502
+ };
74503
+ }, mode);
74504
+ },
74505
+ failTrendLoad: (error) => failSectionLoad("trend", error),
74506
+ beginIdleLoad: () => beginSectionLoad("idle"),
74507
+ applyIdleResponse: (response, updatedAt, mode = "default") => {
74508
+ setState((previous) => {
74509
+ const nextScope = reuseIfEqual(previous.idle.scope, normalizeScope(response.scope));
74510
+ const nextData = reuseIfEqual(previous.idle.data, normalizeIdleBreakdown(response.idle_reason_breakdown));
74511
+ const nextLastUpdated = nextData !== previous.idle.data || nextScope !== previous.idle.scope || previous.idle.lastUpdated === null ? updatedAt : previous.idle.lastUpdated;
74512
+ if (nextData === previous.idle.data && nextScope === previous.idle.scope && previous.idle.loading === false && previous.idle.error === null && nextLastUpdated === previous.idle.lastUpdated) {
74513
+ return previous;
74514
+ }
74515
+ return {
74516
+ ...previous,
74517
+ idle: {
74518
+ scope: nextScope,
74519
+ data: nextData,
74520
+ loading: false,
74521
+ error: null,
74522
+ lastUpdated: nextLastUpdated
74523
+ }
74524
+ };
74525
+ }, mode);
74526
+ },
74527
+ failIdleLoad: (error) => failSectionLoad("idle", error),
74528
+ beginImprovementsLoad: () => beginSectionLoad("improvements"),
74529
+ applyImprovements: (rows, updatedAt, mode = "default") => {
74530
+ setState((previous) => {
74531
+ const nextData = reuseIfEqual(previous.improvements.data, normalizeImprovements(rows));
74532
+ const nextLastUpdated = nextData !== previous.improvements.data || previous.improvements.lastUpdated === null ? updatedAt : previous.improvements.lastUpdated;
74533
+ if (nextData === previous.improvements.data && previous.improvements.loading === false && previous.improvements.error === null && nextLastUpdated === previous.improvements.lastUpdated) {
74534
+ return previous;
74535
+ }
74536
+ return {
74537
+ ...previous,
74538
+ improvements: {
74539
+ data: nextData,
74540
+ loading: false,
74541
+ error: null,
74542
+ lastUpdated: nextLastUpdated
74543
+ }
74544
+ };
74545
+ }, mode);
74546
+ },
74547
+ failImprovementsLoad: (error) => failSectionLoad("improvements", error)
74548
+ };
72584
74549
  };
74550
+ var useOperationsOverviewSelector = (store, selector) => {
74551
+ return React141.useSyncExternalStore(
74552
+ store.subscribe,
74553
+ () => selector(store.getState()),
74554
+ () => selector(store.getState())
74555
+ );
74556
+ };
74557
+ var useOperationsOverviewScope = (store) => useOperationsOverviewSelector(store, (state) => state.scope);
74558
+ var useOperationsOverviewSnapshot = (store) => useOperationsOverviewSelector(store, (state) => state.snapshot);
74559
+ var useOperationsOverviewTrend = (store) => useOperationsOverviewSelector(store, (state) => state.trend);
74560
+ var useOperationsOverviewIdle = (store) => useOperationsOverviewSelector(store, (state) => state.idle);
74561
+ var useOperationsOverviewImprovements = (store) => useOperationsOverviewSelector(store, (state) => state.improvements);
72585
74562
  var efficiencyLineConfig = [
72586
74563
  {
72587
74564
  dataKey: "efficiency",
@@ -72593,6 +74570,9 @@ var efficiencyLineConfig = [
72593
74570
  activeDot: { r: 6, strokeWidth: 0, fill: "#00AB45" }
72594
74571
  }
72595
74572
  ];
74573
+ var bumpRenderCounter = (key) => {
74574
+ if (process.env.NODE_ENV === "test") ;
74575
+ };
72596
74576
  var toNumber3 = (value) => {
72597
74577
  if (typeof value === "number" && Number.isFinite(value)) return value;
72598
74578
  if (typeof value === "string" && value.trim().length > 0) {
@@ -72612,26 +74592,11 @@ var formatSignedIdleDuration = (seconds) => {
72612
74592
  const sign = seconds > 0 ? "+" : "-";
72613
74593
  return `${sign}${formatIdleDuration(Math.abs(seconds))}`;
72614
74594
  };
72615
- var formatComparisonWindow = (dayCount) => {
74595
+ var formatComparisonWindow = (dayCount, comparisonStrategy) => {
74596
+ if (comparisonStrategy === "previous_full_week") return "last week";
72616
74597
  if (!dayCount || !Number.isFinite(dayCount)) return "previous range";
72617
74598
  return `previous ${dayCount} ${dayCount === 1 ? "day" : "days"}`;
72618
74599
  };
72619
- var buildImprovementMetric = (recommendation) => {
72620
- const { pcsGain } = getPositiveImprovementGain(recommendation);
72621
- const metrics2 = recommendation.metrics || {};
72622
- if (pcsGain !== null) {
72623
- return formatImprovementPieceGain(pcsGain);
72624
- }
72625
- const idleMinutes = toNumber3(metrics2.idle_minutes);
72626
- if (idleMinutes !== null) {
72627
- return `-${Math.round(idleMinutes)}m Idle`;
72628
- }
72629
- const impactText = recommendation.impact?.trim();
72630
- if (impactText) {
72631
- return impactText.length > 22 ? `${impactText.slice(0, 22).trim()}...` : impactText;
72632
- }
72633
- return "Review Issue";
72634
- };
72635
74600
  var buildDeltaBadge = (delta, options) => {
72636
74601
  if (delta === null || delta === void 0 || !Number.isFinite(delta)) {
72637
74602
  return {
@@ -72699,368 +74664,225 @@ var OverviewImprovementsSkeleton = () => /* @__PURE__ */ jsxRuntime.jsx("div", {
72699
74664
  ] }),
72700
74665
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsxRuntime.jsx(SectionPulse, { className: "h-6 w-20 rounded-full" }) })
72701
74666
  ] }, index)) });
72702
- var PlantHeadView = () => {
72703
- const supabase = useSupabase();
72704
- const entityConfig = useEntityConfig();
72705
- const appTimezone = useAppTimezone() || "UTC";
72706
- const { navigate } = useNavigation();
72707
- const { accessibleLineIds } = useUserLineAccess();
72708
- const mobileMenuContext = useMobileMenu();
72709
- useHideMobileHeader(!!mobileMenuContext);
72710
- const [dateRange, setDateRange] = React141__namespace.default.useState(() => getCurrentWeekToDateRange(appTimezone));
72711
- const [trendMode, setTrendMode] = React141__namespace.default.useState("all");
72712
- const [poorestLineMode, setPoorestLineMode] = React141__namespace.default.useState("output");
72713
- const [overview, setOverview] = React141__namespace.default.useState(EMPTY_OVERVIEW);
72714
- const [isSnapshotLoading, setIsSnapshotLoading] = React141__namespace.default.useState(false);
72715
- const [isTrendLoading, setIsTrendLoading] = React141__namespace.default.useState(false);
72716
- const [trendFetchNonce, setTrendFetchNonce] = React141__namespace.default.useState(0);
72717
- const [trendViewOpenNonce] = React141__namespace.default.useState(() => Date.now());
72718
- const [idleReasonBreakdown, setIdleReasonBreakdown] = React141__namespace.default.useState([]);
72719
- const [idleReasonScope, setIdleReasonScope] = React141__namespace.default.useState(null);
72720
- const [isIdleReasonBreakdownLoading, setIsIdleReasonBreakdownLoading] = React141__namespace.default.useState(false);
72721
- const [improvements, setImprovements] = React141__namespace.default.useState([]);
72722
- const [isImprovementsLoading, setIsImprovementsLoading] = React141__namespace.default.useState(false);
74667
+ var OperationsOverviewHeader = React141__namespace.default.memo(({
74668
+ dateRange,
74669
+ trendMode,
74670
+ appTimezone,
74671
+ mobileMenuContext,
74672
+ onDateRangeChange,
74673
+ onTrendModeChange
74674
+ }) => {
74675
+ bumpRenderCounter();
72723
74676
  const [isFilterOpen, setIsFilterOpen] = React141__namespace.default.useState(false);
72724
- const [isIdleContributorsOpen, setIsIdleContributorsOpen] = React141__namespace.default.useState(false);
72725
- const [isIdleContributorsPinned, setIsIdleContributorsPinned] = React141__namespace.default.useState(false);
72726
74677
  const filterRef = React141__namespace.default.useRef(null);
72727
74678
  const filterButtonRef = React141__namespace.default.useRef(null);
72728
74679
  const mobileFilterButtonRef = React141__namespace.default.useRef(null);
72729
- const idleContributorsRef = React141__namespace.default.useRef(null);
72730
- React141__namespace.default.useEffect(() => {
72731
- trackCorePageView("Operations Overview");
72732
- }, []);
72733
- const handleDateRangeChange = React141__namespace.default.useCallback((range) => {
72734
- trackCoreEvent("Operations Overview Date Range Changed", {
72735
- start_date: range.startKey,
72736
- end_date: range.endKey
72737
- });
72738
- setDateRange(range);
72739
- }, []);
74680
+ const currentWeekRange = React141__namespace.default.useMemo(
74681
+ () => getCurrentWeekToDateRange(appTimezone),
74682
+ [appTimezone]
74683
+ );
74684
+ const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
74685
+ const mobileSubtitle = React141__namespace.default.useMemo(() => {
74686
+ if (isCurrentWeekToDateRange) {
74687
+ return `Week of ${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMM")}`;
74688
+ }
74689
+ return `${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMM")} - ${dateFns.format(parseDateKeyToDate(dateRange.endKey), "do MMM, yyyy")}`;
74690
+ }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
74691
+ const desktopSubtitle = React141__namespace.default.useMemo(() => {
74692
+ if (isCurrentWeekToDateRange) {
74693
+ return `Week of ${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")}`;
74694
+ }
74695
+ return `${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")} - ${dateFns.format(parseDateKeyToDate(dateRange.endKey), "do MMMM, yyyy")}`;
74696
+ }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
72740
74697
  const handleFilterToggle = React141__namespace.default.useCallback(() => {
72741
74698
  trackCoreEvent("Operations Overview Filter Toggled", {
72742
74699
  action: !isFilterOpen ? "open" : "close"
72743
74700
  });
72744
- setIsFilterOpen(!isFilterOpen);
74701
+ setIsFilterOpen((previous) => !previous);
72745
74702
  }, [isFilterOpen]);
72746
- const handleTrendModeChange = React141__namespace.default.useCallback((e) => {
72747
- const newMode = e.target.value;
74703
+ const handleTrendModeChange = React141__namespace.default.useCallback((event) => {
74704
+ const nextMode = event.target.value;
72748
74705
  trackCoreEvent("Operations Overview Shift Filter Changed", {
72749
- shift_mode: newMode
72750
- });
72751
- setTrendMode(newMode);
72752
- }, []);
72753
- const handlePoorestLineModeChange = React141__namespace.default.useCallback((mode) => {
72754
- trackCoreEvent("Operations Overview Poorest Line Mode Changed", {
72755
- mode
74706
+ shift_mode: nextMode
72756
74707
  });
72757
- setPoorestLineMode(mode);
72758
- }, []);
74708
+ onTrendModeChange(nextMode);
74709
+ }, [onTrendModeChange]);
72759
74710
  React141__namespace.default.useEffect(() => {
72760
- function handleClickOutside(event) {
74711
+ const handleClickOutside = (event) => {
72761
74712
  if (filterRef.current && !filterRef.current.contains(event.target) && filterButtonRef.current && !filterButtonRef.current.contains(event.target) && mobileFilterButtonRef.current && !mobileFilterButtonRef.current.contains(event.target)) {
72762
74713
  setIsFilterOpen(false);
72763
74714
  }
72764
- }
74715
+ };
72765
74716
  document.addEventListener("mousedown", handleClickOutside);
72766
74717
  return () => {
72767
74718
  document.removeEventListener("mousedown", handleClickOutside);
72768
74719
  };
72769
74720
  }, []);
72770
- const initializedTimezoneRef = React141__namespace.default.useRef(appTimezone);
72771
- React141__namespace.default.useEffect(() => {
72772
- if (initializedTimezoneRef.current === appTimezone) return;
72773
- setDateRange(getCurrentWeekToDateRange(appTimezone));
72774
- initializedTimezoneRef.current = appTimezone;
72775
- }, [appTimezone]);
72776
- const companyId = entityConfig.companyId;
72777
- const scopedLineIds = React141__namespace.default.useMemo(
72778
- () => Array.from(new Set((accessibleLineIds || []).filter(Boolean))),
72779
- [accessibleLineIds]
72780
- );
72781
- const lineIdsKey = React141__namespace.default.useMemo(
72782
- () => scopedLineIds.slice().sort().join(","),
72783
- [scopedLineIds]
72784
- );
72785
- React141__namespace.default.useEffect(() => {
72786
- setIsIdleContributorsOpen(false);
72787
- setIsIdleContributorsPinned(false);
72788
- }, [companyId, dateRange.endKey, dateRange.startKey, lineIdsKey, trendMode]);
72789
- const { supervisorsByLineId } = useSupervisorsByLineIds(scopedLineIds, {
72790
- enabled: !!companyId && scopedLineIds.length > 0,
72791
- companyId,
72792
- useBackend: true
72793
- });
72794
- React141__namespace.default.useEffect(() => {
72795
- if (!supabase || !companyId) return void 0;
72796
- if (scopedLineIds.length === 0) {
72797
- setOverview(EMPTY_OVERVIEW);
72798
- setIdleReasonBreakdown([]);
72799
- setIsSnapshotLoading(false);
72800
- return void 0;
72801
- }
72802
- let cancelled = false;
72803
- setOverview((prev) => ({
72804
- ...prev,
72805
- scope: EMPTY_OVERVIEW.scope,
72806
- summary: EMPTY_OVERVIEW.summary,
72807
- poorest_lines: EMPTY_OVERVIEW.poorest_lines
72808
- }));
72809
- setIsSnapshotLoading(true);
72810
- const fetchOverviewSnapshot = async () => {
72811
- const params = new URLSearchParams({
72812
- company_id: companyId,
72813
- start_date: dateRange.startKey,
72814
- end_date: dateRange.endKey,
72815
- trend_shift_mode: trendMode,
72816
- line_ids: scopedLineIds.join(",")
72817
- });
72818
- const response = await fetchBackendJson(
72819
- supabase,
72820
- `/api/dashboard/operations-overview/snapshot?${params.toString()}`
72821
- );
72822
- if (!cancelled) {
72823
- setOverview((prev) => ({
72824
- ...prev,
72825
- scope: response.scope || EMPTY_OVERVIEW.scope,
72826
- summary: response.summary || EMPTY_OVERVIEW.summary,
72827
- poorest_lines: response.poorest_lines || EMPTY_OVERVIEW.poorest_lines
72828
- }));
72829
- }
72830
- };
72831
- fetchOverviewSnapshot().catch((error) => {
72832
- console.error("[PlantHeadView] Failed to fetch operations overview snapshot", error);
72833
- if (!cancelled) {
72834
- setOverview((prev) => ({
72835
- ...prev,
72836
- scope: EMPTY_OVERVIEW.scope,
72837
- summary: EMPTY_OVERVIEW.summary,
72838
- poorest_lines: EMPTY_OVERVIEW.poorest_lines
72839
- }));
72840
- }
72841
- }).finally(() => {
72842
- if (!cancelled) {
72843
- setIsSnapshotLoading(false);
72844
- }
72845
- });
72846
- return () => {
72847
- cancelled = true;
72848
- };
72849
- }, [
72850
- companyId,
72851
- dateRange.endKey,
72852
- dateRange.startKey,
72853
- lineIdsKey,
72854
- scopedLineIds,
72855
- supabase,
72856
- trendMode
72857
- ]);
72858
- React141__namespace.default.useEffect(() => {
72859
- if (!supabase || !companyId) return void 0;
72860
- if (scopedLineIds.length === 0) {
72861
- setOverview((prev) => ({
72862
- ...prev,
72863
- trend: EMPTY_OVERVIEW.trend
72864
- }));
72865
- setIsTrendLoading(false);
72866
- return void 0;
72867
- }
72868
- let cancelled = false;
72869
- setIsTrendLoading(true);
72870
- const fetchOverviewTrend = async () => {
72871
- const params = new URLSearchParams({
72872
- company_id: companyId,
72873
- start_date: dateRange.startKey,
72874
- end_date: dateRange.endKey,
72875
- trend_shift_mode: trendMode,
72876
- line_ids: scopedLineIds.join(",")
72877
- });
72878
- const response = await fetchBackendJson(
72879
- supabase,
72880
- `/api/dashboard/operations-overview/trend?${params.toString()}`
72881
- );
72882
- if (!cancelled) {
72883
- setOverview((prev) => ({
72884
- ...prev,
72885
- trend: response.trend || EMPTY_OVERVIEW.trend
72886
- }));
72887
- setTrendFetchNonce((prev) => prev + 1);
72888
- }
72889
- };
72890
- fetchOverviewTrend().catch((error) => {
72891
- console.error("[PlantHeadView] Failed to fetch operations overview trend", error);
72892
- }).finally(() => {
72893
- if (!cancelled) {
72894
- setIsTrendLoading(false);
72895
- }
72896
- });
72897
- return () => {
72898
- cancelled = true;
72899
- };
72900
- }, [
72901
- companyId,
72902
- dateRange.endKey,
72903
- dateRange.startKey,
72904
- lineIdsKey,
72905
- scopedLineIds,
72906
- supabase,
72907
- trendMode
72908
- ]);
72909
- React141__namespace.default.useEffect(() => {
72910
- if (!supabase || !companyId) return void 0;
72911
- if (scopedLineIds.length === 0) {
72912
- setIdleReasonScope(null);
72913
- setIdleReasonBreakdown([]);
72914
- setIsIdleReasonBreakdownLoading(false);
72915
- return void 0;
72916
- }
72917
- let cancelled = false;
72918
- setIdleReasonScope(null);
72919
- setIdleReasonBreakdown([]);
72920
- setIsIdleReasonBreakdownLoading(true);
72921
- const fetchIdleReasonBreakdown = async () => {
72922
- const params = new URLSearchParams({
72923
- company_id: companyId,
72924
- start_date: dateRange.startKey,
72925
- end_date: dateRange.endKey,
72926
- trend_shift_mode: trendMode,
72927
- line_ids: scopedLineIds.join(",")
72928
- });
72929
- const response = await fetchBackendJson(
72930
- supabase,
72931
- `/api/dashboard/operations-overview/idle-reason-breakdown?${params.toString()}`
72932
- );
72933
- if (!cancelled) {
72934
- setIdleReasonScope(response.scope || null);
72935
- setIdleReasonBreakdown(response.idle_reason_breakdown || []);
72936
- }
72937
- };
72938
- fetchIdleReasonBreakdown().catch((error) => {
72939
- console.error("[PlantHeadView] Failed to fetch idle reason breakdown", error);
72940
- if (!cancelled) {
72941
- setIdleReasonScope(null);
72942
- setIdleReasonBreakdown([]);
72943
- }
72944
- }).finally(() => {
72945
- if (!cancelled) {
72946
- setIsIdleReasonBreakdownLoading(false);
72947
- }
72948
- });
72949
- return () => {
72950
- cancelled = true;
72951
- };
72952
- }, [
72953
- companyId,
72954
- dateRange.endKey,
72955
- dateRange.startKey,
72956
- lineIdsKey,
72957
- scopedLineIds,
72958
- supabase,
72959
- trendMode
72960
- ]);
72961
- React141__namespace.default.useEffect(() => {
72962
- if (!supabase || !companyId) return void 0;
72963
- if (scopedLineIds.length === 0) {
72964
- setImprovements([]);
72965
- setIsImprovementsLoading(false);
72966
- return void 0;
72967
- }
72968
- let cancelled = false;
72969
- setIsImprovementsLoading(true);
72970
- const fetchImprovements = async () => {
72971
- const params = new URLSearchParams({
72972
- company_id: companyId,
72973
- status: "open",
72974
- limit: "200",
72975
- line_ids: scopedLineIds.join(",")
72976
- });
72977
- const response = await fetchBackendJson(
72978
- supabase,
72979
- `/api/improvement-center/recommendations?${params.toString()}`
72980
- );
72981
- if (cancelled) return;
72982
- const allowedLineIds = new Set(scopedLineIds);
72983
- const scopedRecommendations = (response.recommendations || []).filter((recommendation) => {
72984
- return !recommendation.line_id || allowedLineIds.has(recommendation.line_id);
72985
- });
72986
- const nextImprovements = [...scopedRecommendations].sort(compareImprovementRecommendationPriority).slice(0, 3).map((recommendation) => ({
72987
- id: recommendation.issue_id || recommendation.id,
72988
- issueId: recommendation.issue_id || recommendation.id,
72989
- issueNumber: recommendation.issue_number,
72990
- title: recommendation.title?.trim() || "Untitled issue",
72991
- metric: buildImprovementMetric(recommendation),
72992
- location: recommendation.location,
72993
- line: recommendation.line,
72994
- lineId: recommendation.line_id,
72995
- workspaceId: recommendation.workspace_id
72996
- }));
72997
- setImprovements(nextImprovements);
72998
- };
72999
- fetchImprovements().catch((error) => {
73000
- console.error("[PlantHeadView] Failed to fetch improvements", error);
73001
- if (!cancelled) {
73002
- setImprovements([]);
73003
- }
73004
- }).finally(() => {
73005
- if (!cancelled) {
73006
- setIsImprovementsLoading(false);
73007
- }
73008
- });
73009
- return () => {
73010
- cancelled = true;
73011
- };
73012
- }, [companyId, lineIdsKey, scopedLineIds, supabase]);
73013
- const availableLineModes = overview.scope?.available_line_modes;
73014
- React141__namespace.default.useEffect(() => {
73015
- const hasOutput = !!availableLineModes?.has_output;
73016
- const hasUptime = !!availableLineModes?.has_uptime;
73017
- if (hasOutput && !hasUptime && poorestLineMode !== "output") {
73018
- setPoorestLineMode("output");
73019
- } else if (hasUptime && !hasOutput && poorestLineMode !== "uptime") {
73020
- setPoorestLineMode("uptime");
73021
- }
73022
- }, [availableLineModes?.has_output, availableLineModes?.has_uptime, poorestLineMode]);
73023
- const comparisonLabel = React141__namespace.default.useMemo(
73024
- () => formatComparisonWindow(overview.scope?.current_range?.day_count ?? null),
73025
- [overview.scope?.current_range?.day_count]
73026
- );
74721
+ return /* @__PURE__ */ jsxRuntime.jsx("header", { className: "sticky top-0 z-10 bg-white border-b flex-shrink-0 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 sm:px-4 md:px-6 py-2 sm:py-3 relative", children: [
74722
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
74723
+ mobileMenuContext ? /* @__PURE__ */ jsxRuntime.jsx(
74724
+ HamburgerButton,
74725
+ {
74726
+ onClick: mobileMenuContext.onMobileMenuOpen || (() => {
74727
+ }),
74728
+ className: "flex-shrink-0 -ml-1"
74729
+ }
74730
+ ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 flex-shrink-0" }),
74731
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center", children: [
74732
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold text-gray-900 text-center px-1 truncate max-w-[200px]", children: "Operations Overview" }),
74733
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium text-slate-500 text-center mt-0.5", children: mobileSubtitle })
74734
+ ] }),
74735
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-shrink-0 flex items-center gap-1.5", children: [
74736
+ /* @__PURE__ */ jsxRuntime.jsx(
74737
+ MonthlyRangeFilter_default,
74738
+ {
74739
+ month: parseDateKeyToDate(dateRange.startKey).getMonth(),
74740
+ year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
74741
+ timezone: appTimezone,
74742
+ value: dateRange,
74743
+ onChange: onDateRangeChange,
74744
+ showLabel: false
74745
+ }
74746
+ ),
74747
+ /* @__PURE__ */ jsxRuntime.jsxs(
74748
+ "button",
74749
+ {
74750
+ ref: mobileFilterButtonRef,
74751
+ onClick: handleFilterToggle,
74752
+ className: `p-2 rounded-full transition-colors relative ${isFilterOpen || trendMode !== "all" ? "bg-blue-50" : "active:bg-gray-100"}`,
74753
+ "aria-label": "Open filters",
74754
+ children: [
74755
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: `w-5 h-5 ${trendMode !== "all" ? "text-blue-600" : "text-gray-700"}` }),
74756
+ trendMode !== "all" ? /* @__PURE__ */ jsxRuntime.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
74757
+ ]
74758
+ }
74759
+ )
74760
+ ] })
74761
+ ] }) }),
74762
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center relative min-h-[56px]", children: [
74763
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute left-1/2 -translate-x-1/2 flex flex-col items-center pointer-events-none", children: [
74764
+ /* @__PURE__ */ jsxRuntime.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" }),
74765
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium text-slate-500 text-center pointer-events-auto", children: desktopSubtitle })
74766
+ ] }),
74767
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute right-0 flex items-center gap-3", children: [
74768
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
74769
+ MonthlyRangeFilter_default,
74770
+ {
74771
+ month: parseDateKeyToDate(dateRange.startKey).getMonth(),
74772
+ year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
74773
+ timezone: appTimezone,
74774
+ value: dateRange,
74775
+ onChange: onDateRangeChange,
74776
+ showLabel: false
74777
+ }
74778
+ ) }),
74779
+ /* @__PURE__ */ jsxRuntime.jsxs(
74780
+ "button",
74781
+ {
74782
+ ref: filterButtonRef,
74783
+ onClick: handleFilterToggle,
74784
+ 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"}`,
74785
+ "aria-label": "Open filters",
74786
+ children: [
74787
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: `w-[18px] h-[18px] ${trendMode !== "all" ? "text-blue-600" : "text-slate-500"}` }),
74788
+ "Filters",
74789
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: `w-4 h-4 ml-0.5 transition-transform duration-200 ${isFilterOpen ? "rotate-180" : ""}` })
74790
+ ]
74791
+ }
74792
+ )
74793
+ ] })
74794
+ ] }) }),
74795
+ isFilterOpen ? /* @__PURE__ */ jsxRuntime.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: [
74796
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-3", children: [
74797
+ /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-gray-900", children: "Filter View" }),
74798
+ trendMode !== "all" ? /* @__PURE__ */ jsxRuntime.jsx(
74799
+ "button",
74800
+ {
74801
+ onClick: () => {
74802
+ onTrendModeChange("all");
74803
+ setIsFilterOpen(false);
74804
+ },
74805
+ className: "text-xs text-red-600 hover:text-red-700 font-medium",
74806
+ children: "Clear all"
74807
+ }
74808
+ ) : null
74809
+ ] }),
74810
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
74811
+ /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide ml-1", children: "Shift" }),
74812
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
74813
+ "select",
74814
+ {
74815
+ value: trendMode,
74816
+ onChange: handleTrendModeChange,
74817
+ 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",
74818
+ style: {
74819
+ 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")`,
74820
+ backgroundPosition: "right 0.75rem center",
74821
+ backgroundRepeat: "no-repeat",
74822
+ backgroundSize: "1.2em 1.2em"
74823
+ },
74824
+ children: [
74825
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Shifts" }),
74826
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "day", children: "Day Shift" }),
74827
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "night", children: "Night Shift" })
74828
+ ]
74829
+ }
74830
+ ) })
74831
+ ] }) })
74832
+ ] }) : null
74833
+ ] }) });
74834
+ });
74835
+ OperationsOverviewHeader.displayName = "OperationsOverviewHeader";
74836
+ var OverviewSummaryCards = React141__namespace.default.memo(({ store }) => {
74837
+ bumpRenderCounter();
74838
+ const scope = useOperationsOverviewScope(store);
74839
+ const snapshot = useOperationsOverviewSnapshot(store);
74840
+ const showSnapshotSkeleton = snapshot.loading && !snapshot.hasLoadedOnce;
74841
+ const comparisonLabel = React141__namespace.default.useMemo(() => {
74842
+ return formatComparisonWindow(
74843
+ scope.previous_range?.day_count ?? null,
74844
+ scope.comparison_strategy
74845
+ );
74846
+ }, [scope.comparison_strategy, scope.previous_range?.day_count]);
74847
+ const [isIdleContributorsOpen, setIsIdleContributorsOpen] = React141__namespace.default.useState(false);
74848
+ const [isIdleContributorsPinned, setIsIdleContributorsPinned] = React141__namespace.default.useState(false);
74849
+ const idleContributorsRef = React141__namespace.default.useRef(null);
73027
74850
  const plantEfficiencyBadge = React141__namespace.default.useMemo(() => {
73028
- return buildDeltaBadge(overview.summary?.plant_efficiency?.delta_pp, {
74851
+ return buildDeltaBadge(snapshot.data.summary.plant_efficiency?.delta_pp, {
73029
74852
  positiveIsGood: true,
73030
74853
  formatter: (value) => `${value >= 0 ? "+" : ""}${roundOne(value)}%`,
73031
74854
  comparisonLabel
73032
74855
  });
73033
- }, [comparisonLabel, overview.summary?.plant_efficiency?.delta_pp]);
74856
+ }, [comparisonLabel, snapshot.data.summary.plant_efficiency?.delta_pp]);
73034
74857
  const idleBadge = React141__namespace.default.useMemo(() => {
73035
- return buildDeltaBadge(overview.summary?.avg_idle_per_workstation?.delta_seconds, {
74858
+ return buildDeltaBadge(snapshot.data.summary.avg_idle_per_workstation?.delta_seconds, {
73036
74859
  positiveIsGood: false,
73037
74860
  formatter: (value) => formatSignedIdleDuration(value),
73038
74861
  comparisonLabel
73039
74862
  });
73040
- }, [comparisonLabel, overview.summary?.avg_idle_per_workstation?.delta_seconds]);
74863
+ }, [comparisonLabel, snapshot.data.summary.avg_idle_per_workstation?.delta_seconds]);
73041
74864
  const canInspectIdleContributors = React141__namespace.default.useMemo(() => {
73042
- return !isSnapshotLoading && overview.summary?.avg_idle_per_workstation?.current_seconds !== null && overview.summary?.avg_idle_per_workstation?.current_seconds !== void 0;
73043
- }, [isSnapshotLoading, overview.summary?.avg_idle_per_workstation?.current_seconds]);
74865
+ return !showSnapshotSkeleton && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== null && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== void 0;
74866
+ }, [showSnapshotSkeleton, snapshot.data.summary.avg_idle_per_workstation?.current_seconds]);
73044
74867
  const idleTopContributors = React141__namespace.default.useMemo(() => {
73045
- return (overview.summary?.avg_idle_per_workstation?.top_contributors || []).map((item) => ({
74868
+ return (snapshot.data.summary.avg_idle_per_workstation?.top_contributors || []).map((item) => ({
73046
74869
  workspaceId: item.workspace_id || "",
73047
74870
  workspaceName: item.workspace_name?.trim() || item.workspace_id || "Unknown",
73048
- lineId: item.line_id || "",
73049
74871
  lineName: item.line_name?.trim() || "Unknown Line",
73050
74872
  avgIdleSeconds: toNumber3(item.avg_idle_seconds)
73051
74873
  })).slice(0, 5);
73052
- }, [overview.summary?.avg_idle_per_workstation?.top_contributors]);
74874
+ }, [snapshot.data.summary.avg_idle_per_workstation?.top_contributors]);
73053
74875
  const showIdleContributorLineNames = React141__namespace.default.useMemo(() => {
73054
- return (overview.scope?.line_count ?? 0) > 1;
73055
- }, [overview.scope?.line_count]);
74876
+ return (scope.line_count ?? 0) > 1;
74877
+ }, [scope.line_count]);
73056
74878
  const closeIdleContributors = React141__namespace.default.useCallback(() => {
73057
74879
  setIsIdleContributorsOpen(false);
73058
74880
  setIsIdleContributorsPinned(false);
73059
74881
  }, []);
73060
74882
  const handleIdleContributorsToggle = React141__namespace.default.useCallback(() => {
73061
74883
  if (!canInspectIdleContributors) return;
73062
- setIsIdleContributorsPinned((prev) => {
73063
- const next = !prev;
74884
+ setIsIdleContributorsPinned((previous) => {
74885
+ const next = !previous;
73064
74886
  setIsIdleContributorsOpen(next);
73065
74887
  return next;
73066
74888
  });
@@ -73077,6 +74899,10 @@ var PlantHeadView = () => {
73077
74899
  closeIdleContributors();
73078
74900
  }
73079
74901
  }, [canInspectIdleContributors, closeIdleContributors, handleIdleContributorsToggle]);
74902
+ React141__namespace.default.useEffect(() => {
74903
+ setIsIdleContributorsOpen(false);
74904
+ setIsIdleContributorsPinned(false);
74905
+ }, [scope.comparison_strategy, scope.current_range?.start_date, scope.current_range?.end_date, scope.line_count, scope.shift_mode]);
73080
74906
  React141__namespace.default.useEffect(() => {
73081
74907
  if (!isIdleContributorsOpen) return void 0;
73082
74908
  const handleClickOutside = (event) => {
@@ -73099,14 +74925,298 @@ var PlantHeadView = () => {
73099
74925
  document.removeEventListener("keydown", handleEscape);
73100
74926
  };
73101
74927
  }, [closeIdleContributors, isIdleContributorsOpen, isIdleContributorsPinned]);
74928
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
74929
+ /* @__PURE__ */ jsxRuntime.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: [
74930
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between items-center mb-1", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Overall Efficiency" }) }),
74931
+ showSnapshotSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewMetricCardSkeleton, {}) : snapshot.data.summary.plant_efficiency?.current !== null && snapshot.data.summary.plant_efficiency?.current !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
74932
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: [
74933
+ roundOne(snapshot.data.summary.plant_efficiency.current),
74934
+ "%"
74935
+ ] }),
74936
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${plantEfficiencyBadge.className}`, children: [
74937
+ plantEfficiencyBadge.icon === "up" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : plantEfficiencyBadge.icon === "down" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
74938
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium", children: plantEfficiencyBadge.text })
74939
+ ] })
74940
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No efficiency data available" })
74941
+ ] }),
74942
+ /* @__PURE__ */ jsxRuntime.jsxs(
74943
+ "div",
74944
+ {
74945
+ ref: idleContributorsRef,
74946
+ "data-testid": "idle-kpi-card-region",
74947
+ className: "relative",
74948
+ onMouseEnter: () => {
74949
+ if (canInspectIdleContributors) {
74950
+ setIsIdleContributorsOpen(true);
74951
+ }
74952
+ },
74953
+ onMouseLeave: () => {
74954
+ if (!isIdleContributorsPinned) {
74955
+ setIsIdleContributorsOpen(false);
74956
+ }
74957
+ },
74958
+ onFocus: () => {
74959
+ if (canInspectIdleContributors) {
74960
+ setIsIdleContributorsOpen(true);
74961
+ }
74962
+ },
74963
+ onBlur: (event) => {
74964
+ if (isIdleContributorsPinned) return;
74965
+ const nextTarget = event.relatedTarget;
74966
+ if (nextTarget && idleContributorsRef.current?.contains(nextTarget)) return;
74967
+ setIsIdleContributorsOpen(false);
74968
+ },
74969
+ children: [
74970
+ /* @__PURE__ */ jsxRuntime.jsxs(
74971
+ "div",
74972
+ {
74973
+ "data-testid": "idle-kpi-card",
74974
+ role: canInspectIdleContributors ? "button" : void 0,
74975
+ tabIndex: canInspectIdleContributors ? 0 : -1,
74976
+ "aria-controls": canInspectIdleContributors ? "idle-kpi-popover" : void 0,
74977
+ "aria-expanded": canInspectIdleContributors ? isIdleContributorsOpen : void 0,
74978
+ 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"}`,
74979
+ onClick: handleIdleContributorsToggle,
74980
+ onKeyDown: handleIdleContributorsKeyDown,
74981
+ children: [
74982
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time per Workstation" }) }),
74983
+ showSnapshotSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewMetricCardSkeleton, {}) : snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== null && snapshot.data.summary.avg_idle_per_workstation?.current_seconds !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
74984
+ /* @__PURE__ */ jsxRuntime.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) }),
74985
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${idleBadge.className}`, children: [
74986
+ idleBadge.icon === "up" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : idleBadge.icon === "down" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
74987
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium", children: idleBadge.text })
74988
+ ] })
74989
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No idle time data available" })
74990
+ ]
74991
+ }
74992
+ ),
74993
+ canInspectIdleContributors && isIdleContributorsOpen ? /* @__PURE__ */ jsxRuntime.jsxs(
74994
+ "div",
74995
+ {
74996
+ id: "idle-kpi-popover",
74997
+ "data-testid": "idle-kpi-popover",
74998
+ 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]",
74999
+ children: [
75000
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 pb-3 mb-3 border-b border-slate-100", children: [
75001
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2.5 h-2.5 rounded-full flex-shrink-0 bg-red-500" }),
75002
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-slate-800 text-[15px]", children: "Idle Time per Workstation" })
75003
+ ] }),
75004
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
75005
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400 mb-3", children: "TOP CONTRIBUTORS" }),
75006
+ idleTopContributors.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2.5", children: idleTopContributors.map((contributor, index) => /* @__PURE__ */ jsxRuntime.jsxs(
75007
+ "div",
75008
+ {
75009
+ className: "flex items-start justify-between gap-3",
75010
+ children: [
75011
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
75012
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-slate-600 text-[13px] truncate", title: contributor.workspaceName, children: contributor.workspaceName }),
75013
+ showIdleContributorLineNames && contributor.lineName ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] font-medium text-slate-400 truncate", title: contributor.lineName, children: contributor.lineName }) : null
75014
+ ] }),
75015
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-slate-500 text-[13px] text-right whitespace-nowrap", children: formatIdleDuration(contributor.avgIdleSeconds) })
75016
+ ]
75017
+ },
75018
+ `${contributor.workspaceId || contributor.workspaceName}-${index}`
75019
+ )) }) : /* @__PURE__ */ jsxRuntime.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." })
75020
+ ] })
75021
+ ]
75022
+ }
75023
+ ) : null
75024
+ ]
75025
+ }
75026
+ )
75027
+ ] });
75028
+ });
75029
+ OverviewSummaryCards.displayName = "OverviewSummaryCards";
75030
+ var PoorestPerformersCard = React141__namespace.default.memo(({
75031
+ store,
75032
+ supervisorsByLineId,
75033
+ onViewAll,
75034
+ onLineClick
75035
+ }) => {
75036
+ bumpRenderCounter();
75037
+ const scope = useOperationsOverviewScope(store);
75038
+ const snapshot = useOperationsOverviewSnapshot(store);
75039
+ const [poorestLineMode, setPoorestLineMode] = React141__namespace.default.useState("output");
75040
+ const availableLineModes = scope.available_line_modes;
75041
+ React141__namespace.default.useEffect(() => {
75042
+ const hasOutput = !!availableLineModes?.has_output;
75043
+ const hasUptime = !!availableLineModes?.has_uptime;
75044
+ if (hasOutput && !hasUptime && poorestLineMode !== "output") {
75045
+ setPoorestLineMode("output");
75046
+ } else if (hasUptime && !hasOutput && poorestLineMode !== "uptime") {
75047
+ setPoorestLineMode("uptime");
75048
+ }
75049
+ }, [availableLineModes?.has_output, availableLineModes?.has_uptime, poorestLineMode]);
75050
+ const comparisonLabel = React141__namespace.default.useMemo(() => {
75051
+ return formatComparisonWindow(
75052
+ scope.previous_range?.day_count ?? null,
75053
+ scope.comparison_strategy
75054
+ );
75055
+ }, [scope.comparison_strategy, scope.previous_range?.day_count]);
75056
+ const showSnapshotSkeleton = snapshot.loading && !snapshot.hasLoadedOnce;
75057
+ const mergedPoorestLines = React141__namespace.default.useMemo(() => {
75058
+ const rows = snapshot.data.poorest_lines?.[poorestLineMode] || [];
75059
+ return rows.slice(0, 3).map((line) => {
75060
+ const lineId = line.line_id || "";
75061
+ const supervisors = supervisorsByLineId.get(lineId) || [];
75062
+ const supervisor = supervisors[0];
75063
+ return {
75064
+ id: lineId,
75065
+ name: line.line_name?.trim() || "Unknown Line",
75066
+ efficiency: roundOne(toNumber3(line.avg_efficiency) || 0),
75067
+ previousEfficiency: toNumber3(line.previous_avg_efficiency),
75068
+ delta: toNumber3(line.delta_pp),
75069
+ supervisor: supervisor?.displayName || "Unassigned",
75070
+ supervisorImage: supervisor?.profilePhotoUrl ?? null
75071
+ };
75072
+ });
75073
+ }, [poorestLineMode, snapshot.data.poorest_lines, supervisorsByLineId]);
75074
+ const showPoorestModeToggle = !!availableLineModes?.has_output && !!availableLineModes?.has_uptime;
75075
+ const poorestMetricLabel = poorestLineMode === "uptime" ? "Uptime" : "Efficiency";
75076
+ const handlePoorestLineModeChange = React141__namespace.default.useCallback((mode) => {
75077
+ trackCoreEvent("Operations Overview Poorest Line Mode Changed", { mode });
75078
+ setPoorestLineMode(mode);
75079
+ }, []);
75080
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
75081
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 border-b border-slate-50 flex justify-between items-center gap-3 flex-wrap", children: [
75082
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
75083
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Poorest Performers" }),
75084
+ showPoorestModeToggle ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex bg-slate-100 p-0.5 rounded-lg", children: [
75085
+ /* @__PURE__ */ jsxRuntime.jsx(
75086
+ "button",
75087
+ {
75088
+ type: "button",
75089
+ onClick: () => handlePoorestLineModeChange("output"),
75090
+ 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"}`,
75091
+ children: "Output"
75092
+ }
75093
+ ),
75094
+ /* @__PURE__ */ jsxRuntime.jsx(
75095
+ "button",
75096
+ {
75097
+ type: "button",
75098
+ onClick: () => handlePoorestLineModeChange("uptime"),
75099
+ 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"}`,
75100
+ children: "Uptime"
75101
+ }
75102
+ )
75103
+ ] }) : null
75104
+ ] }),
75105
+ /* @__PURE__ */ jsxRuntime.jsx(
75106
+ "button",
75107
+ {
75108
+ type: "button",
75109
+ "aria-label": "View all",
75110
+ onClick: onViewAll,
75111
+ className: "inline-flex items-center justify-center rounded-md p-1 text-slate-500 hover:text-slate-800 transition-colors",
75112
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRight, { className: "h-4 w-4 shrink-0", strokeWidth: 2.5, "aria-hidden": true })
75113
+ }
75114
+ )
75115
+ ] }),
75116
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex flex-col p-0 overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-slate-50 flex-1 px-5", children: [
75117
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between py-2", children: [
75118
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider min-w-[120px]", children: "Line" }),
75119
+ /* @__PURE__ */ jsxRuntime.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 })
75120
+ ] }),
75121
+ showSnapshotSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewListSkeleton, {}) : mergedPoorestLines.length > 0 ? mergedPoorestLines.map((line) => {
75122
+ const lineDelta = buildLineDeltaTone(line.delta, comparisonLabel);
75123
+ return /* @__PURE__ */ jsxRuntime.jsx(
75124
+ "div",
75125
+ {
75126
+ onClick: () => onLineClick(line.id, line.name),
75127
+ className: "block py-3 hover:bg-slate-50/50 transition-colors cursor-pointer group relative",
75128
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
75129
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
75130
+ /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
75131
+ "img",
75132
+ {
75133
+ src: line.supervisorImage,
75134
+ alt: line.supervisor,
75135
+ className: "w-full h-full object-cover"
75136
+ }
75137
+ ) : /* @__PURE__ */ jsxRuntime.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) }) }),
75138
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
75139
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-bold text-slate-800 text-[13px] truncate group-hover:text-indigo-600 transition-colors", children: line.name }) }),
75140
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 mt-0.5 flex-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-slate-400 font-medium", children: line.supervisor }) })
75141
+ ] })
75142
+ ] }),
75143
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between shrink-0 w-[110px]", children: [
75144
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[15px] leading-none font-bold text-slate-800", children: [
75145
+ line.efficiency,
75146
+ "%"
75147
+ ] }),
75148
+ line.delta !== null && line.delta !== void 0 && Number.isFinite(line.delta) ? /* @__PURE__ */ jsxRuntime.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: [
75149
+ line.delta >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3 h-3", strokeWidth: 2.5 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3 h-3", strokeWidth: 2.5 }),
75150
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] leading-none font-bold", children: lineDelta.text.split(" vs ")[0].replace("+", "") })
75151
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-0.5 px-2 py-0.5 rounded-full bg-slate-50 text-slate-400", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] leading-none font-bold", children: "\u2014" }) })
75152
+ ] })
75153
+ ] })
75154
+ },
75155
+ line.id
75156
+ );
75157
+ }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: `No ${poorestLineMode} line data available` })
75158
+ ] }) })
75159
+ ] });
75160
+ });
75161
+ PoorestPerformersCard.displayName = "PoorestPerformersCard";
75162
+ var IdleBreakdownCard = React141__namespace.default.memo(({
75163
+ store,
75164
+ scopedLineCount
75165
+ }) => {
75166
+ bumpRenderCounter();
75167
+ const idle = useOperationsOverviewIdle(store);
75168
+ const showInitialSkeleton = idle.loading && idle.lastUpdated === null;
75169
+ const idleBreakdown = React141__namespace.default.useMemo(() => {
75170
+ return idle.data.map((item) => ({
75171
+ name: item.reason?.trim() || "Unknown",
75172
+ value: toNumber3(item.percentage) || 0,
75173
+ totalDurationSeconds: toNumber3(item.total_duration_seconds),
75174
+ efficiencyLossPercentage: toNumber3(item.efficiency_loss_percentage),
75175
+ contributors: (item.contributors || []).map((contributor) => ({
75176
+ workspaceId: contributor.workspace_id || "",
75177
+ workspaceName: contributor.workspace_name?.trim() || "Unknown",
75178
+ totalDurationSeconds: toNumber3(contributor.total_duration_seconds),
75179
+ percentageWithinReason: toNumber3(contributor.percentage_within_reason)
75180
+ }))
75181
+ })).filter((item) => item.value > 0);
75182
+ }, [idle.data]);
75183
+ const showIdleModuleNotEnabledState = React141__namespace.default.useMemo(() => {
75184
+ const enabledLineCount = idle.scope.idle_time_vlm_enabled_line_count;
75185
+ return !showInitialSkeleton && scopedLineCount > 0 && typeof enabledLineCount === "number" && enabledLineCount === 0;
75186
+ }, [idle.scope.idle_time_vlm_enabled_line_count, scopedLineCount, showInitialSkeleton]);
75187
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden text-left", children: [
75188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50 relative", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time Breakdown" }) }),
75189
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-[250px] p-4 pt-2 relative", children: showInitialSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewIdleBreakdownSkeleton, {}) : showIdleModuleNotEnabledState ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs("div", { children: [
75190
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-semibold text-slate-700", children: "Module not enabled" }),
75191
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-slate-500", children: "Enable idle-time classification on at least one line to view this breakdown." })
75192
+ ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
75193
+ IdleTimeReasonChart,
75194
+ {
75195
+ data: idleBreakdown,
75196
+ isLoading: false,
75197
+ hideTotalDuration: true,
75198
+ updateAnimation: "smooth"
75199
+ }
75200
+ ) })
75201
+ ] });
75202
+ });
75203
+ IdleBreakdownCard.displayName = "IdleBreakdownCard";
75204
+ var EfficiencyTrendCard = React141__namespace.default.memo(({
75205
+ store,
75206
+ dateRange,
75207
+ appTimezone
75208
+ }) => {
75209
+ bumpRenderCounter();
75210
+ const trend = useOperationsOverviewTrend(store);
73102
75211
  const currentWeekRange = React141__namespace.default.useMemo(
73103
75212
  () => getCurrentWeekToDateRange(appTimezone),
73104
75213
  [appTimezone]
73105
75214
  );
73106
75215
  const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
75216
+ const showInitialSkeleton = trend.loading && trend.lastUpdated === null;
73107
75217
  const trendData = React141__namespace.default.useMemo(() => {
73108
75218
  const pointsByDate = new Map(
73109
- (overview.trend?.points || []).flatMap((point) => {
75219
+ (trend.data.points || []).flatMap((point) => {
73110
75220
  if (!point.date) return [];
73111
75221
  const pointDate = parseDateKeyToDate(point.date);
73112
75222
  return [[point.date, {
@@ -73131,7 +75241,7 @@ var PlantHeadView = () => {
73131
75241
  };
73132
75242
  });
73133
75243
  }
73134
- return (overview.trend?.points || []).map((point) => {
75244
+ return (trend.data.points || []).map((point) => {
73135
75245
  const pointDate = point.date ? parseDateKeyToDate(point.date) : null;
73136
75246
  return {
73137
75247
  name: pointDate ? dateFns.format(pointDate, "MMM d") : "",
@@ -73142,55 +75252,42 @@ var PlantHeadView = () => {
73142
75252
  })()
73143
75253
  };
73144
75254
  });
73145
- }, [currentWeekRange.startKey, isCurrentWeekToDateRange, overview.trend?.points]);
73146
- const trendPlayKey = React141__namespace.default.useMemo(() => {
73147
- return `${trendViewOpenNonce}:${trendFetchNonce}`;
73148
- }, [trendFetchNonce, trendViewOpenNonce]);
73149
- const idleBreakdown = React141__namespace.default.useMemo(() => {
73150
- return idleReasonBreakdown.map((item) => ({
73151
- name: item.reason?.trim() || "Unknown",
73152
- value: toNumber3(item.percentage) || 0,
73153
- totalDurationSeconds: toNumber3(item.total_duration_seconds),
73154
- efficiencyLossPercentage: toNumber3(item.efficiency_loss_percentage),
73155
- contributors: (item.contributors || []).map((contributor) => ({
73156
- workspaceId: contributor.workspace_id || "",
73157
- workspaceName: contributor.workspace_name?.trim() || "Unknown",
73158
- totalDurationSeconds: toNumber3(contributor.total_duration_seconds),
73159
- percentageWithinReason: toNumber3(contributor.percentage_within_reason)
73160
- }))
73161
- })).filter((item) => item.value > 0);
73162
- }, [idleReasonBreakdown]);
73163
- const showIdleModuleNotEnabledState = React141__namespace.default.useMemo(() => {
73164
- const enabledLineCount = idleReasonScope?.idle_time_vlm_enabled_line_count;
73165
- return !isIdleReasonBreakdownLoading && scopedLineIds.length > 0 && typeof enabledLineCount === "number" && enabledLineCount === 0;
73166
- }, [idleReasonScope?.idle_time_vlm_enabled_line_count, isIdleReasonBreakdownLoading, scopedLineIds.length]);
73167
- const mergedPoorestLines = React141__namespace.default.useMemo(() => {
73168
- const rows = overview.poorest_lines?.[poorestLineMode] || [];
73169
- return rows.slice(0, 3).map((line) => {
73170
- const lineId = line.line_id || "";
73171
- const supervisors = supervisorsByLineId.get(lineId) || [];
73172
- const supervisor = supervisors[0];
73173
- return {
73174
- id: lineId,
73175
- name: line.line_name?.trim() || "Unknown Line",
73176
- efficiency: roundOne(toNumber3(line.avg_efficiency) || 0),
73177
- previousEfficiency: toNumber3(line.previous_avg_efficiency),
73178
- delta: toNumber3(line.delta_pp),
73179
- supervisor: supervisor?.displayName || "Unassigned",
73180
- supervisorImage: supervisor?.profilePhotoUrl ?? null
73181
- };
73182
- });
73183
- }, [overview.poorest_lines, poorestLineMode, supervisorsByLineId]);
73184
- const showPoorestModeToggle = !!availableLineModes?.has_output && !!availableLineModes?.has_uptime;
73185
- availableLineModes?.has_uptime && !availableLineModes?.has_output ? "Uptime" : "Output";
73186
- const poorestMetricLabel = poorestLineMode === "uptime" ? "Uptime" : "Efficiency";
75255
+ }, [currentWeekRange.startKey, isCurrentWeekToDateRange, trend.data.points]);
73187
75256
  const trendTooltipLabelFormatter = React141__namespace.default.useCallback((label, payload) => {
73188
75257
  const dayOfWeek = payload?.[0]?.payload?.dayOfWeek;
73189
75258
  if (!dayOfWeek || typeof label !== "string") return label;
73190
75259
  return `${label} (${dayOfWeek})`;
73191
75260
  }, []);
75261
+ return /* @__PURE__ */ jsxRuntime.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: [
75262
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-5 flex-none flex justify-between items-center border-b border-slate-50/50", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Efficiency Trend" }) }),
75263
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-[250px] w-full p-4 pt-4 relative", children: showInitialSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewChartSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pb-2 pr-4 pl-1", children: /* @__PURE__ */ jsxRuntime.jsx(
75264
+ LineChart,
75265
+ {
75266
+ data: trendData,
75267
+ lines: efficiencyLineConfig,
75268
+ xAxisDataKey: "name",
75269
+ yAxisUnit: "%",
75270
+ yAxisDomain: [0, 100],
75271
+ showLegend: false,
75272
+ showGrid: true,
75273
+ fillContainer: true,
75274
+ tooltipLabelFormatter: trendTooltipLabelFormatter
75275
+ }
75276
+ ) }) })
75277
+ ] });
75278
+ });
75279
+ EfficiencyTrendCard.displayName = "EfficiencyTrendCard";
75280
+ var TopImprovementsCard = React141__namespace.default.memo(({
75281
+ store,
75282
+ supervisorsByLineId,
75283
+ onViewAll,
75284
+ onItemClick
75285
+ }) => {
75286
+ bumpRenderCounter();
75287
+ const improvements = useOperationsOverviewImprovements(store);
75288
+ const showInitialSkeleton = improvements.loading && improvements.lastUpdated === null;
73192
75289
  const displayImprovements = React141__namespace.default.useMemo(() => {
73193
- return improvements.map((item) => {
75290
+ return improvements.data.map((item) => {
73194
75291
  const supervisors = item.lineId ? supervisorsByLineId.get(item.lineId) || [] : [];
73195
75292
  return {
73196
75293
  ...item,
@@ -73203,436 +75300,592 @@ var PlantHeadView = () => {
73203
75300
  })
73204
75301
  };
73205
75302
  });
73206
- }, [improvements, supervisorsByLineId]);
73207
- const mobileSubtitle = React141__namespace.default.useMemo(() => {
73208
- if (isCurrentWeekToDateRange) {
73209
- return `Week of ${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMM")}`;
75303
+ }, [improvements.data, supervisorsByLineId]);
75304
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
75305
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50", children: [
75306
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Top improvements" }),
75307
+ /* @__PURE__ */ jsxRuntime.jsx(
75308
+ "button",
75309
+ {
75310
+ type: "button",
75311
+ "aria-label": "View all",
75312
+ onClick: onViewAll,
75313
+ className: "inline-flex items-center justify-center rounded-md p-1 text-slate-500 hover:text-slate-800 transition-colors",
75314
+ children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowRight, { className: "h-4 w-4 shrink-0", strokeWidth: 2.5, "aria-hidden": true })
75315
+ }
75316
+ )
75317
+ ] }),
75318
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 p-0 flex flex-col px-5 py-2 justify-start overflow-auto", children: showInitialSkeleton ? /* @__PURE__ */ jsxRuntime.jsx(OverviewImprovementsSkeleton, {}) : displayImprovements.length > 0 ? displayImprovements.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
75319
+ "div",
75320
+ {
75321
+ "data-testid": `plant-head-improvement-${item.issueId}`,
75322
+ onClick: () => onItemClick(item),
75323
+ className: "flex items-center justify-between py-3 border-b border-slate-50 last:border-0 group cursor-pointer",
75324
+ children: [
75325
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0 pr-4", children: [
75326
+ item.ticketLabel ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.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,
75327
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
75328
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 min-w-0 mb-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-[13px] font-semibold text-slate-800 truncate transition-colors group-hover:text-indigo-600", children: item.title }) }),
75329
+ /* @__PURE__ */ jsxRuntime.jsx(
75330
+ "p",
75331
+ {
75332
+ className: "text-[10px] font-medium text-slate-400 truncate",
75333
+ title: item.metadataLabel,
75334
+ children: item.metadataLabel
75335
+ }
75336
+ )
75337
+ ] })
75338
+ ] }),
75339
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsxRuntime.jsx(
75340
+ "span",
75341
+ {
75342
+ 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"}`,
75343
+ children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: item.metric })
75344
+ }
75345
+ ) })
75346
+ ]
75347
+ },
75348
+ item.id
75349
+ )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: "No open improvement issues" }) })
75350
+ ] });
75351
+ });
75352
+ TopImprovementsCard.displayName = "TopImprovementsCard";
75353
+ var DEBUG_DASHBOARD_LOGS4 = process.env.NEXT_PUBLIC_DEBUG_DASHBOARD === "true";
75354
+ var debugRefreshLog = (message, payload) => {
75355
+ if (!DEBUG_DASHBOARD_LOGS4) return;
75356
+ if (payload) {
75357
+ console.log(`[OperationsOverviewRefresh] ${message}`, payload);
75358
+ return;
75359
+ }
75360
+ console.log(`[OperationsOverviewRefresh] ${message}`);
75361
+ };
75362
+ var isAbortError = (error) => {
75363
+ return error instanceof DOMException && error.name === "AbortError";
75364
+ };
75365
+ var toNumber4 = (value) => {
75366
+ if (typeof value === "number" && Number.isFinite(value)) return value;
75367
+ if (typeof value === "string" && value.trim().length > 0) {
75368
+ const parsed = Number(value);
75369
+ return Number.isFinite(parsed) ? parsed : null;
75370
+ }
75371
+ return null;
75372
+ };
75373
+ var formatImprovementMetric = (recommendation) => {
75374
+ const estimatedGain = toNumber4(recommendation.estimated_gain_pieces);
75375
+ if (estimatedGain !== null && estimatedGain > 0) {
75376
+ return `+${Math.round(estimatedGain).toLocaleString()} pcs / day`;
75377
+ }
75378
+ const idleMinutes = toNumber4(recommendation.metrics?.idle_minutes);
75379
+ if (idleMinutes !== null) {
75380
+ return `-${Math.round(idleMinutes)}m Idle`;
75381
+ }
75382
+ const impactText = recommendation.impact?.trim();
75383
+ if (impactText) {
75384
+ return impactText.length > 22 ? `${impactText.slice(0, 22).trim()}...` : impactText;
75385
+ }
75386
+ return "Review Issue";
75387
+ };
75388
+ var normalizeImprovements2 = (recommendations, lineIds) => {
75389
+ const allowedLineIds = new Set(lineIds);
75390
+ const scopedRecommendations = (recommendations || []).filter((recommendation) => {
75391
+ return !recommendation.line_id || allowedLineIds.has(recommendation.line_id);
75392
+ });
75393
+ return [...scopedRecommendations].sort(compareImprovementRecommendationPriority).slice(0, 3).map((recommendation) => ({
75394
+ id: recommendation.issue_id || recommendation.id,
75395
+ issueId: recommendation.issue_id || recommendation.id,
75396
+ issueNumber: recommendation.issue_number,
75397
+ title: recommendation.title?.trim() || "Untitled issue",
75398
+ metric: formatImprovementMetric(recommendation),
75399
+ location: recommendation.location,
75400
+ line: recommendation.line,
75401
+ lineId: recommendation.line_id,
75402
+ workspaceId: recommendation.workspace_id
75403
+ }));
75404
+ };
75405
+ var useOperationsOverviewRefresh = ({
75406
+ store,
75407
+ supabase,
75408
+ companyId,
75409
+ lineIds,
75410
+ startKey,
75411
+ endKey,
75412
+ trendMode,
75413
+ comparisonStrategy,
75414
+ isLiveScope
75415
+ }) => {
75416
+ const lineIdsKey = React141__namespace.default.useMemo(() => lineIds.join(","), [lineIds]);
75417
+ const scopeSignature = React141__namespace.default.useMemo(
75418
+ () => [companyId || "", startKey, endKey, trendMode, comparisonStrategy || "", lineIdsKey].join("::"),
75419
+ [companyId, comparisonStrategy, endKey, lineIdsKey, startKey, trendMode]
75420
+ );
75421
+ const controllersRef = React141__namespace.default.useRef({});
75422
+ const requestIdsRef = React141__namespace.default.useRef({
75423
+ snapshot: 0,
75424
+ trend: 0,
75425
+ idle: 0,
75426
+ improvements: 0
75427
+ });
75428
+ const intervalRef = React141__namespace.default.useRef(null);
75429
+ const isPageActiveRef = React141__namespace.default.useRef(true);
75430
+ const lastResumeRefreshAtRef = React141__namespace.default.useRef(0);
75431
+ const abortAll = React141__namespace.default.useCallback(() => {
75432
+ Object.values(controllersRef.current).forEach((controller) => {
75433
+ controller?.abort();
75434
+ });
75435
+ controllersRef.current = {};
75436
+ }, []);
75437
+ React141__namespace.default.useEffect(() => {
75438
+ return () => {
75439
+ abortAll();
75440
+ };
75441
+ }, [abortAll]);
75442
+ const getIsPageActive = React141__namespace.default.useCallback(() => {
75443
+ if (typeof document === "undefined") {
75444
+ return true;
73210
75445
  }
73211
- return `${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMM")} - ${dateFns.format(parseDateKeyToDate(dateRange.endKey), "do MMM, yyyy")}`;
73212
- }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
73213
- const desktopSubtitle = React141__namespace.default.useMemo(() => {
73214
- if (isCurrentWeekToDateRange) {
73215
- return `Week of ${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")}`;
75446
+ const isVisible = document.visibilityState === "visible";
75447
+ const hasFocus = typeof document.hasFocus === "function" ? document.hasFocus() : true;
75448
+ return isVisible && hasFocus;
75449
+ }, []);
75450
+ const stopPolling = React141__namespace.default.useCallback((reason) => {
75451
+ if (intervalRef.current === null) {
75452
+ return;
73216
75453
  }
73217
- return `${dateFns.format(parseDateKeyToDate(dateRange.startKey), "do MMMM, yyyy")} - ${dateFns.format(parseDateKeyToDate(dateRange.endKey), "do MMMM, yyyy")}`;
73218
- }, [dateRange.endKey, dateRange.startKey, isCurrentWeekToDateRange]);
73219
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-screen bg-slate-50 w-full font-sans", children: [
73220
- /* @__PURE__ */ jsxRuntime.jsx("header", { className: "sticky top-0 z-10 bg-white border-b flex-shrink-0 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-3 sm:px-4 md:px-6 py-2 sm:py-3 relative", children: [
73221
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "sm:hidden", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center", children: [
73222
- mobileMenuContext ? /* @__PURE__ */ jsxRuntime.jsx(
73223
- HamburgerButton,
73224
- {
73225
- onClick: mobileMenuContext.onMobileMenuOpen,
73226
- className: "flex-shrink-0 -ml-1"
75454
+ window.clearInterval(intervalRef.current);
75455
+ intervalRef.current = null;
75456
+ debugRefreshLog("poll stopped", { reason });
75457
+ }, []);
75458
+ const runRefresh = React141__namespace.default.useCallback(
75459
+ async (section, begin, onSuccess, onError, request, reason) => {
75460
+ if (!supabase || !companyId || lineIds.length === 0) return;
75461
+ const requestId = requestIdsRef.current[section] + 1;
75462
+ requestIdsRef.current[section] = requestId;
75463
+ controllersRef.current[section]?.abort();
75464
+ const controller = new AbortController();
75465
+ controllersRef.current[section] = controller;
75466
+ begin();
75467
+ try {
75468
+ const response = await request(controller.signal, requestId);
75469
+ if (controller.signal.aborted || requestIdsRef.current[section] !== requestId) {
75470
+ return;
75471
+ }
75472
+ onSuccess(response, Date.now(), reason === "live_refresh" ? "transition" : "default");
75473
+ } catch (error) {
75474
+ if (controller.signal.aborted || requestIdsRef.current[section] !== requestId || isAbortError(error)) {
75475
+ return;
75476
+ }
75477
+ onError(error instanceof Error ? error.message : `Failed to refresh ${section}`);
75478
+ }
75479
+ },
75480
+ [companyId, lineIds.length, supabase]
75481
+ );
75482
+ const refreshSnapshot = React141__namespace.default.useCallback(
75483
+ async (reason) => {
75484
+ await runRefresh(
75485
+ "snapshot",
75486
+ store.beginSnapshotLoad,
75487
+ store.applySnapshotResponse,
75488
+ store.failSnapshotLoad,
75489
+ (signal, requestId) => {
75490
+ const params = new URLSearchParams({
75491
+ company_id: companyId || "",
75492
+ start_date: startKey,
75493
+ end_date: endKey,
75494
+ trend_shift_mode: trendMode,
75495
+ line_ids: lineIdsKey
75496
+ });
75497
+ if (comparisonStrategy) {
75498
+ params.set("comparison_strategy", comparisonStrategy);
73227
75499
  }
73228
- ) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-8 flex-shrink-0" }),
73229
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center", children: [
73230
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-lg font-semibold text-gray-900 text-center px-1 truncate max-w-[200px]", children: "Operations Overview" }),
73231
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] font-medium text-slate-500 text-center mt-0.5", children: mobileSubtitle })
73232
- ] }),
73233
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-shrink-0 flex items-center gap-1.5", children: [
73234
- /* @__PURE__ */ jsxRuntime.jsx(
73235
- MonthlyRangeFilter_default,
75500
+ return fetchBackendJson(
75501
+ supabase,
75502
+ `/api/dashboard/operations-overview/snapshot?${params.toString()}`,
73236
75503
  {
73237
- month: parseDateKeyToDate(dateRange.startKey).getMonth(),
73238
- year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
73239
- timezone: appTimezone,
73240
- value: dateRange,
73241
- onChange: handleDateRangeChange,
73242
- showLabel: false
75504
+ signal,
75505
+ dedupeKey: `operations-overview:snapshot:${scopeSignature}:${requestId}`
73243
75506
  }
73244
- ),
73245
- /* @__PURE__ */ jsxRuntime.jsxs(
73246
- "button",
73247
- {
73248
- ref: mobileFilterButtonRef,
73249
- onClick: handleFilterToggle,
73250
- className: `p-2 rounded-full transition-colors relative ${isFilterOpen || trendMode !== "all" ? "bg-blue-50" : "active:bg-gray-100"}`,
73251
- "aria-label": "Open filters",
73252
- children: [
73253
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: `w-5 h-5 ${trendMode !== "all" ? "text-blue-600" : "text-gray-700"}` }),
73254
- trendMode !== "all" && /* @__PURE__ */ jsxRuntime.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" })
73255
- ]
73256
- }
73257
- )
73258
- ] })
73259
- ] }) }),
73260
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "hidden sm:block", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center relative min-h-[56px]", children: [
73261
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute left-1/2 -translate-x-1/2 flex flex-col items-center pointer-events-none", children: [
73262
- /* @__PURE__ */ jsxRuntime.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" }),
73263
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium text-slate-500 text-center pointer-events-auto", children: desktopSubtitle })
73264
- ] }),
73265
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute right-0 flex items-center gap-3", children: [
73266
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
73267
- MonthlyRangeFilter_default,
73268
- {
73269
- month: parseDateKeyToDate(dateRange.startKey).getMonth(),
73270
- year: parseDateKeyToDate(dateRange.startKey).getFullYear(),
73271
- timezone: appTimezone,
73272
- value: dateRange,
73273
- onChange: handleDateRangeChange,
73274
- showLabel: false
73275
- }
73276
- ) }),
73277
- /* @__PURE__ */ jsxRuntime.jsxs(
73278
- "button",
75507
+ );
75508
+ },
75509
+ reason
75510
+ );
75511
+ },
75512
+ [companyId, comparisonStrategy, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75513
+ );
75514
+ const refreshTrend = React141__namespace.default.useCallback(
75515
+ async (reason) => {
75516
+ await runRefresh(
75517
+ "trend",
75518
+ store.beginTrendLoad,
75519
+ store.applyTrendResponse,
75520
+ store.failTrendLoad,
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/trend?${params.toString()}`,
73279
75532
  {
73280
- ref: filterButtonRef,
73281
- onClick: handleFilterToggle,
73282
- 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"}`,
73283
- "aria-label": "Open filters",
73284
- children: [
73285
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Filter, { className: `w-[18px] h-[18px] ${trendMode !== "all" ? "text-blue-600" : "text-slate-500"}` }),
73286
- "Filters",
73287
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: `w-4 h-4 ml-0.5 transition-transform duration-200 ${isFilterOpen ? "rotate-180" : ""}` })
73288
- ]
75533
+ signal,
75534
+ dedupeKey: `operations-overview:trend:${scopeSignature}:${requestId}`
73289
75535
  }
73290
- )
73291
- ] })
73292
- ] }) }),
73293
- isFilterOpen && /* @__PURE__ */ jsxRuntime.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: [
73294
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between mb-3", children: [
73295
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-sm font-semibold text-gray-900", children: "Filter View" }),
73296
- trendMode !== "all" && /* @__PURE__ */ jsxRuntime.jsx(
73297
- "button",
75536
+ );
75537
+ },
75538
+ reason
75539
+ );
75540
+ },
75541
+ [companyId, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75542
+ );
75543
+ const refreshIdle = React141__namespace.default.useCallback(
75544
+ async (reason) => {
75545
+ await runRefresh(
75546
+ "idle",
75547
+ store.beginIdleLoad,
75548
+ store.applyIdleResponse,
75549
+ store.failIdleLoad,
75550
+ (signal, requestId) => {
75551
+ const params = new URLSearchParams({
75552
+ company_id: companyId || "",
75553
+ start_date: startKey,
75554
+ end_date: endKey,
75555
+ trend_shift_mode: trendMode,
75556
+ line_ids: lineIdsKey
75557
+ });
75558
+ return fetchBackendJson(
75559
+ supabase,
75560
+ `/api/dashboard/operations-overview/idle-reason-breakdown?${params.toString()}`,
73298
75561
  {
73299
- onClick: () => {
73300
- setTrendMode("all");
73301
- setIsFilterOpen(false);
73302
- },
73303
- className: "text-xs text-red-600 hover:text-red-700 font-medium",
73304
- children: "Clear all"
75562
+ signal,
75563
+ dedupeKey: `operations-overview:idle:${scopeSignature}:${requestId}`
73305
75564
  }
73306
- )
73307
- ] }),
73308
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-1", children: [
73309
- /* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-xs font-medium text-gray-500 uppercase tracking-wide ml-1", children: "Shift" }),
73310
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative", children: /* @__PURE__ */ jsxRuntime.jsxs(
73311
- "select",
75565
+ );
75566
+ },
75567
+ reason
75568
+ );
75569
+ },
75570
+ [companyId, endKey, lineIdsKey, runRefresh, scopeSignature, startKey, store, supabase, trendMode]
75571
+ );
75572
+ const refreshImprovements = React141__namespace.default.useCallback(
75573
+ async (reason) => {
75574
+ await runRefresh(
75575
+ "improvements",
75576
+ store.beginImprovementsLoad,
75577
+ (response, updatedAt, mode) => {
75578
+ store.applyImprovements(normalizeImprovements2(response.recommendations, lineIds), updatedAt, mode);
75579
+ },
75580
+ store.failImprovementsLoad,
75581
+ (signal, requestId) => {
75582
+ const params = new URLSearchParams({
75583
+ company_id: companyId || "",
75584
+ status: "open",
75585
+ limit: "200",
75586
+ line_ids: lineIdsKey
75587
+ });
75588
+ return fetchBackendJson(
75589
+ supabase,
75590
+ `/api/improvement-center/recommendations?${params.toString()}`,
73312
75591
  {
73313
- value: trendMode,
73314
- onChange: handleTrendModeChange,
73315
- 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",
73316
- 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` },
73317
- children: [
73318
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All Shifts" }),
73319
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "day", children: "Day Shift" }),
73320
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "night", children: "Night Shift" })
73321
- ]
75592
+ signal,
75593
+ dedupeKey: `operations-overview:improvements:${scopeSignature}:${requestId}`
73322
75594
  }
73323
- ) })
73324
- ] }) })
73325
- ] })
73326
- ] }) }),
75595
+ );
75596
+ },
75597
+ reason
75598
+ );
75599
+ },
75600
+ [companyId, lineIds, lineIdsKey, runRefresh, scopeSignature, store, supabase]
75601
+ );
75602
+ const refreshAll = React141__namespace.default.useCallback(
75603
+ async (reason) => {
75604
+ await Promise.allSettled([
75605
+ refreshSnapshot(reason),
75606
+ refreshTrend(reason),
75607
+ refreshIdle(reason),
75608
+ refreshImprovements(reason)
75609
+ ]);
75610
+ },
75611
+ [refreshIdle, refreshImprovements, refreshSnapshot, refreshTrend]
75612
+ );
75613
+ const startPolling = React141__namespace.default.useCallback((reason) => {
75614
+ if (!isLiveScope || !supabase || !companyId || lineIds.length === 0) {
75615
+ return;
75616
+ }
75617
+ if (intervalRef.current !== null) {
75618
+ return;
75619
+ }
75620
+ intervalRef.current = window.setInterval(() => {
75621
+ if (!isPageActiveRef.current) {
75622
+ debugRefreshLog("poll skipped because hidden/unfocused", {
75623
+ reason: "interval_tick",
75624
+ visibilityState: typeof document !== "undefined" ? document.visibilityState : "unknown",
75625
+ hasFocus: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : true
75626
+ });
75627
+ stopPolling("inactive_during_tick");
75628
+ return;
75629
+ }
75630
+ void refreshAll("live_refresh");
75631
+ }, LIVE_REFRESH_INTERVAL_MS);
75632
+ debugRefreshLog("poll started", { reason, intervalMs: LIVE_REFRESH_INTERVAL_MS });
75633
+ }, [companyId, isLiveScope, lineIds.length, refreshAll, stopPolling, supabase]);
75634
+ const refreshFromResume = React141__namespace.default.useCallback((reason) => {
75635
+ const now4 = Date.now();
75636
+ if (now4 - lastResumeRefreshAtRef.current < 1e3) {
75637
+ debugRefreshLog("resume refresh suppressed", { reason });
75638
+ return;
75639
+ }
75640
+ lastResumeRefreshAtRef.current = now4;
75641
+ stopPolling("resume_refresh");
75642
+ debugRefreshLog("resume refresh fired", { reason });
75643
+ void refreshAll("live_refresh").finally(() => {
75644
+ if (isPageActiveRef.current) {
75645
+ startPolling("resume");
75646
+ }
75647
+ });
75648
+ }, [refreshAll, startPolling, stopPolling]);
75649
+ React141__namespace.default.useEffect(() => {
75650
+ if (!supabase || !companyId || lineIds.length === 0) {
75651
+ stopPolling("scope_invalid");
75652
+ abortAll();
75653
+ store.reset();
75654
+ return;
75655
+ }
75656
+ void refreshAll("scope_change");
75657
+ }, [abortAll, companyId, lineIds.length, refreshAll, scopeSignature, stopPolling, store, supabase]);
75658
+ React141__namespace.default.useEffect(() => {
75659
+ if (!isLiveScope || !supabase || !companyId || lineIds.length === 0) {
75660
+ isPageActiveRef.current = false;
75661
+ stopPolling("live_scope_disabled");
75662
+ return;
75663
+ }
75664
+ const logInactive = (reason) => {
75665
+ debugRefreshLog("poll skipped because hidden/unfocused", {
75666
+ reason,
75667
+ visibilityState: typeof document !== "undefined" ? document.visibilityState : "unknown",
75668
+ hasFocus: typeof document !== "undefined" && typeof document.hasFocus === "function" ? document.hasFocus() : true
75669
+ });
75670
+ };
75671
+ const markInactive = (reason) => {
75672
+ isPageActiveRef.current = false;
75673
+ logInactive(reason);
75674
+ stopPolling(reason);
75675
+ };
75676
+ const syncActivity = (reason) => {
75677
+ const nextIsActive = getIsPageActive();
75678
+ const wasActive = isPageActiveRef.current;
75679
+ isPageActiveRef.current = nextIsActive;
75680
+ if (!nextIsActive) {
75681
+ logInactive(reason);
75682
+ stopPolling(reason);
75683
+ return;
75684
+ }
75685
+ if (!wasActive) {
75686
+ refreshFromResume(reason);
75687
+ return;
75688
+ }
75689
+ startPolling(reason);
75690
+ };
75691
+ isPageActiveRef.current = getIsPageActive();
75692
+ if (isPageActiveRef.current) {
75693
+ startPolling("effect_mount");
75694
+ } else {
75695
+ logInactive("effect_mount");
75696
+ }
75697
+ const handleVisibilityChange = () => syncActivity("visibilitychange");
75698
+ const handleFocus = () => syncActivity("focus");
75699
+ const handleBlur = () => markInactive("blur");
75700
+ const handlePageShow = () => syncActivity("pageshow");
75701
+ const handlePageHide = () => markInactive("pagehide");
75702
+ document.addEventListener("visibilitychange", handleVisibilityChange);
75703
+ window.addEventListener("focus", handleFocus);
75704
+ window.addEventListener("blur", handleBlur);
75705
+ window.addEventListener("pageshow", handlePageShow);
75706
+ window.addEventListener("pagehide", handlePageHide);
75707
+ return () => {
75708
+ stopPolling("cleanup");
75709
+ document.removeEventListener("visibilitychange", handleVisibilityChange);
75710
+ window.removeEventListener("focus", handleFocus);
75711
+ window.removeEventListener("blur", handleBlur);
75712
+ window.removeEventListener("pageshow", handlePageShow);
75713
+ window.removeEventListener("pagehide", handlePageHide);
75714
+ };
75715
+ }, [companyId, getIsPageActive, isLiveScope, lineIds.length, refreshFromResume, startPolling, stopPolling, supabase]);
75716
+ };
75717
+ var PlantHeadView = () => {
75718
+ const supabase = useSupabase();
75719
+ const entityConfig = useEntityConfig();
75720
+ const appTimezone = useAppTimezone() || "UTC";
75721
+ const { navigate } = useNavigation();
75722
+ const { accessibleLineIds } = useUserLineAccess();
75723
+ const mobileMenuContext = useMobileMenu();
75724
+ useHideMobileHeader(!!mobileMenuContext);
75725
+ const storeRef = React141__namespace.default.useRef(createOperationsOverviewStore());
75726
+ const store = storeRef.current;
75727
+ const [dateRange, setDateRange] = React141__namespace.default.useState(() => getCurrentWeekToDateRange(appTimezone));
75728
+ const [usesThisWeekComparison, setUsesThisWeekComparison] = React141__namespace.default.useState(true);
75729
+ const [trendMode, setTrendMode] = React141__namespace.default.useState("all");
75730
+ React141__namespace.default.useEffect(() => {
75731
+ trackCorePageView("Operations Overview", {
75732
+ dashboard_surface: "operations_overview"
75733
+ });
75734
+ }, []);
75735
+ const currentWeekRange = React141__namespace.default.useMemo(
75736
+ () => getCurrentWeekToDateRange(appTimezone),
75737
+ [appTimezone]
75738
+ );
75739
+ const isCurrentWeekToDateRange = dateRange.startKey === currentWeekRange.startKey && dateRange.endKey === currentWeekRange.endKey;
75740
+ const normalizedLineIds = React141__namespace.default.useMemo(
75741
+ () => Array.from(new Set((accessibleLineIds || []).filter(Boolean))).sort(),
75742
+ [accessibleLineIds]
75743
+ );
75744
+ const lineIdsKey = React141__namespace.default.useMemo(
75745
+ () => normalizedLineIds.join(","),
75746
+ [normalizedLineIds]
75747
+ );
75748
+ const scopedLineIds = React141__namespace.default.useMemo(
75749
+ () => lineIdsKey ? lineIdsKey.split(",") : [],
75750
+ [lineIdsKey]
75751
+ );
75752
+ const initializedTimezoneRef = React141__namespace.default.useRef(appTimezone);
75753
+ React141__namespace.default.useEffect(() => {
75754
+ if (initializedTimezoneRef.current === appTimezone) return;
75755
+ setDateRange(getCurrentWeekToDateRange(appTimezone));
75756
+ setUsesThisWeekComparison(true);
75757
+ initializedTimezoneRef.current = appTimezone;
75758
+ }, [appTimezone]);
75759
+ const handleDateRangeChange = React141__namespace.default.useCallback((range, meta) => {
75760
+ trackCoreEvent("Operations Overview Date Range Changed", {
75761
+ start_date: range.startKey,
75762
+ end_date: range.endKey
75763
+ });
75764
+ setDateRange(range);
75765
+ setUsesThisWeekComparison((previous) => {
75766
+ if (meta?.source === "preset") {
75767
+ return meta.presetLabel === "This Week";
75768
+ }
75769
+ if (meta?.source === "custom") {
75770
+ return false;
75771
+ }
75772
+ return previous;
75773
+ });
75774
+ }, []);
75775
+ const handleTrendModeChange = React141__namespace.default.useCallback((mode) => {
75776
+ setTrendMode(mode);
75777
+ }, []);
75778
+ const buildLineMonthlyHistoryUrl = React141__namespace.default.useCallback((lineId) => {
75779
+ const rangeStartDate = parseDateKeyToDate(dateRange.startKey);
75780
+ const params = new URLSearchParams();
75781
+ params.set("tab", "monthly_history");
75782
+ params.set("month", rangeStartDate.getMonth().toString());
75783
+ params.set("year", rangeStartDate.getFullYear().toString());
75784
+ params.set("rangeStart", dateRange.startKey);
75785
+ params.set("rangeEnd", dateRange.endKey);
75786
+ return `/kpis/${lineId}?${params.toString()}`;
75787
+ }, [dateRange.endKey, dateRange.startKey]);
75788
+ const handleOpenLineMonthlyHistory = React141__namespace.default.useCallback((lineId, lineName) => {
75789
+ trackCoreEvent("Operations Overview Line Clicked", {
75790
+ line_id: lineId,
75791
+ line_name: lineName,
75792
+ range_start: dateRange.startKey,
75793
+ range_end: dateRange.endKey
75794
+ });
75795
+ navigate(buildLineMonthlyHistoryUrl(lineId));
75796
+ }, [buildLineMonthlyHistoryUrl, dateRange.endKey, dateRange.startKey, navigate]);
75797
+ const handleViewAllPoorestPerformers = React141__namespace.default.useCallback(() => {
75798
+ trackCoreEvent("Operations Overview View All Clicked", { section: "poorest_performers" });
75799
+ navigate("/kpis?tab=leaderboard");
75800
+ }, [navigate]);
75801
+ const handleViewAllImprovements = React141__namespace.default.useCallback(() => {
75802
+ trackCoreEvent("Operations Overview View All Clicked", { section: "improvements" });
75803
+ navigate("/improvement-center");
75804
+ }, [navigate]);
75805
+ const handleOpenImprovement = React141__namespace.default.useCallback((item) => {
75806
+ trackCoreEvent("Operations Overview Improvement Clicked", {
75807
+ issue_id: item.issueId,
75808
+ issue_number: item.issueNumber,
75809
+ title: item.title
75810
+ });
75811
+ const params = new URLSearchParams({
75812
+ focusIssueId: item.issueId
75813
+ });
75814
+ navigate(`/improvement-center?${params.toString()}`);
75815
+ }, [navigate]);
75816
+ const comparisonStrategy = React141__namespace.default.useMemo(() => {
75817
+ if (usesThisWeekComparison && isCurrentWeekToDateRange) {
75818
+ return "previous_full_week";
75819
+ }
75820
+ return void 0;
75821
+ }, [isCurrentWeekToDateRange, usesThisWeekComparison]);
75822
+ useOperationsOverviewRefresh({
75823
+ store,
75824
+ supabase,
75825
+ companyId: entityConfig.companyId,
75826
+ lineIds: scopedLineIds,
75827
+ startKey: dateRange.startKey,
75828
+ endKey: dateRange.endKey,
75829
+ trendMode,
75830
+ comparisonStrategy,
75831
+ isLiveScope: isCurrentWeekToDateRange
75832
+ });
75833
+ const { supervisorsByLineId } = useSupervisorsByLineIds(scopedLineIds, {
75834
+ enabled: !!entityConfig.companyId && scopedLineIds.length > 0,
75835
+ companyId: entityConfig.companyId,
75836
+ useBackend: true
75837
+ });
75838
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col min-h-screen bg-slate-50 w-full font-sans", children: [
75839
+ /* @__PURE__ */ jsxRuntime.jsx(
75840
+ OperationsOverviewHeader,
75841
+ {
75842
+ dateRange,
75843
+ trendMode,
75844
+ appTimezone,
75845
+ mobileMenuContext,
75846
+ onDateRangeChange: handleDateRangeChange,
75847
+ onTrendModeChange: handleTrendModeChange
75848
+ }
75849
+ ),
73327
75850
  /* @__PURE__ */ jsxRuntime.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: [
73328
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
73329
- /* @__PURE__ */ jsxRuntime.jsxs(
73330
- "div",
73331
- {
73332
- 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",
73333
- children: [
73334
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-between items-center mb-1", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Overall Efficiency" }) }),
73335
- isSnapshotLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewMetricCardSkeleton, {}) : overview.summary?.plant_efficiency?.current !== null && overview.summary?.plant_efficiency?.current !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
73336
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-2xl sm:text-3xl font-bold text-slate-800 tracking-tight", children: [
73337
- roundOne(overview.summary.plant_efficiency.current),
73338
- "%"
73339
- ] }),
73340
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${plantEfficiencyBadge.className}`, children: [
73341
- plantEfficiencyBadge.icon === "up" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : plantEfficiencyBadge.icon === "down" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
73342
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium", children: plantEfficiencyBadge.text })
73343
- ] })
73344
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No efficiency data available" })
73345
- ]
73346
- }
73347
- ),
73348
- /* @__PURE__ */ jsxRuntime.jsxs(
73349
- "div",
73350
- {
73351
- ref: idleContributorsRef,
73352
- "data-testid": "idle-kpi-card-region",
73353
- className: "relative",
73354
- onMouseEnter: () => {
73355
- if (canInspectIdleContributors) {
73356
- setIsIdleContributorsOpen(true);
73357
- }
73358
- },
73359
- onMouseLeave: () => {
73360
- if (!isIdleContributorsPinned) {
73361
- setIsIdleContributorsOpen(false);
73362
- }
73363
- },
73364
- onFocus: () => {
73365
- if (canInspectIdleContributors) {
73366
- setIsIdleContributorsOpen(true);
73367
- }
73368
- },
73369
- onBlur: (event) => {
73370
- if (isIdleContributorsPinned) return;
73371
- const nextTarget = event.relatedTarget;
73372
- if (nextTarget && idleContributorsRef.current?.contains(nextTarget)) return;
73373
- setIsIdleContributorsOpen(false);
73374
- },
73375
- children: [
73376
- /* @__PURE__ */ jsxRuntime.jsxs(
73377
- "div",
73378
- {
73379
- "data-testid": "idle-kpi-card",
73380
- role: canInspectIdleContributors ? "button" : void 0,
73381
- tabIndex: canInspectIdleContributors ? 0 : -1,
73382
- "aria-controls": canInspectIdleContributors ? "idle-kpi-popover" : void 0,
73383
- "aria-expanded": canInspectIdleContributors ? isIdleContributorsOpen : void 0,
73384
- 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"}`,
73385
- onClick: handleIdleContributorsToggle,
73386
- onKeyDown: handleIdleContributorsKeyDown,
73387
- children: [
73388
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-1", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time per Workstation" }) }),
73389
- isSnapshotLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewMetricCardSkeleton, {}) : overview.summary?.avg_idle_per_workstation?.current_seconds !== null && overview.summary?.avg_idle_per_workstation?.current_seconds !== void 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2 sm:gap-3 mt-1", children: [
73390
- /* @__PURE__ */ jsxRuntime.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) }),
73391
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex items-center gap-1 px-2.5 py-1 rounded-full ${idleBadge.className}`, children: [
73392
- idleBadge.icon === "up" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : idleBadge.icon === "down" ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3.5 h-3.5", strokeWidth: 2.5 }) : null,
73393
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs sm:text-sm font-medium", children: idleBadge.text })
73394
- ] })
73395
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-2 text-sm text-slate-400", children: "No idle time data available" })
73396
- ]
73397
- }
73398
- ),
73399
- canInspectIdleContributors && isIdleContributorsOpen ? /* @__PURE__ */ jsxRuntime.jsxs(
73400
- "div",
73401
- {
73402
- id: "idle-kpi-popover",
73403
- "data-testid": "idle-kpi-popover",
73404
- 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]",
73405
- children: [
73406
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 pb-3 mb-3 border-b border-slate-100", children: [
73407
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-2.5 h-2.5 rounded-full flex-shrink-0 bg-red-500" }),
73408
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-slate-800 text-[15px]", children: "Idle Time per Workstation" })
73409
- ] }),
73410
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
73411
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-[10px] font-bold uppercase tracking-wider text-slate-400 mb-3", children: "TOP CONTRIBUTORS" }),
73412
- idleTopContributors.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-2.5", children: idleTopContributors.map((contributor, index) => /* @__PURE__ */ jsxRuntime.jsxs(
73413
- "div",
73414
- {
73415
- className: "flex items-start justify-between gap-3",
73416
- children: [
73417
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
73418
- /* @__PURE__ */ jsxRuntime.jsx(
73419
- "div",
73420
- {
73421
- className: "text-slate-600 text-[13px] truncate",
73422
- title: contributor.workspaceName,
73423
- children: contributor.workspaceName
73424
- }
73425
- ),
73426
- showIdleContributorLineNames && contributor.lineName ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-[11px] font-medium text-slate-400 truncate", title: contributor.lineName, children: contributor.lineName }) : null
73427
- ] }),
73428
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-slate-500 text-[13px] text-right whitespace-nowrap", children: formatIdleDuration(contributor.avgIdleSeconds) })
73429
- ]
73430
- },
73431
- `${contributor.workspaceId || contributor.workspaceName}-${index}`
73432
- )) }) : /* @__PURE__ */ jsxRuntime.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." })
73433
- ] })
73434
- ]
73435
- }
73436
- ) : null
73437
- ]
73438
- }
73439
- )
73440
- ] }),
75851
+ /* @__PURE__ */ jsxRuntime.jsx(OverviewSummaryCards, { store }),
73441
75852
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 min-h-0 grid grid-cols-1 xl:grid-cols-2 gap-5 auto-rows-fr", children: [
73442
75853
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-rows-1 xl:grid-rows-2 gap-5 min-h-0", children: [
73443
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
73444
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 border-b border-slate-50 flex justify-between items-center gap-3 flex-wrap", children: [
73445
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-wrap", children: [
73446
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Poorest Performers" }),
73447
- showPoorestModeToggle && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex bg-slate-100 p-0.5 rounded-lg", children: [
73448
- /* @__PURE__ */ jsxRuntime.jsx(
73449
- "button",
73450
- {
73451
- type: "button",
73452
- onClick: () => handlePoorestLineModeChange("output"),
73453
- 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"}`,
73454
- children: "Output"
73455
- }
73456
- ),
73457
- /* @__PURE__ */ jsxRuntime.jsx(
73458
- "button",
73459
- {
73460
- type: "button",
73461
- onClick: () => handlePoorestLineModeChange("uptime"),
73462
- 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"}`,
73463
- children: "Uptime"
73464
- }
73465
- )
73466
- ] })
73467
- ] }),
73468
- /* @__PURE__ */ jsxRuntime.jsx(
73469
- "button",
73470
- {
73471
- type: "button",
73472
- onClick: () => {
73473
- trackCoreEvent("Operations Overview View All Clicked", { section: "poorest_performers" });
73474
- navigate("/kpis?tab=leaderboard");
73475
- },
73476
- className: "text-[11px] font-bold text-slate-500 hover:text-slate-800 transition-colors",
73477
- children: "View All"
73478
- }
73479
- )
73480
- ] }),
73481
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex flex-col p-0 overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-slate-50 flex-1 px-5", children: [
73482
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between py-2", children: [
73483
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-semibold text-slate-400 text-[10px] uppercase tracking-wider min-w-[120px]", children: "Line" }),
73484
- /* @__PURE__ */ jsxRuntime.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 })
73485
- ] }),
73486
- isSnapshotLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewListSkeleton, {}) : mergedPoorestLines.length > 0 ? mergedPoorestLines.map((line) => {
73487
- const lineDelta = buildLineDeltaTone(line.delta, comparisonLabel);
73488
- return /* @__PURE__ */ jsxRuntime.jsx(
73489
- "div",
73490
- {
73491
- onClick: () => {
73492
- trackCoreEvent("Operations Overview Line Clicked", { line_id: line.id, line_name: line.name });
73493
- navigate(`/kpis/${line.id}`);
73494
- },
73495
- className: "block py-3 hover:bg-slate-50/50 transition-colors cursor-pointer group relative",
73496
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
73497
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
73498
- /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(
73499
- "img",
73500
- {
73501
- src: line.supervisorImage,
73502
- alt: line.supervisor,
73503
- className: "w-full h-full object-cover"
73504
- }
73505
- ) : /* @__PURE__ */ jsxRuntime.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) }) }),
73506
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0", children: [
73507
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-bold text-slate-800 text-[13px] truncate group-hover:text-indigo-600 transition-colors", children: line.name }) }),
73508
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 mt-0.5 flex-wrap", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[10px] text-slate-400 font-medium", children: line.supervisor }) })
73509
- ] })
73510
- ] }),
73511
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 shrink-0 justify-start min-w-[110px]", children: [
73512
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-[15px] font-bold text-slate-800", children: [
73513
- line.efficiency,
73514
- "%"
73515
- ] }),
73516
- line.delta !== null && line.delta !== void 0 && Number.isFinite(line.delta) ? /* @__PURE__ */ jsxRuntime.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: [
73517
- line.delta >= 0 ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowUp, { className: "w-3 h-3", strokeWidth: 2.5 }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowDown, { className: "w-3 h-3", strokeWidth: 2.5 }),
73518
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold", children: lineDelta.text.split(" vs ")[0].replace("+", "") })
73519
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-0.5 px-2 py-0.5 rounded-full bg-slate-50 text-slate-400", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] font-bold", children: "\u2014" }) })
73520
- ] })
73521
- ] })
73522
- },
73523
- line.id
73524
- );
73525
- }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: `No ${poorestLineMode} line data available` })
73526
- ] }) })
73527
- ] }),
73528
- /* @__PURE__ */ jsxRuntime.jsxs(
73529
- "div",
75854
+ /* @__PURE__ */ jsxRuntime.jsx(
75855
+ PoorestPerformersCard,
73530
75856
  {
73531
- className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden text-left",
73532
- children: [
73533
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50 relative", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Idle Time Breakdown" }) }),
73534
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 p-4 pt-2 relative", children: isIdleReasonBreakdownLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewIdleBreakdownSkeleton, {}) : showIdleModuleNotEnabledState ? /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsxs("div", { children: [
73535
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-semibold text-slate-700", children: "Module not enabled" }),
73536
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-xs text-slate-500", children: "Enable idle-time classification on at least one line to view this breakdown." })
73537
- ] }) }) : /* @__PURE__ */ jsxRuntime.jsx(
73538
- IdleTimeReasonChart,
73539
- {
73540
- data: idleBreakdown,
73541
- isLoading: false,
73542
- hideTotalDuration: true
73543
- }
73544
- ) })
73545
- ]
75857
+ store,
75858
+ supervisorsByLineId,
75859
+ onViewAll: handleViewAllPoorestPerformers,
75860
+ onLineClick: handleOpenLineMonthlyHistory
75861
+ }
75862
+ ),
75863
+ /* @__PURE__ */ jsxRuntime.jsx(
75864
+ IdleBreakdownCard,
75865
+ {
75866
+ store,
75867
+ scopedLineCount: scopedLineIds.length
73546
75868
  }
73547
75869
  )
73548
75870
  ] }),
73549
75871
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-rows-1 xl:grid-rows-2 gap-5 min-h-0", children: [
73550
- /* @__PURE__ */ jsxRuntime.jsxs(
73551
- "div",
75872
+ /* @__PURE__ */ jsxRuntime.jsx(
75873
+ EfficiencyTrendCard,
73552
75874
  {
73553
- 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",
73554
- children: [
73555
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-6 py-5 flex-none flex justify-between items-center border-b border-slate-50/50", children: /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Efficiency Trend" }) }),
73556
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 min-h-0 w-full p-4 pt-4 relative", children: isTrendLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewChartSkeleton, {}) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 pb-2 pr-4 pl-1", children: /* @__PURE__ */ jsxRuntime.jsx(
73557
- LineChart,
73558
- {
73559
- data: trendData,
73560
- lines: efficiencyLineConfig,
73561
- xAxisDataKey: "name",
73562
- yAxisUnit: "%",
73563
- yAxisDomain: [0, 100],
73564
- showLegend: false,
73565
- showGrid: true,
73566
- fillContainer: true,
73567
- tooltipLabelFormatter: trendTooltipLabelFormatter
73568
- },
73569
- trendPlayKey
73570
- ) }) })
73571
- ]
75875
+ store,
75876
+ dateRange,
75877
+ appTimezone
73572
75878
  }
73573
75879
  ),
73574
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-sm border border-slate-100 flex flex-col overflow-hidden", children: [
73575
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "px-5 py-4 flex-none flex justify-between items-center border-b border-slate-50/50", children: [
73576
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-lg font-semibold text-gray-700", children: "Improvements" }),
73577
- /* @__PURE__ */ jsxRuntime.jsx(
73578
- "button",
73579
- {
73580
- type: "button",
73581
- onClick: () => {
73582
- trackCoreEvent("Operations Overview View All Clicked", { section: "improvements" });
73583
- navigate("/improvement-center");
73584
- },
73585
- className: "text-[11px] font-bold text-slate-500 hover:text-slate-800 transition-colors",
73586
- children: "View All"
73587
- }
73588
- )
73589
- ] }),
73590
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 p-0 flex flex-col px-5 py-2 justify-start overflow-auto", children: isImprovementsLoading ? /* @__PURE__ */ jsxRuntime.jsx(OverviewImprovementsSkeleton, {}) : displayImprovements.length > 0 ? displayImprovements.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(
73591
- "div",
73592
- {
73593
- "data-testid": `plant-head-improvement-${item.issueId}`,
73594
- onClick: () => {
73595
- trackCoreEvent("Operations Overview Improvement Clicked", {
73596
- issue_id: item.issueId,
73597
- issue_number: item.issueNumber,
73598
- title: item.title
73599
- });
73600
- const params = new URLSearchParams({
73601
- focusIssueId: item.issueId
73602
- });
73603
- navigate(`/improvement-center?${params.toString()}`);
73604
- },
73605
- className: "flex items-center justify-between py-3 border-b border-slate-50 last:border-0 group cursor-pointer",
73606
- children: [
73607
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 flex-1 min-w-0 pr-4", children: [
73608
- item.ticketLabel && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.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 }) }),
73609
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
73610
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-2 min-w-0 mb-0.5", children: /* @__PURE__ */ jsxRuntime.jsx("h4", { className: "text-[13px] font-semibold text-slate-800 truncate transition-colors group-hover:text-indigo-600", children: item.title }) }),
73611
- /* @__PURE__ */ jsxRuntime.jsx(
73612
- "p",
73613
- {
73614
- className: "text-[10px] font-medium text-slate-400 truncate",
73615
- title: item.metadataLabel,
73616
- children: item.metadataLabel
73617
- }
73618
- )
73619
- ] })
73620
- ] }),
73621
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-end flex-shrink-0 ml-4", children: /* @__PURE__ */ jsxRuntime.jsxs(
73622
- "span",
73623
- {
73624
- 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"}`,
73625
- children: [
73626
- (item.metric.includes("pcs / day") || item.metric.includes("gain")) && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.TrendingUp, { className: "h-3 w-3" }),
73627
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold", children: item.metric })
73628
- ]
73629
- }
73630
- ) })
73631
- ]
73632
- },
73633
- item.id
73634
- )) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-8 text-center text-sm text-slate-400", children: "No open improvement issues" }) })
73635
- ] })
75880
+ /* @__PURE__ */ jsxRuntime.jsx(
75881
+ TopImprovementsCard,
75882
+ {
75883
+ store,
75884
+ supervisorsByLineId,
75885
+ onViewAll: handleViewAllImprovements,
75886
+ onItemClick: handleOpenImprovement
75887
+ }
75888
+ )
73636
75889
  ] })
73637
75890
  ] })
73638
75891
  ] })
@@ -74358,6 +76611,18 @@ exports.awardsService = awardsService;
74358
76611
  exports.buildDateKey = buildDateKey;
74359
76612
  exports.buildKPIsFromLineMetricsRow = buildKPIsFromLineMetricsRow;
74360
76613
  exports.buildShiftGroupsKey = buildShiftGroupsKey;
76614
+ exports.canRoleAccessDashboardPath = canRoleAccessDashboardPath;
76615
+ exports.canRoleAccessTeamManagement = canRoleAccessTeamManagement;
76616
+ exports.canRoleAssignFactories = canRoleAssignFactories;
76617
+ exports.canRoleAssignLines = canRoleAssignLines;
76618
+ exports.canRoleChangeRole = canRoleChangeRole;
76619
+ exports.canRoleInviteRole = canRoleInviteRole;
76620
+ exports.canRoleManageCompany = canRoleManageCompany;
76621
+ exports.canRoleManageTargets = canRoleManageTargets;
76622
+ exports.canRoleManageUsers = canRoleManageUsers;
76623
+ exports.canRoleRemoveUser = canRoleRemoveUser;
76624
+ exports.canRoleViewClipsCost = canRoleViewClipsCost;
76625
+ exports.canRoleViewUsageStats = canRoleViewUsageStats;
74361
76626
  exports.captureSentryException = captureSentryException;
74362
76627
  exports.captureSentryMessage = captureSentryMessage;
74363
76628
  exports.checkRateLimit = checkRateLimit2;
@@ -74401,6 +76666,8 @@ exports.getAllThreadMessages = getAllThreadMessages;
74401
76666
  exports.getAllWorkspaceDisplayNamesAsync = getAllWorkspaceDisplayNamesAsync;
74402
76667
  exports.getAllWorkspaceDisplayNamesSnapshot = getAllWorkspaceDisplayNamesSnapshot;
74403
76668
  exports.getAnonClient = getAnonClient;
76669
+ exports.getAssignableRoles = getAssignableRoles;
76670
+ exports.getAssignmentColumnLabel = getAssignmentColumnLabel;
74404
76671
  exports.getAvailableShiftIds = getAvailableShiftIds;
74405
76672
  exports.getAwardBadgeType = getAwardBadgeType;
74406
76673
  exports.getAwardDescription = getAwardDescription;
@@ -74432,6 +76699,11 @@ exports.getMonthWeekRanges = getMonthWeekRanges;
74432
76699
  exports.getNextUpdateInterval = getNextUpdateInterval;
74433
76700
  exports.getOperationalDate = getOperationalDate;
74434
76701
  exports.getReasonColor = getReasonColor;
76702
+ exports.getRoleAssignmentKind = getRoleAssignmentKind;
76703
+ exports.getRoleDescription = getRoleDescription;
76704
+ exports.getRoleLabel = getRoleLabel;
76705
+ exports.getRoleMetadata = getRoleMetadata;
76706
+ exports.getRoleNavPaths = getRoleNavPaths;
74435
76707
  exports.getS3SignedUrl = getS3SignedUrl;
74436
76708
  exports.getS3VideoSrc = getS3VideoSrc;
74437
76709
  exports.getShiftData = getShiftData;
@@ -74446,6 +76718,7 @@ exports.getThreadMessages = getThreadMessages;
74446
76718
  exports.getUniformShiftGroup = getUniformShiftGroup;
74447
76719
  exports.getUserThreads = getUserThreads;
74448
76720
  exports.getUserThreadsPaginated = getUserThreadsPaginated;
76721
+ exports.getVisibleRolesForCurrentUser = getVisibleRolesForCurrentUser;
74449
76722
  exports.getWorkspaceDisplayName = getWorkspaceDisplayName;
74450
76723
  exports.getWorkspaceDisplayNameAsync = getWorkspaceDisplayNameAsync;
74451
76724
  exports.getWorkspaceDisplayNamesMap = getWorkspaceDisplayNamesMap;
@@ -74456,10 +76729,12 @@ exports.hasAnyShiftData = hasAnyShiftData;
74456
76729
  exports.identifyCoreUser = identifyCoreUser;
74457
76730
  exports.initializeCoreMixpanel = initializeCoreMixpanel;
74458
76731
  exports.isEfficiencyOnTrack = isEfficiencyOnTrack;
76732
+ exports.isFactoryScopedRole = isFactoryScopedRole;
74459
76733
  exports.isFullMonthRange = isFullMonthRange;
74460
76734
  exports.isLegacyConfiguration = isLegacyConfiguration;
74461
76735
  exports.isPrefetchError = isPrefetchError;
74462
76736
  exports.isSafari = isSafari;
76737
+ exports.isSupervisorRole = isSupervisorRole;
74463
76738
  exports.isTransitionPeriod = isTransitionPeriod;
74464
76739
  exports.isUrlPermanentlyFailed = isUrlPermanentlyFailed;
74465
76740
  exports.isValidFactoryViewConfiguration = isValidFactoryViewConfiguration;
@@ -74475,6 +76750,7 @@ exports.linesService = linesService;
74475
76750
  exports.mergeWithDefaultConfig = mergeWithDefaultConfig;
74476
76751
  exports.migrateLegacyConfiguration = migrateLegacyConfiguration;
74477
76752
  exports.normalizeDateKeyRange = normalizeDateKeyRange;
76753
+ exports.normalizeRoleLevel = normalizeRoleLevel;
74478
76754
  exports.optifyeAgentClient = optifyeAgentClient;
74479
76755
  exports.parseDateKeyToDate = parseDateKeyToDate;
74480
76756
  exports.parseS3Uri = parseS3Uri;