@optifye/dashboard-core 6.12.6 → 6.12.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -5228,46 +5228,83 @@ var dashboardService = {
5228
5228
  const dbConfig = config.databaseConfig ?? DEFAULT_DATABASE_CONFIG;
5229
5229
  const linesTable = getTable(dbConfig, "lines");
5230
5230
  const companyId = config.entityConfig?.companyId;
5231
+ const baseLineSelect = `
5232
+ id,
5233
+ line_name,
5234
+ factory_id,
5235
+ factories!lines_factory_id_fkey(factory_name),
5236
+ company_id,
5237
+ companies!lines_company_id_fkey(company_name:name),
5238
+ enable,
5239
+ monitoring_mode,
5240
+ assembly,
5241
+ video_grid_metric_mode,
5242
+ recent_flow_window_minutes
5243
+ `;
5244
+ const lineSelectWithArea = `
5245
+ ${baseLineSelect},
5246
+ factory_area_id,
5247
+ factory_line_areas!lines_factory_area_id_factory_id_fkey(
5248
+ area_key,
5249
+ area_name,
5250
+ sort_order,
5251
+ enabled
5252
+ )
5253
+ `;
5254
+ const shouldRetryWithoutFactoryArea = (error) => {
5255
+ const errorText = [
5256
+ error?.message,
5257
+ error?.details,
5258
+ error?.hint,
5259
+ error?.code
5260
+ ].filter(Boolean).join(" ").toLowerCase();
5261
+ return errorText.includes("factory_area_id") || errorText.includes("factory_line_areas") || errorText.includes("lines_factory_area_id_factory_id_fkey");
5262
+ };
5231
5263
  try {
5232
- let query = supabase.from(linesTable).select(`
5233
- id,
5234
- line_name,
5235
- factory_id,
5236
- factories!lines_factory_id_fkey(factory_name),
5237
- company_id,
5238
- companies!lines_company_id_fkey(company_name:name),
5239
- enable,
5240
- monitoring_mode,
5241
- assembly,
5242
- video_grid_metric_mode,
5243
- recent_flow_window_minutes
5244
- `).eq("enable", true);
5245
- if (companyId) {
5246
- query = query.eq("company_id", companyId);
5247
- }
5248
- const { data, error } = await query;
5264
+ const fetchLines = async (selectClause) => {
5265
+ let query = supabase.from(linesTable).select(selectClause).eq("enable", true);
5266
+ if (companyId) {
5267
+ query = query.eq("company_id", companyId);
5268
+ }
5269
+ return await query;
5270
+ };
5271
+ let { data, error } = await fetchLines(lineSelectWithArea);
5272
+ if (error && shouldRetryWithoutFactoryArea(error)) {
5273
+ console.warn("[dashboardService.getAllLines] Factory area metadata unavailable, falling back to line-only metadata:", error);
5274
+ const fallbackResult = await fetchLines(baseLineSelect);
5275
+ data = fallbackResult.data;
5276
+ error = fallbackResult.error;
5277
+ }
5249
5278
  if (error) {
5250
5279
  console.error("Error fetching all lines:", error);
5251
5280
  throw error;
5252
5281
  }
5253
5282
  if (!data) return [];
5254
- const transformedLines = data.map((line) => ({
5255
- id: line.id,
5256
- line_name: line.line_name,
5257
- factory_id: line.factory_id,
5258
- factory_name: line.factories?.factory_name ?? "N/A",
5259
- company_id: line.company_id,
5260
- company_name: line.companies?.company_name ?? "N/A",
5261
- enable: line.enable ?? true,
5262
- // Default to true if not specified
5263
- monitoring_mode: line.monitoring_mode ?? "output",
5264
- assembly: line.assembly ?? false,
5265
- video_grid_metric_mode: normalizeVideoGridMetricMode(
5266
- line.video_grid_metric_mode,
5267
- line.assembly ?? false
5268
- ),
5269
- recent_flow_window_minutes: line.recent_flow_window_minutes ?? 7
5270
- }));
5283
+ const transformedLines = data.map((line) => {
5284
+ const factoryArea = Array.isArray(line.factory_line_areas) ? line.factory_line_areas[0] : line.factory_line_areas;
5285
+ return {
5286
+ id: line.id,
5287
+ line_name: line.line_name,
5288
+ factory_id: line.factory_id,
5289
+ factory_name: line.factories?.factory_name ?? "N/A",
5290
+ company_id: line.company_id,
5291
+ company_name: line.companies?.company_name ?? "N/A",
5292
+ enable: line.enable ?? true,
5293
+ // Default to true if not specified
5294
+ monitoring_mode: line.monitoring_mode ?? "output",
5295
+ assembly: line.assembly ?? false,
5296
+ video_grid_metric_mode: normalizeVideoGridMetricMode(
5297
+ line.video_grid_metric_mode,
5298
+ line.assembly ?? false
5299
+ ),
5300
+ recent_flow_window_minutes: line.recent_flow_window_minutes ?? 7,
5301
+ factory_area_id: line.factory_area_id ?? null,
5302
+ factory_area_key: factoryArea?.area_key ?? null,
5303
+ factory_area_name: factoryArea?.area_name ?? null,
5304
+ factory_area_sort_order: factoryArea?.sort_order ?? null,
5305
+ factory_area_enabled: factoryArea?.enabled ?? null
5306
+ };
5307
+ });
5271
5308
  return transformedLines;
5272
5309
  } catch (err) {
5273
5310
  console.error("Exception in getAllLines:", err);
@@ -14236,7 +14273,9 @@ var useLeaderboardMetrics = (date, shiftId, limit = 10, filter2 = "all") => {
14236
14273
  `/api/dashboard/leaderboard?${params.toString()}`
14237
14274
  );
14238
14275
  let entries = (data.entries || []).slice();
14239
- entries.sort((a, b) => (b.efficiency || 0) - (a.efficiency || 0));
14276
+ entries.sort(
14277
+ (a, b) => (b.leaderboard_value ?? b.efficiency ?? 0) - (a.leaderboard_value ?? a.efficiency ?? 0)
14278
+ );
14240
14279
  if (filter2 === "top") {
14241
14280
  entries = entries.slice(0, limit);
14242
14281
  } else if (filter2 === "bottom") {
@@ -22000,6 +22039,84 @@ var aggregateKPIsFromLineMetricsRows = (rows) => {
22000
22039
  };
22001
22040
  };
22002
22041
 
22042
+ // src/lib/utils/kpiHierarchy.ts
22043
+ var FACTORY_LEVEL_MIN_FACTORY_COUNT = 3;
22044
+ var compareText = (left, right) => left.localeCompare(right, void 0, { sensitivity: "base", numeric: true });
22045
+ var compareLinesByName = (left, right) => compareText(left.line_name || "", right.line_name || "");
22046
+ var normalizeAreaSortOrder = (value) => {
22047
+ if (typeof value === "number" && Number.isFinite(value)) return value;
22048
+ if (typeof value === "string" && value.trim() !== "") {
22049
+ const parsed = Number(value);
22050
+ return Number.isFinite(parsed) ? parsed : null;
22051
+ }
22052
+ return null;
22053
+ };
22054
+ var getEnabledAreaInfo = (line) => {
22055
+ if (!line.factory_area_id) return null;
22056
+ if (line.factory_area_enabled !== true) return null;
22057
+ if (!line.factory_area_name || line.factory_area_name.trim().length === 0) return null;
22058
+ return {
22059
+ id: line.factory_area_id,
22060
+ areaName: line.factory_area_name,
22061
+ areaKey: line.factory_area_key ?? null,
22062
+ sortOrder: normalizeAreaSortOrder(line.factory_area_sort_order)
22063
+ };
22064
+ };
22065
+ var buildKpiLineHierarchy = (lines) => {
22066
+ const factoryMap = /* @__PURE__ */ new Map();
22067
+ lines.forEach((line) => {
22068
+ const factoryId = line.factory_id || "unknown-factory";
22069
+ let factory = factoryMap.get(factoryId);
22070
+ if (!factory) {
22071
+ factory = {
22072
+ id: factoryId,
22073
+ factoryName: line.factory_name || "Factory",
22074
+ lines: [],
22075
+ areas: [],
22076
+ ungroupedLines: [],
22077
+ areaMap: /* @__PURE__ */ new Map()
22078
+ };
22079
+ factoryMap.set(factoryId, factory);
22080
+ }
22081
+ factory.lines.push(line);
22082
+ const areaInfo = getEnabledAreaInfo(line);
22083
+ if (!areaInfo) {
22084
+ factory.ungroupedLines.push(line);
22085
+ return;
22086
+ }
22087
+ let area = factory.areaMap.get(areaInfo.id);
22088
+ if (!area) {
22089
+ area = {
22090
+ id: areaInfo.id,
22091
+ areaName: areaInfo.areaName,
22092
+ areaKey: areaInfo.areaKey,
22093
+ sortOrder: areaInfo.sortOrder,
22094
+ lines: []
22095
+ };
22096
+ factory.areaMap.set(areaInfo.id, area);
22097
+ factory.areas.push(area);
22098
+ }
22099
+ area.lines.push(line);
22100
+ });
22101
+ const factories = Array.from(factoryMap.values()).map(({ areaMap: _areaMap, ...factory }) => {
22102
+ factory.lines.sort(compareLinesByName);
22103
+ factory.ungroupedLines.sort(compareLinesByName);
22104
+ factory.areas.forEach((area) => area.lines.sort(compareLinesByName));
22105
+ factory.areas.sort((left, right) => {
22106
+ const leftOrder = left.sortOrder ?? Number.POSITIVE_INFINITY;
22107
+ const rightOrder = right.sortOrder ?? Number.POSITIVE_INFINITY;
22108
+ if (leftOrder !== rightOrder) return leftOrder - rightOrder;
22109
+ return compareText(left.areaName, right.areaName);
22110
+ });
22111
+ return factory;
22112
+ });
22113
+ factories.sort((left, right) => compareText(left.factoryName, right.factoryName));
22114
+ return {
22115
+ factories,
22116
+ showFactoryLevel: factories.length >= FACTORY_LEVEL_MIN_FACTORY_COUNT
22117
+ };
22118
+ };
22119
+
22003
22120
  // src/lib/utils/awards.ts
22004
22121
  var toNumber2 = (value) => {
22005
22122
  if (typeof value === "number" && Number.isFinite(value)) return value;
@@ -38234,7 +38351,8 @@ var WorkspaceMetricCardsImpl = ({
38234
38351
  legend,
38235
38352
  skuAware,
38236
38353
  skuBreakdown,
38237
- activeSkuId
38354
+ activeSkuId,
38355
+ liveSkuId
38238
38356
  }) => {
38239
38357
  const effectiveLegend = legend || DEFAULT_EFFICIENCY_LEGEND;
38240
38358
  const activeSku = React144__default.useMemo(() => {
@@ -38243,6 +38361,13 @@ var WorkspaceMetricCardsImpl = ({
38243
38361
  }
38244
38362
  return null;
38245
38363
  }, [skuAware, activeSkuId, skuBreakdown]);
38364
+ const displaySku = React144__default.useMemo(() => {
38365
+ if (activeSku) return activeSku;
38366
+ if (skuAware && !activeSkuId && liveSkuId && skuBreakdown) {
38367
+ return skuBreakdown.find((s) => s.sku_id === liveSkuId) ?? null;
38368
+ }
38369
+ return null;
38370
+ }, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
38246
38371
  const pphValue = activeSku ? activeSku.avg_pph : workspace.avg_pph;
38247
38372
  const pphThreshold = activeSku ? activeSku.pph_threshold : workspace.pph_threshold;
38248
38373
  const cycleValue = activeSku ? activeSku.avg_cycle_time : workspace.avg_cycle_time;
@@ -38277,7 +38402,7 @@ var WorkspaceMetricCardsImpl = ({
38277
38402
  /* @__PURE__ */ jsxs(Card2, { className: "flex flex-col bg-white shadow-sm h-full min-h-[150px] sm:min-h-0", children: [
38278
38403
  /* @__PURE__ */ jsxs(CardHeader2, { className: "pb-2 flex-none text-center", children: [
38279
38404
  /* @__PURE__ */ jsx(CardTitle2, { className: "text-lg", children: "PPH" }),
38280
- activeSku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: activeSku.sku_code, children: activeSku.sku_code })
38405
+ displaySku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: displaySku.sku_code, children: displaySku.sku_code })
38281
38406
  ] }),
38282
38407
  /* @__PURE__ */ jsx(CardContent2, { className: "flex-1 flex items-center justify-center py-6 sm:py-3", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
38283
38408
  /* @__PURE__ */ jsx("p", { className: `text-5xl font-bold ${pphValue >= pphThreshold ? "text-green-500" : "text-red-500"}`, children: pphValue.toFixed(1) }),
@@ -38290,7 +38415,7 @@ var WorkspaceMetricCardsImpl = ({
38290
38415
  /* @__PURE__ */ jsxs(Card2, { className: "flex flex-col bg-white shadow-sm h-full min-h-[150px] sm:min-h-0", children: [
38291
38416
  /* @__PURE__ */ jsxs(CardHeader2, { className: "pb-2 flex-none text-center", children: [
38292
38417
  /* @__PURE__ */ jsx(CardTitle2, { className: "text-lg", children: "Avg. Cycle Time" }),
38293
- activeSku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: activeSku.sku_code, children: activeSku.sku_code })
38418
+ displaySku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: displaySku.sku_code, children: displaySku.sku_code })
38294
38419
  ] }),
38295
38420
  /* @__PURE__ */ jsx(CardContent2, { className: "flex-1 flex items-center justify-center py-6 sm:py-3", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
38296
38421
  /* @__PURE__ */ jsx("p", { className: `text-5xl font-bold ${cycleValue > (cycleStandard || 0) ? "text-red-500" : "text-green-500"}`, children: cycleValue.toFixed(1) }),
@@ -54272,7 +54397,8 @@ var WorkspaceCycleTimeMetricCards = ({
54272
54397
  idleTimeData,
54273
54398
  skuAware,
54274
54399
  skuBreakdown,
54275
- activeSkuId
54400
+ activeSkuId,
54401
+ liveSkuId
54276
54402
  }) => {
54277
54403
  const effectiveLegend = legend || DEFAULT_EFFICIENCY_LEGEND;
54278
54404
  const activeSku = React144__default.useMemo(() => {
@@ -54281,6 +54407,13 @@ var WorkspaceCycleTimeMetricCards = ({
54281
54407
  }
54282
54408
  return null;
54283
54409
  }, [skuAware, activeSkuId, skuBreakdown]);
54410
+ const displaySku = React144__default.useMemo(() => {
54411
+ if (activeSku) return activeSku;
54412
+ if (skuAware && !activeSkuId && liveSkuId && skuBreakdown) {
54413
+ return skuBreakdown.find((s) => s.sku_id === liveSkuId) ?? null;
54414
+ }
54415
+ return null;
54416
+ }, [activeSku, skuAware, activeSkuId, liveSkuId, skuBreakdown]);
54284
54417
  const cycleValue = activeSku ? activeSku.avg_cycle_time : workspace.avg_cycle_time;
54285
54418
  const cycleStandard = activeSku ? activeSku.ideal_cycle_time : workspace.ideal_cycle_time;
54286
54419
  const efficiencyValue = workspace.avg_efficiency || 0;
@@ -54310,7 +54443,7 @@ var WorkspaceCycleTimeMetricCards = ({
54310
54443
  /* @__PURE__ */ jsxs(Card2, { className: "flex flex-col bg-white shadow-sm border border-gray-200 h-full min-h-[150px] sm:min-h-0 rounded-xl", children: [
54311
54444
  /* @__PURE__ */ jsxs(CardHeader2, { className: "pb-1 pt-5 flex-none text-center", children: [
54312
54445
  /* @__PURE__ */ jsx(CardTitle2, { className: "text-[15px] font-bold text-gray-900 tracking-wide", children: "Cycle Time (s)" }),
54313
- activeSku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: activeSku.sku_code, children: activeSku.sku_code })
54446
+ displaySku && /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-blue-600 mt-1 truncate px-2", title: displaySku.sku_code, children: displaySku.sku_code })
54314
54447
  ] }),
54315
54448
  /* @__PURE__ */ jsxs(CardContent2, { className: "flex-1 flex flex-col items-center justify-center pb-6", children: [
54316
54449
  /* @__PURE__ */ jsx("p", { className: `text-5xl font-bold tracking-tight ${cycleValue > (cycleStandard || 0) ? "text-red-500" : "text-[#34C759]"}`, children: cycleValue.toFixed(1) }),
@@ -68400,6 +68533,9 @@ var KPIDetailView = ({
68400
68533
  var KPIDetailViewWithDisplayNames = withSelectedLineDisplayNames(KPIDetailView);
68401
68534
  var KPIDetailView_default = KPIDetailViewWithDisplayNames;
68402
68535
  var isNonEmptyString = (value) => typeof value === "string" && value.trim().length > 0;
68536
+ var KPI_FACTORY_QUERY_PARAM = "factory_id";
68537
+ var KPI_FACTORY_AREA_QUERY_PARAM = "factory_area_id";
68538
+ var getSingleQueryValue = (value) => typeof value === "string" && value.length > 0 ? value : void 0;
68403
68539
  var resolveCompanyId = (...candidates) => candidates.find(isNonEmptyString);
68404
68540
  var parseTimeToMinutes3 = (value) => {
68405
68541
  if (!value) return null;
@@ -68436,7 +68572,9 @@ var getMonthDateInfo = (timezone) => {
68436
68572
  var createKpisOverviewUrl = ({
68437
68573
  tab,
68438
68574
  date,
68439
- shift
68575
+ shift,
68576
+ factoryId,
68577
+ factoryAreaId
68440
68578
  }) => {
68441
68579
  const params = new URLSearchParams();
68442
68580
  if (tab) {
@@ -68448,6 +68586,12 @@ var createKpisOverviewUrl = ({
68448
68586
  if (typeof shift === "number" && Number.isFinite(shift)) {
68449
68587
  params.set("shift", shift.toString());
68450
68588
  }
68589
+ if (!tab && factoryId) {
68590
+ params.set(KPI_FACTORY_QUERY_PARAM, factoryId);
68591
+ }
68592
+ if (!tab && factoryId && factoryAreaId) {
68593
+ params.set(KPI_FACTORY_AREA_QUERY_PARAM, factoryAreaId);
68594
+ }
68451
68595
  const queryString = params.toString();
68452
68596
  return queryString ? `/kpis?${queryString}` : "/kpis";
68453
68597
  };
@@ -68969,6 +69113,101 @@ var LineCard = ({
68969
69113
  }
68970
69114
  );
68971
69115
  };
69116
+ var KpiGroupCard = ({
69117
+ title,
69118
+ subtitle,
69119
+ kpis,
69120
+ isLoading,
69121
+ error,
69122
+ isUptimeMode,
69123
+ onClick
69124
+ }) => {
69125
+ const isOnTrack = React144__default.useMemo(() => {
69126
+ if (!kpis) return null;
69127
+ return isEfficiencyOnTrack(kpis.efficiency.value);
69128
+ }, [kpis]);
69129
+ const outputTarget = Number(kpis?.outputProgress?.target ?? 0);
69130
+ const outputCurrent = Number(kpis?.outputProgress?.current ?? 0);
69131
+ const progressPercent = outputTarget > 0 ? Math.min(outputCurrent / outputTarget * 100, 100) : 0;
69132
+ return /* @__PURE__ */ jsxs(
69133
+ motion.div,
69134
+ {
69135
+ initial: { opacity: 0, y: 20 },
69136
+ animate: { opacity: 1, y: 0 },
69137
+ transition: { duration: 0.3 },
69138
+ onClick,
69139
+ className: "relative bg-white border border-gray-200/80 shadow-sm hover:shadow-lg \n rounded-xl p-4 sm:p-5 md:p-6 transition-all duration-200 cursor-pointer \n hover:scale-[1.01] active:scale-[0.99] group",
69140
+ children: [
69141
+ /* @__PURE__ */ jsx("div", { className: "mb-4 sm:mb-5 md:mb-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-start gap-2 sm:gap-3", children: [
69142
+ /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
69143
+ /* @__PURE__ */ jsx(
69144
+ FittingTitle,
69145
+ {
69146
+ title,
69147
+ className: "text-[10px] sm:text-xs md:text-sm"
69148
+ }
69149
+ ),
69150
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs font-medium text-gray-500", children: subtitle })
69151
+ ] }),
69152
+ !isUptimeMode && kpis && isOnTrack !== null && /* @__PURE__ */ jsxs("div", { className: `flex items-center gap-1.5 px-2.5 sm:px-3 py-1 sm:py-1.5 rounded-full text-xs font-medium flex-shrink-0 ${isOnTrack ? "bg-emerald-100 text-emerald-700 border border-emerald-200" : "bg-red-100 text-red-700 border border-red-200"}`, style: { minWidth: "fit-content" }, children: [
69153
+ /* @__PURE__ */ jsx("div", { className: `w-2 h-2 rounded-full ${isOnTrack ? "bg-emerald-500" : "bg-red-500"} animate-pulse` }),
69154
+ /* @__PURE__ */ jsx("span", { children: isOnTrack ? "On Track" : "Behind" })
69155
+ ] })
69156
+ ] }) }),
69157
+ isLoading && !kpis && /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
69158
+ /* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
69159
+ /* @__PURE__ */ jsx("div", { className: "h-4 bg-gray-200 rounded w-1/3 mb-2" }),
69160
+ /* @__PURE__ */ jsx("div", { className: "h-8 bg-gray-200 rounded w-1/2" })
69161
+ ] }),
69162
+ /* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
69163
+ /* @__PURE__ */ jsx("div", { className: "h-4 bg-gray-200 rounded w-1/3 mb-2" }),
69164
+ /* @__PURE__ */ jsx("div", { className: "h-8 bg-gray-200 rounded w-3/4" })
69165
+ ] }),
69166
+ /* @__PURE__ */ jsxs("div", { className: "animate-pulse", children: [
69167
+ /* @__PURE__ */ jsx("div", { className: "h-4 bg-gray-200 rounded w-1/3 mb-2" }),
69168
+ /* @__PURE__ */ jsx("div", { className: "h-8 bg-gray-200 rounded w-1/2" })
69169
+ ] })
69170
+ ] }),
69171
+ error && !kpis && /* @__PURE__ */ jsx("div", { className: "text-center py-8", children: /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-500", children: "Unable to load metrics" }) }),
69172
+ kpis && /* @__PURE__ */ jsxs("div", { className: "space-y-4 sm:space-y-5 pb-8 sm:pb-10", children: [
69173
+ /* @__PURE__ */ jsxs("div", { children: [
69174
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-medium text-gray-500 uppercase tracking-wider mb-1.5 sm:mb-2", children: isUptimeMode ? "Utilization" : "Efficiency" }),
69175
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between", children: [
69176
+ /* @__PURE__ */ jsxs("span", { className: "text-2xl sm:text-3xl font-semibold text-gray-900", children: [
69177
+ kpis.efficiency.value.toFixed(1),
69178
+ "%"
69179
+ ] }),
69180
+ kpis.efficiency.change !== 0 && /* @__PURE__ */ jsxs("span", { className: `text-xs sm:text-sm font-medium ${kpis.efficiency.change > 0 ? "text-emerald-600" : "text-red-600"}`, children: [
69181
+ kpis.efficiency.change > 0 ? "+" : "",
69182
+ kpis.efficiency.change.toFixed(1),
69183
+ "%"
69184
+ ] })
69185
+ ] })
69186
+ ] }),
69187
+ /* @__PURE__ */ jsxs("div", { children: [
69188
+ /* @__PURE__ */ jsx("div", { className: "text-xs font-medium text-gray-500 uppercase tracking-wider mb-1.5 sm:mb-2", children: isUptimeMode ? "Stoppages" : "Output Progress" }),
69189
+ /* @__PURE__ */ jsxs("div", { className: "flex items-baseline justify-between mb-2 sm:mb-3", children: [
69190
+ /* @__PURE__ */ jsx("span", { className: `${isUptimeMode ? "text-2xl sm:text-3xl font-bold text-red-600" : "text-xl sm:text-2xl font-semibold text-gray-900"}`, children: kpis.outputProgress.current }),
69191
+ !isUptimeMode && /* @__PURE__ */ jsxs("span", { className: "text-xs sm:text-sm text-gray-500 font-medium", children: [
69192
+ "/ ",
69193
+ kpis.outputProgress.target,
69194
+ " units"
69195
+ ] })
69196
+ ] }),
69197
+ !isUptimeMode && /* @__PURE__ */ jsx("div", { className: "w-full bg-gray-200 rounded-full h-2 sm:h-2.5", children: /* @__PURE__ */ jsx(
69198
+ "div",
69199
+ {
69200
+ className: "bg-blue-600 h-2 sm:h-2.5 rounded-full transition-all duration-500 ease-out",
69201
+ style: { width: `${progressPercent}%` }
69202
+ }
69203
+ ) })
69204
+ ] })
69205
+ ] }),
69206
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-3 right-3 sm:bottom-4 sm:right-4", children: /* @__PURE__ */ jsx("div", { className: "p-2 sm:p-2.5 rounded-full bg-gray-50 group-hover:bg-blue-50 transition-colors shadow-sm", children: /* @__PURE__ */ jsx(ArrowRightIcon, { className: "w-4 h-4 sm:w-5 sm:h-5 text-gray-400 group-hover:text-blue-600 transition-colors" }) }) })
69207
+ ]
69208
+ }
69209
+ );
69210
+ };
68972
69211
  var KPIsOverviewView = ({
68973
69212
  companyId,
68974
69213
  navigate,
@@ -69134,6 +69373,20 @@ var KPIsOverviewView = ({
69134
69373
  const effectiveLeaderboardDate = selectedLeaderboardDate || currentShiftDate;
69135
69374
  const effectiveLeaderboardShiftId = Number.isFinite(selectedLeaderboardShiftId) ? selectedLeaderboardShiftId : currentShiftId;
69136
69375
  const isHistoricalLeaderboardDaily = activeTab === "leaderboard" && timeRange === "today" && (effectiveLeaderboardDate !== currentShiftDate || effectiveLeaderboardShiftId !== currentShiftId);
69376
+ const selectedFactoryIdFromUrl = getSingleQueryValue(router.query[KPI_FACTORY_QUERY_PARAM]);
69377
+ const selectedFactoryAreaIdFromUrl = getSingleQueryValue(router.query[KPI_FACTORY_AREA_QUERY_PARAM]);
69378
+ const kpiLineHierarchy = React144__default.useMemo(
69379
+ () => buildKpiLineHierarchy(linesForView),
69380
+ [linesForView]
69381
+ );
69382
+ const selectedFactoryNode = React144__default.useMemo(
69383
+ () => kpiLineHierarchy.showFactoryLevel && selectedFactoryIdFromUrl ? kpiLineHierarchy.factories.find((factory) => factory.id === selectedFactoryIdFromUrl) : void 0,
69384
+ [kpiLineHierarchy, selectedFactoryIdFromUrl]
69385
+ );
69386
+ const selectedFactoryAreaNode = React144__default.useMemo(
69387
+ () => selectedFactoryNode && selectedFactoryAreaIdFromUrl ? selectedFactoryNode.areas.find((area) => area.id === selectedFactoryAreaIdFromUrl) : void 0,
69388
+ [selectedFactoryNode, selectedFactoryAreaIdFromUrl]
69389
+ );
69137
69390
  useEffect(() => {
69138
69391
  if (!router.isReady) return;
69139
69392
  const tabQuery = router.query.tab;
@@ -69161,20 +69414,27 @@ var KPIsOverviewView = ({
69161
69414
  ]);
69162
69415
  useEffect(() => {
69163
69416
  if (!router.isReady || !hasHydratedLeaderboardRouteState) return;
69417
+ if (activeTab === "today" && loading) return;
69164
69418
  const expectedTab = activeTab === "leaderboard" ? "leaderboard" : void 0;
69165
69419
  const expectedDate = activeTab === "leaderboard" && timeRange === "today" && isHistoricalLeaderboardDaily ? effectiveLeaderboardDate : void 0;
69166
69420
  const expectedShift = expectedDate !== void 0 ? effectiveLeaderboardShiftId.toString() : void 0;
69421
+ const expectedFactory = activeTab === "today" && selectedFactoryNode ? selectedFactoryNode.id : void 0;
69422
+ const expectedFactoryArea = activeTab === "today" && selectedFactoryNode && selectedFactoryAreaNode ? selectedFactoryAreaNode.id : void 0;
69167
69423
  const currentTab = typeof router.query.tab === "string" ? router.query.tab : void 0;
69168
69424
  const currentDateQuery = typeof router.query.date === "string" ? router.query.date : void 0;
69169
69425
  const currentShiftQuery = typeof router.query.shift === "string" ? router.query.shift : void 0;
69170
- if (currentTab === expectedTab && currentDateQuery === expectedDate && currentShiftQuery === expectedShift) {
69426
+ const currentFactoryQuery = getSingleQueryValue(router.query[KPI_FACTORY_QUERY_PARAM]);
69427
+ const currentFactoryAreaQuery = getSingleQueryValue(router.query[KPI_FACTORY_AREA_QUERY_PARAM]);
69428
+ if (currentTab === expectedTab && currentDateQuery === expectedDate && currentShiftQuery === expectedShift && currentFactoryQuery === expectedFactory && currentFactoryAreaQuery === expectedFactoryArea) {
69171
69429
  return;
69172
69430
  }
69173
69431
  void router.replace(
69174
69432
  createKpisOverviewUrl({
69175
69433
  tab: expectedTab === "leaderboard" ? "leaderboard" : void 0,
69176
69434
  date: expectedDate,
69177
- shift: expectedShift !== void 0 ? Number.parseInt(expectedShift, 10) : void 0
69435
+ shift: expectedShift !== void 0 ? Number.parseInt(expectedShift, 10) : void 0,
69436
+ factoryId: expectedFactory,
69437
+ factoryAreaId: expectedFactoryArea
69178
69438
  }),
69179
69439
  void 0,
69180
69440
  { shallow: true }
@@ -69186,7 +69446,10 @@ var KPIsOverviewView = ({
69186
69446
  effectiveLeaderboardDate,
69187
69447
  effectiveLeaderboardShiftId,
69188
69448
  hasHydratedLeaderboardRouteState,
69189
- isHistoricalLeaderboardDaily
69449
+ isHistoricalLeaderboardDaily,
69450
+ loading,
69451
+ selectedFactoryNode,
69452
+ selectedFactoryAreaNode
69190
69453
  ]);
69191
69454
  const factoryViewId = entityConfig.factoryViewId || "factory";
69192
69455
  const {
@@ -69198,13 +69461,42 @@ var KPIsOverviewView = ({
69198
69461
  userAccessibleLineIds: metricsLineIds
69199
69462
  });
69200
69463
  const defaultKPIs = React144__default.useMemo(() => createDefaultKPIs(), []);
69201
- const kpisByLineId = React144__default.useMemo(() => {
69464
+ const lineModeById = React144__default.useMemo(() => {
69465
+ const map = /* @__PURE__ */ new Map();
69466
+ linesForView.forEach((line) => {
69467
+ map.set(line.id, line.monitoring_mode ?? "output");
69468
+ });
69469
+ return map;
69470
+ }, [linesForView]);
69471
+ const lineMetricRowsByLineId = React144__default.useMemo(() => {
69202
69472
  const map = /* @__PURE__ */ new Map();
69203
69473
  lineMetrics.forEach((row) => {
69204
- if (row?.line_id) map.set(row.line_id, buildKPIsFromLineMetricsRow(row));
69474
+ if (!row?.line_id) return;
69475
+ const monitoringMode = lineModeById.get(row.line_id);
69476
+ map.set(
69477
+ row.line_id,
69478
+ monitoringMode ? { ...row, monitoring_mode: monitoringMode } : row
69479
+ );
69205
69480
  });
69206
69481
  return map;
69207
- }, [lineMetrics]);
69482
+ }, [lineMetrics, lineModeById]);
69483
+ const kpisByLineId = React144__default.useMemo(() => {
69484
+ const map = /* @__PURE__ */ new Map();
69485
+ lineMetricRowsByLineId.forEach((row, lineId) => {
69486
+ map.set(lineId, buildKPIsFromLineMetricsRow(row));
69487
+ });
69488
+ return map;
69489
+ }, [lineMetricRowsByLineId]);
69490
+ const getLineCardKpis = React144__default.useCallback((line) => {
69491
+ if (metricsError) return null;
69492
+ return kpisByLineId.get(line.id) ?? (metricsLoading ? null : defaultKPIs);
69493
+ }, [defaultKPIs, kpisByLineId, metricsError, metricsLoading]);
69494
+ const getAggregateCardKpis = React144__default.useCallback((cardLines) => {
69495
+ if (metricsError) return null;
69496
+ const rows = cardLines.map((line) => lineMetricRowsByLineId.get(line.id)).filter(Boolean);
69497
+ if (metricsLoading && rows.length === 0) return null;
69498
+ return aggregateKPIsFromLineMetricsRows(rows);
69499
+ }, [lineMetricRowsByLineId, metricsError, metricsLoading]);
69208
69500
  const supervisorLineIds = React144__default.useMemo(
69209
69501
  () => (leaderboardLines.length > 0 ? leaderboardLines : lines).map((l) => l.id),
69210
69502
  [leaderboardLines, lines]
@@ -69408,6 +69700,20 @@ var KPIsOverviewView = ({
69408
69700
  if (activeTab !== "leaderboard" || timeRange !== "today") return;
69409
69701
  fetchDailyLeaderboard();
69410
69702
  }, [activeTab, timeRange, fetchDailyLeaderboard]);
69703
+ const navigateTodayHierarchy = useCallback((factoryId, factoryAreaId) => {
69704
+ void router.push(
69705
+ createKpisOverviewUrl({ factoryId, factoryAreaId }),
69706
+ void 0,
69707
+ { shallow: true }
69708
+ );
69709
+ }, [router]);
69710
+ const lineDetailReturnTo = React144__default.useMemo(() => {
69711
+ if (activeTab !== "today" || !selectedFactoryNode) return void 0;
69712
+ return createKpisOverviewUrl({
69713
+ factoryId: selectedFactoryNode.id,
69714
+ factoryAreaId: selectedFactoryAreaNode?.id
69715
+ });
69716
+ }, [activeTab, selectedFactoryNode, selectedFactoryAreaNode]);
69411
69717
  const formatTopPerformerWeek = (periodStart, periodEnd) => {
69412
69718
  const dateToUse = periodStart ? /* @__PURE__ */ new Date(`${periodStart}T00:00:00`) : /* @__PURE__ */ new Date();
69413
69719
  if (Number.isNaN(dateToUse.getTime())) {
@@ -69494,7 +69800,8 @@ var KPIsOverviewView = ({
69494
69800
  );
69495
69801
  return;
69496
69802
  }
69497
- navigation.navigate(`/kpis/${line.id}`);
69803
+ const returnToQuery = lineDetailReturnTo ? `?returnTo=${encodeURIComponent(lineDetailReturnTo)}` : "";
69804
+ navigation.navigate(`/kpis/${line.id}${returnToQuery}`);
69498
69805
  };
69499
69806
  const handleBackClick = useCallback(() => {
69500
69807
  trackCoreEvent("Back Button Clicked", {
@@ -69563,6 +69870,70 @@ var KPIsOverviewView = ({
69563
69870
  }
69564
69871
  return /* @__PURE__ */ jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" }) });
69565
69872
  };
69873
+ const renderLineCard = (line) => /* @__PURE__ */ jsx(
69874
+ LineCard,
69875
+ {
69876
+ line,
69877
+ kpis: getLineCardKpis(line),
69878
+ isLoading: metricsLoading,
69879
+ error: metricsError,
69880
+ onClick: (kpis) => handleLineClick(line, kpis),
69881
+ supervisorEnabled,
69882
+ supervisorName: supervisorNamesByLineId.get(line.id) || null,
69883
+ supervisors: supervisorsByLineId?.get(line.id)
69884
+ },
69885
+ line.id
69886
+ );
69887
+ const renderGroupCard = ({
69888
+ key,
69889
+ title,
69890
+ subtitle,
69891
+ lines: cardLines,
69892
+ onClick
69893
+ }) => /* @__PURE__ */ jsx(
69894
+ KpiGroupCard,
69895
+ {
69896
+ title,
69897
+ subtitle,
69898
+ kpis: getAggregateCardKpis(cardLines),
69899
+ isLoading: metricsLoading,
69900
+ error: metricsError,
69901
+ isUptimeMode: viewType === "machine",
69902
+ onClick
69903
+ },
69904
+ key
69905
+ );
69906
+ const renderTodayCards = () => {
69907
+ if (!kpiLineHierarchy.showFactoryLevel) {
69908
+ return linesForView.map(renderLineCard);
69909
+ }
69910
+ if (selectedFactoryNode && selectedFactoryAreaNode) {
69911
+ return selectedFactoryAreaNode.lines.map(renderLineCard);
69912
+ }
69913
+ if (selectedFactoryNode) {
69914
+ return [
69915
+ ...selectedFactoryNode.areas.map(
69916
+ (area) => renderGroupCard({
69917
+ key: `area-${area.id}`,
69918
+ title: area.areaName,
69919
+ subtitle: `${area.lines.length} ${area.lines.length === 1 ? "line" : "lines"}`,
69920
+ lines: area.lines,
69921
+ onClick: () => navigateTodayHierarchy(selectedFactoryNode.id, area.id)
69922
+ })
69923
+ ),
69924
+ ...selectedFactoryNode.ungroupedLines.map(renderLineCard)
69925
+ ];
69926
+ }
69927
+ return kpiLineHierarchy.factories.map(
69928
+ (factory) => renderGroupCard({
69929
+ key: `factory-${factory.id}`,
69930
+ title: factory.factoryName,
69931
+ subtitle: `${factory.lines.length} ${factory.lines.length === 1 ? "line" : "lines"}`,
69932
+ lines: factory.lines,
69933
+ onClick: () => navigateTodayHierarchy(factory.id)
69934
+ })
69935
+ );
69936
+ };
69566
69937
  if (loading || isShiftConfigLoading) {
69567
69938
  return /* @__PURE__ */ jsx(LoadingPage, { message: "Loading production lines..." });
69568
69939
  }
@@ -69995,23 +70366,34 @@ var KPIsOverviewView = ({
69995
70366
  ] })
69996
70367
  ] })
69997
70368
  ] }) }),
69998
- /* @__PURE__ */ jsx("main", { className: `flex-1 p-3 sm:p-4 md:p-6 bg-slate-50 ${activeTab === "leaderboard" ? "overflow-hidden flex flex-col" : "overflow-y-auto"}`, children: activeTab === "today" ? (
69999
- /* Line Cards Grid */
70000
- /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 sm:gap-4 md:gap-6", children: linesForView.map((line) => /* @__PURE__ */ jsx(
70001
- LineCard,
70002
- {
70003
- line,
70004
- kpis: metricsError ? null : kpisByLineId.get(line.id) ?? (metricsLoading ? null : defaultKPIs),
70005
- isLoading: metricsLoading,
70006
- error: metricsError,
70007
- onClick: (kpis) => handleLineClick(line, kpis),
70008
- supervisorEnabled,
70009
- supervisorName: supervisorNamesByLineId.get(line.id) || null,
70010
- supervisors: supervisorsByLineId?.get(line.id)
70011
- },
70012
- line.id
70013
- )) })
70014
- ) : showLeaderboardLoader ? /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col items-center justify-center bg-white rounded-2xl border border-gray-100 shadow-sm m-2 sm:m-4", children: /* @__PURE__ */ jsx(
70369
+ /* @__PURE__ */ jsx("main", { className: `flex-1 p-3 sm:p-4 md:p-6 bg-slate-50 ${activeTab === "leaderboard" ? "overflow-hidden flex flex-col" : "overflow-y-auto"}`, children: activeTab === "today" ? /* @__PURE__ */ jsxs("div", { className: "space-y-3 sm:space-y-4", children: [
70370
+ kpiLineHierarchy.showFactoryLevel && selectedFactoryNode && /* @__PURE__ */ jsxs("nav", { className: "flex flex-wrap items-center gap-2 text-sm", "aria-label": "KPI hierarchy", children: [
70371
+ /* @__PURE__ */ jsx(
70372
+ "button",
70373
+ {
70374
+ type: "button",
70375
+ onClick: () => navigateTodayHierarchy(),
70376
+ className: "font-medium text-gray-500 hover:text-blue-600 transition-colors",
70377
+ children: "Factories"
70378
+ }
70379
+ ),
70380
+ /* @__PURE__ */ jsx("span", { className: "text-gray-300", children: "/" }),
70381
+ selectedFactoryAreaNode ? /* @__PURE__ */ jsx(
70382
+ "button",
70383
+ {
70384
+ type: "button",
70385
+ onClick: () => navigateTodayHierarchy(selectedFactoryNode.id),
70386
+ className: "font-medium text-gray-500 hover:text-blue-600 transition-colors",
70387
+ children: selectedFactoryNode.factoryName
70388
+ }
70389
+ ) : /* @__PURE__ */ jsx("span", { className: "font-semibold text-gray-900", children: selectedFactoryNode.factoryName }),
70390
+ selectedFactoryAreaNode && /* @__PURE__ */ jsxs(Fragment, { children: [
70391
+ /* @__PURE__ */ jsx("span", { className: "text-gray-300", children: "/" }),
70392
+ /* @__PURE__ */ jsx("span", { className: "font-semibold text-gray-900", children: selectedFactoryAreaNode.areaName })
70393
+ ] })
70394
+ ] }),
70395
+ /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3 sm:gap-4 md:gap-6", children: renderTodayCards() })
70396
+ ] }) : showLeaderboardLoader ? /* @__PURE__ */ jsx("div", { className: "flex-1 flex flex-col items-center justify-center bg-white rounded-2xl border border-gray-100 shadow-sm m-2 sm:m-4", children: /* @__PURE__ */ jsx(
70015
70397
  OptifyeLogoLoader_default,
70016
70398
  {
70017
70399
  size: "lg",
@@ -70058,6 +70440,27 @@ var AnimatedEfficiency = memo$1(({ value }) => {
70058
70440
  return prevProps.value === nextProps.value;
70059
70441
  });
70060
70442
  AnimatedEfficiency.displayName = "AnimatedEfficiency";
70443
+ var getWorkspaceLeaderboardMetricValue = (workspace) => {
70444
+ if (workspace.monitoring_mode === "output") {
70445
+ return toFiniteNumber(workspace.efficiency);
70446
+ }
70447
+ if (workspace.leaderboard_metric_kind === "recent_flow_shift_average") {
70448
+ return toFiniteNumber(workspace.leaderboard_value);
70449
+ }
70450
+ return toFiniteNumber(workspace.leaderboard_value) ?? toFiniteNumber(workspace.efficiency);
70451
+ };
70452
+ var getWorkspaceDisplayedMetricValue = (workspace) => getWorkspaceLeaderboardMetricValue(workspace);
70453
+ var getWorkspaceLeaderboardMetricLabel = (workspace, defaultLabel) => workspace.monitoring_mode !== "output" && workspace.leaderboard_metric_kind === "recent_flow_shift_average" ? "Avg Flow" : defaultLabel;
70454
+ var renderWorkspaceLeaderboardMetric = (workspace, isAssemblyMode) => {
70455
+ if (isAssemblyMode) {
70456
+ return /* @__PURE__ */ jsx(CycleTimeComparison, { workspace });
70457
+ }
70458
+ const displayedMetricValue = getWorkspaceDisplayedMetricValue(workspace);
70459
+ if (displayedMetricValue === null) {
70460
+ return /* @__PURE__ */ jsx("span", { className: "tabular-nums", children: "--" });
70461
+ }
70462
+ return /* @__PURE__ */ jsx(AnimatedEfficiency, { value: displayedMetricValue });
70463
+ };
70061
70464
  var HeaderRibbon = memo$1(({
70062
70465
  currentDate,
70063
70466
  currentMobileDate,
@@ -70136,13 +70539,13 @@ var MobileWorkspaceCard = memo$1(({
70136
70539
  ] })
70137
70540
  ] }),
70138
70541
  /* @__PURE__ */ jsxs("div", { className: "text-right", children: [
70139
- /* @__PURE__ */ jsx("div", { className: "font-bold text-gray-900 text-lg flex justify-end", children: isAssemblyMode ? /* @__PURE__ */ jsx(CycleTimeComparison, { workspace }) : /* @__PURE__ */ jsx(AnimatedEfficiency, { value: workspace.efficiency || 0 }) }),
70140
- /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: metricLabel })
70542
+ /* @__PURE__ */ jsx("div", { className: "font-bold text-gray-900 text-lg flex justify-end", children: renderWorkspaceLeaderboardMetric(workspace, isAssemblyMode) }),
70543
+ /* @__PURE__ */ jsx("div", { className: "text-xs text-gray-500", children: getWorkspaceLeaderboardMetricLabel(workspace, metricLabel) })
70141
70544
  ] })
70142
70545
  ] })
70143
70546
  }
70144
70547
  ), (prevProps, nextProps) => {
70145
- return prevProps.metricLabel === nextProps.metricLabel && prevProps.isAssemblyMode === nextProps.isAssemblyMode && prevProps.rank === nextProps.rank && prevProps.cardClass === nextProps.cardClass && prevProps.isClickable === nextProps.isClickable && prevProps.workspace.workspace_uuid === nextProps.workspace.workspace_uuid && prevProps.workspace.efficiency === nextProps.workspace.efficiency && prevProps.workspace.ideal_cycle_time === nextProps.workspace.ideal_cycle_time && prevProps.workspace.action_count === nextProps.workspace.action_count && prevProps.workspace.action_threshold === nextProps.workspace.action_threshold && prevProps.workspace.avg_cycle_time === nextProps.workspace.avg_cycle_time && prevProps.workspace.displayName === nextProps.workspace.displayName && prevProps.workspace.lineName === nextProps.workspace.lineName;
70548
+ return prevProps.metricLabel === nextProps.metricLabel && prevProps.isAssemblyMode === nextProps.isAssemblyMode && prevProps.rank === nextProps.rank && prevProps.cardClass === nextProps.cardClass && prevProps.isClickable === nextProps.isClickable && prevProps.workspace.workspace_uuid === nextProps.workspace.workspace_uuid && prevProps.workspace.leaderboard_value === nextProps.workspace.leaderboard_value && prevProps.workspace.leaderboard_metric_kind === nextProps.workspace.leaderboard_metric_kind && prevProps.workspace.efficiency === nextProps.workspace.efficiency && prevProps.workspace.ideal_cycle_time === nextProps.workspace.ideal_cycle_time && prevProps.workspace.action_count === nextProps.workspace.action_count && prevProps.workspace.action_threshold === nextProps.workspace.action_threshold && prevProps.workspace.avg_cycle_time === nextProps.workspace.avg_cycle_time && prevProps.workspace.displayName === nextProps.workspace.displayName && prevProps.workspace.lineName === nextProps.workspace.lineName;
70146
70549
  });
70147
70550
  MobileWorkspaceCard.displayName = "MobileWorkspaceCard";
70148
70551
  var DesktopWorkspaceRow = memo$1(({
@@ -70169,11 +70572,11 @@ var DesktopWorkspaceRow = memo$1(({
70169
70572
  ] }) }),
70170
70573
  /* @__PURE__ */ jsx("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base whitespace-nowrap", children: /* @__PURE__ */ jsx("div", { className: "font-medium", children: workspace.displayName }) }),
70171
70574
  /* @__PURE__ */ jsx("td", { className: "px-3 py-2.5 sm:p-4 text-sm sm:text-base whitespace-nowrap", children: /* @__PURE__ */ jsx("div", { className: "font-medium", children: workspace.lineName }) }),
70172
- /* @__PURE__ */ jsx("td", { className: `px-3 py-2.5 sm:p-4 text-sm sm:text-base font-medium ${isAssemblyMode ? "" : "whitespace-nowrap"}`, children: isAssemblyMode ? /* @__PURE__ */ jsx(CycleTimeComparison, { workspace }) : /* @__PURE__ */ jsx(AnimatedEfficiency, { value: workspace.efficiency || 0 }) })
70575
+ /* @__PURE__ */ jsx("td", { className: `px-3 py-2.5 sm:p-4 text-sm sm:text-base font-medium ${isAssemblyMode ? "" : "whitespace-nowrap"}`, children: isAssemblyMode ? renderWorkspaceLeaderboardMetric(workspace, true) : /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: renderWorkspaceLeaderboardMetric(workspace, false) }) })
70173
70576
  ]
70174
70577
  }
70175
70578
  ), (prevProps, nextProps) => {
70176
- return prevProps.index === nextProps.index && prevProps.rowClass === nextProps.rowClass && prevProps.isClickable === nextProps.isClickable && prevProps.isAssemblyMode === nextProps.isAssemblyMode && prevProps.workspace.workspace_uuid === nextProps.workspace.workspace_uuid && prevProps.workspace.efficiency === nextProps.workspace.efficiency && prevProps.workspace.ideal_cycle_time === nextProps.workspace.ideal_cycle_time && prevProps.workspace.avg_cycle_time === nextProps.workspace.avg_cycle_time && prevProps.workspace.displayName === nextProps.workspace.displayName && prevProps.workspace.lineName === nextProps.workspace.lineName;
70579
+ return prevProps.index === nextProps.index && prevProps.rowClass === nextProps.rowClass && prevProps.isClickable === nextProps.isClickable && prevProps.isAssemblyMode === nextProps.isAssemblyMode && prevProps.workspace.workspace_uuid === nextProps.workspace.workspace_uuid && prevProps.workspace.leaderboard_value === nextProps.workspace.leaderboard_value && prevProps.workspace.leaderboard_metric_kind === nextProps.workspace.leaderboard_metric_kind && prevProps.workspace.efficiency === nextProps.workspace.efficiency && prevProps.workspace.ideal_cycle_time === nextProps.workspace.ideal_cycle_time && prevProps.workspace.avg_cycle_time === nextProps.workspace.avg_cycle_time && prevProps.workspace.displayName === nextProps.workspace.displayName && prevProps.workspace.lineName === nextProps.workspace.lineName;
70177
70580
  });
70178
70581
  DesktopWorkspaceRow.displayName = "DesktopWorkspaceRow";
70179
70582
  var LeaderboardDetailView = memo$1(({
@@ -70272,6 +70675,8 @@ var LeaderboardDetailView = memo$1(({
70272
70675
  const [monthlyError, setMonthlyError] = useState(null);
70273
70676
  const todayRequestKeyRef = useRef(null);
70274
70677
  const monthlyRequestKeyRef = useRef(null);
70678
+ const monthlyLoadKeyRef = useRef(null);
70679
+ const monthlyLoadPromiseRef = useRef(null);
70275
70680
  const leaderboardUpdateQueuedRef = useRef(false);
70276
70681
  const leaderboardUpdateTimerRef = useRef(null);
70277
70682
  const leaderboardViewTrackedRef = useRef(null);
@@ -70546,6 +70951,9 @@ var LeaderboardDetailView = memo$1(({
70546
70951
  trend: 0,
70547
70952
  predicted_output: 0,
70548
70953
  efficiency: entry.efficiency || 0,
70954
+ avg_recent_flow: toFiniteNumber(entry.avg_recent_flow),
70955
+ leaderboard_value: toFiniteNumber(entry.leaderboard_value),
70956
+ leaderboard_metric_kind: entry.leaderboard_metric_kind ?? "efficiency",
70549
70957
  action_threshold: entry.total_day_output || 0,
70550
70958
  displayName: entry.workspace_display_name,
70551
70959
  monitoring_mode: entry.monitoring_mode ?? "output"
@@ -70576,7 +70984,10 @@ var LeaderboardDetailView = memo$1(({
70576
70984
  searchParams.set("monitoring_mode", viewType === "machine" ? "uptime" : "output");
70577
70985
  const data = await fetchBackendJson(
70578
70986
  supabase,
70579
- `/api/dashboard/leaderboard?${searchParams.toString()}`
70987
+ `/api/dashboard/leaderboard?${searchParams.toString()}`,
70988
+ {
70989
+ timeoutMs: params.startDate && params.endDate ? 3e4 : void 0
70990
+ }
70580
70991
  );
70581
70992
  return data.entries || [];
70582
70993
  }, [supabase, entityConfig.companyId, configuredLineIds, viewType]);
@@ -70654,15 +71065,21 @@ var LeaderboardDetailView = memo$1(({
70654
71065
  setMonthlyLoading(true);
70655
71066
  setMonthlyError(null);
70656
71067
  try {
70657
- const entries = await fetchLeaderboardEntries({
70658
- startDate: normalizedRange.startKey,
70659
- endDate: normalizedRange.endKey,
70660
- shiftId: monthlyShiftId
70661
- });
71068
+ const loadPromise = monthlyLoadPromiseRef.current && monthlyLoadKeyRef.current === requestKey ? monthlyLoadPromiseRef.current : (async () => {
71069
+ const entries = await fetchLeaderboardEntries({
71070
+ startDate: normalizedRange.startKey,
71071
+ endDate: normalizedRange.endKey,
71072
+ shiftId: monthlyShiftId
71073
+ });
71074
+ return mapEntriesToWorkspaces(entries, normalizedRange.endKey, monthlyShiftId);
71075
+ })();
71076
+ monthlyLoadKeyRef.current = requestKey;
71077
+ monthlyLoadPromiseRef.current = loadPromise;
71078
+ const workspaces = await loadPromise;
70662
71079
  if (monthlyRequestKeyRef.current !== requestKey) {
70663
71080
  return;
70664
71081
  }
70665
- setMonthlyEntries(mapEntriesToWorkspaces(entries, normalizedRange.endKey, monthlyShiftId));
71082
+ setMonthlyEntries(workspaces);
70666
71083
  } catch (err) {
70667
71084
  console.error("[LeaderboardDetailView] Error fetching monthly leaderboard:", err);
70668
71085
  if (monthlyRequestKeyRef.current !== requestKey) {
@@ -70671,6 +71088,9 @@ var LeaderboardDetailView = memo$1(({
70671
71088
  setMonthlyError({ message: err.message, code: err.code || "FETCH_ERROR" });
70672
71089
  setMonthlyEntries([]);
70673
71090
  } finally {
71091
+ if (monthlyLoadKeyRef.current === requestKey && monthlyLoadPromiseRef.current) {
71092
+ monthlyLoadPromiseRef.current = null;
71093
+ }
70674
71094
  if (monthlyRequestKeyRef.current === requestKey) {
70675
71095
  setMonthlyLoading(false);
70676
71096
  }
@@ -70683,6 +71103,46 @@ var LeaderboardDetailView = memo$1(({
70683
71103
  monthlyShiftId,
70684
71104
  lineKey
70685
71105
  ]);
71106
+ useEffect(() => {
71107
+ if (activeTab !== "today") {
71108
+ return;
71109
+ }
71110
+ const requestKey = `${normalizedRange.startKey}|${normalizedRange.endKey}|${monthlyShiftId}|${lineKey}|${viewType}`;
71111
+ let cancelled = false;
71112
+ const loadPromise = monthlyLoadPromiseRef.current && monthlyLoadKeyRef.current === requestKey ? monthlyLoadPromiseRef.current : (async () => {
71113
+ const entries = await fetchLeaderboardEntries({
71114
+ startDate: normalizedRange.startKey,
71115
+ endDate: normalizedRange.endKey,
71116
+ shiftId: monthlyShiftId
71117
+ });
71118
+ return mapEntriesToWorkspaces(entries, normalizedRange.endKey, monthlyShiftId);
71119
+ })();
71120
+ monthlyLoadKeyRef.current = requestKey;
71121
+ monthlyLoadPromiseRef.current = loadPromise;
71122
+ loadPromise.then((workspaces) => {
71123
+ if (cancelled) {
71124
+ return;
71125
+ }
71126
+ setMonthlyEntries(workspaces);
71127
+ }).catch(() => {
71128
+ }).finally(() => {
71129
+ if (!cancelled && monthlyLoadKeyRef.current === requestKey && monthlyLoadPromiseRef.current === loadPromise) {
71130
+ monthlyLoadPromiseRef.current = null;
71131
+ }
71132
+ });
71133
+ return () => {
71134
+ cancelled = true;
71135
+ };
71136
+ }, [
71137
+ activeTab,
71138
+ fetchLeaderboardEntries,
71139
+ mapEntriesToWorkspaces,
71140
+ normalizedRange.endKey,
71141
+ normalizedRange.startKey,
71142
+ monthlyShiftId,
71143
+ lineKey,
71144
+ viewType
71145
+ ]);
70686
71146
  useEffect(() => {
70687
71147
  if (activeTab === "today") {
70688
71148
  fetchTodayLeaderboard();
@@ -70817,6 +71277,9 @@ var LeaderboardDetailView = memo$1(({
70817
71277
  total_workspaces: workspacesLengthRef.current,
70818
71278
  // Use ref instead of state to avoid dependency
70819
71279
  metric_context: viewType === "machine" ? "machine" : outputCategory,
71280
+ leaderboard_value: getWorkspaceLeaderboardMetricValue(workspace),
71281
+ leaderboard_metric_kind: workspace.leaderboard_metric_kind ?? "efficiency",
71282
+ avg_recent_flow: workspace.avg_recent_flow ?? null,
70820
71283
  efficiency: workspace.efficiency,
70821
71284
  action_count: workspace.action_count,
70822
71285
  action_threshold: workspace.action_threshold,
@@ -70897,9 +71360,12 @@ var LeaderboardDetailView = memo$1(({
70897
71360
  if (ratioB === null) return -1;
70898
71361
  return sortAscending ? ratioA - ratioB : ratioB - ratioA;
70899
71362
  }
70900
- const effA = a.efficiency || 0;
70901
- const effB = b.efficiency || 0;
70902
- return sortAscending ? effA - effB : effB - effA;
71363
+ const metricA = getWorkspaceLeaderboardMetricValue(a);
71364
+ const metricB = getWorkspaceLeaderboardMetricValue(b);
71365
+ if (metricA === null && metricB === null) return 0;
71366
+ if (metricA === null) return 1;
71367
+ if (metricB === null) return -1;
71368
+ return sortAscending ? metricA - metricB : metricB - metricA;
70903
71369
  });
70904
71370
  }, [workspaceDisplayData, sortAscending, selectedLineFilter, selectedShiftFilter, activeTab, viewType, isAssemblyMode]);
70905
71371
  const loading = activeTab === "today" ? todayLoading : monthlyLoading;
@@ -70928,6 +71394,8 @@ var LeaderboardDetailView = memo$1(({
70928
71394
  workspace_count: sortedWorkspaces.length,
70929
71395
  top_workspace_id: topWorkspace?.workspace_uuid ?? null,
70930
71396
  top_workspace_name: topWorkspace?.workspace_name ?? null,
71397
+ top_leaderboard_value: topWorkspace ? getWorkspaceLeaderboardMetricValue(topWorkspace) : null,
71398
+ top_leaderboard_metric_kind: topWorkspace?.leaderboard_metric_kind ?? null,
70931
71399
  top_efficiency: topWorkspace?.efficiency ?? null,
70932
71400
  top_avg_cycle_time: topWorkspace?.avg_cycle_time ?? null,
70933
71401
  top_ideal_cycle_time: topWorkspace?.ideal_cycle_time ?? null,
@@ -76073,7 +76541,11 @@ var WorkspaceDetailView = ({
76073
76541
  workspace,
76074
76542
  legend: efficiencyLegend,
76075
76543
  layout: "stack",
76076
- idleTimeData: idleTimeVlmEnabled ? idleTimeData : void 0
76544
+ idleTimeData: idleTimeVlmEnabled ? idleTimeData : void 0,
76545
+ skuAware: isSkuAware,
76546
+ skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
76547
+ activeSkuId,
76548
+ liveSkuId: isHistoricView ? null : liveSkuId
76077
76549
  }
76078
76550
  ) : /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
76079
76551
  WorkspaceMetricCards,
@@ -76083,7 +76555,8 @@ var WorkspaceDetailView = ({
76083
76555
  className: "flex-1",
76084
76556
  skuAware: isSkuAware,
76085
76557
  skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
76086
- activeSkuId
76558
+ activeSkuId,
76559
+ liveSkuId: isHistoricView ? null : liveSkuId
76087
76560
  }
76088
76561
  ) })
76089
76562
  ] }),
@@ -76226,7 +76699,11 @@ var WorkspaceDetailView = ({
76226
76699
  legend: efficiencyLegend,
76227
76700
  layout: "grid",
76228
76701
  className: desktopBottomSectionClass,
76229
- idleTimeData: idleTimeVlmEnabled ? idleTimeData : void 0
76702
+ idleTimeData: idleTimeVlmEnabled ? idleTimeData : void 0,
76703
+ skuAware: isSkuAware,
76704
+ skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
76705
+ activeSkuId,
76706
+ liveSkuId: isHistoricView ? null : liveSkuId
76230
76707
  }
76231
76708
  ) : /* @__PURE__ */ jsx("div", { className: clsx("flex min-h-0", desktopBottomSectionClass), children: /* @__PURE__ */ jsx(
76232
76709
  WorkspaceMetricCards,
@@ -76236,7 +76713,8 @@ var WorkspaceDetailView = ({
76236
76713
  className: "flex-1",
76237
76714
  skuAware: isSkuAware,
76238
76715
  skuBreakdown: isSkuAware ? realSkuBreakdown : void 0,
76239
- activeSkuId
76716
+ activeSkuId,
76717
+ liveSkuId: isHistoricView ? null : liveSkuId
76240
76718
  }
76241
76719
  ) })
76242
76720
  ] })
@@ -85275,4 +85753,4 @@ var streamProxyConfig = {
85275
85753
  }
85276
85754
  };
85277
85755
 
85278
- export { ACTION_FAMILIES, ACTION_NAMES, AIAgentView_default as AIAgentView, AcceptInvite, AcceptInviteView_default as AcceptInviteView, AdvancedFilterDialog, AdvancedFilterPanel, AudioService, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthService, AuthenticatedBottleneckClipsView, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedShiftsView, AuthenticatedTargetsView, AuthenticatedTicketsView, AuthenticatedWorkspaceHealthView, AvatarUpload, AxelNotificationPopup, AxelOrb, BackButton, BackButtonMinimal, BarChart, BaseHistoryCalendar, BottleneckClipsModal, BottleneckClipsView_default as BottleneckClipsView, BottlenecksContent, BreakNotificationPopup, CachePrefetchStatus, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, ChangeRoleDialog, ClipFilterProvider, ClipsCostView_default as ClipsCostView, CompactWorkspaceHealthCard, ConfirmRemoveUserDialog, CongratulationsOverlay, CroppedHlsVideoPlayer, CroppedVideoPlayer, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_HOME_VIEW_CONFIG, DEFAULT_MAP_VIEW_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_SHIFT_DATA, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, DetailedHealthStatus, DiagnosisVideoModal, EFFICIENCY_ON_TRACK_THRESHOLD, EmptyStateMessage, EncouragementOverlay, FactoryAssignmentDropdown, FactoryView_default as FactoryView, FileManagerFilters, FilterDialogTrigger, FirstTimeLoginDebug, FirstTimeLoginHandler, FittingTitle, GaugeChart, GridComponentsPlaceholder, HamburgerButton, Header, HealthDateShiftSelector, HealthStatusGrid, HealthStatusIndicator, HelpView_default as HelpView, HlsVideoPlayer, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, HourlyUptimeChart, ISTTimer_default as ISTTimer, IdleTimeVlmConfigProvider, ImprovementCenterView_default as ImprovementCenterView, InlineEditableText, InteractiveOnboardingTour, InvitationService, InvitationsTable, InviteUserDialog, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend5 as Legend, LineAssignmentDropdown, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LinesService, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingState, LoginPage, LoginView_default as LoginView, Logo, MainLayout, MapGridView, MetricCard_default as MetricCard, MinimalOnboardingPopup, MobileMenuProvider, NewClipsNotification, NoWorkspaceData, OnboardingDemo, OnboardingTour, OptifyeAgentClient, OptifyeLogoLoader_default as OptifyeLogoLoader, OutputProgressChart, PageHeader, PieChart4 as PieChart, PlantHeadView_default as PlantHeadView, PlayPauseIndicator, PrefetchConfigurationError, PrefetchError, PrefetchEvents, PrefetchStatus, PrefetchTimeoutError, ProfileView_default as ProfileView, ROOT_DASHBOARD_EVENT_NAMES, RegistryProvider, RoleBadge, S3ClipsSupabaseService as S3ClipsService, S3Service, SENTRY_HANDLED_EVENT_SESSION_LIMIT, SENTRY_HANDLED_EVENT_WINDOW_MS, SENTRY_QUOTA_STORAGE_KEY, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SessionTracker, SessionTrackingContext, SessionTrackingProvider, SettingsPopup, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SignupWithInvitation, SilentErrorBoundary, SimpleOnboardingPopup, SingleVideoStream_default as SingleVideoStream, Skeleton, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, SupervisorDropdown_default as SupervisorDropdown, SupervisorManagementView_default as SupervisorManagementView, SupervisorService, TargetWorkspaceGrid, TargetsView_default as TargetsView, TeamManagementView_default as TeamManagementView, ThreadSidebar, TicketHistory_default as TicketHistory, TicketHistoryService, TicketsView_default as TicketsView, TimeDisplay_default as TimeDisplay, TimePickerDropdown, Timer_default as Timer, TimezoneProvider, TimezoneService, UptimeDonutChart, UptimeLineChart, UptimeMetricCards, UserAvatar, UserManagementService, UserManagementTable, UserService, UserUsageDetailModal, UserUsageStats, VideoCard, VideoGridView, VideoPlayer, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceCycleTimeMetricCards, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHealthCard, WorkspaceHealthView_default as WorkspaceHealthView, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMetricCardsImpl, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyHistory, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, addSentryBreadcrumb, aggregateKPIsFromLineMetricsRows, alertsService, apiUtils, areAllLinesOnSameShift, authCoreService, authOTPService, authRateLimitService, awardsService, buildDateKey, buildKPIsFromLineMetricsRow, buildLineSkuBreakdown, buildShiftGroupsKey, canRoleAccessDashboardPath, canRoleAccessTeamManagement, canRoleAssignFactories, canRoleAssignLines, canRoleChangeRole, canRoleInviteRole, canRoleManageCompany, canRoleManageTargets, canRoleManageUsers, canRoleRemoveUser, canRoleViewClipsCost, canRoleViewUsageStats, captureHandledFrontendException, captureSentryException, captureSentryMessage, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearSentryContext, clearWorkspaceDisplayNamesCache, cn, combineLineMetricsRows, countRealSkus, createDefaultKPIs, createInvitationService, createLinesService, createSessionTracker, createStorageService, createStreamProxyHandler, createSupabaseClient, createSupervisorService, createThrottledReload, createUserManagementService, createUserService, dashboardService, deleteThread, fetchIdleTimeReasons, fetchLineDummySkuId, fetchLineSkuCatalog, filterDataByDateKeyRange, filterRealSkuBreakdown, forceRefreshWorkspaceDisplayNames, formatAwardMonth, formatDateInZone, formatDateKeyForDisplay, formatDateTimeInZone, formatDuration2 as formatDuration, formatISTDate, formatIdleTime, formatRangeLabel, formatReasonLabel, formatRelativeTime, formatTimeInZone, fromUrlFriendlyName, getActionDisplayName, getActiveShift, getAllLineDisplayNames, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAllWorkspaceDisplayNamesSnapshot, getAnonClient, getAssignableRoles, getAssignmentColumnLabel, getAvailableShiftIds, getAwardBadgeType, getAwardDescription, getAwardTitle, getBrowserName, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getConfiguredLineIds, getCoreSessionRecordingProperties, getCoreSessionReplayUrl, getCurrentShift, getCurrentShiftForLine, getCurrentTimeInZone, getCurrentWeekFullRange, getCurrentWeekToDateRange, getDashboardHeaderTimeInZone, getDateKeyFromDate, getDateKeyFromValue, getDayDateKey, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultLineId, getDefaultTabForWorkspace, getInitials, getLineDisplayName, getManufacturingInsights, getMetricsTablePrefix, getMonthKeyBounds, getMonthWeekRanges, getMonthlyTrendComparisonLabel, getNextUpdateInterval, getOperationalDate, getRoleAssignmentKind, getRoleDescription, getRoleLabel, getRoleMetadata, getRoleNavPaths, getS3SignedUrl, getS3VideoSrc, getShiftData, getShiftNameById, getShiftWorkDurationSeconds, getShortShiftName, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUniformShiftGroup, getUserThreads, getUserThreadsPaginated, getVisibleRolesForCurrentUser, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, groupLinesByShift, hasAnyShiftData, identifyCoreUser, initializeCoreMixpanel, isEfficiencyOnTrack, isFactoryScopedRole, isFullMonthRange, isIgnorableFrontendError, isLegacyConfiguration, isLoopbackHostname, isPrefetchError, isRealSku, isRecentFlowVideoGridMetricMode, isSafari, isSupervisorRole, isTransitionPeriod, isUrlPermanentlyFailed, isValidFactoryViewConfiguration, isValidLineInfoPayload, isValidPrefetchParams, isValidPrefetchStatus, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWipGatedVideoGridMetricMode, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, lineLeaderboardService, linesService, mergeWithDefaultConfig, migrateLegacyConfiguration, normalizeActionFamily, normalizeDateKeyRange, normalizeRoleLevel, normalizeVideoGridMetricMode, optifyeAgentClient, parseDateKeyToDate, parseS3Uri, pickPreferredLineMetricsRow, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetFailedUrl, resetSentryQuotaForTests, resetSubscriptionManager, resolveDefaultSkuId, resolveLiveSkuId, s3VideoPreloader, selectPreferredLineMetricsRow, setSentryUserContext, setSentryWorkspaceContext, shouldEnableLocalDevTestLogin, shuffleArray, simulateApiDelay, skuService, startCoreSessionRecording, stopCoreSessionRecording, storeWorkspaceMapping, streamProxyConfig, subscribeWorkspaceDisplayNames, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, transformToChartData, updateThreadTitle, upsertWorkspaceDisplayNameInCache, useAccessControl, useActiveBreaks, useActiveLineId, useAllWorkspaceMetrics, useAnalyticsConfig, useAppTimezone, useAudioService, useAuth, useAuthConfig, useAxelNotifications, useCanSaveTargets, useClipFilter, useClipTypes, useClipTypesWithCounts, useClipsInit, useCompanyClipsCost, useCompanyFastSlowClipFiltersEnabled, useCompanyHasVlmEnabledLine, useCompanyUsersUsage, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useDynamicShiftConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHasLineAccess, useHideMobileHeader, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useHourEndTimer, useHourlyTargetAchievements, useHourlyTargetMisses, useIdleTimeClipClassifications, useIdleTimeReasons, useIdleTimeVlmConfig, useKpiTrends, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineShiftConfig, useLineSupervisor, useLineWorkspaceMetrics, useLines, useMessages, useMetrics, useMobileMenu, useMonthlyTrend, useMultiLineShiftConfigs, useNavigation, useOperationalShiftKey, useOptionalSupabase, useOverrides, usePageOverride, usePrefetchClipCounts, useRealtimeLineMetrics, useRegistry, useSKUs, useSessionKeepAlive, useSessionTracking, useSessionTrackingContext, useShiftConfig, useShiftGroups, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useSupervisorsByLineIds, useTargets, useTeamManagementPermissions, useTheme, useThemeConfig, useThreads, useTicketHistory, useTimezoneContext, useUserLineAccess, useUserUsage, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceHealthById, useWorkspaceHealthLastSeen, useWorkspaceHealthStatus, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, useWorkspaceUptimeTimeline, useWorkspaceVideoStreams, userService, videoPrefetchManager, videoPreloader, weeklyTopPerformerService, whatsappService, withAccessControl, withAuth, withRegistry, withTimezone, workspaceHealthService, workspaceService };
85756
+ export { ACTION_FAMILIES, ACTION_NAMES, AIAgentView_default as AIAgentView, AcceptInvite, AcceptInviteView_default as AcceptInviteView, AdvancedFilterDialog, AdvancedFilterPanel, AudioService, AuthCallback, AuthCallbackView_default as AuthCallbackView, AuthProvider, AuthService, AuthenticatedBottleneckClipsView, AuthenticatedFactoryView, AuthenticatedHelpView, AuthenticatedHomeView, AuthenticatedShiftsView, AuthenticatedTargetsView, AuthenticatedTicketsView, AuthenticatedWorkspaceHealthView, AvatarUpload, AxelNotificationPopup, AxelOrb, BackButton, BackButtonMinimal, BarChart, BaseHistoryCalendar, BottleneckClipsModal, BottleneckClipsView_default as BottleneckClipsView, BottlenecksContent, BreakNotificationPopup, CachePrefetchStatus, Card2 as Card, CardContent2 as CardContent, CardDescription2 as CardDescription, CardFooter2 as CardFooter, CardHeader2 as CardHeader, CardTitle2 as CardTitle, ChangeRoleDialog, ClipFilterProvider, ClipsCostView_default as ClipsCostView, CompactWorkspaceHealthCard, ConfirmRemoveUserDialog, CongratulationsOverlay, CroppedHlsVideoPlayer, CroppedVideoPlayer, CycleTimeChart, CycleTimeOverTimeChart, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_HOME_VIEW_CONFIG, DEFAULT_MAP_VIEW_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_SHIFT_DATA, DEFAULT_THEME_CONFIG, DEFAULT_VIDEO_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, DashboardHeader, DashboardLayout, DashboardOverridesProvider, DashboardProvider, DateDisplay_default as DateDisplay, DateTimeDisplay, DebugAuth, DebugAuthView_default as DebugAuthView, DetailedHealthStatus, DiagnosisVideoModal, EFFICIENCY_ON_TRACK_THRESHOLD, EmptyStateMessage, EncouragementOverlay, FactoryAssignmentDropdown, FactoryView_default as FactoryView, FileManagerFilters, FilterDialogTrigger, FirstTimeLoginDebug, FirstTimeLoginHandler, FittingTitle, GaugeChart, GridComponentsPlaceholder, HamburgerButton, Header, HealthDateShiftSelector, HealthStatusGrid, HealthStatusIndicator, HelpView_default as HelpView, HlsVideoPlayer, HomeView_default as HomeView, HourlyOutputChart2 as HourlyOutputChart, HourlyUptimeChart, ISTTimer_default as ISTTimer, IdleTimeVlmConfigProvider, ImprovementCenterView_default as ImprovementCenterView, InlineEditableText, InteractiveOnboardingTour, InvitationService, InvitationsTable, InviteUserDialog, KPICard, KPIDetailView_default as KPIDetailView, KPIGrid, KPIHeader, KPISection, KPIsOverviewView_default as KPIsOverviewView, LINE_1_UUID, LINE_2_UUID, LargeOutputProgressChart, LeaderboardDetailView_default as LeaderboardDetailView, Legend5 as Legend, LineAssignmentDropdown, LineChart, LineHistoryCalendar, LineMonthlyHistory, LineMonthlyPdfGenerator, LinePdfExportButton, LinePdfGenerator, LineWhatsAppShareButton, LinesService, LiveTimer, LoadingInline, LoadingOverlay_default as LoadingOverlay, LoadingPage_default as LoadingPage, LoadingSkeleton, LoadingState, LoginPage, LoginView_default as LoginView, Logo, MainLayout, MapGridView, MetricCard_default as MetricCard, MinimalOnboardingPopup, MobileMenuProvider, NewClipsNotification, NoWorkspaceData, OnboardingDemo, OnboardingTour, OptifyeAgentClient, OptifyeLogoLoader_default as OptifyeLogoLoader, OutputProgressChart, PageHeader, PieChart4 as PieChart, PlantHeadView_default as PlantHeadView, PlayPauseIndicator, PrefetchConfigurationError, PrefetchError, PrefetchEvents, PrefetchStatus, PrefetchTimeoutError, ProfileView_default as ProfileView, ROOT_DASHBOARD_EVENT_NAMES, RegistryProvider, RoleBadge, S3ClipsSupabaseService as S3ClipsService, S3Service, SENTRY_HANDLED_EVENT_SESSION_LIMIT, SENTRY_HANDLED_EVENT_WINDOW_MS, SENTRY_QUOTA_STORAGE_KEY, SKUManagementView, SOPComplianceChart, SSEChatClient, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, SessionTracker, SessionTrackingContext, SessionTrackingProvider, SettingsPopup, ShiftDisplay_default as ShiftDisplay, ShiftsView_default as ShiftsView, SideNavBar, SignupWithInvitation, SilentErrorBoundary, SimpleOnboardingPopup, SingleVideoStream_default as SingleVideoStream, Skeleton, SubscriptionManager, SubscriptionManagerProvider, SupabaseProvider, SupervisorDropdown_default as SupervisorDropdown, SupervisorManagementView_default as SupervisorManagementView, SupervisorService, TargetWorkspaceGrid, TargetsView_default as TargetsView, TeamManagementView_default as TeamManagementView, ThreadSidebar, TicketHistory_default as TicketHistory, TicketHistoryService, TicketsView_default as TicketsView, TimeDisplay_default as TimeDisplay, TimePickerDropdown, Timer_default as Timer, TimezoneProvider, TimezoneService, UptimeDonutChart, UptimeLineChart, UptimeMetricCards, UserAvatar, UserManagementService, UserManagementTable, UserService, UserUsageDetailModal, UserUsageStats, VideoCard, VideoGridView, VideoPlayer, VideoPreloader, WORKSPACE_POSITIONS, WhatsAppShareButton, WorkspaceCard, WorkspaceCycleTimeMetricCards, WorkspaceDetailView_default as WorkspaceDetailView, WorkspaceDisplayNameExample, WorkspaceGrid, WorkspaceGridItem, WorkspaceHealthCard, WorkspaceHealthView_default as WorkspaceHealthView, WorkspaceHistoryCalendar, WorkspaceMetricCards, WorkspaceMetricCardsImpl, WorkspaceMonthlyDataFetcher, WorkspaceMonthlyHistory, WorkspaceMonthlyPdfGenerator, WorkspacePdfExportButton, WorkspacePdfGenerator, WorkspaceWhatsAppShareButton, actionService, addSentryBreadcrumb, aggregateKPIsFromLineMetricsRows, alertsService, apiUtils, areAllLinesOnSameShift, authCoreService, authOTPService, authRateLimitService, awardsService, buildDateKey, buildKPIsFromLineMetricsRow, buildKpiLineHierarchy, buildLineSkuBreakdown, buildShiftGroupsKey, canRoleAccessDashboardPath, canRoleAccessTeamManagement, canRoleAssignFactories, canRoleAssignLines, canRoleChangeRole, canRoleInviteRole, canRoleManageCompany, canRoleManageTargets, canRoleManageUsers, canRoleRemoveUser, canRoleViewClipsCost, canRoleViewUsageStats, captureHandledFrontendException, captureSentryException, captureSentryMessage, checkRateLimit2 as checkRateLimit, clearAllRateLimits2 as clearAllRateLimits, clearRateLimit2 as clearRateLimit, clearS3VideoCache, clearS3VideoFromCache, clearSentryContext, clearWorkspaceDisplayNamesCache, cn, combineLineMetricsRows, countRealSkus, createDefaultKPIs, createInvitationService, createLinesService, createSessionTracker, createStorageService, createStreamProxyHandler, createSupabaseClient, createSupervisorService, createThrottledReload, createUserManagementService, createUserService, dashboardService, deleteThread, fetchIdleTimeReasons, fetchLineDummySkuId, fetchLineSkuCatalog, filterDataByDateKeyRange, filterRealSkuBreakdown, forceRefreshWorkspaceDisplayNames, formatAwardMonth, formatDateInZone, formatDateKeyForDisplay, formatDateTimeInZone, formatDuration2 as formatDuration, formatISTDate, formatIdleTime, formatRangeLabel, formatReasonLabel, formatRelativeTime, formatTimeInZone, fromUrlFriendlyName, getActionDisplayName, getActiveShift, getAllLineDisplayNames, getAllThreadMessages, getAllWorkspaceDisplayNamesAsync, getAllWorkspaceDisplayNamesSnapshot, getAnonClient, getAssignableRoles, getAssignmentColumnLabel, getAvailableShiftIds, getAwardBadgeType, getAwardDescription, getAwardTitle, getBrowserName, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getConfiguredLineIds, getCoreSessionRecordingProperties, getCoreSessionReplayUrl, getCurrentShift, getCurrentShiftForLine, getCurrentTimeInZone, getCurrentWeekFullRange, getCurrentWeekToDateRange, getDashboardHeaderTimeInZone, getDateKeyFromDate, getDateKeyFromValue, getDayDateKey, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultLineId, getDefaultTabForWorkspace, getInitials, getLineDisplayName, getManufacturingInsights, getMetricsTablePrefix, getMonthKeyBounds, getMonthWeekRanges, getMonthlyTrendComparisonLabel, getNextUpdateInterval, getOperationalDate, getRoleAssignmentKind, getRoleDescription, getRoleLabel, getRoleMetadata, getRoleNavPaths, getS3SignedUrl, getS3VideoSrc, getShiftData, getShiftNameById, getShiftWorkDurationSeconds, getShortShiftName, getShortWorkspaceDisplayName, getShortWorkspaceDisplayNameAsync, getStoredWorkspaceMappings, getSubscriptionManager, getThreadMessages, getUniformShiftGroup, getUserThreads, getUserThreadsPaginated, getVisibleRolesForCurrentUser, getWorkspaceDisplayName, getWorkspaceDisplayNameAsync, getWorkspaceDisplayNamesMap, getWorkspaceFromUrl, getWorkspaceNavigationParams, groupLinesByShift, hasAnyShiftData, identifyCoreUser, initializeCoreMixpanel, isEfficiencyOnTrack, isFactoryScopedRole, isFullMonthRange, isIgnorableFrontendError, isLegacyConfiguration, isLoopbackHostname, isPrefetchError, isRealSku, isRecentFlowVideoGridMetricMode, isSafari, isSupervisorRole, isTransitionPeriod, isUrlPermanentlyFailed, isValidFactoryViewConfiguration, isValidLineInfoPayload, isValidPrefetchParams, isValidPrefetchStatus, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, isWipGatedVideoGridMetricMode, isWorkspaceDisplayNamesLoaded, isWorkspaceDisplayNamesLoading, lineLeaderboardService, linesService, mergeWithDefaultConfig, migrateLegacyConfiguration, normalizeActionFamily, normalizeDateKeyRange, normalizeRoleLevel, normalizeVideoGridMetricMode, optifyeAgentClient, parseDateKeyToDate, parseS3Uri, pickPreferredLineMetricsRow, preInitializeWorkspaceDisplayNames, preloadS3Video, preloadS3VideoUrl, preloadS3VideosUrl, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, refreshWorkspaceDisplayNames, resetCoreMixpanel, resetFailedUrl, resetSentryQuotaForTests, resetSubscriptionManager, resolveDefaultSkuId, resolveLiveSkuId, s3VideoPreloader, selectPreferredLineMetricsRow, setSentryUserContext, setSentryWorkspaceContext, shouldEnableLocalDevTestLogin, shuffleArray, simulateApiDelay, skuService, startCoreSessionRecording, stopCoreSessionRecording, storeWorkspaceMapping, streamProxyConfig, subscribeWorkspaceDisplayNames, throttledReloadDashboard, toUrlFriendlyName, trackCoreEvent, trackCorePageView, transformToChartData, updateThreadTitle, upsertWorkspaceDisplayNameInCache, useAccessControl, useActiveBreaks, useActiveLineId, useAllWorkspaceMetrics, useAnalyticsConfig, useAppTimezone, useAudioService, useAuth, useAuthConfig, useAxelNotifications, useCanSaveTargets, useClipFilter, useClipTypes, useClipTypesWithCounts, useClipsInit, useCompanyClipsCost, useCompanyFastSlowClipFiltersEnabled, useCompanyHasVlmEnabledLine, useCompanyUsersUsage, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useDynamicShiftConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHasLineAccess, useHideMobileHeader, useHistoricWorkspaceMetrics, useHlsStream, useHlsStreamWithCropping, useHookOverride, useHourEndTimer, useHourlyTargetAchievements, useHourlyTargetMisses, useIdleTimeClipClassifications, useIdleTimeReasons, useIdleTimeVlmConfig, useKpiTrends, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineShiftConfig, useLineSupervisor, useLineWorkspaceMetrics, useLines, useMessages, useMetrics, useMobileMenu, useMonthlyTrend, useMultiLineShiftConfigs, useNavigation, useOperationalShiftKey, useOptionalSupabase, useOverrides, usePageOverride, usePrefetchClipCounts, useRealtimeLineMetrics, useRegistry, useSKUs, useSessionKeepAlive, useSessionTracking, useSessionTrackingContext, useShiftConfig, useShiftGroups, useShifts, useSubscriptionManager, useSubscriptionManagerSafe, useSupabase, useSupabaseClient, useSupervisorsByLineIds, useTargets, useTeamManagementPermissions, useTheme, useThemeConfig, useThreads, useTicketHistory, useTimezoneContext, useUserLineAccess, useUserUsage, useVideoConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceDisplayName, useWorkspaceDisplayNames, useWorkspaceDisplayNamesMap, useWorkspaceHealthById, useWorkspaceHealthLastSeen, useWorkspaceHealthStatus, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, useWorkspaceUptimeTimeline, useWorkspaceVideoStreams, userService, videoPrefetchManager, videoPreloader, weeklyTopPerformerService, whatsappService, withAccessControl, withAuth, withRegistry, withTimezone, workspaceHealthService, workspaceService };