@optifye/dashboard-core 4.3.8 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -463,25 +463,6 @@ var getTable2 = (dbConfig, tableName) => {
463
463
  return userValue ?? defaults2[tableName];
464
464
  };
465
465
  var dashboardService = {
466
- /**
467
- * Helper method to filter workspaces by line_id for disambiguation
468
- * @param workspaces - Array of workspace metrics
469
- * @param lineId - Line ID to filter by
470
- * @returns Filtered workspace metrics
471
- */
472
- filterWorkspacesByLineId(workspaces, lineId) {
473
- return workspaces.filter((workspace) => workspace.line_id === lineId);
474
- },
475
- /**
476
- * Helper method to get workspace by composite key (line_id + workspace_name)
477
- * @param workspaces - Array of workspace metrics
478
- * @param workspaceName - Workspace name to search for
479
- * @param lineId - Line ID to filter by
480
- * @returns Matching workspace or undefined
481
- */
482
- getWorkspaceByLineIdAndName(workspaces, workspaceName, lineId) {
483
- return workspaces.find((workspace) => workspace.workspace_name === workspaceName && workspace.line_id === lineId);
484
- },
485
466
  // Example for getLineInfo:
486
467
  async getLineInfo(lineIdInput) {
487
468
  const supabase = _getSupabaseInstance();
@@ -642,13 +623,6 @@ var dashboardService = {
642
623
  metrics: metricsForReturn
643
624
  };
644
625
  },
645
- /**
646
- * Get workspace data with line_id-aware filtering
647
- * @param lineIdInput - Specific line ID to filter by, or factory view ID
648
- * @param dateProp - Date to query (optional)
649
- * @param shiftProp - Shift ID to query (optional)
650
- * @returns Array of workspace metrics with line_id context
651
- */
652
626
  async getWorkspacesData(lineIdInput, dateProp, shiftProp) {
653
627
  const supabase = _getSupabaseInstance();
654
628
  const config = _getDashboardConfigInstance();
@@ -675,20 +649,17 @@ var dashboardService = {
675
649
  throw new Error("Factory View requires defaultLineId and secondaryLineId to be configured for workspace data.");
676
650
  }
677
651
  query = query.in("line_id", [defaultLineId, secondaryLineId]);
678
- console.log(`[getWorkspacesData] Querying factory view with lines: ${defaultLineId}, ${secondaryLineId}`);
679
652
  } else {
680
653
  query = query.eq("line_id", lineId);
681
- console.log(`[getWorkspacesData] Querying single line: ${lineId}`);
682
654
  }
683
655
  const { data, error } = await query;
684
656
  if (error) {
685
657
  console.error("Error in getWorkspacesData:", error);
686
658
  throw error;
687
659
  }
688
- const workspaces = (data || []).map((item) => ({
660
+ return (data || []).map((item) => ({
689
661
  company_id: item.company_id,
690
662
  line_id: item.line_id,
691
- // Ensure line_id is always included
692
663
  shift_id: item.shift_id,
693
664
  date: item.date,
694
665
  workspace_uuid: item.workspace_id,
@@ -702,20 +673,6 @@ var dashboardService = {
702
673
  efficiency: item.efficiency || 0,
703
674
  action_threshold: item.total_day_output || 0
704
675
  }));
705
- console.log(`[getWorkspacesData] Retrieved ${workspaces.length} workspaces for line(s): ${lineId || "factory"}`);
706
- console.log(
707
- `[getWorkspacesData] Workspace line_id distribution:`,
708
- workspaces.reduce((acc, ws) => {
709
- acc[ws.line_id] = (acc[ws.line_id] || 0) + 1;
710
- return acc;
711
- }, {})
712
- );
713
- console.log(`[getWorkspacesData] Sample workspaces:`, workspaces.slice(0, 5).map((ws) => ({
714
- workspace_name: ws.workspace_name,
715
- line_id: ws.line_id,
716
- efficiency: ws.efficiency
717
- })));
718
- return workspaces;
719
676
  },
720
677
  async getWorkspaceDetailedMetrics(workspaceUuid, dateProp, shiftIdProp) {
721
678
  const supabase = _getSupabaseInstance();
@@ -2584,7 +2541,7 @@ var useMetrics = (tableName, options) => {
2584
2541
  };
2585
2542
  return { data, isLoading, error, refetch };
2586
2543
  };
2587
- var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId, lineId) => {
2544
+ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
2588
2545
  const entityConfig = useEntityConfig();
2589
2546
  const databaseConfig = useDatabaseConfig();
2590
2547
  const dateTimeConfig = useDateTimeConfig();
@@ -2612,32 +2569,14 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId, lineId) => {
2612
2569
  const currentShift = getCurrentShift(defaultTimezone, shiftConfig);
2613
2570
  const queryDate = date || currentShift.date;
2614
2571
  const queryShiftId = shiftId !== void 0 ? shiftId : currentShift.shiftId;
2615
- console.log("[useWorkspaceDetailedMetrics] Hook called with parameters:", {
2616
- workspaceId,
2617
- date,
2618
- shiftId,
2619
- lineId,
2620
- queryDate,
2621
- queryShiftId
2622
- });
2623
2572
  console.log("[useWorkspaceDetailedMetrics] Using shift ID:", queryShiftId, "from input shift:", shiftId);
2624
2573
  console.log("[useWorkspaceDetailedMetrics] Using date:", queryDate, "from input date:", date);
2625
- console.log(`[useWorkspaceDetailedMetrics] Querying ${metricsTable} for workspace: ${workspaceId}, date: ${queryDate}, shift: ${queryShiftId}, line: ${lineId || "any"}`);
2626
- let query = supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).eq("date", queryDate).eq("shift_id", queryShiftId);
2627
- if (lineId) {
2628
- query = query.eq("line_id", lineId);
2629
- console.log(`[useWorkspaceDetailedMetrics] Filtering by line_id: ${lineId}`);
2630
- }
2631
- const { data, error: fetchError } = await query.maybeSingle();
2574
+ console.log(`[useWorkspaceDetailedMetrics] Querying ${metricsTable} for workspace: ${workspaceId}, date: ${queryDate}, shift: ${queryShiftId}`);
2575
+ const { data, error: fetchError } = await supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).eq("date", queryDate).eq("shift_id", queryShiftId).maybeSingle();
2632
2576
  if (fetchError) throw fetchError;
2633
2577
  if (!data && !date && shiftId === void 0) {
2634
2578
  console.log("[useWorkspaceDetailedMetrics] No data found for current date/shift, attempting to find most recent data...");
2635
- let recentQuery = supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId);
2636
- if (lineId) {
2637
- recentQuery = recentQuery.eq("line_id", lineId);
2638
- console.log(`[useWorkspaceDetailedMetrics] Fallback query filtering by line_id: ${lineId}`);
2639
- }
2640
- const { data: recentData, error: recentError } = await recentQuery.order("date", { ascending: false }).order("shift_id", { ascending: false }).limit(1).maybeSingle();
2579
+ const { data: recentData, error: recentError } = await supabase.from(metricsTable).select("*").eq("workspace_id", workspaceId).order("date", { ascending: false }).order("shift_id", { ascending: false }).limit(1).maybeSingle();
2641
2580
  if (recentError) throw recentError;
2642
2581
  if (recentData) {
2643
2582
  console.log(`[useWorkspaceDetailedMetrics] Found fallback data from date: ${recentData.date}, shift: ${recentData.shift_id}`);
@@ -2855,7 +2794,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId, lineId) => {
2855
2794
  updateQueueRef.current = false;
2856
2795
  setIsLoading(false);
2857
2796
  }
2858
- }, [supabase, workspaceId, date, shiftId, lineId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
2797
+ }, [supabase, workspaceId, date, shiftId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
2859
2798
  const queueUpdate = React14.useCallback(() => {
2860
2799
  if (!workspaceId || updateQueueRef.current) return;
2861
2800
  updateQueueRef.current = true;
@@ -2986,7 +2925,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId, lineId) => {
2986
2925
  supabase.removeChannel(channelRef.current);
2987
2926
  }
2988
2927
  };
2989
- }, [supabase, workspaceId, date, shiftId, lineId, fetchMetrics, queueUpdate, setupSubscription, metricsTable, workspaceMetricsBaseTable, workspaceActionsTable, defaultTimezone, shiftConfig, schema, metricsTablePrefix]);
2928
+ }, [supabase, workspaceId, date, shiftId, fetchMetrics, queueUpdate, setupSubscription, metricsTable, workspaceMetricsBaseTable, workspaceActionsTable, defaultTimezone, shiftConfig, schema, metricsTablePrefix]);
2990
2929
  return {
2991
2930
  metrics: metrics2,
2992
2931
  isLoading,
@@ -3448,7 +3387,6 @@ var setCache = (lineId, metrics2) => {
3448
3387
  }
3449
3388
  };
