@optifye/dashboard-core 4.2.2 → 4.2.4

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
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var React33 = require('react');
3
+ var React14 = require('react');
4
4
  var jsxRuntime = require('react/jsx-runtime');
5
5
  var router = require('next/router');
6
6
  var dateFns = require('date-fns');
@@ -44,7 +44,7 @@ function _interopNamespace(e) {
44
44
  return Object.freeze(n);
45
45
  }
46
46
 
47
- var React33__namespace = /*#__PURE__*/_interopNamespace(React33);
47
+ var React14__namespace = /*#__PURE__*/_interopNamespace(React14);
48
48
  var mixpanel__default = /*#__PURE__*/_interopDefault(mixpanel);
49
49
  var useSWR__default = /*#__PURE__*/_interopDefault(useSWR);
50
50
  var Hls2__default = /*#__PURE__*/_interopDefault(Hls2);
@@ -139,8 +139,9 @@ var DEFAULT_ENDPOINTS_CONFIG = {
139
139
  whatsapp: "/api/send-whatsapp-direct",
140
140
  agnoApiUrl: process.env.NEXT_PUBLIC_AGNO_URL || "https://optifye-agent-production.up.railway.app",
141
141
  // Default AGNO API URL
142
- // Hard-coded Slack webhook so the Help page works out-of-the-box without any config
143
- slackWebhookUrl: "https://hooks.slack.com/services/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",
142
+ // Use environment variable for Slack webhook URL for privacy/security
143
+ // Note: SLACK_WEBHOOK_URL is server-side only, NEXT_PUBLIC_SLACK_WEBHOOK_URL works client-side but is less secure
144
+ slackWebhookUrl: process.env.SLACK_WEBHOOK_URL || process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL || void 0,
144
145
  slackProxyEndpoint: void 0
145
146
  };
146
147
  var DEFAULT_THEME_CONFIG = {
@@ -216,14 +217,14 @@ var _getDashboardConfigInstance = () => {
216
217
  }
217
218
  return dashboardConfigInstance;
218
219
  };
219
- var DashboardConfigContext = React33__namespace.createContext(void 0);
220
+ var DashboardConfigContext = React14__namespace.createContext(void 0);
220
221
  var DashboardProvider = ({ config: userProvidedConfig, children }) => {
221
- const fullConfig = React33__namespace.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
222
+ const fullConfig = React14__namespace.useMemo(() => mergeWithDefaultConfig(userProvidedConfig), [userProvidedConfig]);
222
223
  _setDashboardConfigInstance(fullConfig);
223
- React33__namespace.useEffect(() => {
224
+ React14__namespace.useEffect(() => {
224
225
  _setDashboardConfigInstance(fullConfig);
225
226
  }, [fullConfig]);
226
- React33__namespace.useEffect(() => {
227
+ React14__namespace.useEffect(() => {
227
228
  if (!fullConfig.theme) return;
228
229
  const styleId = "dashboard-core-theme-vars";
229
230
  let styleEl = document.getElementById(styleId);
@@ -249,7 +250,7 @@ var DashboardProvider = ({ config: userProvidedConfig, children }) => {
249
250
  return /* @__PURE__ */ jsxRuntime.jsx(DashboardConfigContext.Provider, { value: fullConfig, children });
250
251
  };
251
252
  var useDashboardConfig = () => {
252
- const ctx = React33__namespace.useContext(DashboardConfigContext);
253
+ const ctx = React14__namespace.useContext(DashboardConfigContext);
253
254
  if (!ctx) throw new Error("useDashboardConfig must be used within a DashboardProvider");
254
255
  return ctx;
255
256
  };
@@ -298,7 +299,7 @@ function useCustomConfig() {
298
299
  const { customConfig } = useDashboardConfig();
299
300
  return customConfig ?? {};
300
301
  }
301
- var AuthContext = React33.createContext({
302
+ var AuthContext = React14.createContext({
302
303
  session: null,
303
304
  user: null,
304
305
  loading: true,
@@ -306,18 +307,18 @@ var AuthContext = React33.createContext({
306
307
  signOut: async () => {
307
308
  }
308
309
  });
309
- var useAuth = () => React33.useContext(AuthContext);
310
+ var useAuth = () => React14.useContext(AuthContext);
310
311
  var AuthProvider = ({ children }) => {
311
312
  const supabase = useSupabase();
312
313
  const { authConfig } = useDashboardConfig();
313
- const [session, setSession] = React33.useState(null);
314
- const [user, setUser] = React33.useState(null);
315
- const [loading, setLoading] = React33.useState(true);
316
- const [error, setError] = React33.useState(null);
314
+ const [session, setSession] = React14.useState(null);
315
+ const [user, setUser] = React14.useState(null);
316
+ const [loading, setLoading] = React14.useState(true);
317
+ const [error, setError] = React14.useState(null);
317
318
  const router$1 = router.useRouter();
318
319
  const userProfileTable = authConfig?.userProfileTable;
319
320
  const roleColumn = authConfig?.roleColumn || "role";
320
- const fetchUserDetails = React33.useCallback(async (supabaseUser) => {
321
+ const fetchUserDetails = React14.useCallback(async (supabaseUser) => {
321
322
  if (!supabaseUser) return null;
322
323
  const basicUser = {
323
324
  id: supabaseUser.id,
@@ -348,7 +349,7 @@ var AuthProvider = ({ children }) => {
348
349
  return basicUser;
349
350
  }
350
351
  }, [supabase, userProfileTable, roleColumn]);
351
- React33.useEffect(() => {
352
+ React14.useEffect(() => {
352
353
  if (!supabase) return;
353
354
  let mounted = true;
354
355
  const safetyTimeout = setTimeout(() => {
@@ -436,12 +437,12 @@ var defaultContextValue = {
436
437
  hooks: {},
437
438
  pages: {}
438
439
  };
439
- var DashboardOverridesContext = React33.createContext(defaultContextValue);
440
+ var DashboardOverridesContext = React14.createContext(defaultContextValue);
440
441
  var DashboardOverridesProvider = ({
441
442
  overrides = defaultContextValue,
442
443
  children
443
444
  }) => {
444
- const normalizedOverrides = React33.useMemo(() => {
445
+ const normalizedOverrides = React14.useMemo(() => {
445
446
  return {
446
447
  components: overrides.components || {},
447
448
  hooks: overrides.hooks || {},
@@ -451,19 +452,19 @@ var DashboardOverridesProvider = ({
451
452
  return /* @__PURE__ */ jsxRuntime.jsx(DashboardOverridesContext.Provider, { value: normalizedOverrides, children });
452
453
  };
453
454
  function useComponentOverride(key, Default) {
454
- const { components = {} } = React33.useContext(DashboardOverridesContext);
455
+ const { components = {} } = React14.useContext(DashboardOverridesContext);
455
456
  return components[key] ?? Default;
456
457
  }
457
458
  function useHookOverride(key, Default) {
458
- const { hooks = {} } = React33.useContext(DashboardOverridesContext);
459
+ const { hooks = {} } = React14.useContext(DashboardOverridesContext);
459
460
  return hooks[key] ?? Default;
460
461
  }
461
462
  function usePageOverride(key, Default) {
462
- const { pages = {} } = React33.useContext(DashboardOverridesContext);
463
+ const { pages = {} } = React14.useContext(DashboardOverridesContext);
463
464
  return pages[key] ?? Default;
464
465
  }
465
466
  function useOverrides() {
466
- return React33.useContext(DashboardOverridesContext);
467
+ return React14.useContext(DashboardOverridesContext);
467
468
  }
468
469
 
469
470
  // src/lib/internal/supabaseClientInstance.ts
@@ -479,17 +480,17 @@ var _getSupabaseInstance = () => {
479
480
  }
480
481
  return supabaseInstance;
481
482
  };
482
- var SupabaseContext = React33.createContext(void 0);
483
+ var SupabaseContext = React14.createContext(void 0);
483
484
  var SupabaseProvider = ({ client, children }) => {
484
485
  _setSupabaseInstance(client);
485
- React33.useEffect(() => {
486
+ React14.useEffect(() => {
486
487
  _setSupabaseInstance(client);
487
488
  }, [client]);
488
- const contextValue = React33.useMemo(() => ({ supabase: client }), [client]);
489
+ const contextValue = React14.useMemo(() => ({ supabase: client }), [client]);
489
490
  return /* @__PURE__ */ jsxRuntime.jsx(SupabaseContext.Provider, { value: contextValue, children });
490
491
  };
491
492
  var useSupabase = () => {
492
- const context = React33.useContext(SupabaseContext);
493
+ const context = React14.useContext(SupabaseContext);
493
494
  if (context === void 0) {
494
495
  throw new Error("useSupabase must be used within a SupabaseProvider.");
495
496
  }
@@ -532,10 +533,10 @@ var useWorkspaceMetrics = (workspaceId) => {
532
533
  const entityConfig = useEntityConfig();
533
534
  useDatabaseConfig();
534
535
  const dateTimeConfig = useDateTimeConfig();
535
- const [workspaceMetrics, setWorkspaceMetrics] = React33.useState(null);
536
- const [isLoading, setIsLoading] = React33.useState(true);
537
- const [error, setError] = React33.useState(null);
538
- const fetchWorkspaceMetrics = React33.useCallback(async () => {
536
+ const [workspaceMetrics, setWorkspaceMetrics] = React14.useState(null);
537
+ const [isLoading, setIsLoading] = React14.useState(true);
538
+ const [error, setError] = React14.useState(null);
539
+ const fetchWorkspaceMetrics = React14.useCallback(async () => {
539
540
  try {
540
541
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
541
542
  const { data, error: fetchError } = await supabase.from("overview_workspace_metrics").select("*").eq("workspace_id", workspaceId).eq("date", operationalDate).single();
@@ -548,7 +549,7 @@ var useWorkspaceMetrics = (workspaceId) => {
548
549
  setIsLoading(false);
549
550
  }
550
551
  }, [supabase, workspaceId, dateTimeConfig.defaultTimezone]);
551
- React33.useEffect(() => {
552
+ React14.useEffect(() => {
552
553
  let channels = [];
553
554
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
554
555
  const setupSubscriptions = () => {
@@ -601,10 +602,10 @@ var useWorkspaceMetrics = (workspaceId) => {
601
602
  var useLineMetrics = (lineId) => {
602
603
  const supabase = useSupabase();
603
604
  const dateTimeConfig = useDateTimeConfig();
604
- const [lineMetrics, setLineMetrics] = React33.useState(null);
605
- const [isLoading, setIsLoading] = React33.useState(true);
606
- const [error, setError] = React33.useState(null);
607
- const fetchLineMetrics = React33.useCallback(async () => {
605
+ const [lineMetrics, setLineMetrics] = React14.useState(null);
606
+ const [isLoading, setIsLoading] = React14.useState(true);
607
+ const [error, setError] = React14.useState(null);
608
+ const fetchLineMetrics = React14.useCallback(async () => {
608
609
  try {
609
610
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
610
611
  const { data, error: fetchError } = await supabase.from("overview_line_metrics").select("*").eq("line_id", lineId).eq("date", operationalDate).single();
@@ -617,7 +618,7 @@ var useLineMetrics = (lineId) => {
617
618
  setIsLoading(false);
618
619
  }
619
620
  }, [supabase, lineId, dateTimeConfig.defaultTimezone]);
620
- React33.useEffect(() => {
621
+ React14.useEffect(() => {
621
622
  let channels = [];
622
623
  const operationalDate = getOperationalDate(dateTimeConfig.defaultTimezone);
623
624
  const setupSubscriptions = () => {
@@ -667,11 +668,11 @@ var useLineMetrics = (lineId) => {
667
668
  var useMetrics = (tableName, options) => {
668
669
  const supabase = useSupabase();
669
670
  const entityConfig = useEntityConfig();
670
- const [data, setData] = React33.useState([]);
671
- const [isLoading, setIsLoading] = React33.useState(true);
672
- const [error, setError] = React33.useState(null);
673
- const channelRef = React33.useRef(null);
674
- React33.useEffect(() => {
671
+ const [data, setData] = React14.useState([]);
672
+ const [isLoading, setIsLoading] = React14.useState(true);
673
+ const [error, setError] = React14.useState(null);
674
+ const channelRef = React14.useRef(null);
675
+ React14.useEffect(() => {
675
676
  const fetchData = async () => {
676
677
  try {
677
678
  setIsLoading(true);
@@ -844,13 +845,13 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
844
845
  const shiftConfig = useShiftConfig();
845
846
  const workspaceConfig = useWorkspaceConfig();
846
847
  const supabase = useSupabase();
847
- const [metrics2, setMetrics] = React33.useState(null);
848
- const [isLoading, setIsLoading] = React33.useState(true);
849
- const [error, setError] = React33.useState(null);
850
- const updateQueueRef = React33.useRef(false);
851
- const isFetchingRef = React33.useRef(false);
852
- const timeoutRef = React33.useRef(null);
853
- const channelRef = React33.useRef(null);
848
+ const [metrics2, setMetrics] = React14.useState(null);
849
+ const [isLoading, setIsLoading] = React14.useState(true);
850
+ const [error, setError] = React14.useState(null);
851
+ const updateQueueRef = React14.useRef(false);
852
+ const isFetchingRef = React14.useRef(false);
853
+ const timeoutRef = React14.useRef(null);
854
+ const channelRef = React14.useRef(null);
854
855
  const schema = databaseConfig.schema ?? "public";
855
856
  const companyId = entityConfig.companyId || "";
856
857
  const metricsTablePrefix = getMetricsTablePrefix();
@@ -858,7 +859,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
858
859
  const defaultTimezone = dateTimeConfig.defaultTimezone;
859
860
  const workspaceMetricsBaseTable = databaseConfig.tables?.workspaces ?? "workspace_metrics";
860
861
  const workspaceActionsTable = databaseConfig.tables?.actions ?? "workspace_actions";
861
- const fetchMetrics = React33.useCallback(async () => {
862
+ const fetchMetrics = React14.useCallback(async () => {
862
863
  if (!workspaceId || isFetchingRef.current) return;
863
864
  try {
864
865
  isFetchingRef.current = true;
@@ -877,6 +878,63 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
877
878
  if (recentData) {
878
879
  console.log(`[useWorkspaceDetailedMetrics] Found fallback data from date: ${recentData.date}, shift: ${recentData.shift_id}`);
879
880
  const outputDifference2 = (recentData.total_output || 0) - (recentData.ideal_output || 0);
881
+ const workspaceMatch2 = recentData.workspace_name?.match(/WS(\d+)/);
882
+ const workspaceNumber2 = workspaceMatch2 ? parseInt(workspaceMatch2[1]) : 0;
883
+ const specialWsStart2 = workspaceConfig.specialWorkspaces?.startId ?? 19;
884
+ const specialWsEnd2 = workspaceConfig.specialWorkspaces?.endId ?? 34;
885
+ const isSpecialWorkspace2 = workspaceNumber2 >= specialWsStart2 && workspaceNumber2 <= specialWsEnd2;
886
+ const outputHourly2 = recentData.output_hourly || {};
887
+ const hasOutputHourlyData2 = outputHourly2 && typeof outputHourly2 === "object" && Object.keys(outputHourly2).length > 0;
888
+ let hourlyActionCounts2 = [];
889
+ if (hasOutputHourlyData2) {
890
+ console.log("Using new output_hourly column for workspace (fallback):", recentData.workspace_name);
891
+ console.log("Raw output_hourly data (fallback):", outputHourly2);
892
+ const isNightShift = recentData.shift_id === 1;
893
+ const shiftStart = recentData.shift_start || (isNightShift ? "22:00" : "06:00");
894
+ const shiftEnd = recentData.shift_end || (isNightShift ? "06:00" : "14:00");
895
+ const startHour = parseInt(shiftStart.split(":")[0]);
896
+ let expectedHours = [];
897
+ if (isNightShift) {
898
+ for (let i = 0; i < 9; i++) {
899
+ expectedHours.push((startHour + i) % 24);
900
+ }
901
+ } else {
902
+ for (let i = 0; i < 9; i++) {
903
+ expectedHours.push((startHour + i) % 24);
904
+ }
905
+ }
906
+ console.log("Expected shift hours (fallback):", expectedHours);
907
+ console.log("Available data hours (fallback):", Object.keys(outputHourly2));
908
+ hourlyActionCounts2 = expectedHours.map((expectedHour) => {
909
+ let hourData = outputHourly2[expectedHour.toString()];
910
+ if (!hourData && isNightShift) {
911
+ for (const [storedHour, data2] of Object.entries(outputHourly2)) {
912
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
913
+ if (storedHour === "18" && expectedHour === 1) {
914
+ hourData = data2;
915
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour} (fallback)`);
916
+ break;
917
+ }
918
+ }
919
+ }
920
+ }
921
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
922
+ });
923
+ console.log("Final hourly action counts (fallback):", hourlyActionCounts2);
924
+ } else {
925
+ console.log("Using output_array fallback for workspace (fallback):", recentData.workspace_name);
926
+ const minuteByMinuteArray = recentData.output_array || [];
927
+ if (isSpecialWorkspace2) {
928
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
929
+ hourlyActionCounts2 = last40Readings;
930
+ } else {
931
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
932
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
933
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
934
+ hourlyActionCounts2.push(hourlySum);
935
+ }
936
+ }
937
+ }
880
938
  const transformedData2 = {
881
939
  workspace_id: recentData.workspace_id,
882
940
  workspace_name: recentData.workspace_name,
@@ -897,12 +955,14 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
897
955
  ideal_cycle_time: recentData.ideal_cycle_time || 0,
898
956
  avg_efficiency: recentData.efficiency || 0,
899
957
  total_actions: recentData.total_output || 0,
900
- hourly_action_counts: recentData.output_array || [],
958
+ hourly_action_counts: hourlyActionCounts2,
959
+ // Now uses the NEW logic with fallback
901
960
  workspace_rank: recentData.workspace_rank || 0,
902
961
  total_workspaces: recentData.total_workspaces || workspaceConfig.totalWorkspaces || 42,
903
962
  ideal_output_until_now: recentData.ideal_output || 0,
904
963
  output_difference: outputDifference2,
905
964
  idle_time: recentData.idle_time || 0,
965
+ idle_time_hourly: recentData.idle_time_hourly || void 0,
906
966
  ...recentData.compliance_efficiency !== void 0 && { compliance_efficiency: recentData.compliance_efficiency },
907
967
  ...recentData.sop_check !== void 0 && { sop_check: recentData.sop_check }
908
968
  };
@@ -929,17 +989,66 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
929
989
  const specialWsStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
930
990
  const specialWsEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
931
991
  const isSpecialWorkspace = workspaceNumber >= specialWsStart && workspaceNumber <= specialWsEnd;
932
- const minuteByMinuteArray = data.output_array || [];
992
+ const outputHourly = data.output_hourly || {};
993
+ console.log("[DEBUG] Raw data.output_hourly:", data.output_hourly);
994
+ console.log("[DEBUG] outputHourly after || {}:", outputHourly);
995
+ console.log("[DEBUG] typeof outputHourly:", typeof outputHourly);
996
+ console.log("[DEBUG] Object.keys(outputHourly):", Object.keys(outputHourly));
997
+ console.log("[DEBUG] Object.keys(outputHourly).length:", Object.keys(outputHourly).length);
998
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
999
+ console.log("[DEBUG] hasOutputHourlyData:", hasOutputHourlyData);
933
1000
  let hourlyActionCounts = [];
934
- if (isSpecialWorkspace) {
935
- const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
936
- hourlyActionCounts = last40Readings;
1001
+ if (hasOutputHourlyData) {
1002
+ console.log("\u2705 Using new output_hourly column for workspace:", data.workspace_name);
1003
+ console.log("Raw output_hourly data:", JSON.stringify(outputHourly));
1004
+ const isNightShift = data.shift_id === 1;
1005
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
1006
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
1007
+ const startHour = parseInt(shiftStart.split(":")[0]);
1008
+ let expectedHours = [];
1009
+ if (isNightShift) {
1010
+ for (let i = 0; i < 9; i++) {
1011
+ expectedHours.push((startHour + i) % 24);
1012
+ }
1013
+ } else {
1014
+ for (let i = 0; i < 9; i++) {
1015
+ expectedHours.push((startHour + i) % 24);
1016
+ }
1017
+ }
1018
+ console.log("Expected shift hours:", expectedHours);
1019
+ console.log("Available data hours:", Object.keys(outputHourly));
1020
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
1021
+ let hourData = outputHourly[expectedHour.toString()];
1022
+ if (!hourData && isNightShift) {
1023
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
1024
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
1025
+ if (storedHour === "18" && expectedHour === 1) {
1026
+ hourData = data2;
1027
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
1028
+ break;
1029
+ }
1030
+ }
1031
+ }
1032
+ }
1033
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1034
+ });
1035
+ console.log("Final hourly action counts:", hourlyActionCounts);
937
1036
  } else {
938
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
939
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
940
- const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
941
- hourlyActionCounts.push(hourlySum);
1037
+ console.log("\u274C Using output_array fallback for workspace:", data.workspace_name);
1038
+ console.log("[DEBUG] Fallback reason - hasOutputHourlyData is false");
1039
+ console.log("[DEBUG] data.output_hourly was:", data.output_hourly);
1040
+ const minuteByMinuteArray = data.output_array || [];
1041
+ if (isSpecialWorkspace) {
1042
+ const last40Readings = minuteByMinuteArray.slice(Math.max(0, minuteByMinuteArray.length - 40));
1043
+ hourlyActionCounts = last40Readings;
1044
+ } else {
1045
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1046
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1047
+ const hourlySum = hourSlice.reduce((sum, count) => sum + count, 0);
1048
+ hourlyActionCounts.push(hourlySum);
1049
+ }
942
1050
  }
1051
+ console.log("Final hourly action counts:", hourlyActionCounts);
943
1052
  }
944
1053
  const transformedData = {
945
1054
  workspace_id: data.workspace_id,
@@ -968,6 +1077,8 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
968
1077
  output_difference: outputDifference,
969
1078
  idle_time: data.idle_time || 0,
970
1079
  // Add idle_time from performance_metrics table
1080
+ idle_time_hourly: data.idle_time_hourly || void 0,
1081
+ // Add idle_time_hourly from performance_metrics table
971
1082
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
972
1083
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
973
1084
  };
@@ -981,7 +1092,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
981
1092
  setIsLoading(false);
982
1093
  }
983
1094
  }, [supabase, workspaceId, date, shiftId, metricsTable, defaultTimezone, shiftConfig, workspaceConfig, companyId]);
984
- const queueUpdate = React33.useCallback(() => {
1095
+ const queueUpdate = React14.useCallback(() => {
985
1096
  if (!workspaceId || updateQueueRef.current) return;
986
1097
  updateQueueRef.current = true;
987
1098
  if (timeoutRef.current) {
@@ -991,7 +1102,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
991
1102
  fetchMetrics();
992
1103
  }, 500);
993
1104
  }, [fetchMetrics, workspaceId]);
994
- const setupSubscription = React33.useCallback(() => {
1105
+ const setupSubscription = React14.useCallback(() => {
995
1106
  if (!workspaceId) return;
996
1107
  if (channelRef.current) {
997
1108
  supabase.removeChannel(channelRef.current);
@@ -1012,7 +1123,7 @@ var useWorkspaceDetailedMetrics = (workspaceId, date, shiftId) => {
1012
1123
  console.log(`Workspace detailed metrics subscription status:`, status);
1013
1124
  });
1014
1125
  }, [supabase, workspaceId, fetchMetrics, schema, metricsTable, metricsTablePrefix]);
1015
- React33.useEffect(() => {
1126
+ React14.useEffect(() => {
1016
1127
  if (!workspaceId) {
1017
1128
  setIsLoading(false);
1018
1129
  return;
@@ -1125,28 +1236,28 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1125
1236
  const dateTimeConfig = useDateTimeConfig();
1126
1237
  const shiftConfig = useShiftConfig();
1127
1238
  const supabase = useSupabase();
1128
- const [workspaces, setWorkspaces] = React33.useState([]);
1129
- const [loading, setLoading] = React33.useState(true);
1130
- const [error, setError] = React33.useState(null);
1131
- const [initialized, setInitialized] = React33.useState(false);
1132
- const queryShiftId = React33.useMemo(() => {
1239
+ const [workspaces, setWorkspaces] = React14.useState([]);
1240
+ const [loading, setLoading] = React14.useState(true);
1241
+ const [error, setError] = React14.useState(null);
1242
+ const [initialized, setInitialized] = React14.useState(false);
1243
+ const queryShiftId = React14.useMemo(() => {
1133
1244
  const currentShift = getCurrentShift(
1134
1245
  dateTimeConfig.defaultTimezone || "Asia/Kolkata",
1135
1246
  shiftConfig
1136
1247
  );
1137
1248
  return options?.initialShiftId !== void 0 ? options.initialShiftId : currentShift.shiftId;
1138
1249
  }, [options?.initialShiftId, dateTimeConfig.defaultTimezone, shiftConfig]);
1139
- const queryDate = React33.useMemo(() => {
1250
+ const queryDate = React14.useMemo(() => {
1140
1251
  return options?.initialDate || getOperationalDate(dateTimeConfig.defaultTimezone);
1141
1252
  }, [options?.initialDate, dateTimeConfig.defaultTimezone]);
1142
- const metricsTable = React33.useMemo(() => {
1253
+ const metricsTable = React14.useMemo(() => {
1143
1254
  const companyId = entityConfig.companyId;
1144
1255
  if (!companyId) return "";
1145
1256
  const metricsTablePrefix = getMetricsTablePrefix();
1146
1257
  return `${metricsTablePrefix}_${companyId.replace(/-/g, "_")}`;
1147
1258
  }, [entityConfig.companyId]);
1148
1259
  const schema = databaseConfig.schema ?? "public";
1149
- const fetchWorkspaceMetrics = React33.useCallback(async () => {
1260
+ const fetchWorkspaceMetrics = React14.useCallback(async () => {
1150
1261
  if (!lineId) return;
1151
1262
  if (!initialized) {
1152
1263
  setLoading(true);
@@ -1197,7 +1308,7 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1197
1308
  setLoading(false);
1198
1309
  }
1199
1310
  }, [lineId, queryDate, queryShiftId, metricsTable, supabase, entityConfig.companyId]);
1200
- React33.useEffect(() => {
1311
+ React14.useEffect(() => {
1201
1312
  if (!initialized) {
1202
1313
  fetchWorkspaceMetrics();
1203
1314
  }
@@ -1227,11 +1338,11 @@ var useLineWorkspaceMetrics = (lineId, options) => {
1227
1338
  }
1228
1339
  };
1229
1340
  }, [lineId, queryDate, queryShiftId, metricsTable, fetchWorkspaceMetrics, initialized, supabase, schema]);
1230
- React33.useEffect(() => {
1341
+ React14.useEffect(() => {
1231
1342
  setInitialized(false);
1232
1343
  }, [lineId, queryDate, queryShiftId]);
1233
1344
  const refreshWorkspaces = fetchWorkspaceMetrics;
1234
- return React33.useMemo(
1345
+ return React14.useMemo(
1235
1346
  () => ({ workspaces, loading, error, refreshWorkspaces }),
1236
1347
  [workspaces, loading, error, refreshWorkspaces]
1237
1348
  );
@@ -1488,16 +1599,56 @@ var dashboardService = {
1488
1599
  const specialStart = workspaceConfig.specialWorkspaces?.startId ?? 19;
1489
1600
  const specialEnd = workspaceConfig.specialWorkspaces?.endId ?? 34;
1490
1601
  const isSpecialWorkspace = workspaceNumber >= specialStart && workspaceNumber <= specialEnd;
1491
- const minuteByMinuteArray = data.output_array || [];
1602
+ const outputHourly = data.output_hourly || {};
1603
+ const hasOutputHourlyData = outputHourly && typeof outputHourly === "object" && Object.keys(outputHourly).length > 0;
1492
1604
  let hourlyActionCounts = [];
1493
- if (isSpecialWorkspace) {
1494
- const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1495
- hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1605
+ if (hasOutputHourlyData) {
1606
+ console.log("Using new output_hourly column for workspace:", data.workspace_name);
1607
+ console.log("Raw output_hourly data:", outputHourly);
1608
+ const isNightShift = data.shift_id === 1;
1609
+ const shiftStart = data.shift_start || (isNightShift ? "22:00" : "06:00");
1610
+ const shiftEnd = data.shift_end || (isNightShift ? "06:00" : "14:00");
1611
+ const startHour = parseInt(shiftStart.split(":")[0]);
1612
+ let expectedHours = [];
1613
+ if (isNightShift) {
1614
+ for (let i = 0; i < 9; i++) {
1615
+ expectedHours.push((startHour + i) % 24);
1616
+ }
1617
+ } else {
1618
+ for (let i = 0; i < 9; i++) {
1619
+ expectedHours.push((startHour + i) % 24);
1620
+ }
1621
+ }
1622
+ console.log("Expected shift hours:", expectedHours);
1623
+ console.log("Available data hours:", Object.keys(outputHourly));
1624
+ hourlyActionCounts = expectedHours.map((expectedHour) => {
1625
+ let hourData = outputHourly[expectedHour.toString()];
1626
+ if (!hourData && isNightShift) {
1627
+ for (const [storedHour, data2] of Object.entries(outputHourly)) {
1628
+ if (Array.isArray(data2) && data2.length > 0 && data2.some((val) => val > 0)) {
1629
+ if (storedHour === "18" && expectedHour === 1) {
1630
+ hourData = data2;
1631
+ console.log(`Mapping stored hour ${storedHour} to expected hour ${expectedHour}`);
1632
+ break;
1633
+ }
1634
+ }
1635
+ }
1636
+ }
1637
+ return Array.isArray(hourData) ? hourData.reduce((sum, count) => sum + (count || 0), 0) : 0;
1638
+ });
1639
+ console.log("Final hourly action counts:", hourlyActionCounts);
1496
1640
  } else {
1497
- for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1498
- const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1499
- const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1500
- hourlyActionCounts.push(hourlySum);
1641
+ console.log("Using output_array fallback for workspace:", data.workspace_name);
1642
+ const minuteByMinuteArray = data.output_array || [];
1643
+ if (isSpecialWorkspace) {
1644
+ const numReadings = workspaceConfig.specialWorkspaces?.hourlyReadingsCount ?? 40;
1645
+ hourlyActionCounts = minuteByMinuteArray.slice(-numReadings);
1646
+ } else {
1647
+ for (let i = 0; i < minuteByMinuteArray.length; i += 60) {
1648
+ const hourSlice = minuteByMinuteArray.slice(i, Math.min(i + 60, minuteByMinuteArray.length));
1649
+ const hourlySum = hourSlice.reduce((sum, count) => sum + (count ?? 0), 0);
1650
+ hourlyActionCounts.push(hourlySum);
1651
+ }
1501
1652
  }
1502
1653
  }
1503
1654
  const transformedData = {
@@ -1526,6 +1677,7 @@ var dashboardService = {
1526
1677
  ideal_output_until_now: data.ideal_output || 0,
1527
1678
  output_difference: outputDifference,
1528
1679
  idle_time: data.idle_time || 0,
1680
+ idle_time_hourly: data.idle_time_hourly || void 0,
1529
1681
  ...data.compliance_efficiency !== void 0 && { compliance_efficiency: data.compliance_efficiency },
1530
1682
  ...data.sop_check !== void 0 && { sop_check: data.sop_check }
1531
1683
  };
@@ -1873,10 +2025,10 @@ var dashboardService = {
1873
2025
  // src/lib/hooks/useHistoricWorkspaceMetrics.ts
1874
2026
  var useHistoricWorkspaceMetrics = (workspaceId, date, inputShiftId) => {
1875
2027
  useSupabase();
1876
- const [metrics2, setMetrics] = React33.useState(null);
1877
- const [isLoading, setIsLoading] = React33.useState(true);
1878
- const [error, setError] = React33.useState(null);
1879
- const fetchAndAnimateMetrics = React33.useCallback(async () => {
2028
+ const [metrics2, setMetrics] = React14.useState(null);
2029
+ const [isLoading, setIsLoading] = React14.useState(true);
2030
+ const [error, setError] = React14.useState(null);
2031
+ const fetchAndAnimateMetrics = React14.useCallback(async () => {
1880
2032
  if (!workspaceId || !date || inputShiftId === void 0) {
1881
2033
  setMetrics(null);
1882
2034
  setIsLoading(false);
@@ -1934,10 +2086,10 @@ var useHistoricWorkspaceMetrics = (workspaceId, date, inputShiftId) => {
1934
2086
  setMetrics(null);
1935
2087
  }
1936
2088
  }, [workspaceId, date, inputShiftId]);
1937
- React33.useEffect(() => {
2089
+ React14.useEffect(() => {
1938
2090
  fetchAndAnimateMetrics();
1939
2091
  }, [fetchAndAnimateMetrics]);
1940
- const refetch = React33.useCallback(async () => {
2092
+ const refetch = React14.useCallback(async () => {
1941
2093
  if (!workspaceId || !date || inputShiftId === void 0) {
1942
2094
  setError(null);
1943
2095
  return;
@@ -2948,15 +3100,15 @@ var useLineDetailedMetrics = (lineIdFromProp) => {
2948
3100
  const dateTimeConfig = useDateTimeConfig();
2949
3101
  const shiftConfig = useShiftConfig();
2950
3102
  const supabase = useSupabase();
2951
- const [lineData, setLineData] = React33.useState(null);
2952
- const [loading, setLoading] = React33.useState(true);
2953
- const [error, setError] = React33.useState(null);
2954
- const channelRef = React33.useRef(null);
3103
+ const [lineData, setLineData] = React14.useState(null);
3104
+ const [loading, setLoading] = React14.useState(true);
3105
+ const [error, setError] = React14.useState(null);
3106
+ const channelRef = React14.useRef(null);
2955
3107
  const defaultTimezone = dateTimeConfig.defaultTimezone;
2956
3108
  const schema = databaseConfig.schema ?? "public";
2957
3109
  const lineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
2958
3110
  const lineIdToUse = lineIdFromProp === "factory" ? entityConfig.factoryViewId || "factory" : lineIdFromProp;
2959
- const fetchData = React33.useCallback(async () => {
3111
+ const fetchData = React14.useCallback(async () => {
2960
3112
  if (!dashboardService || !lineIdToUse) {
2961
3113
  setLoading(false);
2962
3114
  if (!dashboardService && lineIdToUse) {
@@ -2985,7 +3137,7 @@ var useLineDetailedMetrics = (lineIdFromProp) => {
2985
3137
  setLoading(false);
2986
3138
  }
2987
3139
  }, [dashboardService, lineIdToUse, defaultTimezone, shiftConfig, entityConfig]);
2988
- React33.useEffect(() => {
3140
+ React14.useEffect(() => {
2989
3141
  if (!supabase || !lineIdToUse || !entityConfig.companyId) {
2990
3142
  setLoading(false);
2991
3143
  if (!entityConfig.companyId && (!error || error.code !== "SERVICE_ERROR")) {
@@ -3067,15 +3219,15 @@ var useLeaderboardMetrics = (lineId, topCount = 10) => {
3067
3219
  const dateTimeConfig = useDateTimeConfig();
3068
3220
  const shiftConfig = useShiftConfig();
3069
3221
  const supabase = useSupabase();
3070
- const [topPerformers, setTopPerformers] = React33.useState([]);
3071
- const [isLoading, setIsLoading] = React33.useState(true);
3072
- const [error, setError] = React33.useState(null);
3073
- const companySpecificMetricsTable = React33.useMemo(() => {
3222
+ const [topPerformers, setTopPerformers] = React14.useState([]);
3223
+ const [isLoading, setIsLoading] = React14.useState(true);
3224
+ const [error, setError] = React14.useState(null);
3225
+ const companySpecificMetricsTable = React14.useMemo(() => {
3074
3226
  return getCompanyMetricsTableName(entityConfig.companyId);
3075
3227
  }, [entityConfig.companyId]);
3076
3228
  const schema = databaseConfig.schema ?? "public";
3077
3229
  const defaultTimezone = dateTimeConfig.defaultTimezone;
3078
- const fetchLeaderboardData = React33.useCallback(async () => {
3230
+ const fetchLeaderboardData = React14.useCallback(async () => {
3079
3231
  if (!lineId || !supabase || companySpecificMetricsTable.includes("unknown_company")) {
3080
3232
  setIsLoading(false);
3081
3233
  if (companySpecificMetricsTable.includes("unknown_company")) {
@@ -3108,7 +3260,7 @@ var useLeaderboardMetrics = (lineId, topCount = 10) => {
3108
3260
  setIsLoading(false);
3109
3261
  }
3110
3262
  }, [supabase, lineId, topCount, companySpecificMetricsTable, defaultTimezone, shiftConfig]);
3111
- React33.useEffect(() => {
3263
+ React14.useEffect(() => {
3112
3264
  if (!lineId || !supabase || companySpecificMetricsTable.includes("unknown_company")) {
3113
3265
  setIsLoading(false);
3114
3266
  if (error?.code !== "CONFIG_ERROR") setError(null);
@@ -3186,27 +3338,27 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3186
3338
  const dateTimeConfig = useDateTimeConfig();
3187
3339
  const shiftConfig = useShiftConfig();
3188
3340
  const supabase = useSupabase();
3189
- const [metrics2, setMetrics] = React33.useState(() => getCache(lineId) || { workspaceMetrics: [], lineMetrics: [] });
3190
- const [isLoading, setIsLoading] = React33.useState(() => !getCache(lineId));
3191
- const [error, setError] = React33.useState(null);
3192
- const lineIdRef = React33.useRef(lineId);
3193
- const isFetchingRef = React33.useRef(false);
3194
- const updateQueueRef = React33.useRef(false);
3195
- const timeoutRef = React33.useRef(null);
3196
- const companySpecificMetricsTable = React33.useMemo(
3341
+ const [metrics2, setMetrics] = React14.useState(() => getCache(lineId) || { workspaceMetrics: [], lineMetrics: [] });
3342
+ const [isLoading, setIsLoading] = React14.useState(() => !getCache(lineId));
3343
+ const [error, setError] = React14.useState(null);
3344
+ const lineIdRef = React14.useRef(lineId);
3345
+ const isFetchingRef = React14.useRef(false);
3346
+ const updateQueueRef = React14.useRef(false);
3347
+ const timeoutRef = React14.useRef(null);
3348
+ const companySpecificMetricsTable = React14.useMemo(
3197
3349
  () => getCompanyMetricsTableName(entityConfig.companyId, "performance_metrics"),
3198
3350
  [entityConfig.companyId]
3199
3351
  );
3200
3352
  const configuredLineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
3201
3353
  const schema = databaseConfig.schema ?? "public";
3202
3354
  const defaultTimezone = dateTimeConfig.defaultTimezone || "UTC";
3203
- React33.useEffect(() => {
3355
+ React14.useEffect(() => {
3204
3356
  lineIdRef.current = lineId;
3205
3357
  const cachedData = getCache(lineId);
3206
3358
  setMetrics(cachedData || { workspaceMetrics: [], lineMetrics: [] });
3207
3359
  setIsLoading(!cachedData);
3208
3360
  }, [lineId]);
3209
- const fetchAllMetrics = React33.useCallback(async () => {
3361
+ const fetchAllMetrics = React14.useCallback(async () => {
3210
3362
  const currentLineIdToUse = lineIdRef.current;
3211
3363
  if (!currentLineIdToUse || !supabase || isFetchingRef.current || companySpecificMetricsTable.includes("unknown_company")) {
3212
3364
  if (!metrics2.workspaceMetrics.length && !metrics2.lineMetrics.length) setIsLoading(false);
@@ -3292,7 +3444,7 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3292
3444
  defaultTimezone,
3293
3445
  shiftConfig
3294
3446
  ]);
3295
- const queueUpdate = React33.useCallback(() => {
3447
+ const queueUpdate = React14.useCallback(() => {
3296
3448
  if (updateQueueRef.current || !supabase) {
3297
3449
  return;
3298
3450
  }
@@ -3304,12 +3456,12 @@ var useDashboardMetrics = ({ onLineMetricsUpdate, lineId }) => {
3304
3456
  fetchAllMetrics();
3305
3457
  }, 500);
3306
3458
  }, [fetchAllMetrics, supabase]);
3307
- React33.useEffect(() => {
3459
+ React14.useEffect(() => {
3308
3460
  if (lineId && supabase) {
3309
3461
  fetchAllMetrics();
3310
3462
  }
3311
3463
  }, [lineId, supabase, fetchAllMetrics]);
3312
- React33.useEffect(() => {
3464
+ React14.useEffect(() => {
3313
3465
  const currentLineIdToUse = lineIdRef.current;
3314
3466
  if (!currentLineIdToUse || !supabase || companySpecificMetricsTable.includes("unknown_company") || !entityConfig.companyId) {
3315
3467
  return;
@@ -3409,27 +3561,27 @@ var useLineKPIs = ({ lineId }) => {
3409
3561
  const dateTimeConfig = useDateTimeConfig();
3410
3562
  const shiftConfig = useShiftConfig();
3411
3563
  const supabase = useSupabase();
3412
- const dashboardServiceInstance = React33.useMemo(() => {
3564
+ const dashboardServiceInstance = React14.useMemo(() => {
3413
3565
  return dashboardService;
3414
3566
  }, []);
3415
- const [kpis, setKPIs] = React33.useState(() => getCache2(lineId));
3416
- const [isLoading, setIsLoading] = React33.useState(!getCache2(lineId));
3417
- const [error, setError] = React33.useState(null);
3418
- const lineIdRef = React33.useRef(lineId);
3419
- const isFetchingRef = React33.useRef(false);
3420
- const updateQueueRef = React33.useRef(false);
3421
- const timeoutRef = React33.useRef(null);
3567
+ const [kpis, setKPIs] = React14.useState(() => getCache2(lineId));
3568
+ const [isLoading, setIsLoading] = React14.useState(!getCache2(lineId));
3569
+ const [error, setError] = React14.useState(null);
3570
+ const lineIdRef = React14.useRef(lineId);
3571
+ const isFetchingRef = React14.useRef(false);
3572
+ const updateQueueRef = React14.useRef(false);
3573
+ const timeoutRef = React14.useRef(null);
3422
3574
  const defaultTimezone = dateTimeConfig.defaultTimezone;
3423
3575
  const schema = databaseConfig.schema ?? "public";
3424
3576
  const lineMetricsTable = databaseConfig.tables?.lineMetrics ?? "line_metrics";
3425
- const companySpecificMetricsTable = React33.useMemo(
3577
+ const companySpecificMetricsTable = React14.useMemo(
3426
3578
  () => entityConfig.companyId ? getCompanyMetricsTableName(entityConfig.companyId, "workspace_performance") : null,
3427
3579
  [entityConfig.companyId]
3428
3580
  );
3429
- React33.useEffect(() => {
3581
+ React14.useEffect(() => {
3430
3582
  lineIdRef.current = lineId;
3431
3583
  }, [lineId]);
3432
- const fetchKPIs = React33.useCallback(async () => {
3584
+ const fetchKPIs = React14.useCallback(async () => {
3433
3585
  const currentLineId = lineIdRef.current;
3434
3586
  if (!currentLineId || !dashboardServiceInstance || isFetchingRef.current) {
3435
3587
  if (!kpis && !isFetchingRef.current) setIsLoading(false);
@@ -3463,7 +3615,7 @@ var useLineKPIs = ({ lineId }) => {
3463
3615
  updateQueueRef.current = false;
3464
3616
  }
3465
3617
  }, [dashboardServiceInstance, kpis, defaultTimezone, shiftConfig, entityConfig.companyId]);
3466
- const queueUpdate = React33.useCallback(() => {
3618
+ const queueUpdate = React14.useCallback(() => {
3467
3619
  if (updateQueueRef.current) return;
3468
3620
  updateQueueRef.current = true;
3469
3621
  if (timeoutRef.current) {
@@ -3473,7 +3625,7 @@ var useLineKPIs = ({ lineId }) => {
3473
3625
  fetchKPIs();
3474
3626
  }, 500);
3475
3627
  }, [fetchKPIs]);
3476
- React33.useEffect(() => {
3628
+ React14.useEffect(() => {
3477
3629
  const currentLineId = lineIdRef.current;
3478
3630
  if (!currentLineId || !supabase || !dashboardServiceInstance) {
3479
3631
  if (!kpis) setIsLoading(false);
@@ -3556,23 +3708,23 @@ var useRealtimeLineMetrics = ({
3556
3708
  useDatabaseConfig();
3557
3709
  const dateTimeConfig = useDateTimeConfig();
3558
3710
  const shiftConfig = useShiftConfig();
3559
- const [metrics2, setMetrics] = React33.useState(null);
3560
- const [lineDetails, setLineDetails] = React33.useState(null);
3561
- const [loading, setLoading] = React33.useState(true);
3562
- const [error, setError] = React33.useState(null);
3563
- const [initialized, setInitialized] = React33.useState(false);
3564
- const lineIdRef = React33.useRef(null);
3565
- const updateQueueRef = React33.useRef(false);
3566
- const timeoutRef = React33.useRef(null);
3567
- const isFetchingRef = React33.useRef(false);
3568
- const channelsRef = React33.useRef([]);
3569
- const currentShift = React33.useMemo(() => getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig), [dateTimeConfig.defaultTimezone, shiftConfig]);
3570
- const shiftId = React33.useMemo(
3711
+ const [metrics2, setMetrics] = React14.useState(null);
3712
+ const [lineDetails, setLineDetails] = React14.useState(null);
3713
+ const [loading, setLoading] = React14.useState(true);
3714
+ const [error, setError] = React14.useState(null);
3715
+ const [initialized, setInitialized] = React14.useState(false);
3716
+ const lineIdRef = React14.useRef(null);
3717
+ const updateQueueRef = React14.useRef(false);
3718
+ const timeoutRef = React14.useRef(null);
3719
+ const isFetchingRef = React14.useRef(false);
3720
+ const channelsRef = React14.useRef([]);
3721
+ const currentShift = React14.useMemo(() => getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig), [dateTimeConfig.defaultTimezone, shiftConfig]);
3722
+ const shiftId = React14.useMemo(
3571
3723
  () => urlShiftId !== void 0 ? urlShiftId : currentShift.shiftId,
3572
3724
  [urlShiftId, currentShift.shiftId]
3573
3725
  );
3574
- const date = React33.useMemo(() => urlDate || getOperationalDate(dateTimeConfig.defaultTimezone), [urlDate, dateTimeConfig.defaultTimezone]);
3575
- const fetchData = React33.useCallback(async () => {
3726
+ const date = React14.useMemo(() => urlDate || getOperationalDate(dateTimeConfig.defaultTimezone), [urlDate, dateTimeConfig.defaultTimezone]);
3727
+ const fetchData = React14.useCallback(async () => {
3576
3728
  try {
3577
3729
  if (!lineIdRef.current || isFetchingRef.current) return;
3578
3730
  isFetchingRef.current = true;
@@ -3783,7 +3935,7 @@ var useRealtimeLineMetrics = ({
3783
3935
  isFetchingRef.current = false;
3784
3936
  }
3785
3937
  }, [supabase, date, shiftId, urlShiftId, onMetricsUpdate, entityConfig, dateTimeConfig.defaultTimezone]);
3786
- const queueUpdate = React33.useCallback(() => {
3938
+ const queueUpdate = React14.useCallback(() => {
3787
3939
  if (updateQueueRef.current) return;
3788
3940
  updateQueueRef.current = true;
3789
3941
  if (timeoutRef.current) {
@@ -3793,7 +3945,7 @@ var useRealtimeLineMetrics = ({
3793
3945
  fetchData();
3794
3946
  }, 500);
3795
3947
  }, [fetchData]);
3796
- const setupSubscriptions = React33.useCallback(() => {
3948
+ const setupSubscriptions = React14.useCallback(() => {
3797
3949
  if (channelsRef.current.length > 0) {
3798
3950
  channelsRef.current.forEach((channel) => {
3799
3951
  supabase.removeChannel(channel);
@@ -3863,7 +4015,7 @@ var useRealtimeLineMetrics = ({
3863
4015
  });
3864
4016
  channelsRef.current = [lineMetricsChannel, metricsChannel];
3865
4017
  }, [supabase, queueUpdate, urlDate, shiftId, entityConfig, dateTimeConfig.defaultTimezone]);
3866
- React33.useEffect(() => {
4018
+ React14.useEffect(() => {
3867
4019
  if (!lineId) return;
3868
4020
  lineIdRef.current = lineId;
3869
4021
  if (!initialized) {
@@ -3884,10 +4036,10 @@ var useRealtimeLineMetrics = ({
3884
4036
  }
3885
4037
  };
3886
4038
  }, [lineId, fetchData, setupSubscriptions, initialized, supabase]);
3887
- React33.useEffect(() => {
4039
+ React14.useEffect(() => {
3888
4040
  setInitialized(false);
3889
4041
  }, [lineId, date, shiftId]);
3890
- return React33.useMemo(() => ({
4042
+ return React14.useMemo(() => ({
3891
4043
  metrics: metrics2,
3892
4044
  lineDetails,
3893
4045
  loading,
@@ -3899,11 +4051,11 @@ var DEFAULT_TARGETS_TABLE_NAME = "targets";
3899
4051
  var useTargets = (options) => {
3900
4052
  const { companyId } = useEntityConfig();
3901
4053
  const supabase = useSupabase();
3902
- const [targets, setTargets] = React33.useState([]);
3903
- const [isLoading, setIsLoading] = React33.useState(true);
3904
- const [error, setError] = React33.useState(null);
4054
+ const [targets, setTargets] = React14.useState([]);
4055
+ const [isLoading, setIsLoading] = React14.useState(true);
4056
+ const [error, setError] = React14.useState(null);
3905
4057
  const targetsTable = DEFAULT_TARGETS_TABLE_NAME;
3906
- const fetchData = React33.useCallback(async () => {
4058
+ const fetchData = React14.useCallback(async () => {
3907
4059
  if (!supabase) {
3908
4060
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
3909
4061
  setIsLoading(false);
@@ -3947,7 +4099,7 @@ var useTargets = (options) => {
3947
4099
  setIsLoading(false);
3948
4100
  }
3949
4101
  }, [supabase, companyId, targetsTable, options]);
3950
- React33.useEffect(() => {
4102
+ React14.useEffect(() => {
3951
4103
  fetchData();
3952
4104
  }, [fetchData]);
3953
4105
  return {
@@ -3962,15 +4114,15 @@ var useShifts = () => {
3962
4114
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
3963
4115
  const { companyId } = useEntityConfig();
3964
4116
  const { tables } = useDatabaseConfig();
3965
- const [shifts, setShifts] = React33.useState([]);
3966
- const [isLoading, setIsLoading] = React33.useState(true);
3967
- const [error, setError] = React33.useState(null);
3968
- const supabase = React33.useMemo(() => {
4117
+ const [shifts, setShifts] = React14.useState([]);
4118
+ const [isLoading, setIsLoading] = React14.useState(true);
4119
+ const [error, setError] = React14.useState(null);
4120
+ const supabase = React14.useMemo(() => {
3969
4121
  if (!supabaseUrl || !supabaseKey) return null;
3970
4122
  return supabaseJs.createClient(supabaseUrl, supabaseKey);
3971
4123
  }, [supabaseUrl, supabaseKey]);
3972
4124
  const shiftsTable = tables?.shiftConfigurations || DEFAULT_SHIFTS_TABLE_NAME;
3973
- const fetchData = React33.useCallback(async () => {
4125
+ const fetchData = React14.useCallback(async () => {
3974
4126
  if (!supabase) {
3975
4127
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
3976
4128
  setIsLoading(false);
@@ -3999,7 +4151,7 @@ var useShifts = () => {
3999
4151
  setIsLoading(false);
4000
4152
  }
4001
4153
  }, [supabase, companyId, shiftsTable]);
4002
- React33.useEffect(() => {
4154
+ React14.useEffect(() => {
4003
4155
  fetchData();
4004
4156
  }, [fetchData]);
4005
4157
  return {
@@ -4013,11 +4165,11 @@ var DEFAULT_OPERATORS_TABLE_NAME = "workspace_operator_assignments";
4013
4165
  var useWorkspaceOperators = (workspaceId, options) => {
4014
4166
  const { companyId } = useEntityConfig();
4015
4167
  const supabase = useSupabase();
4016
- const [operators, setOperators] = React33.useState([]);
4017
- const [isLoading, setIsLoading] = React33.useState(true);
4018
- const [error, setError] = React33.useState(null);
4168
+ const [operators, setOperators] = React14.useState([]);
4169
+ const [isLoading, setIsLoading] = React14.useState(true);
4170
+ const [error, setError] = React14.useState(null);
4019
4171
  const operatorsTable = DEFAULT_OPERATORS_TABLE_NAME;
4020
- const fetchData = React33.useCallback(async () => {
4172
+ const fetchData = React14.useCallback(async () => {
4021
4173
  if (!workspaceId) {
4022
4174
  setError({ message: "Workspace ID is required.", code: "MISSING_PARAM" });
4023
4175
  setIsLoading(false);
@@ -4059,7 +4211,7 @@ var useWorkspaceOperators = (workspaceId, options) => {
4059
4211
  setIsLoading(false);
4060
4212
  }
4061
4213
  }, [supabase, companyId, workspaceId, operatorsTable, options]);
4062
- React33.useEffect(() => {
4214
+ React14.useEffect(() => {
4063
4215
  fetchData();
4064
4216
  }, [fetchData]);
4065
4217
  return {
@@ -4100,7 +4252,7 @@ function useThreads() {
4100
4252
  revalidateOnFocus: false,
4101
4253
  revalidateOnReconnect: true
4102
4254
  });
4103
- const createThread = React33.useCallback(async (title) => {
4255
+ const createThread = React14.useCallback(async (title) => {
4104
4256
  const { data: { session } } = await supabase.auth.getSession();
4105
4257
  if (!session?.user) throw new Error("Not authenticated");
4106
4258
  const user = session.user;
@@ -4122,7 +4274,7 @@ function useThreads() {
4122
4274
  mutate([data, ...threads], false);
4123
4275
  return data;
4124
4276
  }, [supabase, threads, mutate]);
4125
- const deleteThread2 = React33.useCallback(async (threadId) => {
4277
+ const deleteThread2 = React14.useCallback(async (threadId) => {
4126
4278
  const { error: error2 } = await supabase.schema("ai").from("chat_threads").delete().eq("id", threadId);
4127
4279
  if (error2) throw error2;
4128
4280
  mutate(threads.filter((t) => t.id !== threadId), false);
@@ -4138,10 +4290,10 @@ function useThreads() {
4138
4290
  }
4139
4291
  function useMessages(threadId) {
4140
4292
  const supabase = _getSupabaseInstance();
4141
- const [messages, setMessages] = React33.useState([]);
4142
- const [isLoading, setIsLoading] = React33.useState(true);
4143
- const [error, setError] = React33.useState(null);
4144
- React33.useEffect(() => {
4293
+ const [messages, setMessages] = React14.useState([]);
4294
+ const [isLoading, setIsLoading] = React14.useState(true);
4295
+ const [error, setError] = React14.useState(null);
4296
+ React14.useEffect(() => {
4145
4297
  if (!threadId) {
4146
4298
  setMessages([]);
4147
4299
  setIsLoading(false);
@@ -4163,7 +4315,7 @@ function useMessages(threadId) {
4163
4315
  };
4164
4316
  loadMessages();
4165
4317
  }, [threadId, supabase]);
4166
- const addMessage = React33.useCallback(async (message) => {
4318
+ const addMessage = React14.useCallback(async (message) => {
4167
4319
  const maxPosition = messages.reduce((max, msg) => Math.max(max, msg.position), -1);
4168
4320
  const { data, error: insertError } = await supabase.schema("ai").from("chat_messages").insert([{
4169
4321
  ...message,
@@ -4172,7 +4324,7 @@ function useMessages(threadId) {
4172
4324
  if (insertError) throw insertError;
4173
4325
  return data;
4174
4326
  }, [supabase, messages]);
4175
- const updateMessage = React33.useCallback(async (id3, content) => {
4327
+ const updateMessage = React14.useCallback(async (id3, content) => {
4176
4328
  const { error: updateError } = await supabase.schema("ai").from("chat_messages").update({ content }).eq("id", id3);
4177
4329
  if (updateError) throw updateError;
4178
4330
  }, [supabase]);
@@ -4191,14 +4343,14 @@ var useFactoryOverviewMetrics = (options) => {
4191
4343
  const { defaultTimezone } = useDateTimeConfig();
4192
4344
  const shiftConfig = useShiftConfig();
4193
4345
  const supabase = useSupabase();
4194
- const [factoryOverview, setFactoryOverview] = React33.useState(null);
4195
- const [isLoading, setIsLoading] = React33.useState(true);
4196
- const [error, setError] = React33.useState(null);
4346
+ const [factoryOverview, setFactoryOverview] = React14.useState(null);
4347
+ const [isLoading, setIsLoading] = React14.useState(true);
4348
+ const [error, setError] = React14.useState(null);
4197
4349
  const overviewTable = DEFAULT_FACTORY_OVERVIEW_TABLE_NAME;
4198
4350
  const determinedDate = options?.date;
4199
4351
  const determinedShiftId = options?.shiftId;
4200
4352
  const targetFactoryId = options?.factoryId || entityFactoryId;
4201
- const fetchData = React33.useCallback(async () => {
4353
+ const fetchData = React14.useCallback(async () => {
4202
4354
  if (!supabase) {
4203
4355
  setError({ message: "Supabase client not initialized.", code: "CLIENT_INIT_ERROR" });
4204
4356
  setIsLoading(false);
@@ -4237,7 +4389,7 @@ var useFactoryOverviewMetrics = (options) => {
4237
4389
  setIsLoading(false);
4238
4390
  }
4239
4391
  }, [supabase, companyId, targetFactoryId, overviewTable, determinedDate, determinedShiftId, defaultTimezone, shiftConfig]);
4240
- React33.useEffect(() => {
4392
+ React14.useEffect(() => {
4241
4393
  fetchData();
4242
4394
  }, [fetchData]);
4243
4395
  return {
@@ -4312,8 +4464,26 @@ async function initializeWorkspaceDisplayNames(explicitLineId) {
4312
4464
  isInitializing = false;
4313
4465
  }
4314
4466
  }
4467
+ var preInitializeWorkspaceDisplayNames = async (lineId) => {
4468
+ console.log("\u{1F504} preInitializeWorkspaceDisplayNames called for lineId:", lineId);
4469
+ if (isInitialized || isInitializing) {
4470
+ console.log("\u{1F504} Already initialized or initializing, skipping pre-init");
4471
+ return;
4472
+ }
4473
+ await initializeWorkspaceDisplayNames(lineId);
4474
+ };
4475
+ var forceRefreshWorkspaceDisplayNames = async (lineId) => {
4476
+ console.log("\u{1F504} forceRefreshWorkspaceDisplayNames called for lineId:", lineId);
4477
+ clearWorkspaceDisplayNamesCache();
4478
+ await initializeWorkspaceDisplayNames(lineId);
4479
+ };
4315
4480
  console.log("\u{1F504} Module loaded, will initialize lazily when first function is called");
4316
4481
  var getWorkspaceDisplayName = (workspaceId, lineId) => {
4482
+ if (!isInitialized && !isInitializing) {
4483
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Not initialized, triggering lazy init...`);
4484
+ } else if (isInitializing) {
4485
+ console.log(`\u{1F504} [DEBUG] getWorkspaceDisplayName(${workspaceId}) - Currently initializing...`);
4486
+ }
4317
4487
  if (!isInitialized && !isInitializing) {
4318
4488
  console.log("\u{1F504} Lazy initialization triggered by getWorkspaceDisplayName");
4319
4489
  initializeWorkspaceDisplayNames(lineId).catch((error) => {
@@ -4397,14 +4567,15 @@ var clearWorkspaceDisplayNamesCache = () => {
4397
4567
  workspaceService.clearWorkspaceDisplayNamesCache();
4398
4568
  runtimeWorkspaceDisplayNames = {};
4399
4569
  isInitialized = false;
4570
+ isInitializing = false;
4400
4571
  };
4401
4572
 
4402
4573
  // src/lib/hooks/useWorkspaceDisplayNames.ts
4403
4574
  var useWorkspaceDisplayNames = (companyId, lineId) => {
4404
- const [displayNames, setDisplayNames] = React33.useState({});
4405
- const [loading, setLoading] = React33.useState(true);
4406
- const [error, setError] = React33.useState(null);
4407
- const fetchDisplayNames = React33.useCallback(async () => {
4575
+ const [displayNames, setDisplayNames] = React14.useState({});
4576
+ const [loading, setLoading] = React14.useState(true);
4577
+ const [error, setError] = React14.useState(null);
4578
+ const fetchDisplayNames = React14.useCallback(async () => {
4408
4579
  try {
4409
4580
  setLoading(true);
4410
4581
  setError(null);
@@ -4416,7 +4587,7 @@ var useWorkspaceDisplayNames = (companyId, lineId) => {
4416
4587
  setLoading(false);
4417
4588
  }
4418
4589
  }, [companyId, lineId]);
4419
- React33.useEffect(() => {
4590
+ React14.useEffect(() => {
4420
4591
  fetchDisplayNames();
4421
4592
  }, [fetchDisplayNames]);
4422
4593
  return {
@@ -4427,10 +4598,10 @@ var useWorkspaceDisplayNames = (companyId, lineId) => {
4427
4598
  };
4428
4599
  };
4429
4600
  var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4430
- const [displayName, setDisplayName] = React33.useState(workspaceId);
4431
- const [loading, setLoading] = React33.useState(true);
4432
- const [error, setError] = React33.useState(null);
4433
- const fetchDisplayName = React33.useCallback(async () => {
4601
+ const [displayName, setDisplayName] = React14.useState(workspaceId);
4602
+ const [loading, setLoading] = React14.useState(true);
4603
+ const [error, setError] = React14.useState(null);
4604
+ const fetchDisplayName = React14.useCallback(async () => {
4434
4605
  try {
4435
4606
  setLoading(true);
4436
4607
  setError(null);
@@ -4443,7 +4614,7 @@ var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4443
4614
  setLoading(false);
4444
4615
  }
4445
4616
  }, [workspaceId, companyId, lineId]);
4446
- React33.useEffect(() => {
4617
+ React14.useEffect(() => {
4447
4618
  fetchDisplayName();
4448
4619
  }, [fetchDisplayName]);
4449
4620
  return {
@@ -4454,10 +4625,10 @@ var useWorkspaceDisplayName = (workspaceId, companyId, lineId) => {
4454
4625
  };
4455
4626
  };
4456
4627
  var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4457
- const [displayNames, setDisplayNames] = React33.useState({});
4458
- const [loading, setLoading] = React33.useState(true);
4459
- const [error, setError] = React33.useState(null);
4460
- const fetchDisplayNames = React33.useCallback(async () => {
4628
+ const [displayNames, setDisplayNames] = React14.useState({});
4629
+ const [loading, setLoading] = React14.useState(true);
4630
+ const [error, setError] = React14.useState(null);
4631
+ const fetchDisplayNames = React14.useCallback(async () => {
4461
4632
  try {
4462
4633
  setLoading(true);
4463
4634
  setError(null);
@@ -4473,7 +4644,7 @@ var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4473
4644
  setLoading(false);
4474
4645
  }
4475
4646
  }, [workspaceIds, companyId, lineId]);
4476
- React33.useEffect(() => {
4647
+ React14.useEffect(() => {
4477
4648
  fetchDisplayNames();
4478
4649
  }, [fetchDisplayNames]);
4479
4650
  return {
@@ -4484,9 +4655,9 @@ var useWorkspaceDisplayNamesMap = (workspaceIds, companyId, lineId) => {
4484
4655
  };
4485
4656
  };
4486
4657
  var useActiveBreaks = (lineIds) => {
4487
- const [activeBreaks, setActiveBreaks] = React33.useState([]);
4488
- const [isLoading, setIsLoading] = React33.useState(true);
4489
- const [error, setError] = React33.useState(null);
4658
+ const [activeBreaks, setActiveBreaks] = React14.useState([]);
4659
+ const [isLoading, setIsLoading] = React14.useState(true);
4660
+ const [error, setError] = React14.useState(null);
4490
4661
  const supabase = useSupabase();
4491
4662
  const parseTimeToMinutes2 = (timeStr) => {
4492
4663
  const [hours, minutes] = timeStr.split(":").map(Number);
@@ -4533,7 +4704,7 @@ var useActiveBreaks = (lineIds) => {
4533
4704
  return currentMinutes >= dayStartMinutes && currentMinutes < nightStartMinutes ? "day" : "night";
4534
4705
  }
4535
4706
  };
4536
- const checkActiveBreaks = React33.useCallback(async () => {
4707
+ const checkActiveBreaks = React14.useCallback(async () => {
4537
4708
  try {
4538
4709
  setError(null);
4539
4710
  if (!lineIds || lineIds.length === 0) {
@@ -4598,7 +4769,7 @@ var useActiveBreaks = (lineIds) => {
4598
4769
  setIsLoading(false);
4599
4770
  }
4600
4771
  }, [lineIds, supabase]);
4601
- React33.useEffect(() => {
4772
+ React14.useEffect(() => {
4602
4773
  checkActiveBreaks();
4603
4774
  const interval = setInterval(checkActiveBreaks, 6e4);
4604
4775
  return () => clearInterval(interval);
@@ -4617,18 +4788,18 @@ function useNavigation(customNavigate) {
4617
4788
  const pathname = router$1.pathname;
4618
4789
  const query = router$1.query;
4619
4790
  const isReady = router$1.isReady;
4620
- const isActive = React33.useCallback((path) => {
4791
+ const isActive = React14.useCallback((path) => {
4621
4792
  const normalizedPath = path.endsWith("/") ? path.slice(0, -1) : path;
4622
4793
  const normalizedPathname = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname;
4623
4794
  return normalizedPathname === normalizedPath;
4624
4795
  }, [pathname]);
4625
- const isInSection = React33.useCallback((path) => {
4796
+ const isInSection = React14.useCallback((path) => {
4626
4797
  return pathname.startsWith(path);
4627
4798
  }, [pathname]);
4628
- const goToDashboard = React33.useCallback(() => {
4799
+ const goToDashboard = React14.useCallback(() => {
4629
4800
  router$1.push("/");
4630
4801
  }, [router$1]);
4631
- const goToWorkspace = React33.useCallback(({ workspaceId, date, shift, sourceType }) => {
4802
+ const goToWorkspace = React14.useCallback(({ workspaceId, date, shift, sourceType }) => {
4632
4803
  const queryParams = {};
4633
4804
  if (date) queryParams.date = date;
4634
4805
  if (shift !== void 0) queryParams.shift = String(shift);
@@ -4638,7 +4809,7 @@ function useNavigation(customNavigate) {
4638
4809
  query: queryParams
4639
4810
  });
4640
4811
  }, [router$1]);
4641
- const goToLine = React33.useCallback(({ lineId, date, shift, tab }) => {
4812
+ const goToLine = React14.useCallback(({ lineId, date, shift, tab }) => {
4642
4813
  const queryParams = {};
4643
4814
  if (date) queryParams.date = date;
4644
4815
  if (shift !== void 0) queryParams.shift = String(shift);
@@ -4648,42 +4819,42 @@ function useNavigation(customNavigate) {
4648
4819
  query: queryParams
4649
4820
  });
4650
4821
  }, [router$1]);
4651
- const goToTargets = React33.useCallback(() => {
4822
+ const goToTargets = React14.useCallback(() => {
4652
4823
  router$1.push("/targets");
4653
4824
  }, [router$1]);
4654
- const goToShifts = React33.useCallback(() => {
4825
+ const goToShifts = React14.useCallback(() => {
4655
4826
  router$1.push("/shifts");
4656
4827
  }, [router$1]);
4657
- const goToLeaderboard = React33.useCallback(() => {
4828
+ const goToLeaderboard = React14.useCallback(() => {
4658
4829
  const lineId = entityConfig?.defaultLineId || "line-1";
4659
4830
  router$1.push(`/leaderboard/${lineId}`);
4660
4831
  }, [router$1, entityConfig?.defaultLineId]);
4661
- const goToFactoryView = React33.useCallback(() => {
4832
+ const goToFactoryView = React14.useCallback(() => {
4662
4833
  router$1.push("/factory-view");
4663
4834
  }, [router$1]);
4664
- const goToProfile = React33.useCallback(() => {
4835
+ const goToProfile = React14.useCallback(() => {
4665
4836
  router$1.push("/profile");
4666
4837
  }, [router$1]);
4667
- const isLineView = React33.useMemo(() => {
4838
+ const isLineView = React14.useMemo(() => {
4668
4839
  return pathname.startsWith("/kpis/") && !!router$1.query.lineId;
4669
4840
  }, [pathname, router$1.query.lineId]);
4670
- const isWorkspaceView = React33.useMemo(() => {
4841
+ const isWorkspaceView = React14.useMemo(() => {
4671
4842
  return pathname.startsWith("/workspace/") && !!router$1.query.id;
4672
4843
  }, [pathname, router$1.query.id]);
4673
4844
  const defaultLineIdFromConfig = entityConfig?.defaultLineId;
4674
- const activeLineId = React33.useMemo(() => {
4845
+ const activeLineId = React14.useMemo(() => {
4675
4846
  if (isLineView && typeof router$1.query.lineId === "string") {
4676
4847
  return router$1.query.lineId;
4677
4848
  }
4678
4849
  return defaultLineIdFromConfig;
4679
4850
  }, [isLineView, router$1.query.lineId, defaultLineIdFromConfig]);
4680
- const activeWorkspaceId = React33.useMemo(() => {
4851
+ const activeWorkspaceId = React14.useMemo(() => {
4681
4852
  if (isWorkspaceView && typeof router$1.query.id === "string") {
4682
4853
  return router$1.query.id;
4683
4854
  }
4684
4855
  return null;
4685
4856
  }, [isWorkspaceView, router$1.query.id]);
4686
- const navigate = React33.useCallback(
4857
+ const navigate = React14.useCallback(
4687
4858
  async (path, options) => {
4688
4859
  if (options?.trackingEvent) {
4689
4860
  trackCoreEvent(options.trackingEvent.name, options.trackingEvent.properties);
@@ -4732,7 +4903,7 @@ function useNavigation(customNavigate) {
4732
4903
  }
4733
4904
  function useWorkspaceNavigation() {
4734
4905
  const { defaultTimezone } = useDateTimeConfig();
4735
- const getWorkspaceNavigationParams3 = React33.useCallback(
4906
+ const getWorkspaceNavigationParams3 = React14.useCallback(
4736
4907
  (workspaceId, options) => {
4737
4908
  let dateToUse = options?.date;
4738
4909
  if (!dateToUse && options?.useCurrentDate) {
@@ -4753,7 +4924,7 @@ function useWorkspaceNavigation() {
4753
4924
  }
4754
4925
  function useDateFormatter() {
4755
4926
  const { defaultTimezone, defaultLocale, dateFormatOptions, timeFormatOptions, dateTimeFormatOptions } = useDateTimeConfig();
4756
- const formatDate = React33.useCallback(
4927
+ const formatDate = React14.useCallback(
4757
4928
  (date, formatString) => {
4758
4929
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4759
4930
  if (!dateFns.isValid(dateObj)) return "Invalid Date";
@@ -4766,7 +4937,7 @@ function useDateFormatter() {
4766
4937
  },
4767
4938
  [defaultTimezone, defaultLocale, dateFormatOptions]
4768
4939
  );
4769
- const formatTime2 = React33.useCallback(
4940
+ const formatTime2 = React14.useCallback(
4770
4941
  (date, formatString) => {
4771
4942
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4772
4943
  if (!dateFns.isValid(dateObj)) return "Invalid Time";
@@ -4779,7 +4950,7 @@ function useDateFormatter() {
4779
4950
  },
4780
4951
  [defaultTimezone, defaultLocale, timeFormatOptions]
4781
4952
  );
4782
- const formatDateTime = React33.useCallback(
4953
+ const formatDateTime = React14.useCallback(
4783
4954
  (date, formatString) => {
4784
4955
  const dateObj = typeof date === "string" ? dateFns.parseISO(date) : date;
4785
4956
  if (!dateFns.isValid(dateObj)) return "Invalid Date/Time";
@@ -4792,7 +4963,7 @@ function useDateFormatter() {
4792
4963
  },
4793
4964
  [defaultTimezone, defaultLocale, dateTimeFormatOptions]
4794
4965
  );
4795
- const getNow = React33.useCallback(() => {
4966
+ const getNow = React14.useCallback(() => {
4796
4967
  return /* @__PURE__ */ new Date();
4797
4968
  }, []);
4798
4969
  return {
@@ -4806,7 +4977,7 @@ function useDateFormatter() {
4806
4977
  }
4807
4978
  var useFormatNumber = () => {
4808
4979
  const { defaultLocale } = useDateTimeConfig();
4809
- const formatNumber = React33.useCallback(
4980
+ const formatNumber = React14.useCallback(
4810
4981
  (value, options) => {
4811
4982
  try {
4812
4983
  return new Intl.NumberFormat(defaultLocale || "en-US", options).format(value);
@@ -4866,14 +5037,14 @@ var HLS_CONFIG = {
4866
5037
  // Follow live edge aggressively
4867
5038
  };
4868
5039
  function useHlsStream(videoRef, { src, shouldPlay, onFatalError }) {
4869
- const [restartKey, setRestartKey] = React33.useState(0);
4870
- const hlsRef = React33.useRef(null);
4871
- const stallCheckIntervalRef = React33.useRef(null);
4872
- const noProgressTimerRef = React33.useRef(null);
4873
- const lastTimeUpdateRef = React33.useRef(0);
4874
- const softRestartCountRef = React33.useRef(0);
4875
- const isNativeHlsRef = React33.useRef(false);
4876
- const waitingTimerRef = React33.useRef(null);
5040
+ const [restartKey, setRestartKey] = React14.useState(0);
5041
+ const hlsRef = React14.useRef(null);
5042
+ const stallCheckIntervalRef = React14.useRef(null);
5043
+ const noProgressTimerRef = React14.useRef(null);
5044
+ const lastTimeUpdateRef = React14.useRef(0);
5045
+ const softRestartCountRef = React14.useRef(0);
5046
+ const isNativeHlsRef = React14.useRef(false);
5047
+ const waitingTimerRef = React14.useRef(null);
4877
5048
  const cleanup = () => {
4878
5049
  if (stallCheckIntervalRef.current) {
4879
5050
  clearInterval(stallCheckIntervalRef.current);
@@ -4995,7 +5166,7 @@ function useHlsStream(videoRef, { src, shouldPlay, onFatalError }) {
4995
5166
  }
4996
5167
  }, 7e3);
4997
5168
  };
4998
- React33.useEffect(() => {
5169
+ React14.useEffect(() => {
4999
5170
  if (!src || !shouldPlay) {
5000
5171
  cleanup();
5001
5172
  return;
@@ -8014,7 +8185,7 @@ var formatIdleTime = (idleTimeInSeconds) => {
8014
8185
  };
8015
8186
  function useSupabaseClient() {
8016
8187
  const { supabaseUrl, supabaseKey } = useDashboardConfig();
8017
- const supabase = React33.useMemo(() => supabaseJs.createClient(supabaseUrl, supabaseKey), [supabaseUrl, supabaseKey]);
8188
+ const supabase = React14.useMemo(() => supabaseJs.createClient(supabaseUrl, supabaseKey), [supabaseUrl, supabaseKey]);
8018
8189
  return supabase;
8019
8190
  }
8020
8191
  var createSupabaseClient = (url, key) => supabaseJs.createClient(url, key, {
@@ -8049,23 +8220,23 @@ var getAnonClient = () => {
8049
8220
  }
8050
8221
  });
8051
8222
  };
8052
- var LayoutGroupContext = React33.createContext({});
8223
+ var LayoutGroupContext = React14.createContext({});
8053
8224
  function useConstant(init) {
8054
- const ref = React33.useRef(null);
8225
+ const ref = React14.useRef(null);
8055
8226
  if (ref.current === null) {
8056
8227
  ref.current = init();
8057
8228
  }
8058
8229
  return ref.current;
8059
8230
  }
8060
- var PresenceContext = React33.createContext(null);
8061
- var MotionConfigContext = React33.createContext({
8231
+ var PresenceContext = React14.createContext(null);
8232
+ var MotionConfigContext = React14.createContext({
8062
8233
  transformPagePoint: (p) => p,
8063
8234
  isStatic: false,
8064
8235
  reducedMotion: "never"
8065
8236
  });
8066
8237
 
8067
8238
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PopChild.mjs
8068
- var PopChildMeasure = class extends React33__namespace.Component {
8239
+ var PopChildMeasure = class extends React14__namespace.Component {
8069
8240
  getSnapshotBeforeUpdate(prevProps) {
8070
8241
  const element = this.props.childRef.current;
8071
8242
  if (element && prevProps.isPresent && !this.props.isPresent) {
@@ -8087,16 +8258,16 @@ var PopChildMeasure = class extends React33__namespace.Component {
8087
8258
  }
8088
8259
  };
8089
8260
  function PopChild({ children, isPresent }) {
8090
- const id3 = React33.useId();
8091
- const ref = React33.useRef(null);
8092
- const size = React33.useRef({
8261
+ const id3 = React14.useId();
8262
+ const ref = React14.useRef(null);
8263
+ const size = React14.useRef({
8093
8264
  width: 0,
8094
8265
  height: 0,
8095
8266
  top: 0,
8096
8267
  left: 0
8097
8268
  });
8098
- const { nonce } = React33.useContext(MotionConfigContext);
8099
- React33.useInsertionEffect(() => {
8269
+ const { nonce } = React14.useContext(MotionConfigContext);
8270
+ React14.useInsertionEffect(() => {
8100
8271
  const { width, height, top, left } = size.current;
8101
8272
  if (isPresent || !ref.current || !width || !height)
8102
8273
  return;
@@ -8120,14 +8291,14 @@ function PopChild({ children, isPresent }) {
8120
8291
  document.head.removeChild(style);
8121
8292
  };
8122
8293
  }, [isPresent]);
8123
- return jsxRuntime.jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React33__namespace.cloneElement(children, { ref }) });
8294
+ return jsxRuntime.jsx(PopChildMeasure, { isPresent, childRef: ref, sizeRef: size, children: React14__namespace.cloneElement(children, { ref }) });
8124
8295
  }
8125
8296
 
8126
8297
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/PresenceChild.mjs
8127
8298
  var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, presenceAffectsLayout, mode }) => {
8128
8299
  const presenceChildren = useConstant(newChildrenMap);
8129
- const id3 = React33.useId();
8130
- const memoizedOnExitComplete = React33.useCallback((childId) => {
8300
+ const id3 = React14.useId();
8301
+ const memoizedOnExitComplete = React14.useCallback((childId) => {
8131
8302
  presenceChildren.set(childId, true);
8132
8303
  for (const isComplete of presenceChildren.values()) {
8133
8304
  if (!isComplete)
@@ -8135,7 +8306,7 @@ var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, pre
8135
8306
  }
8136
8307
  onExitComplete && onExitComplete();
8137
8308
  }, [presenceChildren, onExitComplete]);
8138
- const context = React33.useMemo(
8309
+ const context = React14.useMemo(
8139
8310
  () => ({
8140
8311
  id: id3,
8141
8312
  initial,
@@ -8154,10 +8325,10 @@ var PresenceChild = ({ children, initial, isPresent, onExitComplete, custom, pre
8154
8325
  */
8155
8326
  presenceAffectsLayout ? [Math.random(), memoizedOnExitComplete] : [isPresent, memoizedOnExitComplete]
8156
8327
  );
8157
- React33.useMemo(() => {
8328
+ React14.useMemo(() => {
8158
8329
  presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
8159
8330
  }, [isPresent]);
8160
- React33__namespace.useEffect(() => {
8331
+ React14__namespace.useEffect(() => {
8161
8332
  !isPresent && !presenceChildren.size && onExitComplete && onExitComplete();
8162
8333
  }, [isPresent]);
8163
8334
  if (mode === "popLayout") {
@@ -8169,23 +8340,23 @@ function newChildrenMap() {
8169
8340
  return /* @__PURE__ */ new Map();
8170
8341
  }
8171
8342
  function usePresence(subscribe = true) {
8172
- const context = React33.useContext(PresenceContext);
8343
+ const context = React14.useContext(PresenceContext);
8173
8344
  if (context === null)
8174
8345
  return [true, null];
8175
8346
  const { isPresent, onExitComplete, register } = context;
8176
- const id3 = React33.useId();
8177
- React33.useEffect(() => {
8347
+ const id3 = React14.useId();
8348
+ React14.useEffect(() => {
8178
8349
  if (subscribe)
8179
8350
  register(id3);
8180
8351
  }, [subscribe]);
8181
- const safeToRemove = React33.useCallback(() => subscribe && onExitComplete && onExitComplete(id3), [id3, onExitComplete, subscribe]);
8352
+ const safeToRemove = React14.useCallback(() => subscribe && onExitComplete && onExitComplete(id3), [id3, onExitComplete, subscribe]);
8182
8353
  return !isPresent && onExitComplete ? [false, safeToRemove] : [true];
8183
8354
  }
8184
8355
  var getChildKey = (child) => child.key || "";
8185
8356
  function onlyElements(children) {
8186
8357
  const filtered = [];
8187
- React33.Children.forEach(children, (child) => {
8188
- if (React33.isValidElement(child))
8358
+ React14.Children.forEach(children, (child) => {
8359
+ if (React14.isValidElement(child))
8189
8360
  filtered.push(child);
8190
8361
  });
8191
8362
  return filtered;
@@ -8195,18 +8366,18 @@ function onlyElements(children) {
8195
8366
  var isBrowser = typeof window !== "undefined";
8196
8367
 
8197
8368
  // ../../node_modules/framer-motion/dist/es/utils/use-isomorphic-effect.mjs
8198
- var useIsomorphicLayoutEffect = isBrowser ? React33.useLayoutEffect : React33.useEffect;
8369
+ var useIsomorphicLayoutEffect = isBrowser ? React14.useLayoutEffect : React14.useEffect;
8199
8370
 
8200
8371
  // ../../node_modules/framer-motion/dist/es/components/AnimatePresence/index.mjs
8201
8372
  var AnimatePresence = ({ children, custom, initial = true, onExitComplete, presenceAffectsLayout = true, mode = "sync", propagate = false }) => {
8202
8373
  const [isParentPresent, safeToRemove] = usePresence(propagate);
8203
- const presentChildren = React33.useMemo(() => onlyElements(children), [children]);
8374
+ const presentChildren = React14.useMemo(() => onlyElements(children), [children]);
8204
8375
  const presentKeys = propagate && !isParentPresent ? [] : presentChildren.map(getChildKey);
8205
- const isInitialRender = React33.useRef(true);
8206
- const pendingPresentChildren = React33.useRef(presentChildren);
8376
+ const isInitialRender = React14.useRef(true);
8377
+ const pendingPresentChildren = React14.useRef(presentChildren);
8207
8378
  const exitComplete = useConstant(() => /* @__PURE__ */ new Map());
8208
- const [diffedChildren, setDiffedChildren] = React33.useState(presentChildren);
8209
- const [renderedChildren, setRenderedChildren] = React33.useState(presentChildren);
8379
+ const [diffedChildren, setDiffedChildren] = React14.useState(presentChildren);
8380
+ const [renderedChildren, setRenderedChildren] = React14.useState(presentChildren);
8210
8381
  useIsomorphicLayoutEffect(() => {
8211
8382
  isInitialRender.current = false;
8212
8383
  pendingPresentChildren.current = presentChildren;
@@ -8242,7 +8413,7 @@ var AnimatePresence = ({ children, custom, initial = true, onExitComplete, prese
8242
8413
  if (process.env.NODE_ENV !== "production" && mode === "wait" && renderedChildren.length > 1) {
8243
8414
  console.warn(`You're attempting to animate multiple children within AnimatePresence, but its mode is set to "wait". This will lead to odd visual behaviour.`);
8244
8415
  }
8245
- const { forceRender } = React33.useContext(LayoutGroupContext);
8416
+ const { forceRender } = React14.useContext(LayoutGroupContext);
8246
8417
  return jsxRuntime.jsx(jsxRuntime.Fragment, { children: renderedChildren.map((child) => {
8247
8418
  const key = getChildKey(child);
8248
8419
  const isPresent = propagate && !isParentPresent ? false : presentChildren === renderedChildren || presentKeys.includes(key);
@@ -8409,7 +8580,7 @@ function createRenderBatcher(scheduleNextBatch, allowKeepAlive) {
8409
8580
 
8410
8581
  // ../../node_modules/framer-motion/dist/es/frameloop/frame.mjs
8411
8582
  var { schedule: frame, cancel: cancelFrame, state: frameData, steps: frameSteps } = createRenderBatcher(typeof requestAnimationFrame !== "undefined" ? requestAnimationFrame : motionUtils.noop, true);
8412
- var LazyContext = React33.createContext({ strict: false });
8583
+ var LazyContext = React14.createContext({ strict: false });
8413
8584
 
8414
8585
  // ../../node_modules/framer-motion/dist/es/motion/features/definitions.mjs
8415
8586
  var featureProps = {
@@ -8547,7 +8718,7 @@ function createDOMMotionComponentProxy(componentFactory) {
8547
8718
  }
8548
8719
  });
8549
8720
  }
8550
- var MotionContext = React33.createContext({});
8721
+ var MotionContext = React14.createContext({});
8551
8722
 
8552
8723
  // ../../node_modules/framer-motion/dist/es/render/utils/is-variant-label.mjs
8553
8724
  function isVariantLabel(v) {
@@ -8593,8 +8764,8 @@ function getCurrentTreeVariants(props, context) {
8593
8764
 
8594
8765
  // ../../node_modules/framer-motion/dist/es/context/MotionContext/create.mjs
8595
8766
  function useCreateMotionContext(props) {
8596
- const { initial, animate } = getCurrentTreeVariants(props, React33.useContext(MotionContext));
8597
- return React33.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8767
+ const { initial, animate } = getCurrentTreeVariants(props, React14.useContext(MotionContext));
8768
+ return React14.useMemo(() => ({ initial, animate }), [variantLabelsAsDependency(initial), variantLabelsAsDependency(animate)]);
8598
8769
  }
8599
8770
  function variantLabelsAsDependency(prop) {
8600
8771
  return Array.isArray(prop) ? prop.join(" ") : prop;
@@ -8610,7 +8781,7 @@ function isRefObject(ref) {
8610
8781
 
8611
8782
  // ../../node_modules/framer-motion/dist/es/motion/utils/use-motion-ref.mjs
8612
8783
  function useMotionRef(visualState, visualElement, externalRef) {
8613
- return React33.useCallback(
8784
+ return React14.useCallback(
8614
8785
  (instance) => {
8615
8786
  if (instance) {
8616
8787
  visualState.onMount && visualState.onMount(instance);
@@ -8648,16 +8819,16 @@ var optimizedAppearDataAttribute = "data-" + camelToDash(optimizedAppearDataId);
8648
8819
 
8649
8820
  // ../../node_modules/framer-motion/dist/es/frameloop/microtask.mjs
8650
8821
  var { schedule: microtask} = createRenderBatcher(queueMicrotask, false);
8651
- var SwitchLayoutGroupContext = React33.createContext({});
8822
+ var SwitchLayoutGroupContext = React14.createContext({});
8652
8823
 
8653
8824
  // ../../node_modules/framer-motion/dist/es/motion/utils/use-visual-element.mjs
8654
8825
  function useVisualElement(Component3, visualState, props, createVisualElement, ProjectionNodeConstructor) {
8655
8826
  var _a, _b;
8656
- const { visualElement: parent } = React33.useContext(MotionContext);
8657
- const lazyContext = React33.useContext(LazyContext);
8658
- const presenceContext = React33.useContext(PresenceContext);
8659
- const reducedMotionConfig = React33.useContext(MotionConfigContext).reducedMotion;
8660
- const visualElementRef = React33.useRef(null);
8827
+ const { visualElement: parent } = React14.useContext(MotionContext);
8828
+ const lazyContext = React14.useContext(LazyContext);
8829
+ const presenceContext = React14.useContext(PresenceContext);
8830
+ const reducedMotionConfig = React14.useContext(MotionConfigContext).reducedMotion;
8831
+ const visualElementRef = React14.useRef(null);
8661
8832
  createVisualElement = createVisualElement || lazyContext.renderer;
8662
8833
  if (!visualElementRef.current && createVisualElement) {
8663
8834
  visualElementRef.current = createVisualElement(Component3, {
@@ -8670,18 +8841,18 @@ function useVisualElement(Component3, visualState, props, createVisualElement, P
8670
8841
  });
8671
8842
  }
8672
8843
  const visualElement = visualElementRef.current;
8673
- const initialLayoutGroupConfig = React33.useContext(SwitchLayoutGroupContext);
8844
+ const initialLayoutGroupConfig = React14.useContext(SwitchLayoutGroupContext);
8674
8845
  if (visualElement && !visualElement.projection && ProjectionNodeConstructor && (visualElement.type === "html" || visualElement.type === "svg")) {
8675
8846
  createProjectionNode(visualElementRef.current, props, ProjectionNodeConstructor, initialLayoutGroupConfig);
8676
8847
  }
8677
- const isMounted = React33.useRef(false);
8678
- React33.useInsertionEffect(() => {
8848
+ const isMounted = React14.useRef(false);
8849
+ React14.useInsertionEffect(() => {
8679
8850
  if (visualElement && isMounted.current) {
8680
8851
  visualElement.update(props, presenceContext);
8681
8852
  }
8682
8853
  });
8683
8854
  const optimisedAppearId = props[optimizedAppearDataAttribute];
8684
- const wantsHandoff = React33.useRef(Boolean(optimisedAppearId) && !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) && ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
8855
+ const wantsHandoff = React14.useRef(Boolean(optimisedAppearId) && !((_a = window.MotionHandoffIsComplete) === null || _a === void 0 ? void 0 : _a.call(window, optimisedAppearId)) && ((_b = window.MotionHasOptimisedAnimation) === null || _b === void 0 ? void 0 : _b.call(window, optimisedAppearId)));
8685
8856
  useIsomorphicLayoutEffect(() => {
8686
8857
  if (!visualElement)
8687
8858
  return;
@@ -8693,7 +8864,7 @@ function useVisualElement(Component3, visualState, props, createVisualElement, P
8693
8864
  visualElement.animationState.animateChanges();
8694
8865
  }
8695
8866
  });
8696
- React33.useEffect(() => {
8867
+ React14.useEffect(() => {
8697
8868
  if (!visualElement)
8698
8869
  return;
8699
8870
  if (!wantsHandoff.current && visualElement.animationState) {
@@ -8743,7 +8914,7 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
8743
8914
  function MotionComponent(props, externalRef) {
8744
8915
  let MeasureLayout2;
8745
8916
  const configAndProps = {
8746
- ...React33.useContext(MotionConfigContext),
8917
+ ...React14.useContext(MotionConfigContext),
8747
8918
  ...props,
8748
8919
  layoutId: useLayoutId(props)
8749
8920
  };
@@ -8759,16 +8930,16 @@ function createRendererMotionComponent({ preloadedFeatures, createVisualElement,
8759
8930
  return jsxRuntime.jsxs(MotionContext.Provider, { value: context, children: [MeasureLayout2 && context.visualElement ? jsxRuntime.jsx(MeasureLayout2, { visualElement: context.visualElement, ...configAndProps }) : null, useRender(Component3, props, useMotionRef(visualState, context.visualElement, externalRef), visualState, isStatic, context.visualElement)] });
8760
8931
  }
8761
8932
  MotionComponent.displayName = `motion.${typeof Component3 === "string" ? Component3 : `create(${(_b = (_a = Component3.displayName) !== null && _a !== void 0 ? _a : Component3.name) !== null && _b !== void 0 ? _b : ""})`}`;
8762
- const ForwardRefMotionComponent = React33.forwardRef(MotionComponent);
8933
+ const ForwardRefMotionComponent = React14.forwardRef(MotionComponent);
8763
8934
  ForwardRefMotionComponent[motionComponentSymbol] = Component3;
8764
8935
  return ForwardRefMotionComponent;
8765
8936
  }
8766
8937
  function useLayoutId({ layoutId }) {
8767
- const layoutGroupId = React33.useContext(LayoutGroupContext).id;
8938
+ const layoutGroupId = React14.useContext(LayoutGroupContext).id;
8768
8939
  return layoutGroupId && layoutId !== void 0 ? layoutGroupId + "-" + layoutId : layoutId;
8769
8940
  }
8770
8941
  function useStrictMode(configAndProps, preloadedFeatures) {
8771
- const isStrict = React33.useContext(LazyContext).strict;
8942
+ const isStrict = React14.useContext(LazyContext).strict;
8772
8943
  if (process.env.NODE_ENV !== "production" && preloadedFeatures && isStrict) {
8773
8944
  const strictMessage = "You have rendered a `motion` component within a `LazyMotion` component. This will break tree shaking. Import and render a `m` component instead.";
8774
8945
  configAndProps.ignoreStrict ? motionUtils.warning(false, strictMessage) : motionUtils.invariant(false, strictMessage);
@@ -8900,8 +9071,8 @@ function makeState({ scrapeMotionValuesFromProps: scrapeMotionValuesFromProps3,
8900
9071
  return state;
8901
9072
  }
8902
9073
  var makeUseVisualState = (config) => (props, isStatic) => {
8903
- const context = React33.useContext(MotionContext);
8904
- const presenceContext = React33.useContext(PresenceContext);
9074
+ const context = React14.useContext(MotionContext);
9075
+ const presenceContext = React14.useContext(PresenceContext);
8905
9076
  const make = () => makeState(config, props, context, presenceContext);
8906
9077
  return isStatic ? make() : useConstant(make);
8907
9078
  };
@@ -9427,7 +9598,7 @@ function copyRawValuesOnly(target, source, props) {
9427
9598
  }
9428
9599
  }
9429
9600
  function useInitialMotionValues({ transformTemplate }, visualState) {
9430
- return React33.useMemo(() => {
9601
+ return React14.useMemo(() => {
9431
9602
  const state = createHtmlRenderState();
9432
9603
  buildHTMLStyles(state, visualState, transformTemplate);
9433
9604
  return Object.assign({}, state.vars, state.style);
@@ -9455,7 +9626,7 @@ function useHTMLProps(props, visualState) {
9455
9626
  return htmlProps;
9456
9627
  }
9457
9628
  function useSVGProps(props, visualState, _isStatic, Component3) {
9458
- const visualProps = React33.useMemo(() => {
9629
+ const visualProps = React14.useMemo(() => {
9459
9630
  const state = createSvgRenderState();
9460
9631
  buildSVGAttrs(state, visualState, isSVGTag(Component3), props.transformTemplate);
9461
9632
  return {
@@ -9477,10 +9648,10 @@ function createUseRender(forwardMotionProps = false) {
9477
9648
  const useVisualProps = isSVGComponent(Component3) ? useSVGProps : useHTMLProps;
9478
9649
  const visualProps = useVisualProps(props, latestValues, isStatic, Component3);
9479
9650
  const filteredProps = filterProps(props, typeof Component3 === "string", forwardMotionProps);
9480
- const elementProps = Component3 !== React33.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
9651
+ const elementProps = Component3 !== React14.Fragment ? { ...filteredProps, ...visualProps, ref } : {};
9481
9652
  const { children } = props;
9482
- const renderedChildren = React33.useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
9483
- return React33.createElement(Component3, {
9653
+ const renderedChildren = React14.useMemo(() => isMotionValue(children) ? children.get() : children, [children]);
9654
+ return React14.createElement(Component3, {
9484
9655
  ...elementProps,
9485
9656
  children: renderedChildren
9486
9657
  });
@@ -13179,7 +13350,7 @@ var correctBoxShadow = {
13179
13350
  };
13180
13351
 
13181
13352
  // ../../node_modules/framer-motion/dist/es/motion/features/layout/MeasureLayout.mjs
13182
- var MeasureLayoutWithContext = class extends React33.Component {
13353
+ var MeasureLayoutWithContext = class extends React14.Component {
13183
13354
  /**
13184
13355
  * This only mounts projection nodes for components that
13185
13356
  * need measuring, we might want to do it for all components
@@ -13263,8 +13434,8 @@ var MeasureLayoutWithContext = class extends React33.Component {
13263
13434
  };
13264
13435
  function MeasureLayout(props) {
13265
13436
  const [isPresent, safeToRemove] = usePresence();
13266
- const layoutGroup = React33.useContext(LayoutGroupContext);
13267
- return jsxRuntime.jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: React33.useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
13437
+ const layoutGroup = React14.useContext(LayoutGroupContext);
13438
+ return jsxRuntime.jsx(MeasureLayoutWithContext, { ...props, layoutGroup, switchLayoutGroup: React14.useContext(SwitchLayoutGroupContext), isPresent, safeToRemove });
13268
13439
  }
13269
13440
  var defaultScaleCorrectors = {
13270
13441
  borderRadius: {
@@ -15388,7 +15559,7 @@ var SVGVisualElement = class extends DOMVisualElement {
15388
15559
  // ../../node_modules/framer-motion/dist/es/render/dom/create-visual-element.mjs
15389
15560
  var createDomVisualElement = (Component3, options) => {
15390
15561
  return isSVGComponent(Component3) ? new SVGVisualElement(options) : new HTMLVisualElement(options, {
15391
- allowProjection: Component3 !== React33.Fragment
15562
+ allowProjection: Component3 !== React14.Fragment
15392
15563
  });
15393
15564
  };
15394
15565
 
@@ -15426,7 +15597,7 @@ var LoadingPage = ({
15426
15597
  subMessage = "Please wait while we prepare your data",
15427
15598
  className
15428
15599
  }) => {
15429
- React33__namespace.default.useEffect(() => {
15600
+ React14__namespace.default.useEffect(() => {
15430
15601
  console.log("LoadingPage rendered with message:", message);
15431
15602
  const timeout = setTimeout(() => {
15432
15603
  console.warn("LoadingPage has been visible for more than 8 seconds. This might indicate an issue.");
@@ -15469,10 +15640,10 @@ var withAuth = (WrappedComponent2, options) => {
15469
15640
  return function WithAuthComponent(props) {
15470
15641
  const { session, loading } = useAuth();
15471
15642
  const router$1 = router.useRouter();
15472
- React33__namespace.useEffect(() => {
15643
+ React14__namespace.useEffect(() => {
15473
15644
  console.log("withAuth state:", { loading, hasSession: !!session, requireAuth: defaultOptions.requireAuth });
15474
15645
  }, [session, loading]);
15475
- React33__namespace.useEffect(() => {
15646
+ React14__namespace.useEffect(() => {
15476
15647
  if (!loading && defaultOptions.requireAuth && !session) {
15477
15648
  console.log("Redirecting to login from withAuth");
15478
15649
  router$1.replace(defaultOptions.redirectTo);
@@ -15493,12 +15664,12 @@ var LoginPage = ({
15493
15664
  logoAlt = "Optifye",
15494
15665
  brandName = "Optifye"
15495
15666
  }) => {
15496
- const [email, setEmail] = React33.useState("");
15497
- const [otp, setOtp] = React33.useState("");
15498
- const [step, setStep] = React33.useState("email");
15499
- const [loading, setLoading] = React33.useState(false);
15500
- const [error, setError] = React33.useState(null);
15501
- const [countdown, setCountdown] = React33.useState(0);
15667
+ const [email, setEmail] = React14.useState("");
15668
+ const [otp, setOtp] = React14.useState("");
15669
+ const [step, setStep] = React14.useState("email");
15670
+ const [loading, setLoading] = React14.useState(false);
15671
+ const [error, setError] = React14.useState(null);
15672
+ const [countdown, setCountdown] = React14.useState(0);
15502
15673
  const supabase = useSupabase();
15503
15674
  const router$1 = router.useRouter();
15504
15675
  const handleSendOTP = async (e) => {
@@ -15688,7 +15859,7 @@ var AuthCallback = ({
15688
15859
  }) => {
15689
15860
  const router$1 = router.useRouter();
15690
15861
  const supabase = useSupabase();
15691
- React33.useEffect(() => {
15862
+ React14.useEffect(() => {
15692
15863
  const handleAuthCallback = async () => {
15693
15864
  try {
15694
15865
  const { data: { session }, error } = await supabase.auth.getSession();
@@ -15712,7 +15883,7 @@ var AuthCallback = ({
15712
15883
  return /* @__PURE__ */ jsxRuntime.jsx(LoadingPage, { message: "Completing sign in..." });
15713
15884
  };
15714
15885
  var DebugAuth = () => {
15715
- const [debugInfo, setDebugInfo] = React33.useState({});
15886
+ const [debugInfo, setDebugInfo] = React14.useState({});
15716
15887
  const supabase = useSupabase();
15717
15888
  const checkSupabaseConfig = () => {
15718
15889
  const info = {
@@ -16159,10 +16330,10 @@ var CycleTimeOverTimeChart = ({
16159
16330
  };
16160
16331
  const displayData = getDisplayData(data);
16161
16332
  const DURATION = displayData.length;
16162
- const [animatedData, setAnimatedData] = React33__namespace.default.useState(Array(DURATION).fill(0));
16163
- const prevDataRef = React33__namespace.default.useRef(Array(DURATION).fill(0));
16164
- const animationFrameRef = React33__namespace.default.useRef(null);
16165
- const animateToNewData = React33__namespace.default.useCallback((targetData) => {
16333
+ const [animatedData, setAnimatedData] = React14__namespace.default.useState(Array(DURATION).fill(0));
16334
+ const prevDataRef = React14__namespace.default.useRef(Array(DURATION).fill(0));
16335
+ const animationFrameRef = React14__namespace.default.useRef(null);
16336
+ const animateToNewData = React14__namespace.default.useCallback((targetData) => {
16166
16337
  const startData = [...prevDataRef.current];
16167
16338
  const startTime = performance.now();
16168
16339
  const duration = 1200;
@@ -16192,7 +16363,7 @@ var CycleTimeOverTimeChart = ({
16192
16363
  }
16193
16364
  animationFrameRef.current = requestAnimationFrame(animate);
16194
16365
  }, []);
16195
- React33__namespace.default.useEffect(() => {
16366
+ React14__namespace.default.useEffect(() => {
16196
16367
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16197
16368
  const processedData = getDisplayData(data);
16198
16369
  animateToNewData(processedData);
@@ -16416,7 +16587,7 @@ var CycleTimeOverTimeChart = ({
16416
16587
  renderLegend()
16417
16588
  ] });
16418
16589
  };
16419
- var Card = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16590
+ var Card = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16420
16591
  "div",
16421
16592
  {
16422
16593
  ref,
@@ -16428,7 +16599,7 @@ var Card = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @_
16428
16599
  }
16429
16600
  ));
16430
16601
  Card.displayName = "Card";
16431
- var CardHeader = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16602
+ var CardHeader = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16432
16603
  "div",
16433
16604
  {
16434
16605
  ref,
@@ -16437,7 +16608,7 @@ var CardHeader = React33__namespace.forwardRef(({ className, ...props }, ref) =>
16437
16608
  }
16438
16609
  ));
16439
16610
  CardHeader.displayName = "CardHeader";
16440
- var CardTitle = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16611
+ var CardTitle = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16441
16612
  "h3",
16442
16613
  {
16443
16614
  ref,
@@ -16449,7 +16620,7 @@ var CardTitle = React33__namespace.forwardRef(({ className, ...props }, ref) =>
16449
16620
  }
16450
16621
  ));
16451
16622
  CardTitle.displayName = "CardTitle";
16452
- var CardDescription = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16623
+ var CardDescription = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16453
16624
  "p",
16454
16625
  {
16455
16626
  ref,
@@ -16458,9 +16629,9 @@ var CardDescription = React33__namespace.forwardRef(({ className, ...props }, re
16458
16629
  }
16459
16630
  ));
16460
16631
  CardDescription.displayName = "CardDescription";
16461
- var CardContent = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16632
+ var CardContent = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
16462
16633
  CardContent.displayName = "CardContent";
16463
- var CardFooter = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16634
+ var CardFooter = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16464
16635
  "div",
16465
16636
  {
16466
16637
  ref,
@@ -16536,7 +16707,7 @@ var buttonVariants = cva(
16536
16707
  }
16537
16708
  }
16538
16709
  );
16539
- var Button = React33__namespace.forwardRef(
16710
+ var Button = React14__namespace.forwardRef(
16540
16711
  ({ className, variant, size, asChild = false, ...props }, ref) => {
16541
16712
  const Comp = asChild ? reactSlot.Slot : "button";
16542
16713
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -16567,10 +16738,30 @@ var HourlyOutputChart = ({
16567
16738
  };
16568
16739
  const shiftStartTime = getTimeFromTimeString(shiftStart);
16569
16740
  const SHIFT_DURATION = 11;
16570
- const [animatedData, setAnimatedData] = React33__namespace.default.useState(Array(SHIFT_DURATION).fill(0));
16571
- const prevDataRef = React33__namespace.default.useRef(Array(SHIFT_DURATION).fill(0));
16572
- const animationFrameRef = React33__namespace.default.useRef(null);
16573
- const animateToNewData = React33__namespace.default.useCallback((targetData) => {
16741
+ const [animatedData, setAnimatedData] = React14__namespace.default.useState(Array(SHIFT_DURATION).fill(0));
16742
+ const prevDataRef = React14__namespace.default.useRef(Array(SHIFT_DURATION).fill(0));
16743
+ const animationFrameRef = React14__namespace.default.useRef(null);
16744
+ const [shouldAnimateIdle, setShouldAnimateIdle] = React14__namespace.default.useState(false);
16745
+ const prevShowIdleTimeRef = React14__namespace.default.useRef(showIdleTime);
16746
+ const animationTimeoutRef = React14__namespace.default.useRef(null);
16747
+ React14__namespace.default.useEffect(() => {
16748
+ if (showIdleTime && !prevShowIdleTimeRef.current) {
16749
+ setShouldAnimateIdle(true);
16750
+ if (animationTimeoutRef.current) {
16751
+ clearTimeout(animationTimeoutRef.current);
16752
+ }
16753
+ animationTimeoutRef.current = setTimeout(() => {
16754
+ setShouldAnimateIdle(false);
16755
+ }, 1e3);
16756
+ }
16757
+ prevShowIdleTimeRef.current = showIdleTime;
16758
+ return () => {
16759
+ if (animationTimeoutRef.current) {
16760
+ clearTimeout(animationTimeoutRef.current);
16761
+ }
16762
+ };
16763
+ }, [showIdleTime]);
16764
+ const animateToNewData = React14__namespace.default.useCallback((targetData) => {
16574
16765
  const startData = [...prevDataRef.current];
16575
16766
  const startTime = performance.now();
16576
16767
  const duration = 1200;
@@ -16600,7 +16791,7 @@ var HourlyOutputChart = ({
16600
16791
  }
16601
16792
  animationFrameRef.current = requestAnimationFrame(animate);
16602
16793
  }, []);
16603
- React33__namespace.default.useEffect(() => {
16794
+ React14__namespace.default.useEffect(() => {
16604
16795
  if (JSON.stringify(data) !== JSON.stringify(prevDataRef.current)) {
16605
16796
  const shiftData = data.slice(0, SHIFT_DURATION);
16606
16797
  animateToNewData(shiftData);
@@ -16611,7 +16802,7 @@ var HourlyOutputChart = ({
16611
16802
  }
16612
16803
  };
16613
16804
  }, [data, animateToNewData]);
16614
- const formatHour = (hourIndex) => {
16805
+ const formatHour = React14__namespace.default.useCallback((hourIndex) => {
16615
16806
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16616
16807
  const startHour = Math.floor(startDecimalHour) % 24;
16617
16808
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16627,8 +16818,8 @@ var HourlyOutputChart = ({
16627
16818
  return `${hour12}:${m.toString().padStart(2, "0")}${period}`;
16628
16819
  };
16629
16820
  return `${formatTime2(startHour, startMinute)}-${formatTime2(endHour, endMinute)}`;
16630
- };
16631
- const formatTimeRange = (hourIndex) => {
16821
+ }, [shiftStartTime.decimalHour]);
16822
+ const formatTimeRange = React14__namespace.default.useCallback((hourIndex) => {
16632
16823
  const startDecimalHour = shiftStartTime.decimalHour + hourIndex;
16633
16824
  const startHour = Math.floor(startDecimalHour) % 24;
16634
16825
  const startMinute = Math.round(startDecimalHour % 1 * 60);
@@ -16641,22 +16832,24 @@ var HourlyOutputChart = ({
16641
16832
  return `${hour12}:${m.toString().padStart(2, "0")} ${period}`;
16642
16833
  };
16643
16834
  return `${formatTime2(startHour, startMinute)} - ${formatTime2(endHour, endMinute)}`;
16644
- };
16645
- const chartData = Array.from({ length: SHIFT_DURATION }, (_, i) => {
16646
- const actualHour = (shiftStartTime.hour + i) % 24;
16647
- const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16648
- const idleMinutes = idleArray.filter((val) => val === "1").length;
16649
- return {
16650
- hour: formatHour(i),
16651
- timeRange: formatTimeRange(i),
16652
- output: animatedData[i] || 0,
16653
- originalOutput: data[i] || 0,
16654
- // Keep original data for labels
16655
- color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16656
- idleMinutes,
16657
- idleArray
16658
- };
16659
- });
16835
+ }, [shiftStartTime.decimalHour]);
16836
+ const chartData = React14__namespace.default.useMemo(() => {
16837
+ return Array.from({ length: SHIFT_DURATION }, (_, i) => {
16838
+ const actualHour = (shiftStartTime.hour + i) % 24;
16839
+ const idleArray = idleTimeHourly?.[actualHour.toString()] || [];
16840
+ const idleMinutes = idleArray.filter((val) => val === "1").length;
16841
+ return {
16842
+ hour: formatHour(i),
16843
+ timeRange: formatTimeRange(i),
16844
+ output: animatedData[i] || 0,
16845
+ originalOutput: data[i] || 0,
16846
+ // Keep original data for labels
16847
+ color: (animatedData[i] || 0) >= Math.round(pphThreshold) ? "#00AB45" : "#E34329",
16848
+ idleMinutes,
16849
+ idleArray
16850
+ };
16851
+ });
16852
+ }, [animatedData, data, pphThreshold, idleTimeHourly, shiftStartTime.hour, formatHour, formatTimeRange]);
16660
16853
  const maxYValue = Math.ceil(pphThreshold * 1.5);
16661
16854
  const generateYAxisTicks = () => {
16662
16855
  const targetValue = Math.round(pphThreshold);
@@ -16749,10 +16942,10 @@ var HourlyOutputChart = ({
16749
16942
  contentStyle: {
16750
16943
  backgroundColor: "white",
16751
16944
  border: "none",
16752
- borderRadius: "8px",
16753
- boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
16754
- padding: "8px 12px",
16755
- fontSize: "13px"
16945
+ borderRadius: "12px",
16946
+ boxShadow: "0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
16947
+ padding: "0",
16948
+ fontSize: "14px"
16756
16949
  },
16757
16950
  content: (props) => {
16758
16951
  if (!props.active || !props.payload || props.payload.length === 0) return null;
@@ -16786,48 +16979,54 @@ var HourlyOutputChart = ({
16786
16979
  const hour12 = hour === 0 ? 12 : hour > 12 ? hour - 12 : hour;
16787
16980
  return `${hour12}:${minute.toString().padStart(2, "0")} ${period}`;
16788
16981
  };
16789
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-lg shadow-lg p-3 min-w-[180px]", children: [
16790
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-gray-700 mb-2", children: data2.timeRange }),
16791
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-gray-600", children: [
16792
- "Output: ",
16793
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-gray-800", children: [
16794
- Math.round(data2.output),
16795
- " units"
16796
- ] })
16797
- ] }),
16798
- showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16799
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-gray-600 mb-1 border-t pt-1 mt-1", children: [
16800
- "Idle Time: ",
16801
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-medium text-gray-700", children: [
16802
- data2.idleMinutes,
16803
- " minutes"
16982
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white rounded-xl shadow-xl border border-gray-100 p-4 min-w-[220px]", children: [
16983
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-between mb-3", children: /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-semibold text-gray-900 text-sm", children: data2.timeRange }) }),
16984
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
16985
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
16986
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Output" }),
16987
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-gray-900 text-sm", children: [
16988
+ Math.round(data2.output),
16989
+ " units"
16804
16990
  ] })
16805
16991
  ] }),
16806
- idleRanges.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 text-xs", children: [
16807
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-gray-600 mb-1", children: "Idle periods:" }),
16808
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-0.5 max-h-32 overflow-y-auto", children: idleRanges.map((range, index) => {
16809
- const duration = range.end - range.start + 1;
16810
- const startTime = formatIdleTimestamp(range.start);
16811
- const endTime = formatIdleTimestamp(range.end + 1);
16812
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-gray-500 flex items-center gap-1", children: [
16813
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-1 h-1 bg-gray-400 rounded-full" }),
16814
- duration === 1 ? /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16815
- startTime,
16816
- " ",
16817
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-400", children: "(1 min)" })
16818
- ] }) : /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
16819
- startTime,
16820
- " - ",
16821
- endTime,
16822
- " ",
16823
- /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
16824
- "(",
16825
- duration,
16826
- " min)"
16827
- ] })
16828
- ] })
16829
- ] }, index);
16830
- }) })
16992
+ showIdleTime && data2.idleMinutes > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16993
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-gray-100 pt-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between", children: [
16994
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500", children: "Idle Time" }),
16995
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "font-semibold text-orange-600 text-sm", children: [
16996
+ data2.idleMinutes,
16997
+ " minutes"
16998
+ ] })
16999
+ ] }) }),
17000
+ idleRanges.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 bg-gray-50 rounded-lg p-2.5", children: [
17001
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium text-gray-700 text-xs mb-2", children: "Idle periods:" }),
17002
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-1 max-h-32 overflow-y-auto pr-1", children: idleRanges.map((range, index) => {
17003
+ const duration = range.end - range.start + 1;
17004
+ const startTime = formatIdleTimestamp(range.start);
17005
+ const endTime = formatIdleTimestamp(range.end + 1);
17006
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-gray-600 flex items-center gap-2 text-xs", children: [
17007
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-1.5 h-1.5 bg-orange-400 rounded-full flex-shrink-0" }),
17008
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: duration === 1 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17009
+ startTime,
17010
+ " ",
17011
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
17012
+ "(",
17013
+ duration,
17014
+ " min)"
17015
+ ] })
17016
+ ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
17017
+ startTime,
17018
+ " - ",
17019
+ endTime,
17020
+ " ",
17021
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-gray-400", children: [
17022
+ "(",
17023
+ duration,
17024
+ " min)"
17025
+ ] })
17026
+ ] }) })
17027
+ ] }, index);
17028
+ }) })
17029
+ ] })
16831
17030
  ] })
16832
17031
  ] })
16833
17032
  ] });
@@ -16917,10 +17116,40 @@ var HourlyOutputChart = ({
16917
17116
  radius: [10, 10, 0, 0],
16918
17117
  fill: "url(#idlePattern)",
16919
17118
  opacity: 0.7,
16920
- isAnimationActive: true,
16921
- animationBegin: 200,
16922
- animationDuration: 800,
16923
- animationEasing: "ease-out"
17119
+ isAnimationActive: shouldAnimateIdle,
17120
+ animationBegin: shouldAnimateIdle ? 200 : 0,
17121
+ animationDuration: shouldAnimateIdle ? 800 : 0,
17122
+ animationEasing: "ease-out",
17123
+ children: /* @__PURE__ */ jsxRuntime.jsx(
17124
+ recharts.LabelList,
17125
+ {
17126
+ dataKey: "idleMinutes",
17127
+ position: "top",
17128
+ content: (props) => {
17129
+ const { x, y, width, value } = props;
17130
+ if (!value || value === 0) return null;
17131
+ return /* @__PURE__ */ jsxRuntime.jsxs(
17132
+ "text",
17133
+ {
17134
+ x: x + width / 2,
17135
+ y: y - 2,
17136
+ textAnchor: "middle",
17137
+ fontSize: "9",
17138
+ fontWeight: "600",
17139
+ fill: "#6b7280",
17140
+ style: {
17141
+ opacity: 1,
17142
+ pointerEvents: "none"
17143
+ },
17144
+ children: [
17145
+ value,
17146
+ "m"
17147
+ ]
17148
+ }
17149
+ );
17150
+ }
17151
+ }
17152
+ )
16924
17153
  }
16925
17154
  ),
16926
17155
  /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("pattern", { id: "idlePattern", patternUnits: "userSpaceOnUse", width: "4", height: "4", children: [
@@ -16943,9 +17172,9 @@ var defaults = {
16943
17172
  Button,
16944
17173
  HourlyOutputChart
16945
17174
  };
16946
- var RegistryCtx = React33.createContext(defaults);
17175
+ var RegistryCtx = React14.createContext(defaults);
16947
17176
  var useRegistry = () => {
16948
- const context = React33.useContext(RegistryCtx);
17177
+ const context = React14.useContext(RegistryCtx);
16949
17178
  if (!context) {
16950
17179
  throw new Error("useRegistry must be used within a RegistryProvider");
16951
17180
  }
@@ -17023,10 +17252,10 @@ var SOPComplianceChart = ({
17023
17252
  { length: TOTAL_MINUTES },
17024
17253
  () => Math.floor(Math.random() * 10) + 90
17025
17254
  );
17026
- const [animatedData, setAnimatedData] = React33.useState([]);
17027
- const prevDataRef = React33.useRef([]);
17028
- const animationFrameRef = React33.useRef(null);
17029
- const animateToNewData = React33.useCallback((targetData) => {
17255
+ const [animatedData, setAnimatedData] = React14.useState([]);
17256
+ const prevDataRef = React14.useRef([]);
17257
+ const animationFrameRef = React14.useRef(null);
17258
+ const animateToNewData = React14.useCallback((targetData) => {
17030
17259
  const startData = [...prevDataRef.current];
17031
17260
  while (startData.length < targetData.length) {
17032
17261
  startData.push(startData.length > 0 ? startData[startData.length - 1] : 0);
@@ -17058,7 +17287,7 @@ var SOPComplianceChart = ({
17058
17287
  }
17059
17288
  animationFrameRef.current = requestAnimationFrame(animate);
17060
17289
  }, []);
17061
- React33.useEffect(() => {
17290
+ React14.useEffect(() => {
17062
17291
  if (data.length === 0) {
17063
17292
  if (prevDataRef.current.length === 0) {
17064
17293
  animateToNewData(mockData);
@@ -17314,8 +17543,8 @@ var DateTimeDisplay = ({
17314
17543
  defaultTimezone
17315
17544
  } = useDateTimeConfig();
17316
17545
  const { formatDate, formatTime: formatTime2 } = useDateFormatter();
17317
- const [now2, setNow] = React33.useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
17318
- React33.useEffect(() => {
17546
+ const [now2, setNow] = React14.useState(() => getCurrentTimeInZone(defaultTimezone || "UTC"));
17547
+ React14.useEffect(() => {
17319
17548
  const timerId = setInterval(() => {
17320
17549
  setNow(getCurrentTimeInZone(defaultTimezone || "UTC"));
17321
17550
  }, 1e3);
@@ -17349,7 +17578,7 @@ var EmptyStateMessage = ({
17349
17578
  iconClassName
17350
17579
  }) => {
17351
17580
  let IconContent = null;
17352
- if (React33__namespace.default.isValidElement(iconType)) {
17581
+ if (React14__namespace.default.isValidElement(iconType)) {
17353
17582
  IconContent = iconType;
17354
17583
  } else if (typeof iconType === "string") {
17355
17584
  const MappedIcon = IconMap[iconType];
@@ -17440,15 +17669,15 @@ var BreakNotificationPopup = ({
17440
17669
  className = "",
17441
17670
  lineNames = {}
17442
17671
  }) => {
17443
- const [isDismissed, setIsDismissed] = React33.useState(false);
17444
- const [currentTime, setCurrentTime] = React33.useState(/* @__PURE__ */ new Date());
17445
- React33.useEffect(() => {
17672
+ const [isDismissed, setIsDismissed] = React14.useState(false);
17673
+ const [currentTime, setCurrentTime] = React14.useState(/* @__PURE__ */ new Date());
17674
+ React14.useEffect(() => {
17446
17675
  const timer = setInterval(() => {
17447
17676
  setCurrentTime(/* @__PURE__ */ new Date());
17448
17677
  }, 6e4);
17449
17678
  return () => clearInterval(timer);
17450
17679
  }, []);
17451
- React33.useEffect(() => {
17680
+ React14.useEffect(() => {
17452
17681
  if (activeBreaks.length > 0) {
17453
17682
  setIsDismissed(false);
17454
17683
  }
@@ -17571,7 +17800,7 @@ var BaseHistoryCalendar = ({
17571
17800
  className,
17572
17801
  dayCellClassName
17573
17802
  }) => {
17574
- const today = React33.useMemo(() => /* @__PURE__ */ new Date(), []);
17803
+ const today = React14.useMemo(() => /* @__PURE__ */ new Date(), []);
17575
17804
  const Day = (dayProps) => {
17576
17805
  const { day, modifiers, ...divProps } = dayProps;
17577
17806
  const date = day.date;
@@ -17651,7 +17880,7 @@ var BaseHistoryCalendar = ({
17651
17880
  }
17652
17881
  );
17653
17882
  };
17654
- var ShiftDisplay = React33.memo(({ className, variant = "default" }) => {
17883
+ var ShiftDisplay = React14.memo(({ className, variant = "default" }) => {
17655
17884
  const { dateTimeConfig, shiftConfig } = useDashboardConfig();
17656
17885
  const getShiftInfo = () => {
17657
17886
  const tz = dateTimeConfig?.defaultTimezone;
@@ -17673,8 +17902,8 @@ var ShiftDisplay = React33.memo(({ className, variant = "default" }) => {
17673
17902
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "currentColor", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M17.293 13.293A8 8 0 016.707 2.707a8.001 8.001 0 1010.586 10.586z" }) });
17674
17903
  }
17675
17904
  };
17676
- const [currentShiftText, setCurrentShiftText] = React33.useState(getShiftInfo());
17677
- React33.useEffect(() => {
17905
+ const [currentShiftText, setCurrentShiftText] = React14.useState(getShiftInfo());
17906
+ React14.useEffect(() => {
17678
17907
  setCurrentShiftText(getShiftInfo());
17679
17908
  const interval = setInterval(() => {
17680
17909
  setCurrentShiftText(getShiftInfo());
@@ -17705,11 +17934,11 @@ ShiftDisplay.displayName = "ShiftDisplay";
17705
17934
  var ShiftDisplay_default = ShiftDisplay;
17706
17935
  var TimeDisplay = ({ className, variant = "default" }) => {
17707
17936
  const { dateTimeConfig } = useDashboardConfig();
17708
- const [time2, setTime] = React33.useState("");
17937
+ const [time2, setTime] = React14.useState("");
17709
17938
  const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
17710
17939
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
17711
17940
  const timeSuffix = "";
17712
- React33.useEffect(() => {
17941
+ React14.useEffect(() => {
17713
17942
  const updateTime = () => {
17714
17943
  const now2 = /* @__PURE__ */ new Date();
17715
17944
  const effectiveFormatOptions = {
@@ -17760,7 +17989,7 @@ var TimeDisplay = ({ className, variant = "default" }) => {
17760
17989
  };
17761
17990
  var TimeDisplay_default = TimeDisplay;
17762
17991
  var TimeDisplay2 = TimeDisplay_default;
17763
- var ISTTimer = React33.memo(() => {
17992
+ var ISTTimer = React14.memo(() => {
17764
17993
  return /* @__PURE__ */ jsxRuntime.jsx(
17765
17994
  TimeDisplay2,
17766
17995
  {
@@ -17784,8 +18013,8 @@ var LinePdfExportButton = ({
17784
18013
  html2canvasOptions,
17785
18014
  jsPdfOptions
17786
18015
  }) => {
17787
- const [isExporting, setIsExporting] = React33.useState(false);
17788
- const handleExport = React33.useCallback(async () => {
18016
+ const [isExporting, setIsExporting] = React14.useState(false);
18017
+ const handleExport = React14.useCallback(async () => {
17789
18018
  const elementToCapture = typeof targetElement === "string" ? document.querySelector(targetElement) : targetElement;
17790
18019
  if (!elementToCapture) {
17791
18020
  console.error("PDF Export Error: Target element not found.");
@@ -17867,11 +18096,11 @@ var LineHistoryCalendar = ({
17867
18096
  const router = useNavigation();
17868
18097
  const { dateTimeConfig } = useDashboardConfig();
17869
18098
  const configuredTimezone = dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
17870
- const todayInZone = React33.useMemo(() => {
18099
+ const todayInZone = React14.useMemo(() => {
17871
18100
  const currentTimeInZone = getCurrentTimeInZone(configuredTimezone);
17872
18101
  return typeof currentTimeInZone === "string" ? new Date(currentTimeInZone) : currentTimeInZone;
17873
18102
  }, [configuredTimezone]);
17874
- const calendarData = React33.useMemo(() => {
18103
+ const calendarData = React14.useMemo(() => {
17875
18104
  const startOfMonth = dateFnsTz.toZonedTime(new Date(year, month, 1), configuredTimezone);
17876
18105
  const endOfMonth = dateFnsTz.toZonedTime(new Date(year, month + 1, 0), configuredTimezone);
17877
18106
  const totalDays = endOfMonth.getDate();
@@ -18202,7 +18431,7 @@ var LineMonthlyPdfGenerator = ({
18202
18431
  selectedShift,
18203
18432
  className
18204
18433
  }) => {
18205
- const [isGenerating, setIsGenerating] = React33.useState(false);
18434
+ const [isGenerating, setIsGenerating] = React14.useState(false);
18206
18435
  const generatePDF = async () => {
18207
18436
  setIsGenerating(true);
18208
18437
  try {
@@ -18517,7 +18746,7 @@ var LinePdfGenerator = ({
18517
18746
  workspaceData,
18518
18747
  className
18519
18748
  }) => {
18520
- const [isGenerating, setIsGenerating] = React33.useState(false);
18749
+ const [isGenerating, setIsGenerating] = React14.useState(false);
18521
18750
  const generatePDF = async () => {
18522
18751
  setIsGenerating(true);
18523
18752
  try {
@@ -18802,8 +19031,8 @@ var WorkspacePdfExportButton = ({
18802
19031
  html2canvasOptions,
18803
19032
  jsPdfOptions
18804
19033
  }) => {
18805
- const [isExporting, setIsExporting] = React33.useState(false);
18806
- const handleExport = React33.useCallback(async () => {
19034
+ const [isExporting, setIsExporting] = React14.useState(false);
19035
+ const handleExport = React14.useCallback(async () => {
18807
19036
  const elementToCapture = typeof targetElement === "string" ? document.querySelector(targetElement) : targetElement;
18808
19037
  if (!elementToCapture) {
18809
19038
  console.error("PDF Export Error: Target element not found.");
@@ -19060,7 +19289,7 @@ var WorkspaceHistoryCalendar = ({
19060
19289
  }) => {
19061
19290
  const { dateTimeConfig } = useDashboardConfig();
19062
19291
  const configuredTimezone = dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
19063
- const calendarData = React33.useMemo(() => {
19292
+ const calendarData = React14.useMemo(() => {
19064
19293
  const startOfMonth = dateFnsTz.toZonedTime(new Date(year, month, 1), configuredTimezone);
19065
19294
  const endOfMonth = dateFnsTz.toZonedTime(new Date(year, month + 1, 0), configuredTimezone);
19066
19295
  const totalDays = endOfMonth.getDate();
@@ -19131,7 +19360,7 @@ var WorkspaceHistoryCalendar = ({
19131
19360
  }
19132
19361
  return calendar;
19133
19362
  }, [data, month, year, configuredTimezone]);
19134
- const monthlyMetrics = React33.useMemo(() => {
19363
+ const monthlyMetrics = React14.useMemo(() => {
19135
19364
  const validDays = data.filter((day) => {
19136
19365
  const date = dateFnsTz.toZonedTime(new Date(day.date), configuredTimezone);
19137
19366
  return date.getMonth() === month && date.getFullYear() === year;
@@ -19156,7 +19385,7 @@ var WorkspaceHistoryCalendar = ({
19156
19385
  totalDays: validShifts.length
19157
19386
  };
19158
19387
  }, [data, month, year, configuredTimezone]);
19159
- const handleDayClick = React33.useCallback((day, shift) => {
19388
+ const handleDayClick = React14.useCallback((day, shift) => {
19160
19389
  if (!day || isFutureDate(day.date)) return;
19161
19390
  const year2 = day.date.getFullYear();
19162
19391
  const month2 = String(day.date.getMonth() + 1).padStart(2, "0");
@@ -19173,7 +19402,7 @@ var WorkspaceHistoryCalendar = ({
19173
19402
  });
19174
19403
  onDateSelect(formattedDate);
19175
19404
  }, [workspaceId, onDateSelect]);
19176
- const handleShiftChange = React33.useCallback((shift) => {
19405
+ const handleShiftChange = React14.useCallback((shift) => {
19177
19406
  trackCoreEvent("Workspace Calendar Shift Changed", {
19178
19407
  workspace_id: workspaceId,
19179
19408
  new_shift: shift
@@ -19182,19 +19411,19 @@ var WorkspaceHistoryCalendar = ({
19182
19411
  onShiftChange(shift);
19183
19412
  }
19184
19413
  }, [workspaceId, onShiftChange]);
19185
- const isCurrentDate = React33.useCallback((date) => {
19414
+ const isCurrentDate = React14.useCallback((date) => {
19186
19415
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19187
19416
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
19188
19417
  return compareDate.getDate() === istNow.getDate() && compareDate.getMonth() === istNow.getMonth() && compareDate.getFullYear() === istNow.getFullYear();
19189
19418
  }, [configuredTimezone]);
19190
- const isFutureDate = React33.useCallback((date) => {
19419
+ const isFutureDate = React14.useCallback((date) => {
19191
19420
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19192
19421
  istNow.setHours(0, 0, 0, 0);
19193
19422
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
19194
19423
  compareDate.setHours(0, 0, 0, 0);
19195
19424
  return compareDate > istNow;
19196
19425
  }, [configuredTimezone]);
19197
- const getPerformanceColor = React33.useCallback((efficiency, date) => {
19426
+ const getPerformanceColor = React14.useCallback((efficiency, date) => {
19198
19427
  const istNow = getTimeInZoneAsDate(configuredTimezone);
19199
19428
  istNow.setHours(0, 0, 0, 0);
19200
19429
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
@@ -19240,7 +19469,7 @@ var WorkspaceHistoryCalendar = ({
19240
19469
  ] })
19241
19470
  ] }) });
19242
19471
  };
19243
- const renderDayCell = React33.useCallback((day) => {
19472
+ const renderDayCell = React14.useCallback((day) => {
19244
19473
  if (!day) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full border border-gray-100 rounded-lg bg-gray-50 transition-all duration-200 ease-in-out" });
19245
19474
  const shiftData = selectedShift === "day" ? day.dayShift : day.nightShift;
19246
19475
  const isToday = isCurrentDate(day.date);
@@ -19366,7 +19595,7 @@ var WorkspaceWhatsAppShareButton = ({
19366
19595
  );
19367
19596
  };
19368
19597
  var WorkspacePdfGenerator = ({ workspace, className }) => {
19369
- const [isGenerating, setIsGenerating] = React33.useState(false);
19598
+ const [isGenerating, setIsGenerating] = React14.useState(false);
19370
19599
  const generatePDF = async () => {
19371
19600
  setIsGenerating(true);
19372
19601
  try {
@@ -19571,7 +19800,7 @@ var WorkspaceMonthlyPdfGenerator = ({
19571
19800
  selectedShift,
19572
19801
  className
19573
19802
  }) => {
19574
- const [isGenerating, setIsGenerating] = React33.useState(false);
19803
+ const [isGenerating, setIsGenerating] = React14.useState(false);
19575
19804
  const generatePDF = async () => {
19576
19805
  setIsGenerating(true);
19577
19806
  try {
@@ -19851,8 +20080,8 @@ var WorkspaceMetricCards = ({
19851
20080
  ] });
19852
20081
  };
19853
20082
  var LiveTimer = () => {
19854
- const [time2, setTime] = React33.useState(/* @__PURE__ */ new Date());
19855
- React33.useEffect(() => {
20083
+ const [time2, setTime] = React14.useState(/* @__PURE__ */ new Date());
20084
+ React14.useEffect(() => {
19856
20085
  const timer = setInterval(() => {
19857
20086
  setTime(/* @__PURE__ */ new Date());
19858
20087
  }, 1e3);
@@ -19915,7 +20144,7 @@ function Skeleton({ className, ...props }) {
19915
20144
  var Select = SelectPrimitive__namespace.Root;
19916
20145
  var SelectGroup = SelectPrimitive__namespace.Group;
19917
20146
  var SelectValue = SelectPrimitive__namespace.Value;
19918
- var SelectTrigger = React33__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
20147
+ var SelectTrigger = React14__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
19919
20148
  SelectPrimitive__namespace.Trigger,
19920
20149
  {
19921
20150
  ref,
@@ -19931,7 +20160,7 @@ var SelectTrigger = React33__namespace.forwardRef(({ className, children, ...pro
19931
20160
  }
19932
20161
  ));
19933
20162
  SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
19934
- var SelectScrollUpButton = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20163
+ var SelectScrollUpButton = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19935
20164
  SelectPrimitive__namespace.ScrollUpButton,
19936
20165
  {
19937
20166
  ref,
@@ -19941,7 +20170,7 @@ var SelectScrollUpButton = React33__namespace.forwardRef(({ className, ...props
19941
20170
  }
19942
20171
  ));
19943
20172
  SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
19944
- var SelectScrollDownButton = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20173
+ var SelectScrollDownButton = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19945
20174
  SelectPrimitive__namespace.ScrollDownButton,
19946
20175
  {
19947
20176
  ref,
@@ -19951,7 +20180,7 @@ var SelectScrollDownButton = React33__namespace.forwardRef(({ className, ...prop
19951
20180
  }
19952
20181
  ));
19953
20182
  SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
19954
- var SelectContent = React33__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
20183
+ var SelectContent = React14__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
19955
20184
  SelectPrimitive__namespace.Content,
19956
20185
  {
19957
20186
  ref,
@@ -19979,7 +20208,7 @@ var SelectContent = React33__namespace.forwardRef(({ className, children, positi
19979
20208
  }
19980
20209
  ) }));
19981
20210
  SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
19982
- var SelectLabel = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20211
+ var SelectLabel = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
19983
20212
  SelectPrimitive__namespace.Label,
19984
20213
  {
19985
20214
  ref,
@@ -19988,7 +20217,7 @@ var SelectLabel = React33__namespace.forwardRef(({ className, ...props }, ref) =
19988
20217
  }
19989
20218
  ));
19990
20219
  SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
19991
- var SelectItem = React33__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
20220
+ var SelectItem = React14__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
19992
20221
  SelectPrimitive__namespace.Item,
19993
20222
  {
19994
20223
  ref,
@@ -20004,7 +20233,7 @@ var SelectItem = React33__namespace.forwardRef(({ className, children, ...props
20004
20233
  }
20005
20234
  ));
20006
20235
  SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
20007
- var SelectSeparator = React33__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20236
+ var SelectSeparator = React14__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
20008
20237
  SelectPrimitive__namespace.Separator,
20009
20238
  {
20010
20239
  ref,
@@ -20039,10 +20268,10 @@ var LoadingOverlay = ({
20039
20268
  var LoadingOverlay_default = LoadingOverlay;
20040
20269
  var DateDisplay = ({ className, variant = "default" }) => {
20041
20270
  const { dateTimeConfig } = useDashboardConfig();
20042
- const [date, setDate] = React33.useState("");
20271
+ const [date, setDate] = React14.useState("");
20043
20272
  const timezoneToDisplay = dateTimeConfig?.defaultTimezone || "UTC";
20044
20273
  const localeToUse = dateTimeConfig?.defaultLocale || "en-US";
20045
- React33.useEffect(() => {
20274
+ React14.useEffect(() => {
20046
20275
  const getCurrentFormattedDate = () => {
20047
20276
  const now2 = /* @__PURE__ */ new Date();
20048
20277
  const effectiveFormatOptions = {
@@ -20129,10 +20358,10 @@ var TimePickerDropdown = ({
20129
20358
  className = "",
20130
20359
  disabled = false
20131
20360
  }) => {
20132
- const [isOpen, setIsOpen] = React33.useState(false);
20133
- const [searchTerm, setSearchTerm] = React33.useState("");
20134
- const dropdownRef = React33.useRef(null);
20135
- const inputRef = React33.useRef(null);
20361
+ const [isOpen, setIsOpen] = React14.useState(false);
20362
+ const [searchTerm, setSearchTerm] = React14.useState("");
20363
+ const dropdownRef = React14.useRef(null);
20364
+ const inputRef = React14.useRef(null);
20136
20365
  const generateTimeSlots = () => {
20137
20366
  const slots = [];
20138
20367
  for (let hour = 0; hour < 24; hour++) {
@@ -20155,7 +20384,7 @@ var TimePickerDropdown = ({
20155
20384
  const slot = timeSlots.find((s) => s.value === value2);
20156
20385
  return slot ? slot.label : value2;
20157
20386
  };
20158
- React33.useEffect(() => {
20387
+ React14.useEffect(() => {
20159
20388
  const handleClickOutside = (event) => {
20160
20389
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
20161
20390
  setIsOpen(false);
@@ -20822,22 +21051,22 @@ var BottlenecksContent = ({
20822
21051
  className
20823
21052
  }) => {
20824
21053
  const dashboardConfig = useDashboardConfig();
20825
- const videoRef = React33.useRef(null);
20826
- const fullscreenContainerRef = React33.useRef(null);
20827
- const timestampFilterRef = React33.useRef(null);
20828
- const [isPlaying, setIsPlaying] = React33.useState(false);
20829
- const [currentTime, setCurrentTime] = React33.useState(0);
20830
- const [duration, setDuration] = React33.useState(0);
20831
- const [isFullscreen, setIsFullscreen] = React33.useState(false);
20832
- const [currentIndex, setCurrentIndex] = React33.useState(0);
20833
- const [activeFilter, setActiveFilter] = React33.useState("low_value");
20834
- const [allVideos, setAllVideos] = React33.useState([]);
20835
- const [isLoading, setIsLoading] = React33.useState(true);
20836
- const [error, setError] = React33.useState(null);
20837
- const [showTimestampFilter, setShowTimestampFilter] = React33.useState(false);
20838
- const [timestampStart, setTimestampStart] = React33.useState("");
20839
- const [timestampEnd, setTimestampEnd] = React33.useState("");
20840
- React33.useEffect(() => {
21054
+ const videoRef = React14.useRef(null);
21055
+ const fullscreenContainerRef = React14.useRef(null);
21056
+ const timestampFilterRef = React14.useRef(null);
21057
+ const [isPlaying, setIsPlaying] = React14.useState(false);
21058
+ const [currentTime, setCurrentTime] = React14.useState(0);
21059
+ const [duration, setDuration] = React14.useState(0);
21060
+ const [isFullscreen, setIsFullscreen] = React14.useState(false);
21061
+ const [currentIndex, setCurrentIndex] = React14.useState(0);
21062
+ const [activeFilter, setActiveFilter] = React14.useState("low_value");
21063
+ const [allVideos, setAllVideos] = React14.useState([]);
21064
+ const [isLoading, setIsLoading] = React14.useState(true);
21065
+ const [error, setError] = React14.useState(null);
21066
+ const [showTimestampFilter, setShowTimestampFilter] = React14.useState(false);
21067
+ const [timestampStart, setTimestampStart] = React14.useState("");
21068
+ const [timestampEnd, setTimestampEnd] = React14.useState("");
21069
+ React14.useEffect(() => {
20841
21070
  const handleClickOutside = (event) => {
20842
21071
  if (timestampFilterRef.current && !timestampFilterRef.current.contains(event.target)) {
20843
21072
  setShowTimestampFilter(false);
@@ -20850,14 +21079,14 @@ var BottlenecksContent = ({
20850
21079
  document.removeEventListener("mousedown", handleClickOutside);
20851
21080
  };
20852
21081
  }, [showTimestampFilter]);
20853
- const s3ClipsService = React33.useMemo(() => {
21082
+ const s3ClipsService = React14.useMemo(() => {
20854
21083
  if (!dashboardConfig?.s3Config) {
20855
21084
  console.warn("S3 configuration not found in dashboard config");
20856
21085
  return null;
20857
21086
  }
20858
21087
  return new S3ClipsService(dashboardConfig);
20859
21088
  }, [dashboardConfig]);
20860
- const fetchClips = React33.useCallback(async () => {
21089
+ const fetchClips = React14.useCallback(async () => {
20861
21090
  if (!workspaceId || !s3ClipsService) return;
20862
21091
  setIsLoading(true);
20863
21092
  setError(null);
@@ -20910,12 +21139,12 @@ var BottlenecksContent = ({
20910
21139
  setIsLoading(false);
20911
21140
  }
20912
21141
  }, [workspaceId, date, s3ClipsService, timestampStart, timestampEnd]);
20913
- React33.useEffect(() => {
21142
+ React14.useEffect(() => {
20914
21143
  if (s3ClipsService) {
20915
21144
  fetchClips();
20916
21145
  }
20917
21146
  }, [workspaceId, fetchClips, s3ClipsService]);
20918
- React33.useEffect(() => {
21147
+ React14.useEffect(() => {
20919
21148
  setCurrentIndex(0);
20920
21149
  const filtered = allVideos.filter((video) => {
20921
21150
  if (activeFilter === "all") return true;
@@ -20932,7 +21161,7 @@ var BottlenecksContent = ({
20932
21161
  preloadVideoUrl2(filtered[0].src);
20933
21162
  }
20934
21163
  }, [activeFilter, allVideos]);
20935
- const filteredVideos = React33.useMemo(() => {
21164
+ const filteredVideos = React14.useMemo(() => {
20936
21165
  if (!allVideos) return [];
20937
21166
  let filtered = [];
20938
21167
  if (activeFilter === "all") {
@@ -20956,7 +21185,7 @@ var BottlenecksContent = ({
20956
21185
  return new Date(b.timestamp).getTime() - new Date(a.timestamp).getTime();
20957
21186
  });
20958
21187
  }, [activeFilter, allVideos]);
20959
- React33.useEffect(() => {
21188
+ React14.useEffect(() => {
20960
21189
  if (filteredVideos.length === 0) return;
20961
21190
  const upcoming = [];
20962
21191
  if (currentIndex + 1 < filteredVideos.length) {
@@ -20970,7 +21199,7 @@ var BottlenecksContent = ({
20970
21199
  }
20971
21200
  preloadVideosUrl2(upcoming);
20972
21201
  }, [currentIndex, filteredVideos]);
20973
- const handleNext = React33.useCallback(() => {
21202
+ const handleNext = React14.useCallback(() => {
20974
21203
  setCurrentIndex((prevIndex) => {
20975
21204
  if (prevIndex < filteredVideos.length - 1) {
20976
21205
  return prevIndex + 1;
@@ -20980,7 +21209,7 @@ var BottlenecksContent = ({
20980
21209
  return 0;
20981
21210
  });
20982
21211
  }, [filteredVideos.length]);
20983
- const handlePrevious = React33.useCallback(() => {
21212
+ const handlePrevious = React14.useCallback(() => {
20984
21213
  setCurrentIndex((prevIndex) => {
20985
21214
  if (prevIndex > 0) {
20986
21215
  return prevIndex - 1;
@@ -20990,7 +21219,7 @@ var BottlenecksContent = ({
20990
21219
  return 0;
20991
21220
  });
20992
21221
  }, [filteredVideos.length]);
20993
- React33.useEffect(() => {
21222
+ React14.useEffect(() => {
20994
21223
  if (videoRef.current && filteredVideos.length > 0 && currentIndex < filteredVideos.length) {
20995
21224
  const video = videoRef.current;
20996
21225
  const currentVideoData = filteredVideos[currentIndex];
@@ -21189,7 +21418,7 @@ var BottlenecksContent = ({
21189
21418
  videoRef.current.load();
21190
21419
  }
21191
21420
  }, [currentIndex, filteredVideos, handleNext]);
21192
- React33.useEffect(() => {
21421
+ React14.useEffect(() => {
21193
21422
  const handleKeyDown = (e) => {
21194
21423
  if (e.key === "Escape" && isFullscreen) {
21195
21424
  setIsFullscreen(false);
@@ -21228,7 +21457,7 @@ var BottlenecksContent = ({
21228
21457
  }
21229
21458
  }
21230
21459
  };
21231
- const clipCounts = React33.useMemo(() => {
21460
+ const clipCounts = React14.useMemo(() => {
21232
21461
  if (!allVideos) return {
21233
21462
  bottlenecks: 0,
21234
21463
  lowValue: 0,
@@ -21256,7 +21485,7 @@ var BottlenecksContent = ({
21256
21485
  total: allVideos.length
21257
21486
  };
21258
21487
  }, [allVideos]);
21259
- const currentVideo = React33.useMemo(() => {
21488
+ const currentVideo = React14.useMemo(() => {
21260
21489
  if (!filteredVideos || filteredVideos.length === 0 || currentIndex >= filteredVideos.length) {
21261
21490
  return null;
21262
21491
  }
@@ -21746,7 +21975,7 @@ var TREND_STYLES = {
21746
21975
  // Up
21747
21976
  };
21748
21977
  var getTrendArrowAndColor = (trend) => TREND_STYLES[trend] || { arrow: "", color: "" };
21749
- var VideoCard = React33__namespace.default.memo(({
21978
+ var VideoCard = React14__namespace.default.memo(({
21750
21979
  workspace,
21751
21980
  hlsUrl,
21752
21981
  shouldPlay,
@@ -21755,7 +21984,7 @@ var VideoCard = React33__namespace.default.memo(({
21755
21984
  isVeryLowEfficiency = false,
21756
21985
  className = ""
21757
21986
  }) => {
21758
- const videoRef = React33.useRef(null);
21987
+ const videoRef = React14.useRef(null);
21759
21988
  useHlsStream(videoRef, {
21760
21989
  src: hlsUrl,
21761
21990
  shouldPlay,
@@ -21784,7 +22013,7 @@ var VideoCard = React33__namespace.default.memo(({
21784
22013
  const efficiencyOverlayClass = getEfficiencyOverlayColor(workspace.efficiency);
21785
22014
  const efficiencyBarClass = getEfficiencyBarColor(workspace.efficiency);
21786
22015
  const trendInfo = workspace.trend !== void 0 ? getTrendArrowAndColor(workspace.trend) : null;
21787
- const handleClick = React33.useCallback(() => {
22016
+ const handleClick = React14.useCallback(() => {
21788
22017
  if (onClick) {
21789
22018
  onClick();
21790
22019
  }
@@ -21877,7 +22106,7 @@ var DEFAULT_WORKSPACE_HLS_URLS = {
21877
22106
  "WS06": "https://59.144.218.58:8443/camera5.m3u8"
21878
22107
  };
21879
22108
  var DEFAULT_HLS_URL = "https://192.168.5.9:8443/cam1.m3u8";
21880
- var VideoGridView = React33__namespace.default.memo(({
22109
+ var VideoGridView = React14__namespace.default.memo(({
21881
22110
  workspaces,
21882
22111
  selectedLine,
21883
22112
  className = "",
@@ -21885,24 +22114,24 @@ var VideoGridView = React33__namespace.default.memo(({
21885
22114
  videoSources = {}
21886
22115
  }) => {
21887
22116
  const router$1 = router.useRouter();
21888
- const containerRef = React33.useRef(null);
21889
- const observerRef = React33.useRef(null);
21890
- const [gridCols, setGridCols] = React33.useState(4);
21891
- const [visibleWorkspaces, setVisibleWorkspaces] = React33.useState(/* @__PURE__ */ new Set());
22117
+ const containerRef = React14.useRef(null);
22118
+ const observerRef = React14.useRef(null);
22119
+ const [gridCols, setGridCols] = React14.useState(4);
22120
+ const [visibleWorkspaces, setVisibleWorkspaces] = React14.useState(/* @__PURE__ */ new Set());
21892
22121
  const mergedVideoSources = {
21893
22122
  defaultHlsUrl: videoSources.defaultHlsUrl || DEFAULT_HLS_URL,
21894
22123
  workspaceHlsUrls: { ...DEFAULT_WORKSPACE_HLS_URLS, ...videoSources.workspaceHlsUrls }
21895
22124
  };
21896
- const getWorkspaceHlsUrl = React33.useCallback((workspaceName) => {
22125
+ const getWorkspaceHlsUrl = React14.useCallback((workspaceName) => {
21897
22126
  const wsName = workspaceName.toUpperCase();
21898
22127
  return mergedVideoSources.workspaceHlsUrls[wsName] || mergedVideoSources.defaultHlsUrl;
21899
22128
  }, [mergedVideoSources]);
21900
- const veryLowEfficiencyWorkspaces = React33.useMemo(() => {
22129
+ const veryLowEfficiencyWorkspaces = React14.useMemo(() => {
21901
22130
  return new Set(
21902
22131
  workspaces.filter((w) => w.efficiency < 50 && w.efficiency >= 10).map((w) => w.workspace_name)
21903
22132
  );
21904
22133
  }, [workspaces]);
21905
- const filteredWorkspaces = React33.useMemo(() => {
22134
+ const filteredWorkspaces = React14.useMemo(() => {
21906
22135
  return selectedLine === 1 ? workspaces.filter((w) => {
21907
22136
  if (w.workspace_name === "WS5-5") return true;
21908
22137
  if (w.workspace_name === "WS32-5") return false;
@@ -21923,7 +22152,7 @@ var VideoGridView = React33__namespace.default.memo(({
21923
22152
  }
21924
22153
  }) : workspaces;
21925
22154
  }, [workspaces, selectedLine]);
21926
- const calculateOptimalGrid = React33.useCallback(() => {
22155
+ const calculateOptimalGrid = React14.useCallback(() => {
21927
22156
  if (!containerRef.current) return;
21928
22157
  const containerPadding = 16;
21929
22158
  const containerWidth = containerRef.current.clientWidth - containerPadding;
@@ -21963,13 +22192,13 @@ var VideoGridView = React33__namespace.default.memo(({
21963
22192
  }
21964
22193
  setGridCols(bestCols);
21965
22194
  }, [filteredWorkspaces.length]);
21966
- React33.useEffect(() => {
22195
+ React14.useEffect(() => {
21967
22196
  calculateOptimalGrid();
21968
22197
  const handleResize = () => calculateOptimalGrid();
21969
22198
  window.addEventListener("resize", handleResize);
21970
22199
  return () => window.removeEventListener("resize", handleResize);
21971
22200
  }, [calculateOptimalGrid]);
21972
- React33.useEffect(() => {
22201
+ React14.useEffect(() => {
21973
22202
  if (!containerRef.current) return;
21974
22203
  const options = {
21975
22204
  root: null,
@@ -21997,7 +22226,7 @@ var VideoGridView = React33__namespace.default.memo(({
21997
22226
  observerRef.current?.disconnect();
21998
22227
  };
21999
22228
  }, [filteredWorkspaces]);
22000
- const handleWorkspaceClick = React33.useCallback((workspace) => {
22229
+ const handleWorkspaceClick = React14.useCallback((workspace) => {
22001
22230
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
22002
22231
  trackCoreEvent("Workspace Detail Clicked", {
22003
22232
  workspace_name: workspace.workspace_name,
@@ -22160,7 +22389,7 @@ var arePropsEqual = (prevProps, nextProps) => {
22160
22389
  return prevProps.data.efficiency === nextProps.data.efficiency && prevProps.data.trend_score === nextProps.data.trend_score && prevProps.data.workspace_id === nextProps.data.workspace_id && prevProps.data.workspace_name === nextProps.data.workspace_name && prevProps.isBottleneck === nextProps.isBottleneck && prevProps.isLowEfficiency === nextProps.isLowEfficiency && prevProps.isVeryLowEfficiency === nextProps.isVeryLowEfficiency && // Position doesn't need deep equality check as it's generally static
22161
22390
  prevProps.position.id === nextProps.position.id;
22162
22391
  };
22163
- var WorkspaceGridItem = React33__namespace.default.memo(({
22392
+ var WorkspaceGridItem = React14__namespace.default.memo(({
22164
22393
  data,
22165
22394
  position,
22166
22395
  isBottleneck = false,
@@ -22169,8 +22398,8 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22169
22398
  onHoverChange
22170
22399
  }) => {
22171
22400
  const { navigate } = useNavigation();
22172
- const isInactive = React33.useMemo(() => !data.workspace_id || data.efficiency < 10, [data.workspace_id, data.efficiency]);
22173
- const colorClass = React33.useMemo(() => {
22401
+ const isInactive = React14.useMemo(() => !data.workspace_id || data.efficiency < 10, [data.workspace_id, data.efficiency]);
22402
+ const colorClass = React14.useMemo(() => {
22174
22403
  const isConveyorEnd = position.size === "conveyor" && position.orientation;
22175
22404
  if (isConveyorEnd) {
22176
22405
  if (isInactive) return "bg-gray-300/90";
@@ -22180,11 +22409,11 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22180
22409
  }
22181
22410
  return isInactive ? "bg-gray-300/90" : getEfficiencyColor(data.efficiency);
22182
22411
  }, [data.efficiency, isInactive, position.size, position.orientation]);
22183
- const { arrow, color: arrowColor } = React33.useMemo(() => getTrendArrowAndColor2(data.trend_score), [data.trend_score]);
22184
- const workspaceNumber = React33.useMemo(() => getWorkspaceNumber(data.workspace_name), [data.workspace_name]);
22185
- const styles = React33.useMemo(() => getWorkspaceStyles(position, isInactive), [position, isInactive]);
22186
- const arrowPosition = React33.useMemo(() => getArrowPositionClass(position), [position]);
22187
- const handleClick = React33.useCallback((e) => {
22412
+ const { arrow, color: arrowColor } = React14.useMemo(() => getTrendArrowAndColor2(data.trend_score), [data.trend_score]);
22413
+ const workspaceNumber = React14.useMemo(() => getWorkspaceNumber(data.workspace_name), [data.workspace_name]);
22414
+ const styles = React14.useMemo(() => getWorkspaceStyles(position, isInactive), [position, isInactive]);
22415
+ const arrowPosition = React14.useMemo(() => getArrowPositionClass(position), [position]);
22416
+ const handleClick = React14.useCallback((e) => {
22188
22417
  e.preventDefault();
22189
22418
  if (isInactive) return;
22190
22419
  const displayName = getWorkspaceDisplayName(data.workspace_name);
@@ -22204,8 +22433,8 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22204
22433
  }
22205
22434
  });
22206
22435
  }, [data, position, navigate, isInactive]);
22207
- const handleMouseEnter = React33.useCallback(() => onHoverChange?.(true), [onHoverChange]);
22208
- const handleMouseLeave = React33.useCallback(() => onHoverChange?.(false), [onHoverChange]);
22436
+ const handleMouseEnter = React14.useCallback(() => onHoverChange?.(true), [onHoverChange]);
22437
+ const handleMouseLeave = React14.useCallback(() => onHoverChange?.(false), [onHoverChange]);
22209
22438
  return /* @__PURE__ */ jsxRuntime.jsxs(
22210
22439
  "div",
22211
22440
  {
@@ -22253,7 +22482,7 @@ var WorkspaceGridItem = React33__namespace.default.memo(({
22253
22482
  );
22254
22483
  }, arePropsEqual);
22255
22484
  WorkspaceGridItem.displayName = "WorkspaceGridItem";
22256
- var WorkspaceGrid = React33__namespace.default.memo(({
22485
+ var WorkspaceGrid = React14__namespace.default.memo(({
22257
22486
  workspaces,
22258
22487
  isPdfMode = false,
22259
22488
  customWorkspacePositions,
@@ -22263,7 +22492,7 @@ var WorkspaceGrid = React33__namespace.default.memo(({
22263
22492
  className = "",
22264
22493
  videoSources = {}
22265
22494
  }) => {
22266
- React33.useEffect(() => {
22495
+ React14.useEffect(() => {
22267
22496
  trackCoreEvent("Dashboard View Loaded", {
22268
22497
  view_type: "Camera Grid",
22269
22498
  total_workspaces: workspaces.length
@@ -22293,8 +22522,8 @@ var TargetWorkspaceGrid = ({
22293
22522
  lineNames = {},
22294
22523
  className = ""
22295
22524
  }) => {
22296
- const [scale2, setScale] = React33.useState(1);
22297
- const filteredPositions = React33.useMemo(() => {
22525
+ const [scale2, setScale] = React14.useState(1);
22526
+ const filteredPositions = React14.useMemo(() => {
22298
22527
  const isLine2 = lineId === "line-2";
22299
22528
  return positions.filter((pos) => {
22300
22529
  if (pos.id === "WS5-5") {
@@ -22312,7 +22541,7 @@ var TargetWorkspaceGrid = ({
22312
22541
  return isLine2 ? wsNumber >= 23 && wsNumber <= 44 : wsNumber >= 1 && wsNumber <= 22;
22313
22542
  });
22314
22543
  }, [lineId, positions]);
22315
- const boundaries = React33.useMemo(() => filteredPositions.reduce(
22544
+ const boundaries = React14.useMemo(() => filteredPositions.reduce(
22316
22545
  (acc, pos) => ({
22317
22546
  minX: Math.min(acc.minX, pos.x),
22318
22547
  maxX: Math.max(acc.maxX, pos.x),
@@ -22321,9 +22550,9 @@ var TargetWorkspaceGrid = ({
22321
22550
  }),
22322
22551
  { minX: Infinity, maxX: -Infinity, minY: Infinity, maxY: -Infinity }
22323
22552
  ), [filteredPositions]);
22324
- const baseWidth = React33.useMemo(() => (boundaries.maxX - boundaries.minX + 1) * 80, [boundaries]);
22325
- const baseHeight = React33.useMemo(() => (boundaries.maxY - boundaries.minY + 1) * 120, [boundaries]);
22326
- const updateLayout2 = React33.useCallback(() => {
22553
+ const baseWidth = React14.useMemo(() => (boundaries.maxX - boundaries.minX + 1) * 80, [boundaries]);
22554
+ const baseHeight = React14.useMemo(() => (boundaries.maxY - boundaries.minY + 1) * 120, [boundaries]);
22555
+ const updateLayout2 = React14.useCallback(() => {
22327
22556
  const container = document.querySelector(".workspace-grid-container");
22328
22557
  if (!container) return;
22329
22558
  const rect = container.getBoundingClientRect();
@@ -22334,7 +22563,7 @@ var TargetWorkspaceGrid = ({
22334
22563
  const finalScale = Math.min(scaleX, scaleY, 1);
22335
22564
  setScale(finalScale);
22336
22565
  }, [baseWidth, baseHeight]);
22337
- React33.useEffect(() => {
22566
+ React14.useEffect(() => {
22338
22567
  updateLayout2();
22339
22568
  window.addEventListener("resize", updateLayout2);
22340
22569
  return () => {
@@ -22442,7 +22671,7 @@ var KPICard = ({
22442
22671
  }) => {
22443
22672
  useThemeConfig();
22444
22673
  const { formatNumber } = useFormatNumber();
22445
- const trendInfo = React33__namespace.default.useMemo(() => {
22674
+ const trendInfo = React14__namespace.default.useMemo(() => {
22446
22675
  let trendValue = trend || "neutral";
22447
22676
  if (change !== void 0 && trend === void 0) {
22448
22677
  trendValue = change > 0 ? "up" : change < 0 ? "down" : "neutral";
@@ -22465,7 +22694,7 @@ var KPICard = ({
22465
22694
  const shouldShowTrend = !(change === 0 && trend === void 0);
22466
22695
  return { trendValue, Icon: Icon2, colorClass, shouldShowTrend };
22467
22696
  }, [trend, change]);
22468
- const formattedValue = React33__namespace.default.useMemo(() => {
22697
+ const formattedValue = React14__namespace.default.useMemo(() => {
22469
22698
  if (title === "Quality Compliance" && typeof value === "number") {
22470
22699
  return value.toFixed(1);
22471
22700
  }
@@ -22479,7 +22708,7 @@ var KPICard = ({
22479
22708
  }
22480
22709
  return value;
22481
22710
  }, [value, title]);
22482
- const formattedChange = React33__namespace.default.useMemo(() => {
22711
+ const formattedChange = React14__namespace.default.useMemo(() => {
22483
22712
  if (change === void 0 || change === 0) return null;
22484
22713
  const absChange = Math.abs(change);
22485
22714
  return formatNumber(absChange, { minimumFractionDigits: 0, maximumFractionDigits: 1 });
@@ -22685,7 +22914,7 @@ var KPIHeader = ({
22685
22914
  }
22686
22915
  );
22687
22916
  };
22688
- var KPISection = React33.memo(({
22917
+ var KPISection = React14.memo(({
22689
22918
  kpis,
22690
22919
  className,
22691
22920
  layout: layout2 = "row",
@@ -22794,7 +23023,7 @@ var KPISection = React33.memo(({
22794
23023
  });
22795
23024
  KPISection.displayName = "KPISection";
22796
23025
  var ISTTimer2 = ISTTimer_default;
22797
- var DashboardHeader = React33.memo(({ lineTitle, className = "" }) => {
23026
+ var DashboardHeader = React14.memo(({ lineTitle, className = "" }) => {
22798
23027
  const getShiftName = () => {
22799
23028
  const now2 = /* @__PURE__ */ new Date();
22800
23029
  const currentHour = now2.getHours();
@@ -22829,7 +23058,7 @@ var DashboardHeader = React33.memo(({ lineTitle, className = "" }) => {
22829
23058
  ] });
22830
23059
  });
22831
23060
  DashboardHeader.displayName = "DashboardHeader";
22832
- var NoWorkspaceData = React33.memo(({ className = "" }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full items-center justify-center ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-4 shadow-md", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2 text-gray-500", children: [
23061
+ var NoWorkspaceData = React14.memo(({ className = "" }) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full items-center justify-center ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-4 shadow-md", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-2 text-gray-500", children: [
22833
23062
  /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-5 w-5", viewBox: "0 0 20 20", fill: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { fillRule: "evenodd", d: "M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z", clipRule: "evenodd" }) }),
22834
23063
  /* @__PURE__ */ jsxRuntime.jsx("span", { children: "No workspace data available" })
22835
23064
  ] }) }) }));
@@ -22842,7 +23071,7 @@ var WorkspaceMonthlyDataFetcher = ({
22842
23071
  onLoadingChange
22843
23072
  }) => {
22844
23073
  const supabase = useSupabase();
22845
- React33.useEffect(() => {
23074
+ React14.useEffect(() => {
22846
23075
  if (!workspaceId) return;
22847
23076
  const fetchMonthlyData = async () => {
22848
23077
  onLoadingChange(true);
@@ -22891,7 +23120,7 @@ var Breadcrumbs = ({ items }) => {
22891
23120
  }
22892
23121
  }
22893
23122
  };
22894
- return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": "Breadcrumb", className: "mb-1 flex items-center space-x-1 text-xs font-medium text-gray-500 dark:text-gray-400", children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React33__namespace.default.Fragment, { children: [
23123
+ return /* @__PURE__ */ jsxRuntime.jsx("nav", { "aria-label": "Breadcrumb", className: "mb-1 flex items-center space-x-1 text-xs font-medium text-gray-500 dark:text-gray-400", children: items.map((item, index) => /* @__PURE__ */ jsxRuntime.jsxs(React14__namespace.default.Fragment, { children: [
22895
23124
  index > 0 && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { className: "h-3 w-3 text-gray-400 dark:text-gray-500" }),
22896
23125
  /* @__PURE__ */ jsxRuntime.jsxs(
22897
23126
  "span",
@@ -22915,9 +23144,9 @@ var UserProfileDropdown = ({ config }) => {
22915
23144
  const { user, signOut } = useAuth();
22916
23145
  const { featureFlags } = useDashboardConfig();
22917
23146
  const navigation = useNavigation();
22918
- const [isOpen, setIsOpen] = React33.useState(false);
22919
- const dropdownRef = React33.useRef(null);
22920
- React33.useEffect(() => {
23147
+ const [isOpen, setIsOpen] = React14.useState(false);
23148
+ const dropdownRef = React14.useRef(null);
23149
+ React14.useEffect(() => {
22921
23150
  const handleClickOutside = (event) => {
22922
23151
  if (dropdownRef.current && !dropdownRef.current.contains(event.target)) {
22923
23152
  setIsOpen(false);
@@ -23017,8 +23246,8 @@ var PageHeader = ({
23017
23246
  headerLogo,
23018
23247
  sticky = true
23019
23248
  }) => {
23020
- const [darkMode, setDarkMode] = React33.useState(false);
23021
- React33.useEffect(() => {
23249
+ const [darkMode, setDarkMode] = React14.useState(false);
23250
+ React14.useEffect(() => {
23022
23251
  if (typeof window !== "undefined") {
23023
23252
  if (localStorage.theme === "dark" || !("theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches) {
23024
23253
  document.documentElement.classList.add("dark");
@@ -23072,7 +23301,7 @@ var PageHeader = ({
23072
23301
  }
23073
23302
  );
23074
23303
  };
23075
- var SideNavBar = React33.memo(({
23304
+ var SideNavBar = React14.memo(({
23076
23305
  // These props are accepted but not used in this implementation
23077
23306
  navItems = [],
23078
23307
  logo,
@@ -23085,13 +23314,13 @@ var SideNavBar = React33.memo(({
23085
23314
  const entityConfig = useEntityConfig();
23086
23315
  const lineId = entityConfig.defaultLineId || LINE_1_UUID;
23087
23316
  const pathname = propPathname || router$1.pathname;
23088
- const getButtonClasses = React33.useCallback((path) => {
23317
+ const getButtonClasses = React14.useCallback((path) => {
23089
23318
  const isActive = pathname === path || pathname.startsWith(path + "/");
23090
23319
  return `w-full flex flex-col items-center justify-center py-3 px-1 rounded-lg relative group
23091
23320
  ${isActive ? "bg-blue-100 text-blue-700 shadow-md border border-blue-200 font-semibold" : "hover:bg-gray-50 text-gray-500 hover:text-gray-700 font-medium"}
23092
23321
  transition-all duration-300 ease-in-out focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2`;
23093
23322
  }, [pathname]);
23094
- const handleHomeClick = React33.useCallback(() => navigate("/", {
23323
+ const handleHomeClick = React14.useCallback(() => navigate("/", {
23095
23324
  trackingEvent: {
23096
23325
  name: "Line Overview Page Clicked",
23097
23326
  properties: {
@@ -23101,7 +23330,7 @@ var SideNavBar = React33.memo(({
23101
23330
  }
23102
23331
  }
23103
23332
  }), [navigate, lineId]);
23104
- const handleLeaderboardClick = React33.useCallback(() => navigate(`/leaderboard/${lineId}`, {
23333
+ const handleLeaderboardClick = React14.useCallback(() => navigate(`/leaderboard/${lineId}`, {
23105
23334
  trackingEvent: {
23106
23335
  name: "Leaderboard Page Clicked",
23107
23336
  properties: {
@@ -23110,7 +23339,7 @@ var SideNavBar = React33.memo(({
23110
23339
  }
23111
23340
  }
23112
23341
  }), [navigate, lineId]);
23113
- const handleKPIsClick = React33.useCallback(() => navigate(`/kpis`, {
23342
+ const handleKPIsClick = React14.useCallback(() => navigate(`/kpis`, {
23114
23343
  trackingEvent: {
23115
23344
  name: "KPI Page Clicked",
23116
23345
  properties: {
@@ -23119,7 +23348,7 @@ var SideNavBar = React33.memo(({
23119
23348
  }
23120
23349
  }
23121
23350
  }), [navigate]);
23122
- const handleTargetsClick = React33.useCallback(() => navigate("/targets", {
23351
+ const handleTargetsClick = React14.useCallback(() => navigate("/targets", {
23123
23352
  trackingEvent: {
23124
23353
  name: "Targets Page Clicked",
23125
23354
  properties: {
@@ -23127,7 +23356,7 @@ var SideNavBar = React33.memo(({
23127
23356
  }
23128
23357
  }
23129
23358
  }), [navigate]);
23130
- const handleShiftsClick = React33.useCallback(() => navigate("/shifts", {
23359
+ const handleShiftsClick = React14.useCallback(() => navigate("/shifts", {
23131
23360
  trackingEvent: {
23132
23361
  name: "Shifts Page Clicked",
23133
23362
  properties: {
@@ -23135,7 +23364,7 @@ var SideNavBar = React33.memo(({
23135
23364
  }
23136
23365
  }
23137
23366
  }), [navigate]);
23138
- const handleAIAgentClick = React33.useCallback(() => navigate("/ai-agent", {
23367
+ const handleAIAgentClick = React14.useCallback(() => navigate("/ai-agent", {
23139
23368
  trackingEvent: {
23140
23369
  name: "AI Agent Page Clicked",
23141
23370
  properties: {
@@ -23143,7 +23372,7 @@ var SideNavBar = React33.memo(({
23143
23372
  }
23144
23373
  }
23145
23374
  }), [navigate]);
23146
- const handleProfileClick = React33.useCallback(() => navigate("/profile", {
23375
+ const handleProfileClick = React14.useCallback(() => navigate("/profile", {
23147
23376
  trackingEvent: {
23148
23377
  name: "Profile Page Clicked",
23149
23378
  properties: {
@@ -23151,7 +23380,7 @@ var SideNavBar = React33.memo(({
23151
23380
  }
23152
23381
  }
23153
23382
  }), [navigate]);
23154
- const handleHelpClick = React33.useCallback(() => navigate("/help", {
23383
+ const handleHelpClick = React14.useCallback(() => navigate("/help", {
23155
23384
  trackingEvent: {
23156
23385
  name: "Help Page Clicked",
23157
23386
  properties: {
@@ -23159,14 +23388,14 @@ var SideNavBar = React33.memo(({
23159
23388
  }
23160
23389
  }
23161
23390
  }), [navigate]);
23162
- const homeButtonClasses = React33.useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
23163
- const leaderboardButtonClasses = React33.useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
23164
- const kpisButtonClasses = React33.useMemo(() => getButtonClasses("/kpis"), [getButtonClasses, pathname]);
23165
- const targetsButtonClasses = React33.useMemo(() => getButtonClasses("/targets"), [getButtonClasses, pathname]);
23166
- const shiftsButtonClasses = React33.useMemo(() => getButtonClasses("/shifts"), [getButtonClasses, pathname]);
23167
- const aiAgentButtonClasses = React33.useMemo(() => getButtonClasses("/ai-agent"), [getButtonClasses, pathname]);
23168
- const profileButtonClasses = React33.useMemo(() => getButtonClasses("/profile"), [getButtonClasses, pathname]);
23169
- const helpButtonClasses = React33.useMemo(() => getButtonClasses("/help"), [getButtonClasses, pathname]);
23391
+ const homeButtonClasses = React14.useMemo(() => getButtonClasses("/"), [getButtonClasses, pathname]);
23392
+ const leaderboardButtonClasses = React14.useMemo(() => getButtonClasses("/leaderboard"), [getButtonClasses, pathname]);
23393
+ const kpisButtonClasses = React14.useMemo(() => getButtonClasses("/kpis"), [getButtonClasses, pathname]);
23394
+ const targetsButtonClasses = React14.useMemo(() => getButtonClasses("/targets"), [getButtonClasses, pathname]);
23395
+ const shiftsButtonClasses = React14.useMemo(() => getButtonClasses("/shifts"), [getButtonClasses, pathname]);
23396
+ const aiAgentButtonClasses = React14.useMemo(() => getButtonClasses("/ai-agent"), [getButtonClasses, pathname]);
23397
+ const profileButtonClasses = React14.useMemo(() => getButtonClasses("/profile"), [getButtonClasses, pathname]);
23398
+ const helpButtonClasses = React14.useMemo(() => getButtonClasses("/help"), [getButtonClasses, pathname]);
23170
23399
  return /* @__PURE__ */ jsxRuntime.jsxs("aside", { className: `w-20 h-screen bg-white shadow-lg border-r border-gray-100 flex flex-col items-center fixed ${className}`, children: [
23171
23400
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full py-6 px-4 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx(
23172
23401
  "button",
@@ -23414,7 +23643,7 @@ var Header = ({
23414
23643
  }) => {
23415
23644
  const { pathname } = useNavigation();
23416
23645
  const { user, signOut } = useAuth();
23417
- const [showDropdown, setShowDropdown] = React33.useState(false);
23646
+ const [showDropdown, setShowDropdown] = React14.useState(false);
23418
23647
  const getPageTitle = () => {
23419
23648
  if (pathname === "/") return "Factory View";
23420
23649
  if (pathname.startsWith("/workspace/")) return "Workspace Details";
@@ -23491,18 +23720,18 @@ var SingleVideoStream = ({
23491
23720
  initialPlayDelay = 100,
23492
23721
  hlsConfig = {}
23493
23722
  }) => {
23494
- const videoRef = React33.useRef(null);
23495
- const hlsRef = React33.useRef(null);
23496
- const [loading, setLoading] = React33.useState(true);
23497
- const [error, setError] = React33.useState(null);
23498
- const [totalRetries, setTotalRetries] = React33.useState(0);
23723
+ const videoRef = React14.useRef(null);
23724
+ const hlsRef = React14.useRef(null);
23725
+ const [loading, setLoading] = React14.useState(true);
23726
+ const [error, setError] = React14.useState(null);
23727
+ const [totalRetries, setTotalRetries] = React14.useState(0);
23499
23728
  const cleanupHls = () => {
23500
23729
  if (hlsRef.current) {
23501
23730
  hlsRef.current.destroy();
23502
23731
  hlsRef.current = null;
23503
23732
  }
23504
23733
  };
23505
- React33.useEffect(() => {
23734
+ React14.useEffect(() => {
23506
23735
  const video = videoRef.current;
23507
23736
  if (!video) return;
23508
23737
  console.log(`SingleVideoStream: Initializing stream for workspace ${workspaceName}`);
@@ -23637,7 +23866,7 @@ var ThreadSidebar = ({
23637
23866
  className = ""
23638
23867
  }) => {
23639
23868
  const { threads, isLoading, error, deleteThread: deleteThread2 } = useThreads();
23640
- const [deletingId, setDeletingId] = React33.useState(null);
23869
+ const [deletingId, setDeletingId] = React14.useState(null);
23641
23870
  const handleDelete = async (e, threadId) => {
23642
23871
  e.stopPropagation();
23643
23872
  if (confirm("Are you sure you want to delete this conversation?")) {
@@ -23710,7 +23939,7 @@ var ThreadSidebar = ({
23710
23939
  ] });
23711
23940
  };
23712
23941
  var axelProfilePng = "/axel-profile.png";
23713
- var ProfilePicture = React33__namespace.default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23942
+ var ProfilePicture = React14__namespace.default.memo(({ alt = "Axel", className = "w-12 h-12" }) => {
23714
23943
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${className} rounded-xl overflow-hidden shadow-sm`, children: /* @__PURE__ */ jsxRuntime.jsx(
23715
23944
  "img",
23716
23945
  {
@@ -23733,23 +23962,23 @@ var AIAgentView = () => {
23733
23962
  const entityConfig = useEntityConfig();
23734
23963
  const dateTimeConfig = useDateTimeConfig();
23735
23964
  const shiftConfig = useShiftConfig();
23736
- const [inputValue, setInputValue] = React33.useState("");
23737
- const [loadingThreads, setLoadingThreads] = React33.useState(/* @__PURE__ */ new Set());
23738
- const [lastError, setLastError] = React33.useState(null);
23739
- const [copiedMessageId, setCopiedMessageId] = React33.useState(null);
23740
- const [activeThreadId, setActiveThreadId] = React33.useState(void 0);
23741
- const [isSidebarOpen, setIsSidebarOpen] = React33.useState(false);
23742
- const [streamingStates, setStreamingStates] = React33.useState(/* @__PURE__ */ new Map());
23743
- const [userId, setUserId] = React33.useState(null);
23744
- const [pendingThreadId, setPendingThreadId] = React33.useState(null);
23745
- const [isTransitioning, setIsTransitioning] = React33.useState(false);
23746
- const [typedText, setTypedText] = React33.useState("");
23747
- const [newChatCount, setNewChatCount] = React33.useState(0);
23748
- const [hasStartedTyping, setHasStartedTyping] = React33.useState(false);
23749
- const [typingStartTime, setTypingStartTime] = React33.useState(null);
23750
- const [lastTypingTime, setLastTypingTime] = React33.useState(null);
23751
- const [characterCount, setCharacterCount] = React33.useState(0);
23752
- const typingTimeoutRef = React33.useRef(null);
23965
+ const [inputValue, setInputValue] = React14.useState("");
23966
+ const [loadingThreads, setLoadingThreads] = React14.useState(/* @__PURE__ */ new Set());
23967
+ const [lastError, setLastError] = React14.useState(null);
23968
+ const [copiedMessageId, setCopiedMessageId] = React14.useState(null);
23969
+ const [activeThreadId, setActiveThreadId] = React14.useState(void 0);
23970
+ const [isSidebarOpen, setIsSidebarOpen] = React14.useState(false);
23971
+ const [streamingStates, setStreamingStates] = React14.useState(/* @__PURE__ */ new Map());
23972
+ const [userId, setUserId] = React14.useState(null);
23973
+ const [pendingThreadId, setPendingThreadId] = React14.useState(null);
23974
+ const [isTransitioning, setIsTransitioning] = React14.useState(false);
23975
+ const [typedText, setTypedText] = React14.useState("");
23976
+ const [newChatCount, setNewChatCount] = React14.useState(0);
23977
+ const [hasStartedTyping, setHasStartedTyping] = React14.useState(false);
23978
+ const [typingStartTime, setTypingStartTime] = React14.useState(null);
23979
+ const [lastTypingTime, setLastTypingTime] = React14.useState(null);
23980
+ const [characterCount, setCharacterCount] = React14.useState(0);
23981
+ const typingTimeoutRef = React14.useRef(null);
23753
23982
  const isThreadLoading = (threadId) => {
23754
23983
  return threadId ? loadingThreads.has(threadId) : false;
23755
23984
  };
@@ -23824,13 +24053,13 @@ var AIAgentView = () => {
23824
24053
  typingTimeoutRef.current = null;
23825
24054
  }
23826
24055
  };
23827
- const textareaRef = React33.useRef(null);
23828
- const messagesEndRef = React33.useRef(null);
23829
- const containerRef = React33.useRef(null);
24056
+ const textareaRef = React14.useRef(null);
24057
+ const messagesEndRef = React14.useRef(null);
24058
+ const containerRef = React14.useRef(null);
23830
24059
  const { createThread, mutate: mutateThreads } = useThreads();
23831
24060
  const { messages, addMessage, setMessages } = useMessages(activeThreadId);
23832
24061
  const agnoApiUrl = config.endpoints?.agnoApiUrl || "https://optifye-agent-production.up.railway.app";
23833
- const sseClient = React33.useMemo(() => {
24062
+ const sseClient = React14.useMemo(() => {
23834
24063
  console.log("[AIAgentView] Using AGNO API URL:", agnoApiUrl);
23835
24064
  return new SSEChatClient(agnoApiUrl);
23836
24065
  }, [agnoApiUrl]);
@@ -23846,20 +24075,20 @@ var AIAgentView = () => {
23846
24075
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
23847
24076
  const companyId = entityConfig.companyId || "default-company-id";
23848
24077
  const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
23849
- React33.useLayoutEffect(() => {
24078
+ React14.useLayoutEffect(() => {
23850
24079
  const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
23851
24080
  if (savedThreadId && savedThreadId !== "undefined") {
23852
24081
  setActiveThreadId(savedThreadId);
23853
24082
  }
23854
24083
  }, [ACTIVE_THREAD_STORAGE_KEY]);
23855
- React33.useEffect(() => {
24084
+ React14.useEffect(() => {
23856
24085
  if (activeThreadId) {
23857
24086
  localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
23858
24087
  } else {
23859
24088
  localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
23860
24089
  }
23861
24090
  }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
23862
- React33.useEffect(() => {
24091
+ React14.useEffect(() => {
23863
24092
  const handleVisibilityChange = () => {
23864
24093
  if (document.visibilityState === "hidden" && activeThreadId) {
23865
24094
  localStorage.setItem(ACTIVE_THREAD_STORAGE_KEY, activeThreadId);
@@ -23880,7 +24109,7 @@ var AIAgentView = () => {
23880
24109
  }
23881
24110
  };
23882
24111
  }, [activeThreadId, ACTIVE_THREAD_STORAGE_KEY]);
23883
- React33.useEffect(() => {
24112
+ React14.useEffect(() => {
23884
24113
  if (textareaRef.current) {
23885
24114
  textareaRef.current.style.height = "auto";
23886
24115
  textareaRef.current.style.height = `${Math.min(textareaRef.current.scrollHeight, 120)}px`;
@@ -23889,12 +24118,12 @@ var AIAgentView = () => {
23889
24118
  const scrollToBottom = () => {
23890
24119
  messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
23891
24120
  };
23892
- React33.useEffect(() => {
24121
+ React14.useEffect(() => {
23893
24122
  if (activeThreadId && messages.length > 0) {
23894
24123
  setTimeout(scrollToBottom, 100);
23895
24124
  }
23896
24125
  }, [activeThreadId]);
23897
- React33.useEffect(() => {
24126
+ React14.useEffect(() => {
23898
24127
  if (messages.length === 0 && !isTransitioning) {
23899
24128
  const fullText = "Hi, I'm Axel - Your AI Supervisor";
23900
24129
  let index = 0;
@@ -23910,7 +24139,7 @@ var AIAgentView = () => {
23910
24139
  return () => clearInterval(typeInterval);
23911
24140
  }
23912
24141
  }, [messages.length, isTransitioning]);
23913
- React33.useEffect(() => {
24142
+ React14.useEffect(() => {
23914
24143
  if (isSidebarOpen) {
23915
24144
  setNewChatCount(0);
23916
24145
  }
@@ -23934,17 +24163,17 @@ var AIAgentView = () => {
23934
24163
  localStorage.removeItem(ACTIVE_THREAD_STORAGE_KEY);
23935
24164
  textareaRef.current?.focus();
23936
24165
  };
23937
- React33.useEffect(() => {
24166
+ React14.useEffect(() => {
23938
24167
  preloadImage(axelProfilePng);
23939
24168
  }, []);
23940
- React33.useEffect(() => {
24169
+ React14.useEffect(() => {
23941
24170
  return () => {
23942
24171
  if (typingTimeoutRef.current) {
23943
24172
  clearTimeout(typingTimeoutRef.current);
23944
24173
  }
23945
24174
  };
23946
24175
  }, []);
23947
- React33.useEffect(() => {
24176
+ React14.useEffect(() => {
23948
24177
  const checkAuth = async () => {
23949
24178
  const supabase2 = _getSupabaseInstance();
23950
24179
  const { data: { session } } = await supabase2.auth.getSession();
@@ -24695,10 +24924,10 @@ var FactoryView = ({
24695
24924
  const supabase = useSupabase();
24696
24925
  const line1DataHook = useLineDetailedMetrics(line1Id);
24697
24926
  const line2DataHook = useLineDetailedMetrics(line2Id);
24698
- const [lines, setLines] = React33.useState([]);
24699
- const [loading, setLoading] = React33.useState(true);
24700
- const [error, setError] = React33.useState(null);
24701
- React33.useMemo(() => {
24927
+ const [lines, setLines] = React14.useState([]);
24928
+ const [loading, setLoading] = React14.useState(true);
24929
+ const [error, setError] = React14.useState(null);
24930
+ React14.useMemo(() => {
24702
24931
  const processLineData = (hookData, defaultName) => {
24703
24932
  const currentLineInfo = hookData.lineData;
24704
24933
  let last5HoursData = [];
@@ -24733,7 +24962,7 @@ var FactoryView = ({
24733
24962
  processLineData(line2DataHook, "Line 2")
24734
24963
  ];
24735
24964
  }, [line1DataHook, line2DataHook]);
24736
- React33.useEffect(() => {
24965
+ React14.useEffect(() => {
24737
24966
  const fetchHourlyData = async () => {
24738
24967
  try {
24739
24968
  if (!supabase) {
@@ -25156,6 +25385,17 @@ var SlackAPI = class {
25156
25385
  const config = _getDashboardConfigInstance();
25157
25386
  const endpointsConfig = config.endpoints ?? DEFAULT_ENDPOINTS_CONFIG;
25158
25387
  const { slackWebhookUrl, slackProxyEndpoint } = endpointsConfig;
25388
+ console.log("SlackAPI Debug - Configuration check:", {
25389
+ hasConfig: !!config,
25390
+ hasEndpoints: !!config.endpoints,
25391
+ slackWebhookUrl: slackWebhookUrl ? "configured" : "not configured",
25392
+ slackProxyEndpoint: slackProxyEndpoint ? "configured" : "not configured",
25393
+ envVariable: process.env.SLACK_WEBHOOK_URL ? "set" : "not set",
25394
+ publicEnvVariable: process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL ? "set" : "not set"
25395
+ });
25396
+ if (process.env.NEXT_PUBLIC_SLACK_WEBHOOK_URL && !process.env.SLACK_WEBHOOK_URL) {
25397
+ console.warn("\u26A0\uFE0F SECURITY WARNING: Using NEXT_PUBLIC_SLACK_WEBHOOK_URL exposes your webhook URL to the client. Consider using a server-side proxy instead.");
25398
+ }
25159
25399
  if (slackWebhookUrl) {
25160
25400
  const slackMessage = this.formatSlackMessage(ticket);
25161
25401
  const response = await fetch(slackWebhookUrl, {
@@ -25190,6 +25430,10 @@ var SlackAPI = class {
25190
25430
  return;
25191
25431
  }
25192
25432
  console.warn("Slack notification skipped: No webhook or proxy endpoint configured");
25433
+ console.info("To fix this, either:");
25434
+ console.info("1. Set up a server-side proxy endpoint and configure slackProxyEndpoint in your dashboard config");
25435
+ console.info("2. For development only: use NEXT_PUBLIC_SLACK_WEBHOOK_URL (not recommended for production)");
25436
+ console.info("3. Configure the webhook URL directly in your dashboard config at runtime");
25193
25437
  } catch (error) {
25194
25438
  console.error("Failed to send Slack notification:", error);
25195
25439
  throw error;
@@ -25298,16 +25542,16 @@ var HelpView = ({
25298
25542
  supportEmail = "support@optifye.com"
25299
25543
  }) => {
25300
25544
  const { navigate } = useNavigation();
25301
- const [formData, setFormData] = React33.useState({
25545
+ const [formData, setFormData] = React14.useState({
25302
25546
  subject: "",
25303
25547
  category: "general",
25304
25548
  priority: "normal",
25305
25549
  description: "",
25306
25550
  email: ""
25307
25551
  });
25308
- const [isSubmitting, setIsSubmitting] = React33.useState(false);
25309
- const [submitStatus, setSubmitStatus] = React33.useState("idle");
25310
- const [errorMessage, setErrorMessage] = React33.useState(null);
25552
+ const [isSubmitting, setIsSubmitting] = React14.useState(false);
25553
+ const [submitStatus, setSubmitStatus] = React14.useState("idle");
25554
+ const [errorMessage, setErrorMessage] = React14.useState(null);
25311
25555
  const categories = [
25312
25556
  { value: "general", label: "General Inquiry", icon: outline.QuestionMarkCircleIcon },
25313
25557
  { value: "technical", label: "Technical Issue", icon: outline.ExclamationCircleIcon },
@@ -25556,11 +25800,29 @@ function HomeView({
25556
25800
  },
25557
25801
  factoryName = "Simba Beer - Line 1"
25558
25802
  }) {
25559
- const [isHydrated, setIsHydrated] = React33.useState(false);
25560
- const [selectedLineId, setSelectedLineId] = React33.useState(defaultLineId);
25561
- const [isChangingFilter, setIsChangingFilter] = React33.useState(false);
25562
- const [errorMessage, setErrorMessage] = React33.useState(null);
25563
- React33.useCallback(() => {
25803
+ const [isHydrated, setIsHydrated] = React14.useState(false);
25804
+ const [selectedLineId, setSelectedLineId] = React14.useState(defaultLineId);
25805
+ const [isChangingFilter, setIsChangingFilter] = React14.useState(false);
25806
+ const [errorMessage, setErrorMessage] = React14.useState(null);
25807
+ const [displayNamesInitialized, setDisplayNamesInitialized] = React14.useState(false);
25808
+ React14.useEffect(() => {
25809
+ const initDisplayNames = async () => {
25810
+ try {
25811
+ await preInitializeWorkspaceDisplayNames(selectedLineId);
25812
+ setDisplayNamesInitialized(true);
25813
+ } catch (error) {
25814
+ console.error("Failed to pre-initialize workspace display names:", error);
25815
+ setDisplayNamesInitialized(true);
25816
+ }
25817
+ };
25818
+ initDisplayNames();
25819
+ }, [selectedLineId]);
25820
+ const {
25821
+ displayNames: workspaceDisplayNames,
25822
+ loading: displayNamesLoading,
25823
+ error: displayNamesError
25824
+ } = useWorkspaceDisplayNames(void 0, selectedLineId);
25825
+ React14.useCallback(() => {
25564
25826
  console.log("Refetching KPIs after line metrics update");
25565
25827
  }, []);
25566
25828
  const {
@@ -25571,7 +25833,7 @@ function HomeView({
25571
25833
  } = useLineKPIs({
25572
25834
  lineId: selectedLineId
25573
25835
  });
25574
- const onLineMetricsUpdate = React33.useCallback(() => {
25836
+ const onLineMetricsUpdate = React14.useCallback(() => {
25575
25837
  const timer = setTimeout(() => {
25576
25838
  refetchKPIs();
25577
25839
  }, 1e3);
@@ -25592,12 +25854,12 @@ function HomeView({
25592
25854
  isLoading: breaksLoading,
25593
25855
  error: breaksError
25594
25856
  } = useActiveBreaks([selectedLineId]);
25595
- const memoizedWorkspaceMetrics = React33.useMemo(() => workspaceMetrics, [
25857
+ const memoizedWorkspaceMetrics = React14.useMemo(() => workspaceMetrics, [
25596
25858
  // Only update reference if meaningful properties change
25597
25859
  workspaceMetrics.length,
25598
25860
  ...workspaceMetrics.map((w) => `${w.workspace_uuid}-${Math.round(w.efficiency)}-${w.trend}`)
25599
25861
  ]);
25600
- const memoizedKPIs = React33.useMemo(() => kpis, [
25862
+ const memoizedKPIs = React14.useMemo(() => kpis, [
25601
25863
  // Only update reference when values change by at least 1%
25602
25864
  kpis?.efficiency?.value ? Math.round(kpis.efficiency.value) : null,
25603
25865
  kpis?.underperformingWorkers?.current,
@@ -25608,10 +25870,10 @@ function HomeView({
25608
25870
  // Round to 1 decimal
25609
25871
  kpis?.qualityCompliance?.value ? Math.round(kpis.qualityCompliance.value) : null
25610
25872
  ]);
25611
- React33.useEffect(() => {
25873
+ React14.useEffect(() => {
25612
25874
  setIsHydrated(true);
25613
25875
  }, []);
25614
- React33.useEffect(() => {
25876
+ React14.useEffect(() => {
25615
25877
  if (metricsError) {
25616
25878
  setErrorMessage(metricsError.message);
25617
25879
  } else if (kpisError) {
@@ -25620,28 +25882,28 @@ function HomeView({
25620
25882
  setErrorMessage(null);
25621
25883
  }
25622
25884
  }, [metricsError, kpisError]);
25623
- React33.useCallback((e) => {
25885
+ React14.useCallback((e) => {
25624
25886
  setIsChangingFilter(true);
25625
25887
  setSelectedLineId(e.target.value);
25626
25888
  }, []);
25627
- React33.useEffect(() => {
25889
+ React14.useEffect(() => {
25628
25890
  if (!metricsLoading && !kpisLoading && isChangingFilter && workspaceMetrics.length > 0) {
25629
25891
  setIsChangingFilter(false);
25630
25892
  }
25631
25893
  }, [metricsLoading, kpisLoading, workspaceMetrics, isChangingFilter]);
25632
- const lineTitle = React33.useMemo(() => {
25894
+ const lineTitle = React14.useMemo(() => {
25633
25895
  return factoryName;
25634
25896
  }, [factoryName]);
25635
- const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter;
25897
+ const isLoading = !isHydrated || metricsLoading || kpisLoading || isChangingFilter || displayNamesLoading || !displayNamesInitialized;
25636
25898
  if (isLoading) {
25637
25899
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-h-screen bg-slate-50", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingPageCmp, { message: "Loading dashboard..." }) });
25638
25900
  }
25639
- if (errorMessage) {
25901
+ if (errorMessage || displayNamesError) {
25640
25902
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-screen items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-lg bg-white p-6 shadow-lg", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center space-x-3 text-red-500", children: [
25641
25903
  /* @__PURE__ */ jsxRuntime.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) }),
25642
25904
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-lg font-medium", children: [
25643
25905
  "Error: ",
25644
- errorMessage
25906
+ errorMessage || displayNamesError?.message
25645
25907
  ] })
25646
25908
  ] }) }) });
25647
25909
  }
@@ -25661,7 +25923,7 @@ function HomeView({
25661
25923
  /* @__PURE__ */ jsxRuntime.jsx(DashboardHeader, { lineTitle, className: "mb-1 sm:mb-0" }),
25662
25924
  memoizedKPIs && /* @__PURE__ */ jsxRuntime.jsx(KPISection2, { kpis: memoizedKPIs, className: "w-full sm:w-auto" })
25663
25925
  ] }) }),
25664
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React33__namespace.default.createElement(WorkspaceGrid, {
25926
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden", children: memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: React14__namespace.default.createElement(WorkspaceGrid, {
25665
25927
  workspaces: memoizedWorkspaceMetrics,
25666
25928
  lineNames,
25667
25929
  factoryView: factoryViewId,
@@ -25682,7 +25944,7 @@ function HomeView({
25682
25944
  }
25683
25945
  );
25684
25946
  }
25685
- var AuthenticatedHomeView = withAuth(React33__namespace.default.memo(HomeView));
25947
+ var AuthenticatedHomeView = withAuth(React14__namespace.default.memo(HomeView));
25686
25948
  var HomeView_default = HomeView;
25687
25949
 
25688
25950
  // src/views/kpi-detail-view.types.ts
@@ -25757,7 +26019,7 @@ var formatLocalDate = (date) => {
25757
26019
  };
25758
26020
  return date.toLocaleDateString("en-US", options);
25759
26021
  };
25760
- var MetricCards = React33.memo(({ lineInfo }) => {
26022
+ var MetricCards = React14.memo(({ lineInfo }) => {
25761
26023
  return /* @__PURE__ */ jsxRuntime.jsxs(
25762
26024
  motion.div,
25763
26025
  {
@@ -25803,7 +26065,7 @@ var MetricCards = React33.memo(({ lineInfo }) => {
25803
26065
  return prevMetrics.current_output === nextMetrics.current_output && prevMetrics.line_threshold === nextMetrics.line_threshold && prevMetrics.underperforming_workspaces === nextMetrics.underperforming_workspaces && prevMetrics.total_workspaces === nextMetrics.total_workspaces && prevMetrics.avg_efficiency === nextMetrics.avg_efficiency;
25804
26066
  });
25805
26067
  MetricCards.displayName = "MetricCards";
25806
- var BottomSection = React33.memo(({
26068
+ var BottomSection = React14.memo(({
25807
26069
  lineInfo,
25808
26070
  workspaceData,
25809
26071
  sortedByEfficiency,
@@ -25815,7 +26077,7 @@ var BottomSection = React33.memo(({
25815
26077
  }) => {
25816
26078
  const navigation = useNavigation();
25817
26079
  const handleNavigate = navigate || navigation.navigate;
25818
- const handleWorkspaceClick = React33.useCallback((ws, index) => {
26080
+ const handleWorkspaceClick = React14.useCallback((ws, index) => {
25819
26081
  trackCoreEvent("Workspace from KPI Clicked", {
25820
26082
  workspace_name: ws.workspace_name,
25821
26083
  workspace_id: ws.workspace_uuid,
@@ -25959,7 +26221,7 @@ var BottomSection = React33.memo(({
25959
26221
  return true;
25960
26222
  });
25961
26223
  BottomSection.displayName = "BottomSection";
25962
- var QualityOverview = React33.memo(({ lineInfo }) => {
26224
+ var QualityOverview = React14.memo(({ lineInfo }) => {
25963
26225
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center h-full p-6 bg-white rounded-lg shadow-sm", children: [
25964
26226
  /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-semibold text-gray-700 mb-4", children: "Quality Overview" }),
25965
26227
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500", children: "Quality metrics have been deprecated and are no longer available." })
@@ -25979,8 +26241,8 @@ var KPIDetailView = ({
25979
26241
  backLinkUrl,
25980
26242
  onBackClick
25981
26243
  }) => {
25982
- const [activeTab, setActiveTab] = React33.useState("overview");
25983
- const [currentMonth, setCurrentMonth] = React33.useState(() => {
26244
+ const [activeTab, setActiveTab] = React14.useState("overview");
26245
+ const [currentMonth, setCurrentMonth] = React14.useState(() => {
25984
26246
  if (urlMonth && typeof urlMonth === "string") {
25985
26247
  const parsedMonth = parseInt(urlMonth);
25986
26248
  if (!isNaN(parsedMonth) && parsedMonth >= 0 && parsedMonth <= 11) {
@@ -25989,7 +26251,7 @@ var KPIDetailView = ({
25989
26251
  }
25990
26252
  return (/* @__PURE__ */ new Date()).getMonth();
25991
26253
  });
25992
- const [currentYear, setCurrentYear] = React33.useState(() => {
26254
+ const [currentYear, setCurrentYear] = React14.useState(() => {
25993
26255
  if (urlYear && typeof urlYear === "string") {
25994
26256
  const parsedYear = parseInt(urlYear);
25995
26257
  if (!isNaN(parsedYear) && parsedYear >= 2e3 && parsedYear <= 2100) {
@@ -25998,13 +26260,13 @@ var KPIDetailView = ({
25998
26260
  }
25999
26261
  return (/* @__PURE__ */ new Date()).getFullYear();
26000
26262
  });
26001
- const [monthlyData, setMonthlyData] = React33.useState([]);
26002
- const [underperformingWorkspaces, setUnderperformingWorkspaces] = React33.useState({ dayShift: [], nightShift: [] });
26003
- const [selectedShift, setSelectedShift] = React33.useState("day");
26004
- const [showLineDataNotFound, setShowLineDataNotFound] = React33.useState(false);
26263
+ const [monthlyData, setMonthlyData] = React14.useState([]);
26264
+ const [underperformingWorkspaces, setUnderperformingWorkspaces] = React14.useState({ dayShift: [], nightShift: [] });
26265
+ const [selectedShift, setSelectedShift] = React14.useState("day");
26266
+ const [showLineDataNotFound, setShowLineDataNotFound] = React14.useState(false);
26005
26267
  const navigation = useNavigation(navigate);
26006
26268
  const handleNavigate = navigate || navigation.navigate;
26007
- const parsedShiftId = React33.useMemo(() => {
26269
+ const parsedShiftId = React14.useMemo(() => {
26008
26270
  if (urlShift === "0") return 0;
26009
26271
  if (urlShift === "1") return 1;
26010
26272
  if (typeof urlShift === "string") {
@@ -26016,8 +26278,8 @@ var KPIDetailView = ({
26016
26278
  const supabase = useSupabase();
26017
26279
  const dashboardConfig = useDashboardConfig();
26018
26280
  const configuredTimezone = dashboardConfig.dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
26019
- React33.useMemo(() => getCurrentTimeInZone(configuredTimezone), [configuredTimezone]);
26020
- React33.useEffect(() => {
26281
+ React14.useMemo(() => getCurrentTimeInZone(configuredTimezone), [configuredTimezone]);
26282
+ React14.useEffect(() => {
26021
26283
  if (urlDate || urlShift !== void 0) {
26022
26284
  setActiveTab("overview");
26023
26285
  } else if (urlTab === "monthly_history") {
@@ -26028,10 +26290,10 @@ var KPIDetailView = ({
26028
26290
  setActiveTab("overview");
26029
26291
  }
26030
26292
  }, [urlDate, urlShift, urlTab]);
26031
- const getShiftName = React33.useCallback((shiftId) => {
26293
+ const getShiftName = React14.useCallback((shiftId) => {
26032
26294
  return shiftId === 0 ? "Day" : "Night";
26033
26295
  }, []);
26034
- const getShiftIcon = React33.useCallback((shiftId) => {
26296
+ const getShiftIcon = React14.useCallback((shiftId) => {
26035
26297
  const shift = getShiftName(shiftId);
26036
26298
  if (shift === "Day") {
26037
26299
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
@@ -26039,7 +26301,7 @@ var KPIDetailView = ({
26039
26301
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) });
26040
26302
  }
26041
26303
  }, [getShiftName]);
26042
- const getDaysDifference2 = React33.useCallback((date) => {
26304
+ const getDaysDifference2 = React14.useCallback((date) => {
26043
26305
  const today = /* @__PURE__ */ new Date();
26044
26306
  const compareDate = new Date(date);
26045
26307
  const todayInZone = new Date(today.toLocaleString("en-US", { timeZone: configuredTimezone }));
@@ -26072,7 +26334,7 @@ var KPIDetailView = ({
26072
26334
  initialDate: typeof urlDate === "string" ? urlDate : void 0,
26073
26335
  initialShiftId: parsedShiftId
26074
26336
  });
26075
- React33.useEffect(() => {
26337
+ React14.useEffect(() => {
26076
26338
  if (activeTab === "monthly_history" && lineId) {
26077
26339
  if (!supabase || !dashboardConfig || !dashboardConfig.supabaseUrl || !dashboardConfig.supabaseKey) {
26078
26340
  console.error("Supabase client or required config not available in KPIsPage for monthly data");
@@ -26154,7 +26416,7 @@ var KPIDetailView = ({
26154
26416
  });
26155
26417
  }
26156
26418
  }, [activeTab, lineId, currentMonth, currentYear, supabase, dashboardConfig]);
26157
- const lineInfo = React33.useMemo(() => {
26419
+ const lineInfo = React14.useMemo(() => {
26158
26420
  if (!metrics2 || !lineDetails || !lineDetails.factory) {
26159
26421
  return null;
26160
26422
  }
@@ -26186,7 +26448,7 @@ var KPIDetailView = ({
26186
26448
  }
26187
26449
  };
26188
26450
  }, [metrics2, lineDetails, companyId]);
26189
- const hourlyOutputData = React33.useMemo(() => {
26451
+ const hourlyOutputData = React14.useMemo(() => {
26190
26452
  if (!metrics2 || !metrics2.output_array) return [];
26191
26453
  return metrics2.output_array.reduce((acc, val, i) => {
26192
26454
  const hourIndex = Math.floor(i / 60);
@@ -26195,12 +26457,12 @@ var KPIDetailView = ({
26195
26457
  return acc;
26196
26458
  }, []);
26197
26459
  }, [metrics2?.output_array]);
26198
- const hourlyThreshold = React33.useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
26199
- const sortedByEfficiency = React33.useMemo(() => {
26460
+ const hourlyThreshold = React14.useMemo(() => metrics2 ? metrics2.threshold_pph || 0 : 0, [metrics2]);
26461
+ const sortedByEfficiency = React14.useMemo(() => {
26200
26462
  if (!workspaces) return [];
26201
26463
  return [...workspaces].filter((w) => w.efficiency >= 10).sort((a, b) => (a.efficiency || 0) - (b.efficiency || 0)).slice(0, 5);
26202
26464
  }, [workspaces]);
26203
- React33.useEffect(() => {
26465
+ React14.useEffect(() => {
26204
26466
  let timeoutId;
26205
26467
  if (!lineMetricsLoading && !workspacesLoading && !lineInfo && activeTab !== "monthly_history") {
26206
26468
  timeoutId = setTimeout(() => {
@@ -26215,7 +26477,7 @@ var KPIDetailView = ({
26215
26477
  }
26216
26478
  };
26217
26479
  }, [lineMetricsLoading, workspacesLoading, lineInfo, activeTab]);
26218
- React33.useCallback(() => {
26480
+ React14.useCallback(() => {
26219
26481
  trackCoreEvent("Quality Overview Viewed", {
26220
26482
  source: "line_kpi",
26221
26483
  line_id: lineInfo?.line_id,
@@ -26225,12 +26487,12 @@ var KPIDetailView = ({
26225
26487
  const url = `/kpis/${lineId}?tab=overview&month=${currentMonth}&year=${currentYear}`;
26226
26488
  handleNavigate(url, { shallow: true });
26227
26489
  }, [lineInfo, lineId, currentMonth, currentYear, handleNavigate]);
26228
- const handleOverviewClick = React33.useCallback(() => {
26490
+ const handleOverviewClick = React14.useCallback(() => {
26229
26491
  setActiveTab("overview");
26230
26492
  const url = `/kpis/${lineId}?tab=overview&month=${currentMonth}&year=${currentYear}`;
26231
26493
  handleNavigate(url, { shallow: true });
26232
26494
  }, [lineId, currentMonth, currentYear, handleNavigate]);
26233
- const handleMonthlyHistoryClick = React33.useCallback(() => {
26495
+ const handleMonthlyHistoryClick = React14.useCallback(() => {
26234
26496
  trackCoreEvent("Monthly History Viewed", {
26235
26497
  source: "line_kpi",
26236
26498
  line_id: lineInfo?.line_id,
@@ -26240,7 +26502,7 @@ var KPIDetailView = ({
26240
26502
  const url = `/kpis/${lineId}?tab=monthly_history&month=${currentMonth}&year=${currentYear}`;
26241
26503
  handleNavigate(url, { shallow: true });
26242
26504
  }, [lineInfo, lineId, currentMonth, currentYear, handleNavigate]);
26243
- const handleBackClick = React33.useCallback(() => {
26505
+ const handleBackClick = React14.useCallback(() => {
26244
26506
  if (!urlDate && !urlShift) {
26245
26507
  trackCoreEvent("Dashboard Viewed", {
26246
26508
  source: "line_kpi",
@@ -26515,7 +26777,7 @@ var LineCard = ({ line, onClick }) => {
26515
26777
  const { kpis, isLoading, error } = useLineKPIs({ lineId: line.id });
26516
26778
  const shiftConfig = useShiftConfig();
26517
26779
  const dateTimeConfig = useDateTimeConfig();
26518
- const isOnTrack = React33__namespace.default.useMemo(() => {
26780
+ const isOnTrack = React14__namespace.default.useMemo(() => {
26519
26781
  if (!kpis) return null;
26520
26782
  const currentTime = /* @__PURE__ */ new Date();
26521
26783
  const timezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
@@ -26653,16 +26915,16 @@ var KPIsOverviewView = ({
26653
26915
  onBackClick,
26654
26916
  backLinkUrl
26655
26917
  }) => {
26656
- const [lines, setLines] = React33.useState([]);
26657
- const [loading, setLoading] = React33.useState(true);
26658
- const [error, setError] = React33.useState(null);
26918
+ const [lines, setLines] = React14.useState([]);
26919
+ const [loading, setLoading] = React14.useState(true);
26920
+ const [error, setError] = React14.useState(null);
26659
26921
  const supabase = useSupabase();
26660
26922
  const dashboardConfig = useDashboardConfig();
26661
26923
  const navigation = useNavigation(navigate);
26662
26924
  const dateTimeConfig = useDateTimeConfig();
26663
26925
  const shiftConfig = useShiftConfig();
26664
26926
  const configuredTimezone = dateTimeConfig.defaultTimezone || "Asia/Kolkata";
26665
- React33.useEffect(() => {
26927
+ React14.useEffect(() => {
26666
26928
  const fetchLines = async () => {
26667
26929
  try {
26668
26930
  if (!supabase || !dashboardConfig) {
@@ -26689,7 +26951,7 @@ var KPIsOverviewView = ({
26689
26951
  });
26690
26952
  navigation.navigate(`/kpis/${line.id}`);
26691
26953
  };
26692
- const handleBackClick = React33.useCallback(() => {
26954
+ const handleBackClick = React14.useCallback(() => {
26693
26955
  if (onBackClick) {
26694
26956
  onBackClick();
26695
26957
  } else if (backLinkUrl) {
@@ -26810,11 +27072,11 @@ var KPIsOverviewView = ({
26810
27072
  ] });
26811
27073
  };
26812
27074
  var KPIsOverviewView_default = KPIsOverviewView;
26813
- var IsolatedTimer = React33.memo(() => {
27075
+ var IsolatedTimer = React14.memo(() => {
26814
27076
  return /* @__PURE__ */ jsxRuntime.jsx(ISTTimer_default, {});
26815
27077
  }, () => true);
26816
27078
  IsolatedTimer.displayName = "IsolatedTimer";
26817
- var HeaderRibbon = React33.memo(({
27079
+ var HeaderRibbon = React14.memo(({
26818
27080
  currentDate,
26819
27081
  shiftId,
26820
27082
  getShiftIcon,
@@ -26833,7 +27095,7 @@ var HeaderRibbon = React33.memo(({
26833
27095
  ] })
26834
27096
  ] }) }));
26835
27097
  HeaderRibbon.displayName = "HeaderRibbon";
26836
- var MobileWorkspaceCard = React33.memo(({
27098
+ var MobileWorkspaceCard = React14.memo(({
26837
27099
  workspace,
26838
27100
  rank,
26839
27101
  cardClass,
@@ -26890,7 +27152,7 @@ var MobileWorkspaceCard = React33.memo(({
26890
27152
  }
26891
27153
  ));
26892
27154
  MobileWorkspaceCard.displayName = "MobileWorkspaceCard";
26893
- var DesktopWorkspaceRow = React33.memo(({
27155
+ var DesktopWorkspaceRow = React14.memo(({
26894
27156
  workspace,
26895
27157
  index,
26896
27158
  rowClass,
@@ -26929,7 +27191,7 @@ var DesktopWorkspaceRow = React33.memo(({
26929
27191
  }
26930
27192
  ));
26931
27193
  DesktopWorkspaceRow.displayName = "DesktopWorkspaceRow";
26932
- var LeaderboardDetailView = React33.memo(({
27194
+ var LeaderboardDetailView = React14.memo(({
26933
27195
  lineId,
26934
27196
  date,
26935
27197
  shift,
@@ -26940,11 +27202,11 @@ var LeaderboardDetailView = React33.memo(({
26940
27202
  className = ""
26941
27203
  }) => {
26942
27204
  const navigation = useNavigation();
26943
- const [sortAscending, setSortAscending] = React33.useState(true);
26944
- const handleSortToggle = React33.useCallback(() => {
27205
+ const [sortAscending, setSortAscending] = React14.useState(true);
27206
+ const handleSortToggle = React14.useCallback(() => {
26945
27207
  setSortAscending(!sortAscending);
26946
27208
  }, [sortAscending]);
26947
- const realtimeMetricsParams = React33.useMemo(() => ({
27209
+ const realtimeMetricsParams = React14.useMemo(() => ({
26948
27210
  lineId: lineId || "",
26949
27211
  date,
26950
27212
  shiftId: typeof shift === "number" ? shift : typeof shift === "string" ? parseInt(shift) : void 0
@@ -26956,18 +27218,18 @@ var LeaderboardDetailView = React33.memo(({
26956
27218
  error: metricsError,
26957
27219
  refreshMetrics
26958
27220
  } = useRealtimeLineMetrics(realtimeMetricsParams);
26959
- const memoizedLineId = React33.useMemo(() => lineId || "", [lineId]);
27221
+ const memoizedLineId = React14.useMemo(() => lineId || "", [lineId]);
26960
27222
  const {
26961
27223
  workspaces,
26962
27224
  loading: workspacesLoading,
26963
27225
  error: workspacesError,
26964
27226
  refreshWorkspaces
26965
27227
  } = useLineWorkspaceMetrics(memoizedLineId);
26966
- const getShiftName = React33.useCallback((shiftId) => {
27228
+ const getShiftName = React14.useCallback((shiftId) => {
26967
27229
  if (shiftId === void 0) return "Day";
26968
27230
  return shiftId === 0 ? "Day" : "Night";
26969
27231
  }, []);
26970
- const getShiftIcon = React33.useCallback((shiftId) => {
27232
+ const getShiftIcon = React14.useCallback((shiftId) => {
26971
27233
  const shift2 = getShiftName(shiftId);
26972
27234
  if (shift2 === "Day") {
26973
27235
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 3v1m0 16v1m9-9h-1M4 12H3m15.364 6.364l-.707-.707M6.343 6.343l-.707-.707m12.728 0l-.707.707M6.343 17.657l-.707.707M16 12a4 4 0 11-8 0 4 4 0 018 0z" }) });
@@ -26975,7 +27237,7 @@ var LeaderboardDetailView = React33.memo(({
26975
27237
  return /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-4 h-4", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M20.354 15.354A9 9 0 018.646 3.646 9.003 9.003 0 0012 21a9.003 9.003 0 008.354-5.646z" }) });
26976
27238
  }
26977
27239
  }, [getShiftName]);
26978
- const formatDate = React33.useCallback((date2) => {
27240
+ const formatDate = React14.useCallback((date2) => {
26979
27241
  return new Intl.DateTimeFormat("en-US", {
26980
27242
  weekday: "long",
26981
27243
  day: "numeric",
@@ -26984,14 +27246,14 @@ var LeaderboardDetailView = React33.memo(({
26984
27246
  timeZone: "Asia/Kolkata"
26985
27247
  }).format(date2);
26986
27248
  }, []);
26987
- const handleBackClick = React33.useCallback(() => {
27249
+ const handleBackClick = React14.useCallback(() => {
26988
27250
  if (onBackClick) {
26989
27251
  onBackClick();
26990
27252
  } else {
26991
27253
  navigation.navigate("/");
26992
27254
  }
26993
27255
  }, [onBackClick, navigation]);
26994
- const getMedalIcon = React33.useCallback((rank) => {
27256
+ const getMedalIcon = React14.useCallback((rank) => {
26995
27257
  if (sortAscending) return null;
26996
27258
  switch (rank) {
26997
27259
  case 1:
@@ -27004,7 +27266,7 @@ var LeaderboardDetailView = React33.memo(({
27004
27266
  return null;
27005
27267
  }
27006
27268
  }, [sortAscending]);
27007
- const handleWorkspaceClick = React33.useCallback((workspace, rank) => {
27269
+ const handleWorkspaceClick = React14.useCallback((workspace, rank) => {
27008
27270
  trackCoreEvent("Workspace from Leaderboard Clicked", {
27009
27271
  workspace_name: workspace.workspace_name,
27010
27272
  workspace_id: workspace.workspace_uuid,
@@ -27023,7 +27285,7 @@ var LeaderboardDetailView = React33.memo(({
27023
27285
  navigation.navigate(`/workspace/${workspace.workspace_uuid}${navParams}${returnToParam}`);
27024
27286
  }
27025
27287
  }, [onWorkspaceClick, navigation, lineId, workspaces?.length]);
27026
- const sortedWorkspaces = React33.useMemo(() => {
27288
+ const sortedWorkspaces = React14.useMemo(() => {
27027
27289
  if (!workspaces) return [];
27028
27290
  return [...workspaces].sort((a, b) => {
27029
27291
  const effA = a.efficiency || 0;
@@ -27031,9 +27293,9 @@ var LeaderboardDetailView = React33.memo(({
27031
27293
  return sortAscending ? effA - effB : effB - effA;
27032
27294
  });
27033
27295
  }, [workspaces, sortAscending]);
27034
- const loading = React33.useMemo(() => metricsLoading || workspacesLoading, [metricsLoading, workspacesLoading]);
27035
- const error = React33.useMemo(() => metricsError || workspacesError, [metricsError, workspacesError]);
27036
- const currentDateFormatted = React33.useMemo(() => formatDate(/* @__PURE__ */ new Date()), [formatDate]);
27296
+ const loading = React14.useMemo(() => metricsLoading || workspacesLoading, [metricsLoading, workspacesLoading]);
27297
+ const error = React14.useMemo(() => metricsError || workspacesError, [metricsError, workspacesError]);
27298
+ const currentDateFormatted = React14.useMemo(() => formatDate(/* @__PURE__ */ new Date()), [formatDate]);
27037
27299
  if (loading) {
27038
27300
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `h-[calc(100vh-64px)] flex items-center justify-center bg-slate-50 ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xl text-gray-600", children: "Loading workspaces..." }) });
27039
27301
  }
@@ -27178,15 +27440,15 @@ var ProfileView = () => {
27178
27440
  const supabase = useSupabase();
27179
27441
  const navigation = useNavigation();
27180
27442
  const { authConfig } = useDashboardConfig();
27181
- const [activeTab, setActiveTab] = React33.useState("profile");
27182
- const [profileData, setProfileData] = React33.useState({
27443
+ const [activeTab, setActiveTab] = React14.useState("profile");
27444
+ const [profileData, setProfileData] = React14.useState({
27183
27445
  email: user?.email || ""
27184
27446
  });
27185
- const [isEditing, setIsEditing] = React33.useState(false);
27186
- const [loading, setLoading] = React33.useState(false);
27187
- const [error, setError] = React33.useState(null);
27188
- const [success, setSuccess] = React33.useState(null);
27189
- React33.useEffect(() => {
27447
+ const [isEditing, setIsEditing] = React14.useState(false);
27448
+ const [loading, setLoading] = React14.useState(false);
27449
+ const [error, setError] = React14.useState(null);
27450
+ const [success, setSuccess] = React14.useState(null);
27451
+ React14.useEffect(() => {
27190
27452
  const loadProfileData = async () => {
27191
27453
  if (!user || !supabase) return;
27192
27454
  setLoading(true);
@@ -27563,7 +27825,7 @@ var formatBreaks = (breaks) => {
27563
27825
  }))
27564
27826
  };
27565
27827
  };
27566
- var BreakRow = React33.memo(({
27828
+ var BreakRow = React14.memo(({
27567
27829
  break: breakItem,
27568
27830
  onUpdate,
27569
27831
  onRemove,
@@ -27614,7 +27876,7 @@ var BreakRow = React33.memo(({
27614
27876
  ] });
27615
27877
  });
27616
27878
  BreakRow.displayName = "BreakRow";
27617
- var ShiftPanel = React33.memo(({
27879
+ var ShiftPanel = React14.memo(({
27618
27880
  title,
27619
27881
  icon,
27620
27882
  startTime,
@@ -27629,8 +27891,8 @@ var ShiftPanel = React33.memo(({
27629
27891
  }) => {
27630
27892
  const panelId = `panel-${title.toLowerCase().replace(/\s+/g, "-")}`;
27631
27893
  const storageKey = `shift_panel_${panelId}_minimized`;
27632
- const [isMinimized, setIsMinimized] = React33.useState(true);
27633
- React33.useEffect(() => {
27894
+ const [isMinimized, setIsMinimized] = React14.useState(true);
27895
+ React14.useEffect(() => {
27634
27896
  setIsMinimized(true);
27635
27897
  }, []);
27636
27898
  const toggleMinimize = (e) => {
@@ -27761,7 +28023,7 @@ var ShiftsView = ({
27761
28023
  }) => {
27762
28024
  const supabase = useSupabase();
27763
28025
  const auth = useAuth();
27764
- const [lineConfigs, setLineConfigs] = React33.useState(
28026
+ const [lineConfigs, setLineConfigs] = React14.useState(
27765
28027
  () => lineIds.map((id3) => ({
27766
28028
  id: id3,
27767
28029
  name: lineNames[id3] || `Line ${id3.substring(0, 4)}`,
@@ -27780,9 +28042,9 @@ var ShiftsView = ({
27780
28042
  saveSuccess: false
27781
28043
  }))
27782
28044
  );
27783
- const [loading, setLoading] = React33.useState(true);
27784
- const [error, setError] = React33.useState(null);
27785
- const showToast = React33.useCallback((type, message) => {
28045
+ const [loading, setLoading] = React14.useState(true);
28046
+ const [error, setError] = React14.useState(null);
28047
+ const showToast = React14.useCallback((type, message) => {
27786
28048
  if (onToast) {
27787
28049
  onToast(type, message);
27788
28050
  } else {
@@ -27793,7 +28055,7 @@ var ShiftsView = ({
27793
28055
  }
27794
28056
  }
27795
28057
  }, [onToast]);
27796
- React33.useEffect(() => {
28058
+ React14.useEffect(() => {
27797
28059
  const fetchShiftConfigs = async () => {
27798
28060
  try {
27799
28061
  setLoading(true);
@@ -27859,7 +28121,7 @@ var ShiftsView = ({
27859
28121
  };
27860
28122
  fetchShiftConfigs();
27861
28123
  }, [supabase, lineIds, showToast]);
27862
- React33.useCallback((lineId) => {
28124
+ React14.useCallback((lineId) => {
27863
28125
  setLineConfigs((prev) => {
27864
28126
  const typedPrev = prev;
27865
28127
  const newIsOpen = !typedPrev.find((config) => config.id === lineId)?.isOpen;
@@ -27869,7 +28131,7 @@ var ShiftsView = ({
27869
28131
  );
27870
28132
  });
27871
28133
  }, []);
27872
- const updateDayShiftStartTime = React33.useCallback((lineId, value) => {
28134
+ const updateDayShiftStartTime = React14.useCallback((lineId, value) => {
27873
28135
  setLineConfigs((prev) => prev.map((config) => {
27874
28136
  const typedConfig = config;
27875
28137
  if (typedConfig.id === lineId) {
@@ -27882,7 +28144,7 @@ var ShiftsView = ({
27882
28144
  return typedConfig;
27883
28145
  }));
27884
28146
  }, []);
27885
- const updateDayShiftEndTime = React33.useCallback((lineId, value) => {
28147
+ const updateDayShiftEndTime = React14.useCallback((lineId, value) => {
27886
28148
  setLineConfigs((prev) => prev.map((config) => {
27887
28149
  const typedConfig = config;
27888
28150
  if (typedConfig.id === lineId) {
@@ -27895,7 +28157,7 @@ var ShiftsView = ({
27895
28157
  return typedConfig;
27896
28158
  }));
27897
28159
  }, []);
27898
- const updateNightShiftStartTime = React33.useCallback((lineId, value) => {
28160
+ const updateNightShiftStartTime = React14.useCallback((lineId, value) => {
27899
28161
  setLineConfigs((prev) => prev.map((config) => {
27900
28162
  const typedConfig = config;
27901
28163
  if (typedConfig.id === lineId) {
@@ -27908,7 +28170,7 @@ var ShiftsView = ({
27908
28170
  return typedConfig;
27909
28171
  }));
27910
28172
  }, []);
27911
- const updateNightShiftEndTime = React33.useCallback((lineId, value) => {
28173
+ const updateNightShiftEndTime = React14.useCallback((lineId, value) => {
27912
28174
  setLineConfigs((prev) => prev.map((config) => {
27913
28175
  const typedConfig = config;
27914
28176
  if (typedConfig.id === lineId) {
@@ -27921,7 +28183,7 @@ var ShiftsView = ({
27921
28183
  return typedConfig;
27922
28184
  }));
27923
28185
  }, []);
27924
- const addDayShiftBreak = React33.useCallback((lineId) => {
28186
+ const addDayShiftBreak = React14.useCallback((lineId) => {
27925
28187
  setLineConfigs((prev) => prev.map((config) => {
27926
28188
  const typedConfig = config;
27927
28189
  if (typedConfig.id === lineId) {
@@ -27943,7 +28205,7 @@ var ShiftsView = ({
27943
28205
  return typedConfig;
27944
28206
  }));
27945
28207
  }, []);
27946
- const addNightShiftBreak = React33.useCallback((lineId) => {
28208
+ const addNightShiftBreak = React14.useCallback((lineId) => {
27947
28209
  setLineConfigs((prev) => prev.map((config) => {
27948
28210
  const typedConfig = config;
27949
28211
  if (typedConfig.id === lineId) {
@@ -27964,7 +28226,7 @@ var ShiftsView = ({
27964
28226
  return typedConfig;
27965
28227
  }));
27966
28228
  }, []);
27967
- const updateDayShiftBreak = React33.useCallback((lineId, index, field, value) => {
28229
+ const updateDayShiftBreak = React14.useCallback((lineId, index, field, value) => {
27968
28230
  setLineConfigs((prev) => prev.map((config) => {
27969
28231
  const typedConfig = config;
27970
28232
  if (typedConfig.id === lineId) {
@@ -27992,7 +28254,7 @@ var ShiftsView = ({
27992
28254
  return typedConfig;
27993
28255
  }));
27994
28256
  }, []);
27995
- const updateNightShiftBreak = React33.useCallback((lineId, index, field, value) => {
28257
+ const updateNightShiftBreak = React14.useCallback((lineId, index, field, value) => {
27996
28258
  setLineConfigs((prev) => prev.map((config) => {
27997
28259
  const typedConfig = config;
27998
28260
  if (typedConfig.id === lineId) {
@@ -28020,7 +28282,7 @@ var ShiftsView = ({
28020
28282
  return typedConfig;
28021
28283
  }));
28022
28284
  }, []);
28023
- const removeDayShiftBreak = React33.useCallback((lineId, index) => {
28285
+ const removeDayShiftBreak = React14.useCallback((lineId, index) => {
28024
28286
  setLineConfigs((prev) => prev.map((config) => {
28025
28287
  if (config.id === lineId) {
28026
28288
  const dayShift = { ...config.dayShift };
@@ -28035,7 +28297,7 @@ var ShiftsView = ({
28035
28297
  return config;
28036
28298
  }));
28037
28299
  }, []);
28038
- const removeNightShiftBreak = React33.useCallback((lineId, index) => {
28300
+ const removeNightShiftBreak = React14.useCallback((lineId, index) => {
28039
28301
  setLineConfigs((prev) => prev.map((config) => {
28040
28302
  if (config.id === lineId) {
28041
28303
  const nightShift = { ...config.nightShift };
@@ -28050,7 +28312,7 @@ var ShiftsView = ({
28050
28312
  return config;
28051
28313
  }));
28052
28314
  }, []);
28053
- const handleSaveShifts = React33.useCallback(async (lineId) => {
28315
+ const handleSaveShifts = React14.useCallback(async (lineId) => {
28054
28316
  if (!auth.user?.id && false) ;
28055
28317
  setLineConfigs((prev) => prev.map(
28056
28318
  (config) => config.id === lineId ? { ...config, isSaving: true, saveSuccess: false } : config
@@ -28276,27 +28538,27 @@ var BulkConfigureModal = ({
28276
28538
  onSave,
28277
28539
  selectedShift
28278
28540
  }) => {
28279
- const [selectedLine, setSelectedLine] = React33.useState("");
28280
- const [selectedWorkspaces, setSelectedWorkspaces] = React33.useState([]);
28281
- const [actionType, setActionType] = React33.useState("assembly");
28282
- const [targetPPH, setTargetPPH] = React33.useState("");
28283
- const [targetCycleTime, setTargetCycleTime] = React33.useState("");
28284
- const [targetDayOutput, setTargetDayOutput] = React33.useState("");
28285
- const [productId, setProductId] = React33.useState("");
28286
- const [selectedCount, setSelectedCount] = React33.useState(0);
28287
- const shiftHours = React33.useMemo(() => {
28541
+ const [selectedLine, setSelectedLine] = React14.useState("");
28542
+ const [selectedWorkspaces, setSelectedWorkspaces] = React14.useState([]);
28543
+ const [actionType, setActionType] = React14.useState("assembly");
28544
+ const [targetPPH, setTargetPPH] = React14.useState("");
28545
+ const [targetCycleTime, setTargetCycleTime] = React14.useState("");
28546
+ const [targetDayOutput, setTargetDayOutput] = React14.useState("");
28547
+ const [productId, setProductId] = React14.useState("");
28548
+ const [selectedCount, setSelectedCount] = React14.useState(0);
28549
+ const shiftHours = React14.useMemo(() => {
28288
28550
  if (selectedLine && lineWorkspaces[selectedLine]) {
28289
28551
  return lineWorkspaces[selectedLine].shiftHours;
28290
28552
  }
28291
28553
  return 8;
28292
28554
  }, [selectedLine, lineWorkspaces]);
28293
- const selectedLineBreaks = React33.useMemo(() => {
28555
+ const selectedLineBreaks = React14.useMemo(() => {
28294
28556
  if (selectedLine && lineWorkspaces[selectedLine]) {
28295
28557
  return lineWorkspaces[selectedLine].breaks;
28296
28558
  }
28297
28559
  return [];
28298
28560
  }, [selectedLine, lineWorkspaces]);
28299
- React33.useEffect(() => {
28561
+ React14.useEffect(() => {
28300
28562
  if (!isOpen) {
28301
28563
  setTimeout(() => {
28302
28564
  setSelectedLine("");
@@ -28309,12 +28571,12 @@ var BulkConfigureModal = ({
28309
28571
  }, 200);
28310
28572
  }
28311
28573
  }, [isOpen]);
28312
- React33.useEffect(() => {
28574
+ React14.useEffect(() => {
28313
28575
  if (selectedLine && lineWorkspaces[selectedLine]) {
28314
28576
  setProductId(lineWorkspaces[selectedLine].productId);
28315
28577
  }
28316
28578
  }, [selectedLine, lineWorkspaces]);
28317
- React33.useEffect(() => {
28579
+ React14.useEffect(() => {
28318
28580
  setSelectedCount(selectedWorkspaces.length);
28319
28581
  }, [selectedWorkspaces]);
28320
28582
  const handleSave = async () => {
@@ -28369,7 +28631,7 @@ var BulkConfigureModal = ({
28369
28631
  setSelectedWorkspaces(allWorkspaceIds);
28370
28632
  }
28371
28633
  };
28372
- React33.useEffect(() => {
28634
+ React14.useEffect(() => {
28373
28635
  const handleEscape = (e) => {
28374
28636
  if (e.key === "Escape") {
28375
28637
  onClose();
@@ -28893,7 +29155,7 @@ var TargetsView = ({
28893
29155
  userId,
28894
29156
  onSaveChanges
28895
29157
  }) => {
28896
- const initialLineWorkspaces = React33.useMemo(() => {
29158
+ const initialLineWorkspaces = React14.useMemo(() => {
28897
29159
  return lineIds.reduce((acc, lineId) => ({
28898
29160
  ...acc,
28899
29161
  [lineId]: {
@@ -28910,22 +29172,22 @@ var TargetsView = ({
28910
29172
  }
28911
29173
  }), {});
28912
29174
  }, [lineIds]);
28913
- const [lineWorkspaces, setLineWorkspaces] = React33.useState(initialLineWorkspaces);
28914
- const [actionIds, setActionIds] = React33.useState(null);
28915
- const [savingLines, setSavingLines] = React33.useState(
29175
+ const [lineWorkspaces, setLineWorkspaces] = React14.useState(initialLineWorkspaces);
29176
+ const [actionIds, setActionIds] = React14.useState(null);
29177
+ const [savingLines, setSavingLines] = React14.useState(
28916
29178
  () => lineIds.reduce((acc, id3) => ({ ...acc, [id3]: false }), {})
28917
29179
  );
28918
- const [saveSuccess, setSaveSuccess] = React33.useState(
29180
+ const [saveSuccess, setSaveSuccess] = React14.useState(
28919
29181
  () => lineIds.reduce((acc, id3) => ({ ...acc, [id3]: false }), {})
28920
29182
  );
28921
- const [isLoading, setIsLoading] = React33.useState(true);
28922
- const [isBulkConfigureOpen, setIsBulkConfigureOpen] = React33.useState(false);
28923
- const [selectedWorkspaces, setSelectedWorkspaces] = React33.useState([]);
28924
- const [selectedShift, setSelectedShift] = React33.useState(0);
29183
+ const [isLoading, setIsLoading] = React14.useState(true);
29184
+ const [isBulkConfigureOpen, setIsBulkConfigureOpen] = React14.useState(false);
29185
+ const [selectedWorkspaces, setSelectedWorkspaces] = React14.useState([]);
29186
+ const [selectedShift, setSelectedShift] = React14.useState(0);
28925
29187
  const supabase = useSupabase();
28926
29188
  const auth = useAuth();
28927
29189
  userId || auth?.user?.id;
28928
- React33.useEffect(() => {
29190
+ React14.useEffect(() => {
28929
29191
  const fetchLineDetails = async () => {
28930
29192
  if (!supabase || lineIds.length === 0) return;
28931
29193
  const detailsPromises = lineIds.map(async (lineId) => {
@@ -28956,7 +29218,7 @@ var TargetsView = ({
28956
29218
  };
28957
29219
  fetchLineDetails();
28958
29220
  }, [supabase, lineIds]);
28959
- React33.useEffect(() => {
29221
+ React14.useEffect(() => {
28960
29222
  const fetchActions = async () => {
28961
29223
  if (!supabase) {
28962
29224
  console.error("Supabase client not available in fetchActions");
@@ -28989,7 +29251,7 @@ var TargetsView = ({
28989
29251
  };
28990
29252
  fetchActions();
28991
29253
  }, [supabase, companyId]);
28992
- const fetchLineThresholds = React33.useCallback(async () => {
29254
+ const fetchLineThresholds = React14.useCallback(async () => {
28993
29255
  try {
28994
29256
  if (!supabase) return;
28995
29257
  const currentDate = getOperationalDate();
@@ -29080,7 +29342,7 @@ var TargetsView = ({
29080
29342
  console.error("Error in fetchLineThresholds outer try-catch:", error);
29081
29343
  }
29082
29344
  }, [selectedShift, supabase, lineIds, lineWorkspaces]);
29083
- const loadOperatingHours = React33.useCallback(async (lineId, shiftId) => {
29345
+ const loadOperatingHours = React14.useCallback(async (lineId, shiftId) => {
29084
29346
  try {
29085
29347
  if (!supabase) return null;
29086
29348
  const { data, error } = await supabase.from("line_operating_hours").select("start_time, end_time, breaks").eq("line_id", lineId).eq("shift_id", shiftId).maybeSingle();
@@ -29175,7 +29437,7 @@ var TargetsView = ({
29175
29437
  };
29176
29438
  }
29177
29439
  }, [supabase]);
29178
- React33.useEffect(() => {
29440
+ React14.useEffect(() => {
29179
29441
  const allFactoryIdsLoaded = lineIds.every((lineId) => lineWorkspaces[lineId]?.factoryId);
29180
29442
  if (!actionIds || !allFactoryIdsLoaded) {
29181
29443
  return;
@@ -29238,7 +29500,7 @@ var TargetsView = ({
29238
29500
  };
29239
29501
  fetchWorkspacesAndThenThresholds();
29240
29502
  }, [actionIds, supabase, lineIds, lineWorkspaces, fetchLineThresholds]);
29241
- React33.useEffect(() => {
29503
+ React14.useEffect(() => {
29242
29504
  if (Object.keys(lineWorkspaces).length > 0) {
29243
29505
  const updatedLineWorkspaces = { ...lineWorkspaces };
29244
29506
  let hasChanges = false;
@@ -29268,7 +29530,7 @@ var TargetsView = ({
29268
29530
  }
29269
29531
  }
29270
29532
  }, [selectedShift]);
29271
- const toggleLineDropdown = React33.useCallback((lineId) => {
29533
+ const toggleLineDropdown = React14.useCallback((lineId) => {
29272
29534
  setLineWorkspaces((prev) => {
29273
29535
  const newIsOpen = !prev[lineId].isOpen;
29274
29536
  if (typeof window !== "undefined") {
@@ -29380,7 +29642,7 @@ var TargetsView = ({
29380
29642
  };
29381
29643
  loadShiftHours();
29382
29644
  };
29383
- const handleActionTypeChange = React33.useCallback((lineId, workspaceId, newActionType) => {
29645
+ const handleActionTypeChange = React14.useCallback((lineId, workspaceId, newActionType) => {
29384
29646
  if (!actionIds) return;
29385
29647
  setLineWorkspaces((prev) => ({
29386
29648
  ...prev,
@@ -29396,7 +29658,7 @@ var TargetsView = ({
29396
29658
  }
29397
29659
  }));
29398
29660
  }, [actionIds]);
29399
- const handleSaveLine = React33.useCallback(async (lineId) => {
29661
+ const handleSaveLine = React14.useCallback(async (lineId) => {
29400
29662
  console.log(`[handleSaveLine] Attempting to save line: ${lineId}`);
29401
29663
  const hardcodedUserId = "6bf6f271-1e55-4a95-9b89-1c3820b58739";
29402
29664
  const currentEffectiveUserId = hardcodedUserId;
@@ -29631,7 +29893,7 @@ var WorkspaceDetailView = ({
29631
29893
  showCycleTimeChart,
29632
29894
  renderHeaderActions
29633
29895
  }) => {
29634
- const parsedShiftId = React33.useMemo(() => {
29896
+ const parsedShiftId = React14.useMemo(() => {
29635
29897
  if (shift) {
29636
29898
  const shiftNumber = typeof shift === "string" ? parseInt(shift, 10) : shift;
29637
29899
  if (!isNaN(shiftNumber)) {
@@ -29640,19 +29902,19 @@ var WorkspaceDetailView = ({
29640
29902
  }
29641
29903
  return void 0;
29642
29904
  }, [shift]);
29643
- const [previousView, setPreviousView] = React33.useState("dashboard");
29644
- const [monthlyData, setMonthlyData] = React33.useState([]);
29645
- const [monthlyDataLoading, setMonthlyDataLoading] = React33.useState(false);
29905
+ const [previousView, setPreviousView] = React14.useState("dashboard");
29906
+ const [monthlyData, setMonthlyData] = React14.useState([]);
29907
+ const [monthlyDataLoading, setMonthlyDataLoading] = React14.useState(false);
29646
29908
  const today = new Date((/* @__PURE__ */ new Date()).toLocaleString("en-US", { timeZone: "Asia/Kolkata" }));
29647
- const [selectedMonth, setSelectedMonth] = React33.useState(today.getMonth());
29648
- const [selectedYear, setSelectedYear] = React33.useState(today.getFullYear());
29649
- const [selectedShift, setSelectedShift] = React33.useState("day");
29909
+ const [selectedMonth, setSelectedMonth] = React14.useState(today.getMonth());
29910
+ const [selectedYear, setSelectedYear] = React14.useState(today.getFullYear());
29911
+ const [selectedShift, setSelectedShift] = React14.useState("day");
29650
29912
  const isHistoricView = Boolean(date && parsedShiftId !== void 0);
29651
29913
  const initialTab = getInitialTab(sourceType, defaultTab, fromMonthly, date);
29652
- const [activeTab, setActiveTab] = React33.useState(initialTab);
29653
- const [isTransitioning, setIsTransitioning] = React33.useState(false);
29654
- const [usingFallbackData, setUsingFallbackData] = React33.useState(false);
29655
- const [showIdleTime, setShowIdleTime] = React33.useState(false);
29914
+ const [activeTab, setActiveTab] = React14.useState(initialTab);
29915
+ const [isTransitioning, setIsTransitioning] = React14.useState(false);
29916
+ const [usingFallbackData, setUsingFallbackData] = React14.useState(false);
29917
+ const [showIdleTime, setShowIdleTime] = React14.useState(false);
29656
29918
  const {
29657
29919
  metrics: historicMetrics,
29658
29920
  isLoading: historicLoading,
@@ -29674,17 +29936,17 @@ var WorkspaceDetailView = ({
29674
29936
  const workspace = isHistoricView ? historicMetrics : liveMetrics;
29675
29937
  const loading = isHistoricView ? historicLoading : liveLoading;
29676
29938
  const error = isHistoricView ? historicError : liveError;
29677
- React33.useEffect(() => {
29939
+ React14.useEffect(() => {
29678
29940
  if (onTabChange) {
29679
29941
  onTabChange(activeTab);
29680
29942
  }
29681
29943
  }, [activeTab, onTabChange]);
29682
- React33.useEffect(() => {
29944
+ React14.useEffect(() => {
29683
29945
  if (date) {
29684
29946
  setActiveTab("overview");
29685
29947
  }
29686
29948
  }, [date]);
29687
- React33.useEffect(() => {
29949
+ React14.useEffect(() => {
29688
29950
  if (liveMetrics && !date && !shift) {
29689
29951
  const currentDate = getOperationalDate();
29690
29952
  if (liveMetrics.date !== currentDate) {
@@ -29697,7 +29959,7 @@ var WorkspaceDetailView = ({
29697
29959
  }
29698
29960
  }
29699
29961
  }, [liveMetrics, date, shift, activeTab]);
29700
- React33.useMemo(() => {
29962
+ React14.useMemo(() => {
29701
29963
  if (isHistoricView && date) {
29702
29964
  try {
29703
29965
  new Date(date);
@@ -29709,7 +29971,7 @@ var WorkspaceDetailView = ({
29709
29971
  }
29710
29972
  return getOperationalDate();
29711
29973
  }, [isHistoricView, date]);
29712
- const handleMonthlyDataLoaded = React33.useCallback((data) => {
29974
+ const handleMonthlyDataLoaded = React14.useCallback((data) => {
29713
29975
  if (!data || !Array.isArray(data)) {
29714
29976
  console.error("Invalid monthly metrics data received:", data);
29715
29977
  setMonthlyData([]);
@@ -30616,6 +30878,7 @@ exports.createSupabaseClient = createSupabaseClient;
30616
30878
  exports.createThrottledReload = createThrottledReload;
30617
30879
  exports.dashboardService = dashboardService;
30618
30880
  exports.deleteThread = deleteThread;
30881
+ exports.forceRefreshWorkspaceDisplayNames = forceRefreshWorkspaceDisplayNames;
30619
30882
  exports.formatDateInZone = formatDateInZone;
30620
30883
  exports.formatDateTimeInZone = formatDateTimeInZone;
30621
30884
  exports.formatISTDate = formatISTDate;
@@ -30661,6 +30924,7 @@ exports.isWorkspaceDisplayNamesLoaded = isWorkspaceDisplayNamesLoaded;
30661
30924
  exports.isWorkspaceDisplayNamesLoading = isWorkspaceDisplayNamesLoading;
30662
30925
  exports.mergeWithDefaultConfig = mergeWithDefaultConfig;
30663
30926
  exports.optifyeAgentClient = optifyeAgentClient;
30927
+ exports.preInitializeWorkspaceDisplayNames = preInitializeWorkspaceDisplayNames;
30664
30928
  exports.preloadS3Video = preloadS3Video;
30665
30929
  exports.preloadS3VideoUrl = preloadS3VideoUrl;
30666
30930
  exports.preloadS3VideosUrl = preloadS3VideosUrl;