3450
3389
  var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3451
- console.log("[useDashboardMetrics] Hook called with lineId:", lineId);
3452
3390
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
3453
3391
  const entityConfig = useEntityConfig();
3454
3392
  const databaseConfig = useDatabaseConfig();
@@ -3492,33 +3430,14 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3492
3430
  try {
3493
3431
  const currentShiftDetails = getCurrentShift(defaultTimezone, shiftConfig);
3494
3432
  const operationalDate = getOperationalDate(defaultTimezone);
3495
- const isFactoryView = currentLineIdToUse === (entityConfig.factoryViewId || "factory");
3496
- const targetLineIds = isFactoryView ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
3497
- console.log("[useDashboardMetrics] Target line IDs determined:", {
3498
- currentLineIdToUse,
3499
- isFactoryView,
3500
- factoryViewId: entityConfig.factoryViewId,
3501
- defaultLineId: entityConfig.defaultLineId,
3502
- secondaryLineId: entityConfig.secondaryLineId,
3503
- targetLineIds
3504
- });
3433
+ const targetLineIds = currentLineIdToUse === (entityConfig.factoryViewId || "factory") ? [entityConfig.defaultLineId, entityConfig.secondaryLineId].filter((id3) => !!id3) : [currentLineIdToUse];
3505
3434
  if (targetLineIds.length === 0 && currentLineIdToUse === (entityConfig.factoryViewId || "factory")) {
3506
3435
  throw new Error("Factory view selected, but defaultLineId and/or secondaryLineId are not configured in entityConfig.");
3507
3436
  }
3508
3437
  if (targetLineIds.length === 0) {
3509
3438
  throw new Error("No target line IDs available for fetching metrics.");
3510
3439
  }
3511
- console.log("[useDashboardMetrics] Executing workspace query with line IDs:", targetLineIds, "Date:", operationalDate, "ShiftID:", currentShiftDetails.shiftId, "Table:", companySpecificMetricsTable);
3512
3440
  const { data: workspaceData, error: workspaceError } = await supabase.from(companySpecificMetricsTable).select("company_id,line_id,shift_id,date,workspace_id,workspace_name,total_output,avg_pph,performance_score,avg_cycle_time,trend_score,ideal_output,efficiency,total_day_output").eq("date", operationalDate).eq("shift_id", currentShiftDetails.shiftId).in("line_id", targetLineIds);
3513
- console.log("[useDashboardMetrics] Workspace query result:", {
3514
- dataCount: workspaceData?.length || 0,
3515
- error: workspaceError,
3516
- sampleData: workspaceData?.slice(0, 3).map((w) => ({
3517
- workspace_name: w.workspace_name,
3518
- line_id: w.line_id,
3519
- efficiency: w.efficiency
3520
- }))
3521
- });
3522
3441
  if (workspaceError) {
3523
3442
  throw workspaceError;
3524
3443
  }
@@ -4890,16 +4809,12 @@ function getCurrentLineIds() {
4890
4809
  try {
4891
4810
  const config = _getDashboardConfigInstance();
4892
4811
  const entityConfig = config?.entityConfig;
4893
- console.log("\u{1F504} Dashboard config:", config);
4894
- console.log("\u{1F504} Entity config:", entityConfig);
4895
4812
  const lineIds = [];
4896
4813
  if (entityConfig?.defaultLineId) {
4897
4814
  lineIds.push(entityConfig.defaultLineId);
4898
- console.log("\u{1F504} Added defaultLineId:", entityConfig.defaultLineId);
4899
4815
  }
4900
4816
  if (entityConfig?.secondaryLineId) {
4901
4817
  lineIds.push(entityConfig.secondaryLineId);
4902
- console.log("\u{1F504} Added secondaryLineId:", entityConfig.secondaryLineId);
4903
4818
  }
4904
4819
  console.log("\u{1F504} Current line IDs from config:", lineIds);
4905
4820
  return lineIds;
@@ -4917,22 +4832,15 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4917
4832
  let targetLineIds = [];
4918
4833
  if (explicitLineId) {
4919
4834
  targetLineIds = [explicitLineId];
4920
- console.log("\u{1F504} Using explicit lineId:", explicitLineId);
4921
4835
  } else {
4922
4836
  targetLineIds = getCurrentLineIds();
4923
- console.log("\u{1F504} Using line IDs from config:", targetLineIds);
4924
4837
  }
4925
4838
  console.log("\u{1F504} Target line IDs for workspace filtering:", targetLineIds);
4926
4839
  const allDisplayNamesMap = /* @__PURE__ */ new Map();
4927
- console.log("\u{1F504} About to fetch workspaces for lines:", targetLineIds);
4928
4840
  if (targetLineIds.length > 0) {
4929
4841
  for (const lineId of targetLineIds) {
4930
4842
  console.log(`\u{1F504} Fetching workspaces for line: ${lineId}`);
4931
4843
  const lineDisplayNamesMap = await workspaceService.getWorkspaceDisplayNames(void 0, lineId);
4932
- console.log(
4933
- `\u{1F504} Retrieved ${lineDisplayNamesMap.size} workspaces for line ${lineId}:`,
4934
- Array.from(lineDisplayNamesMap.entries()).slice(0, 5)
4935
- );
4936
4844
  lineDisplayNamesMap.forEach((displayName, workspaceId) => {
4937
4845
  allDisplayNamesMap.set(workspaceId, displayName);
4938
4846
  });
@@ -4944,7 +4852,6 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4944
4852
  allDisplayNamesMap.set(workspaceId, displayName);
4945
4853
  });
4946
4854
  }
4947
- console.log("\u{1F504} Final combined display names map size:", allDisplayNamesMap.size);
4948
4855
  runtimeWorkspaceDisplayNames = {};
4949
4856
  allDisplayNamesMap.forEach((displayName, workspaceId) => {
4950
4857
  runtimeWorkspaceDisplayNames[workspaceId] = displayName;
@@ -4972,7 +4879,6 @@ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
4972
4879
  };
4973
4880
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
4974
4881
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
4975
- console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName called with:`, { workspaceId, lineId, isInitialized, isInitializing });
4976
4882
  if (!isInitialized && !isInitializing) {
4977
4883
  console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
4978
4884
  } else if (isInitializing) {
@@ -4984,14 +4890,6 @@ var getWorkspaceDisplayName = (workspaceId, lineId) => {
4984
4890
  console.error("\u274C Lazy initialization failed:", error);
4985
4891
  });
4986
4892
  }
4987
- if (lineId) {
4988
- const lineSpecificKey = `${lineId}_${workspaceId}`;
4989
- const lineSpecificDisplayName = runtimeWorkspaceDisplayNames[lineSpecificKey];
4990
- if (lineSpecificDisplayName) {
4991
- console.log(`getWorkspaceDisplayName(${workspaceId}, ${lineId}) -> ${lineSpecificDisplayName} (line-specific from Supabase)`);
4992
- return lineSpecificDisplayName;
4993
- }
4994
- }
4995
4893
  const displayName = runtimeWorkspaceDisplayNames[workspaceId];
4996
4894
  if (displayName) {
4997
4895
  console.log(`getWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
@@ -5012,14 +4910,6 @@ var getShortWorkspaceDisplayName = (workspaceId, lineId) => {
5012
4910
  console.error("\u274C Lazy initialization failed:", error);
5013
4911
  });
5014
4912
  }
5015
- if (lineId) {
5016
- const lineSpecificKey = `${lineId}_${workspaceId}`;
5017
- const lineSpecificDisplayName = runtimeWorkspaceDisplayNames[lineSpecificKey];
5018
- if (lineSpecificDisplayName) {
5019
- console.log(`getShortWorkspaceDisplayName(${workspaceId}, ${lineId}) -> ${lineSpecificDisplayName} (line-specific from Supabase)`);
5020
- return lineSpecificDisplayName;
5021
- }
5022
- }
5023
4913
  const displayName = runtimeWorkspaceDisplayNames[workspaceId];
5024
4914
  if (displayName) {
5025
4915
  console.log(`getShortWorkspaceDisplayName(${workspaceId}) -> ${displayName} (from Supabase)`);
@@ -8094,36 +7984,18 @@ function cn(...inputs) {
8094
7984
  }
8095
7985
 
8096
7986
  // src/lib/utils/urlMapping.ts
8097
- var toUrlFriendlyName = (workspaceName, lineId) => {
7987
+ var toUrlFriendlyName = (workspaceName) => {
8098
7988
  if (!workspaceName) throw new Error("Workspace name is required");
8099
- const baseName = workspaceName.toLowerCase().replace(/\s+/g, "-");
8100
- return lineId ? `${lineId}-${baseName}` : baseName;
8101
- };
8102
- var fromUrlFriendlyName = (urlName) => {
8103
- const parts = urlName.split("-");
8104
- if (parts.length >= 2 && (parts[0].startsWith("line") || parts[0].length === 36)) {
8105
- return {
8106
- lineId: parts[0],
8107
- workspaceName: parts.slice(1).join("-").toUpperCase()
8108
- };
8109
- }
8110
- return { workspaceName: urlName.toUpperCase() };
7989
+ return workspaceName.toLowerCase().replace(/\s+/g, "-");
8111
7990
  };
7991
+ var fromUrlFriendlyName = (urlName) => urlName.toUpperCase();
8112
7992
  var storeWorkspaceMapping = (mapping) => {
8113
7993
  const mappings = getStoredWorkspaceMappings();
8114
- const key = mapping.lineId ? `${mapping.lineId}_${mapping.urlName}` : mapping.urlName;
8115
- mappings[key] = mapping;
7994
+ mappings[mapping.urlName] = mapping;
8116
7995
  sessionStorage.setItem("workspaceMappings", JSON.stringify(mappings));
8117
7996
  };
8118
- var getWorkspaceFromUrl = (urlName, lineId) => {
7997
+ var getWorkspaceFromUrl = (urlName) => {
8119
7998
  const mappings = getStoredWorkspaceMappings();
8120
- if (lineId) {
8121
- const lineSpecificKey = `${lineId}_${urlName}`;
8122
- const lineSpecificMapping = mappings[lineSpecificKey];
8123
- if (lineSpecificMapping) {
8124
- return lineSpecificMapping;
8125
- }
8126
- }
8127
7999
  return mappings[urlName] || null;
8128
8000
  };
8129
8001
  var getStoredWorkspaceMappings = () => {
@@ -8134,26 +8006,6 @@ var getStoredWorkspaceMappings = () => {
8134
8006
  return {};
8135
8007
  }
8136
8008
  };
8137
- var getWorkspaceMappingsForLine = (lineId) => {
8138
- const allMappings = getStoredWorkspaceMappings();
8139
- const lineMappings = {};
8140
- Object.entries(allMappings).forEach(([key, mapping]) => {
8141
- if (mapping.lineId === lineId) {
8142
- lineMappings[key] = mapping;
8143
- }
8144
- });
8145
- return lineMappings;
8146
- };
8147
- var clearWorkspaceMappingsForLine = (lineId) => {
8148
- const allMappings = getStoredWorkspaceMappings();
8149
- const filteredMappings = {};
8150
- Object.entries(allMappings).forEach(([key, mapping]) => {
8151
- if (mapping.lineId !== lineId) {
8152
- filteredMappings[key] = mapping;
8153
- }
8154
- });
8155
- sessionStorage.setItem("workspaceMappings", JSON.stringify(filteredMappings));
8156
- };
8157
8009
 
8158
8010
  // src/lib/utils/workspacePreferences.ts
8159
8011
  var getDefaultTabForWorkspace = (workspaceId, displayName) => {
@@ -17648,7 +17500,6 @@ var VideoCard = React14__namespace.default.memo(({
17648
17500
  });
17649
17501
  VideoCard.displayName = "VideoCard";
17650
17502
  var DEFAULT_WORKSPACE_HLS_URLS = {
17651
- // Line-agnostic fallbacks
17652
17503
  "WS1": "https://dnh-hls.optifye.ai/cam1/index.m3u8",
17653
17504
  "WS2": "https://dnh-hls.optifye.ai/cam2/index.m3u8",
17654
17505
  "WS3": "https://dnh-hls.optifye.ai/cam3/index.m3u8",
@@ -17659,9 +17510,6 @@ var DEFAULT_WORKSPACE_HLS_URLS = {
17659
17510
  "WS04": "https://59.144.218.58:8443/camera4.m3u8",
17660
17511
  "WS05": "https://59.144.218.58:8443/camera1.m3u8",
17661
17512
  "WS06": "https://59.144.218.58:8443/camera5.m3u8"
17662
- // Line-specific mappings (line_id_workspaceName format)
17663
- // Example: '98a2287e-8d55-4020-b00d-b9940437e3e1_WS1': 'https://line1-hls.optifye.ai/cam1/index.m3u8',
17664
- // Example: 'd93997bb-ecac-4478-a4a6-008d536b724c_WS1': 'https://line2-hls.optifye.ai/cam1/index.m3u8',
17665
17513
  };
17666
17514
  var DEFAULT_HLS_URL = "https://192.168.5.9:8443/cam1.m3u8";
17667
17515
  var VideoGridView = React14__namespace.default.memo(({
@@ -17669,8 +17517,7 @@ var VideoGridView = React14__namespace.default.memo(({
17669
17517
  selectedLine,
17670
17518
  className = "",
17671
17519
  lineIdMapping = {},
17672
- videoSources = {},
17673
- targetLineId
17520
+ videoSources = {}
17674
17521
  }) => {
17675
17522
  const router$1 = router.useRouter();
17676
17523
  const containerRef = React14.useRef(null);
@@ -17678,38 +17525,14 @@ var VideoGridView = React14__namespace.default.memo(({
17678
17525
  const [gridCols, setGridCols] = React14.useState(4);
17679
17526
  const [visibleWorkspaces, setVisibleWorkspaces] = React14.useState(/* @__PURE__ */ new Set());
17680
17527
  const videoConfig = useVideoConfig();
17681
- const entityConfig = useEntityConfig();
17682
17528
  const { cropping, canvasConfig } = videoConfig;
17683
- const defaultLineId = entityConfig.defaultLineId;
17684
- const secondaryLineId = entityConfig.secondaryLineId;
17685
- console.log("[VideoGridView] Line configuration:", {
17686
- defaultLineId,
17687
- secondaryLineId,
17688
- selectedLine,
17689
- targetLineId,
17690
- totalWorkspaces: workspaces.length
17691
- });
17692
17529
  const mergedVideoSources = {
17693
17530
  defaultHlsUrl: videoSources.defaultHlsUrl || DEFAULT_HLS_URL,
17694
17531
  workspaceHlsUrls: { ...DEFAULT_WORKSPACE_HLS_URLS, ...videoSources.workspaceHlsUrls }
17695
17532
  };
17696
- const getWorkspaceHlsUrl = React14.useCallback((workspaceName, lineId) => {
17533
+ const getWorkspaceHlsUrl = React14.useCallback((workspaceName) => {
17697
17534
  const wsName = workspaceName.toUpperCase();
17698
- if (lineId) {
17699
- const lineSpecificKey = `${lineId}_${wsName}`;
17700
- const lineSpecificUrl = mergedVideoSources.workspaceHlsUrls[lineSpecificKey];
17701
- console.log(`[VideoGridView] HLS URL lookup for ${wsName} (line: ${lineId}):`, {
17702
- lineSpecificKey,
17703
- lineSpecificUrl,
17704
- fallbackUrl: mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl
17705
- });
17706
- if (lineSpecificUrl) {
17707
- return lineSpecificUrl;
17708
- }
17709
- }
17710
- const fallbackUrl = mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
17711
- console.log(`[VideoGridView] HLS URL fallback for ${wsName}:`, fallbackUrl);
17712
- return fallbackUrl;
17535
+ return mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
17713
17536
  }, [mergedVideoSources]);
17714
17537
  const getWorkspaceCropping = React14.useCallback((workspaceName) => {
17715
17538
  if (!cropping) return void 0;
@@ -17724,70 +17547,26 @@ var VideoGridView = React14__namespace.default.memo(({
17724
17547
  );
17725
17548
  }, [workspaces]);
17726
17549
  const filteredWorkspaces = React14.useMemo(() => {
17727
- const uniqueLineIds = [...new Set(workspaces.map((w) => w.line_id))];
17728
- console.log("[VideoGridView] Filtering workspaces:", {
17729
- totalWorkspaces: workspaces.length,
17730
- targetLineId,
17731
- selectedLine,
17732
- defaultLineId,
17733
- secondaryLineId,
17734
- uniqueLineIds,
17735
- workspacesByLine: workspaces.reduce((acc, w) => {
17736
- acc[w.line_id] = (acc[w.line_id] || 0) + 1;
17737
- return acc;
17738
- }, {})
17739
- });
17740
- console.log("[VideoGridView] Sample workspaces with line_id:", workspaces.slice(0, 5).map((w) => ({
17741
- workspace_name: w.workspace_name,
17742
- line_id: w.line_id,
17743
- workspace_uuid: w.workspace_uuid
17744
- })));
17745
- if (targetLineId) {
17746
- const filtered = workspaces.filter((w) => w.line_id === targetLineId);
17747
- console.log(`[VideoGridView] Filtered by targetLineId (${targetLineId}):`, filtered.length, "workspaces");
17748
- return filtered;
17749
- }
17750
- if (selectedLine === 1 && defaultLineId) {
17751
- const filtered = workspaces.filter((w) => w.line_id === defaultLineId);
17752
- console.log(`[VideoGridView] Filtered by selectedLine=1 (${defaultLineId}):`, filtered.length, "workspaces");
17753
- return filtered;
17754
- }
17755
- if (selectedLine === 2 && secondaryLineId) {
17756
- const filtered = workspaces.filter((w) => w.line_id === secondaryLineId);
17757
- console.log(`[VideoGridView] Filtered by selectedLine=2 (${secondaryLineId}):`, filtered.length, "workspaces");
17758
- return filtered;
17759
- }
17760
- if (selectedLine === 1) {
17761
- const filtered = workspaces.filter((w) => {
17762
- if (w.workspace_name === "WS5-5") return true;
17763
- if (w.workspace_name === "WS32-5") return false;
17764
- try {
17765
- const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17766
- return wsNumber >= 1 && wsNumber <= 22;
17767
- } catch {
17768
- return true;
17769
- }
17770
- });
17771
- console.log(`[VideoGridView] Legacy filtered by selectedLine=1 (WS1-WS22):`, filtered.length, "workspaces");
17772
- return filtered;
17773
- }
17774
- if (selectedLine === 2) {
17775
- const filtered = workspaces.filter((w) => {
17776
- if (w.workspace_name === "WS5-5") return false;
17777
- if (w.workspace_name === "WS32-5") return true;
17778
- try {
17779
- const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17780
- return wsNumber >= 23 && wsNumber <= 44;
17781
- } catch {
17782
- return false;
17783
- }
17784
- });
17785
- console.log(`[VideoGridView] Legacy filtered by selectedLine=2 (WS23-WS44):`, filtered.length, "workspaces");
17786
- return filtered;
17787
- }
17788
- console.log(`[VideoGridView] No filtering applied, returning all workspaces:`, workspaces.length);
17789
- return workspaces;
17790
- }, [workspaces, selectedLine, targetLineId, defaultLineId, secondaryLineId]);
17550
+ return selectedLine === 1 ? workspaces.filter((w) => {
17551
+ if (w.workspace_name === "WS5-5") return true;
17552
+ if (w.workspace_name === "WS32-5") return false;
17553
+ try {
17554
+ const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17555
+ return wsNumber >= 1 && wsNumber <= 22;
17556
+ } catch {
17557
+ return true;
17558
+ }
17559
+ }) : selectedLine === 2 ? workspaces.filter((w) => {
17560
+ if (w.workspace_name === "WS5-5") return false;
17561
+ if (w.workspace_name === "WS32-5") return true;
17562
+ try {
17563
+ const wsNumber = parseInt(w.workspace_name.replace("WS", ""));
17564
+ return wsNumber >= 23 && wsNumber <= 44;
17565
+ } catch {
17566
+ return false;
17567
+ }
17568
+ }) : workspaces;
17569
+ }, [workspaces, selectedLine]);
17791
17570
  const calculateOptimalGrid = React14.useCallback(() => {
17792
17571
  if (!containerRef.current) return;
17793
17572
  const containerPadding = 16;
@@ -17864,12 +17643,6 @@ var VideoGridView = React14__namespace.default.memo(({
17864
17643
  }, [filteredWorkspaces]);
17865
17644
  const handleWorkspaceClick = React14.useCallback((workspace) => {
17866
17645
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
17867
- console.log("[VideoGridView] Workspace clicked:", {
17868
- workspace_name: workspace.workspace_name,
17869
- workspace_id: workspaceId,
17870
- line_id: workspace.line_id,
17871
- efficiency: workspace.efficiency
17872
- });
17873
17646
  trackCoreEvent("Workspace Detail Clicked", {
17874
17647
  workspace_name: workspace.workspace_name,
17875
17648
  workspace_id: workspaceId,
@@ -17878,15 +17651,8 @@ var VideoGridView = React14__namespace.default.memo(({
17878
17651
  efficiency: workspace.efficiency,
17879
17652
  action_count: workspace.action_count
17880
17653
  });
17881
- const displayName = getWorkspaceDisplayName(workspace.workspace_name, workspace.line_id);
17654
+ const displayName = getWorkspaceDisplayName(workspace.workspace_name);
17882
17655
  const navParams = getWorkspaceNavigationParams(workspaceId, displayName);
17883
- console.log("[VideoGridView] Navigation params:", {
17884
- workspaceId,
17885
- displayName,
17886
- line_id: workspace.line_id,
17887
- navParams,
17888
- finalUrl: `/workspace/${workspaceId}${navParams}`
17889
- });
17890
17656
  router$1.push(`/workspace/${workspaceId}${navParams}`);
17891
17657
  }, [router$1]);
17892
17658
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `relative overflow-hidden h-full w-full ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ref: containerRef, className: "h-full w-full p-2", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -17899,22 +17665,15 @@ var VideoGridView = React14__namespace.default.memo(({
17899
17665
  minHeight: "100%"
17900
17666
  },
17901
17667
  children: filteredWorkspaces.sort((a, b) => {
17902
- if (!targetLineId && !selectedLine) {
17903
- const aIsSecondaryLine = secondaryLineId && a.line_id === secondaryLineId;
17904
- const bIsSecondaryLine = secondaryLineId && b.line_id === secondaryLineId;
17905
- if (aIsSecondaryLine !== bIsSecondaryLine) {
17906
- return aIsSecondaryLine ? 1 : -1;
17907
- }
17908
- if (!secondaryLineId && lineIdMapping.line2) {
17909
- const aIsLine2 = a.line_id === lineIdMapping.line2;
17910
- const bIsLine2 = b.line_id === lineIdMapping.line2;
17911
- if (aIsLine2 !== bIsLine2) {
17912
- return aIsLine2 ? 1 : -1;
17913
- }
17914
- }
17915
- }
17916
17668
  const aNum = parseInt(a.workspace_name.slice(2));
17917
17669
  const bNum = parseInt(b.workspace_name.slice(2));
17670
+ if (!selectedLine) {
17671
+ const aIsLine2 = a.line_id === lineIdMapping.line2;
17672
+ const bIsLine2 = b.line_id === lineIdMapping.line2;
17673
+ if (aIsLine2 !== bIsLine2) {
17674
+ return aIsLine2 ? 1 : -1;
17675
+ }
17676
+ }
17918
17677
  return aNum - bNum;
17919
17678
  }).map((workspace) => {
17920
17679
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
@@ -17931,7 +17690,7 @@ var VideoGridView = React14__namespace.default.memo(({
17931
17690
  VideoCard,
17932
17691
  {
17933
17692
  workspace,
17934
- hlsUrl: getWorkspaceHlsUrl(workspace.workspace_name, workspace.line_id),
17693
+ hlsUrl: getWorkspaceHlsUrl(workspace.workspace_name),
17935
17694
  shouldPlay: isVisible,
17936
17695
  onClick: () => handleWorkspaceClick(workspace),
17937
17696
  onFatalError: throttledReloadDashboard,
@@ -22109,7 +21868,7 @@ var BottlenecksContent = ({
22109
21868
  includeCycleTime: true,
22110
21869
  includeMetadata: true,
22111
21870
  // Always include metadata for timestamp info
22112
- limit: 50,
21871
+ limit: 1e3,
22113
21872
  // Reasonable limit for UI performance
22114
21873
  timestampStart: timestampStartFull,
22115
21874
  timestampEnd: timestampEndFull
@@ -27471,30 +27230,14 @@ function HomeView({
27471
27230
  factoryName = "Simba Beer - Line 1"
27472
27231
  }) {
27473
27232
  const [isHydrated, setIsHydrated] = React14.useState(false);
27474
- const [selectedLineId, setSelectedLineId] = React14.useState(factoryViewId);
27475
- console.log("[HomeView] Component initialized with:", {
27476
- defaultLineId,
27477
- factoryViewId,
27478
- line1Uuid,
27479
- line2Uuid,
27480
- selectedLineId: factoryViewId
27481
- });
27233
+ const [selectedLineId, setSelectedLineId] = React14.useState(defaultLineId);
27482
27234
  const [isChangingFilter, setIsChangingFilter] = React14.useState(false);
27483
27235
  const [errorMessage, setErrorMessage] = React14.useState(null);
27484
27236
  const [displayNamesInitialized, setDisplayNamesInitialized] = React14.useState(false);
27485
- const metricsLineId = selectedLineId;
27486
- console.log("[HomeView] Using metrics line ID:", metricsLineId, "for selectedLineId:", selectedLineId);
27487
27237
  React14.useEffect(() => {
27488
27238
  const initDisplayNames = async () => {
27489
27239
  try {
27490
- if (metricsLineId === factoryViewId) {
27491
- console.log("[HomeView] Initializing display names for factory view (both lines)");
27492
- await preInitializeWorkspaceDisplayNames(line1Uuid);
27493
- await preInitializeWorkspaceDisplayNames(line2Uuid);
27494
- } else {
27495
- console.log("[HomeView] Initializing display names for single line:", selectedLineId);
27496
- await preInitializeWorkspaceDisplayNames(selectedLineId);
27497
- }
27240
+ await preInitializeWorkspaceDisplayNames(selectedLineId);
27498
27241
  setDisplayNamesInitialized(true);
27499
27242
  } catch (error) {
27500
27243
  console.error("Failed to pre-initialize workspace display names:", error);
@@ -27502,13 +27245,12 @@ function HomeView({
27502
27245
  }
27503
27246
  };
27504
27247
  initDisplayNames();
27505
- }, [selectedLineId, metricsLineId, factoryViewId, line1Uuid, line2Uuid]);
27506
- const displayNamesLineId = metricsLineId === factoryViewId ? void 0 : selectedLineId;
27248
+ }, [selectedLineId]);
27507
27249
  const {
27508
27250
  displayNames: workspaceDisplayNames,
27509
27251
  loading: displayNamesLoading,
27510
27252
  error: displayNamesError
27511
- } = useWorkspaceDisplayNames(void 0, displayNamesLineId);
27253
+ } = useWorkspaceDisplayNames(void 0, selectedLineId);
27512
27254
  React14.useCallback(() => {
27513
27255
  console.log("Refetching KPIs after line metrics update");
27514
27256
  }, []);
@@ -27533,16 +27275,14 @@ function HomeView({
27533
27275
  error: metricsError,
27534
27276
  refetch: refetchMetrics
27535
27277
  } = useDashboardMetrics({
27536
- lineId: metricsLineId,
27278
+ lineId: selectedLineId,
27537
27279
  onLineMetricsUpdate
27538
27280
  });
27539
- const breaksLineIds = metricsLineId === factoryViewId ? [line1Uuid, line2Uuid] : [selectedLineId];
27540
- console.log("[HomeView] Using breaks line IDs:", breaksLineIds);
27541
27281
  const {
27542
27282
  activeBreaks,
27543
27283
  isLoading: breaksLoading,
27544
27284
  error: breaksError
27545
- } = useActiveBreaks(breaksLineIds);
27285
+ } = useActiveBreaks([selectedLineId]);
27546
27286
  const memoizedWorkspaceMetrics = React14.useMemo(() => workspaceMetrics, [
27547
27287
  // Only update reference if meaningful properties change
27548
27288
  workspaceMetrics.length,
@@ -27697,12 +27437,8 @@ var itemVariants = {
27697
27437
  };
27698
27438
 
27699
27439
  // src/lib/utils/navigation.ts
27700
- function getWorkspaceNavigationParams2(workspaceUuid, displayName, lineId) {
27701
- const params = new URLSearchParams();
27702
- if (displayName) {
27703
- params.set("name", displayName);
27704
- }
27705
- return params.toString() ? `?${params.toString()}` : "";
27440
+ function getWorkspaceNavigationParams2(workspaceUuid, displayName) {
27441
+ return `?name=${encodeURIComponent(displayName || "")}`;
27706
27442
  }
27707
27443
  var formatLocalDate = (date) => {
27708
27444
  const options = {
@@ -28894,13 +28630,6 @@ var LeaderboardDetailView = React14.memo(({
28894
28630
  line2Id = "",
28895
28631
  className = ""
28896
28632
  }) => {
28897
- console.log("[LeaderboardDetailView] Component initialized with:", {
28898
- lineId,
28899
- line1Id,
28900
- line2Id,
28901
- date,
28902
- shift
28903
- });
28904
28633
  const navigation = useNavigation();
28905
28634
  const [sortAscending, setSortAscending] = React14.useState(true);
28906
28635
  const handleSortToggle = React14.useCallback(() => {
@@ -28918,39 +28647,13 @@ var LeaderboardDetailView = React14.memo(({
28918
28647
  error: metricsError,
28919
28648
  refreshMetrics
28920
28649
  } = useRealtimeLineMetrics(realtimeMetricsParams);
28921
- const isFactoryView = React14.useMemo(() => {
28922
- const hasEssentialLineIds = Boolean(line1Id && line2Id);
28923
- const isFactoryLineId = lineId === "factory" || !lineId;
28924
- return hasEssentialLineIds && isFactoryLineId;
28925
- }, [lineId, line1Id, line2Id]);
28926
28650
  const memoizedLineId = React14.useMemo(() => lineId || "", [lineId]);
28927
- console.log("[LeaderboardDetailView] Factory view check:", {
28928
- isFactoryView,
28929
- lineId,
28930
- line1Id,
28931
- line2Id
28932
- });
28933
- const singleLineResult = useLineWorkspaceMetrics(isFactoryView ? "" : memoizedLineId);
28934
- const factoryResult = useDashboardMetrics({
28935
- lineId: isFactoryView ? "factory" : "",
28936
- onLineMetricsUpdate: void 0
28937
- });
28938
28651
  const {
28939
28652
  workspaces,
28940
28653
  loading: workspacesLoading,
28941
28654
  error: workspacesError,
28942
28655
  refreshWorkspaces
28943
- } = isFactoryView ? {
28944
- workspaces: factoryResult.workspaceMetrics,
28945
- loading: factoryResult.isLoading,
28946
- error: factoryResult.error,
28947
- refreshWorkspaces: factoryResult.refetch
28948
- } : singleLineResult;
28949
- console.log("[LeaderboardDetailView] Workspace data:", {
28950
- workspaces: workspaces?.length || 0,
28951
- loading: workspacesLoading,
28952
- error: workspacesError
28953
- });
28656
+ } = useLineWorkspaceMetrics(memoizedLineId);
28954
28657
  const getShiftName = React14.useCallback((shiftId) => {
28955
28658
  if (shiftId === void 0) return "Day";
28956
28659
  return shiftId === 0 ? "Day" : "Night";
@@ -30881,12 +30584,6 @@ var TargetsView = ({
30881
30584
  userId,
30882
30585
  onSaveChanges
30883
30586
  }) => {
30884
- console.log("[TargetsView] Component initialized with:", {
30885
- lineIds,
30886
- lineNames,
30887
- companyId,
30888
- totalLines: lineIds.length
30889
- });
30890
30587
  const initialLineWorkspaces = React14.useMemo(() => {
30891
30588
  return lineIds.reduce((acc, lineId) => ({
30892
30589
  ...acc,
@@ -31198,9 +30895,7 @@ var TargetsView = ({
31198
30895
  continue;
31199
30896
  }
31200
30897
  try {
31201
- console.log(`[TargetsView] Fetching workspaces for line: ${lineId}`);
31202
30898
  const fetchedLineWorkspacesData = await workspaceService.getWorkspaces(lineId);
31203
- console.log(`[TargetsView] Retrieved ${fetchedLineWorkspacesData.length} workspaces for line ${lineId}`);
31204
30899
  const mappedWorkspaces = fetchedLineWorkspacesData.map((ws) => ({
31205
30900
  id: ws.id,
31206
30901
  name: ws.workspace_id,
@@ -32630,7 +32325,6 @@ exports.clearRateLimit = clearRateLimit2;
32630
32325
  exports.clearS3VideoCache = clearS3VideoCache;
32631
32326
  exports.clearS3VideoFromCache = clearS3VideoFromCache;
32632
32327
  exports.clearWorkspaceDisplayNamesCache = clearWorkspaceDisplayNamesCache;
32633
- exports.clearWorkspaceMappingsForLine = clearWorkspaceMappingsForLine;
32634
32328
  exports.cn = cn;
32635
32329
  exports.createStreamProxyHandler = createStreamProxyHandler;
32636
32330
  exports.createSupabaseClient = createSupabaseClient;
@@ -32672,7 +32366,6 @@ exports.getWorkspaceDisplayName = getWorkspaceDisplayName;
32672
32366
  exports.getWorkspaceDisplayNameAsync = getWorkspaceDisplayNameAsync;
32673
32367
  exports.getWorkspaceDisplayNamesMap = getWorkspaceDisplayNamesMap;
32674
32368
  exports.getWorkspaceFromUrl = getWorkspaceFromUrl;
32675
- exports.getWorkspaceMappingsForLine = getWorkspaceMappingsForLine;
32676
32369
  exports.getWorkspaceNavigationParams = getWorkspaceNavigationParams;
32677
32370
  exports.identifyCoreUser = identifyCoreUser;
32678
32371
  exports.initializeCoreMixpanel = initializeCoreMixpanel;