@optifye/dashboard-core 6.0.5 → 6.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -378,24 +378,6 @@ function createMemoizedFunction(fn, getCacheKey) {
378
378
  return result;
379
379
  };
380
380
  }
381
- var memoizedEfficiencyFilter = createMemoizedFunction(
382
- (data, minEfficiency, maxEfficiency) => {
383
- return data.filter((item) => {
384
- const eff = item.efficiency ?? 0;
385
- return eff >= minEfficiency && (maxEfficiency === void 0 || eff < maxEfficiency);
386
- });
387
- },
388
- (data, min, max = void 0) => `${data.length}-${min}-${max}`
389
- );
390
- var memoizedAverageEfficiency = createMemoizedFunction(
391
- (data, minThreshold = 10) => {
392
- const validItems = data.filter((item) => (item.efficiency ?? 0) >= minThreshold);
393
- if (validItems.length === 0) return 0;
394
- const sum = validItems.reduce((acc, item) => acc + (item.efficiency ?? 0), 0);
395
- return sum / validItems.length;
396
- },
397
- (data, threshold) => `${data.length}-${threshold}`
398
- );
399
381
  var memoizedOutputArrayAggregation = createMemoizedFunction(
400
382
  (arrays) => {
401
383
  if (arrays.length === 0) return [];
@@ -606,7 +588,7 @@ var dashboardService = {
606
588
  const lineMetricsTable = getTable2(dbConfig, "lineMetrics");
607
589
  const companyId = entityConfig.companyId;
608
590
  const metricsTablePrefixStr = getMetricsTablePrefix();
609
- const metricsTable = `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
591
+ `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
610
592
  const configuredLineIds = getConfiguredLineIds(entityConfig);
611
593
  const defaultLineId = configuredLineIds[0];
612
594
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
@@ -617,7 +599,7 @@ var dashboardService = {
617
599
  if (!isValidFactoryViewConfiguration(entityConfig) || !companyId) {
618
600
  throw new Error("Factory View requires at least one configured line and companyId to be configured.");
619
601
  }
620
- const [lineResult, metricsResult, performanceResult] = await Promise.all([
602
+ const [lineResult, metricsResult] = await Promise.all([
621
603
  // Get Line 1's info for general factory details
622
604
  supabase.from(linesTable).select(`
623
605
  id,
@@ -628,28 +610,29 @@ var dashboardService = {
628
610
  companies!lines_company_id_fkey(company_name:name)
629
611
  `).eq("id", defaultLineId).maybeSingle(),
630
612
  // Get metrics from line_metrics table for all configured lines
631
- supabase.from(lineMetricsTable).select("*").in("line_id", configuredLineIds).eq("shift_id", shiftId).eq("date", date),
632
- // Get performance data from the dynamic metrics table for all configured lines
633
- supabase.from(metricsTable).select("efficiency").in("line_id", configuredLineIds).eq("shift_id", shiftId).eq("date", date)
613
+ supabase.from(lineMetricsTable).select("*").in("line_id", configuredLineIds).eq("shift_id", shiftId).eq("date", date)
634
614
  ]);
635
615
  if (lineResult.error) throw lineResult.error;
636
616
  if (!lineResult.data) throw new Error(`Configured default line (${defaultLineId}) not found`);
637
617
  if (metricsResult.error) throw metricsResult.error;
638
- if (performanceResult.error) throw performanceResult.error;
639
618
  const lineData2 = lineResult.data;
640
619
  const metricsData = metricsResult.data;
641
- const performanceData2 = performanceResult.data;
642
- const underperformingWorkspaces2 = memoizedEfficiencyFilter(performanceData2 || [], 10, 70);
643
- const validWorkspaces2 = memoizedEfficiencyFilter(performanceData2 || [], 10);
644
- const underperformingCount2 = underperformingWorkspaces2.length;
645
- validWorkspaces2.length;
646
620
  const combinedMetrics = (metricsData || []).reduce((acc, m) => {
647
- acc.avg_efficiency += m.efficiency ?? 0;
648
621
  acc.current_output += m.current_output ?? 0;
649
622
  acc.ideal_output += m.ideal_output ?? m.line_threshold ?? 0;
623
+ acc.total_workspaces += m.total_workspaces ?? 0;
624
+ acc.underperforming_workspaces += m.underperforming_workspaces ?? 0;
625
+ acc.weightedEfficiencySum += (m.avg_efficiency ?? 0) * (m.total_workspaces ?? 0);
650
626
  return acc;
651
- }, { avg_efficiency: 0, current_output: 0, ideal_output: 0 });
627
+ }, {
628
+ current_output: 0,
629
+ ideal_output: 0,
630
+ total_workspaces: 0,
631
+ underperforming_workspaces: 0,
632
+ weightedEfficiencySum: 0
633
+ });
652
634
  metricsData?.length || 1;
635
+ const avgEfficiency = combinedMetrics.total_workspaces > 0 ? combinedMetrics.weightedEfficiencySum / combinedMetrics.total_workspaces : 0;
653
636
  return {
654
637
  line_id: factoryViewId,
655
638
  // Use configured factory view ID
@@ -662,15 +645,13 @@ var dashboardService = {
662
645
  shift_id: shiftId,
663
646
  date,
664
647
  metrics: {
665
- avg_efficiency: memoizedAverageEfficiency(performanceData2 || [], 10),
666
- // Use memoized calculation for efficiency
648
+ avg_efficiency: avgEfficiency,
667
649
  avg_cycle_time: 0,
668
650
  // Needs calculation logic if required for factory view
669
651
  current_output: combinedMetrics.current_output,
670
652
  ideal_output: combinedMetrics.ideal_output,
671
- total_workspaces: 0,
672
- // SRC ALIGNMENT: Use hardcoded 44 for factory view total_workspaces
673
- underperforming_workspaces: underperformingCount2,
653
+ total_workspaces: combinedMetrics.total_workspaces || 0,
654
+ underperforming_workspaces: combinedMetrics.underperforming_workspaces,
674
655
  underperforming_workspace_names: [],
675
656
  // Populate if needed
676
657
  underperforming_workspace_uuids: [],
@@ -704,13 +685,6 @@ var dashboardService = {
704
685
  } catch (err) {
705
686
  console.error(`Error fetching line metrics for ${lineId}:`, err);
706
687
  }
707
- const { data: performanceData, error: performanceError } = await supabase.from(metricsTable).select("efficiency").eq("line_id", lineId).eq("shift_id", shiftId).eq("date", date);
708
- if (performanceError) throw performanceError;
709
- const underperformingWorkspaces = memoizedEfficiencyFilter(performanceData || [], 10, 70);
710
- const validWorkspaces = memoizedEfficiencyFilter(performanceData || [], 10);
711
- const underperformingCount = underperformingWorkspaces.length;
712
- validWorkspaces.length;
713
- const avgEfficiencyFromPerf = memoizedAverageEfficiency(performanceData || [], 10);
714
688
  const useFallbackMetrics = !metricsFromDb;
715
689
  let metricsForReturn;
716
690
  if (useFallbackMetrics) {
@@ -720,7 +694,7 @@ var dashboardService = {
720
694
  current_output: 0,
721
695
  ideal_output: 0,
722
696
  total_workspaces: 42,
723
- underperforming_workspaces: underperformingCount,
697
+ underperforming_workspaces: 0,
724
698
  underperforming_workspace_names: [],
725
699
  underperforming_workspace_uuids: [],
726
700
  output_array: [],
@@ -733,12 +707,12 @@ var dashboardService = {
733
707
  };
734
708
  } else {
735
709
  metricsForReturn = {
736
- avg_efficiency: metricsFromDb.efficiency ?? avgEfficiencyFromPerf,
710
+ avg_efficiency: metricsFromDb.avg_efficiency ?? 0,
737
711
  avg_cycle_time: metricsFromDb.avg_cycle_time || 0,
738
712
  current_output: metricsFromDb.current_output || 0,
739
713
  ideal_output: metricsFromDb.ideal_output || metricsFromDb.line_threshold || 0,
740
714
  total_workspaces: metricsFromDb.total_workspaces ?? workspaceConfig.totalWorkspaces ?? 42,
741
- underperforming_workspaces: underperformingCount,
715
+ underperforming_workspaces: metricsFromDb.underperforming_workspaces ?? 0,
742
716
  underperforming_workspace_names: metricsFromDb.underperforming_workspace_names || [],
743
717
  underperforming_workspace_uuids: metricsFromDb.underperforming_workspace_uuids || [],
744
718
  output_array: metricsFromDb.output_array || [],
@@ -749,9 +723,6 @@ var dashboardService = {
749
723
  last_updated: metricsFromDb.last_updated || (/* @__PURE__ */ new Date()).toISOString(),
750
724
  poorest_performing_workspaces: metricsFromDb.poorest_performing_workspaces || []
751
725
  };
752
- if (metricsFromDb.efficiency === null || metricsFromDb.efficiency === void 0) {
753
- metricsForReturn.avg_efficiency = avgEfficiencyFromPerf;
754
- }
755
726
  }
756
727
  return {
757
728
  line_id: lineData.id,
@@ -1014,7 +985,7 @@ var dashboardService = {
1014
985
  const lineMetricsTable = getTable2(dbConfig, "lineMetrics");
1015
986
  const companyId = entityConfig.companyId;
1016
987
  const metricsTablePrefixStr = getMetricsTablePrefix();
1017
- const metricsTable = `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
988
+ `${metricsTablePrefixStr}_${companyId ? companyId.replace(/-/g, "_") : "unknown_company"}`;
1018
989
  const configuredLineIds = getConfiguredLineIds(entityConfig);
1019
990
  const defaultLineId = configuredLineIds[0];
1020
991
  const factoryViewId = entityConfig.factoryViewId ?? "factory";
@@ -1029,25 +1000,17 @@ var dashboardService = {
1029
1000
  throw new Error("Factory View requires at least one configured line and companyId to be configured.");
1030
1001
  }
1031
1002
  const lineIdsToQuery = configuredLineIds;
1032
- const [line1Result, metricsResult2, performanceResult2] = await Promise.all([
1003
+ const [line1Result, metricsResult2] = await Promise.all([
1033
1004
  supabase.from(linesTable).select("id, line_name, factory_id, factories!lines_factory_id_fkey(factory_name), company_id, companies!lines_company_id_fkey(company_name:name)").eq("id", defaultLineId).single(),
1034
- supabase.from(lineMetricsTable).select("*").in("line_id", lineIdsToQuery).eq("shift_id", queryShiftId).eq("date", queryDate),
1035
- supabase.from(metricsTable).select("efficiency").in("line_id", lineIdsToQuery).eq("shift_id", queryShiftId).eq("date", queryDate)
1005
+ supabase.from(lineMetricsTable).select("*").in("line_id", lineIdsToQuery).eq("shift_id", queryShiftId).eq("date", queryDate)
1036
1006
  ]);
1037
1007
  if (line1Result.error) throw line1Result.error;
1038
1008
  if (!line1Result.data) {
1039
1009
  throw new Error(`Default line ${defaultLineId} for Factory View not found.`);
1040
1010
  }
1041
1011
  if (metricsResult2.error) throw metricsResult2.error;
1042
- if (performanceResult2.error) throw performanceResult2.error;
1043
1012
  const line1Data = line1Result.data;
1044
1013
  const metricsData = metricsResult2.data;
1045
- const performanceData2 = performanceResult2.data;
1046
- const underperformingWorkspaces2 = memoizedEfficiencyFilter(performanceData2 || [], 10, 70);
1047
- const validWorkspaces2 = memoizedEfficiencyFilter(performanceData2 || [], 10);
1048
- const underperformingCount2 = underperformingWorkspaces2.length;
1049
- const totalValidWorkspaces2 = validWorkspaces2.length;
1050
- const avgEfficiencyFromPerf2 = memoizedAverageEfficiency(performanceData2 || [], 10);
1051
1014
  const initialAccumulator = {
1052
1015
  avg_cycle_time: 0,
1053
1016
  current_output: 0,
@@ -1055,6 +1018,10 @@ var dashboardService = {
1055
1018
  line_threshold: 0,
1056
1019
  threshold_pph: 0,
1057
1020
  total_workspaces: 0,
1021
+ underperforming_workspaces: 0,
1022
+ weightedEfficiencySum: 0,
1023
+ underperforming_workspace_names: [],
1024
+ underperforming_workspace_uuids: [],
1058
1025
  output_array: [],
1059
1026
  outputArrays: []
1060
1027
  };
@@ -1065,13 +1032,21 @@ var dashboardService = {
1065
1032
  acc.line_threshold += m.line_threshold ?? 0;
1066
1033
  acc.threshold_pph += m.threshold_pph ?? 0;
1067
1034
  acc.total_workspaces += m.total_workspaces ?? 0;
1035
+ acc.underperforming_workspaces += m.underperforming_workspaces ?? 0;
1036
+ acc.weightedEfficiencySum += (m.avg_efficiency ?? 0) * (m.total_workspaces ?? 0);
1037
+ if (m.underperforming_workspace_names) {
1038
+ acc.underperforming_workspace_names.push(...m.underperforming_workspace_names);
1039
+ }
1040
+ if (m.underperforming_workspace_uuids) {
1041
+ acc.underperforming_workspace_uuids.push(...m.underperforming_workspace_uuids);
1042
+ }
1068
1043
  if (m.output_array && m.output_array.length > 0) {
1069
1044
  acc.outputArrays.push(m.output_array);
1070
1045
  }
1071
1046
  return acc;
1072
1047
  }, initialAccumulator);
1073
1048
  const numLines = Math.max(metricsData?.length || 0, 1);
1074
- const avgEfficiencyFromLineMetrics = (metricsData?.reduce((sum, m) => sum + (m.avg_efficiency || 0), 0) || 0) / numLines;
1049
+ const avgEfficiency = combinedMetricsData.total_workspaces > 0 ? combinedMetricsData.weightedEfficiencySum / combinedMetricsData.total_workspaces : 0;
1075
1050
  return {
1076
1051
  line_id: factoryViewId,
1077
1052
  line_name: "Factory View",
@@ -1082,22 +1057,20 @@ var dashboardService = {
1082
1057
  date: queryDate,
1083
1058
  shift_id: queryShiftId,
1084
1059
  metrics: {
1085
- avg_efficiency: avgEfficiencyFromPerf2 > 0 ? avgEfficiencyFromPerf2 : avgEfficiencyFromLineMetrics,
1086
- // Use performance data first, fallback to line metrics
1060
+ avg_efficiency: avgEfficiency,
1087
1061
  avg_cycle_time: combinedMetricsData.avg_cycle_time / numLines,
1088
1062
  current_output: combinedMetricsData.current_output,
1089
1063
  ideal_output: combinedMetricsData.ideal_output,
1090
1064
  total_workspaces: combinedMetricsData.total_workspaces || 0,
1091
- // Use combined or default
1092
- underperforming_workspaces: underperformingCount2,
1065
+ underperforming_workspaces: combinedMetricsData.underperforming_workspaces,
1093
1066
  line_threshold: combinedMetricsData.line_threshold,
1094
1067
  threshold_pph: combinedMetricsData.threshold_pph / numLines,
1095
1068
  shift_start: metricsData?.[0]?.shift_start || shiftConfig.dayShift?.startTime || "06:00",
1096
1069
  shift_end: metricsData?.[0]?.shift_end || shiftConfig.dayShift?.endTime || "18:00",
1097
1070
  last_updated: (/* @__PURE__ */ new Date()).toISOString(),
1098
1071
  output_array: combinedMetricsData.outputArrays.length > 0 ? memoizedOutputArrayAggregation(combinedMetricsData.outputArrays) : [],
1099
- underperforming_workspace_names: [],
1100
- underperforming_workspace_uuids: [],
1072
+ underperforming_workspace_names: combinedMetricsData.underperforming_workspace_names,
1073
+ underperforming_workspace_uuids: combinedMetricsData.underperforming_workspace_uuids,
1101
1074
  poorest_performing_workspaces: []
1102
1075
  }
1103
1076
  };
@@ -1105,25 +1078,17 @@ var dashboardService = {
1105
1078
  if (!companyId) {
1106
1079
  throw new Error("Company ID must be configured for detailed line requests.");
1107
1080
  }
1108
- const [lineResult, metricsResult, performanceResult] = await Promise.all([
1081
+ const [lineResult, metricsResult] = await Promise.all([
1109
1082
  supabase.from(linesTable).select("id, line_name, factory_id, factories!lines_factory_id_fkey(factory_name), company_id, companies!lines_company_id_fkey(company_name:name)").eq("id", lineIdToQuery).single(),
1110
- supabase.from(lineMetricsTable).select("*").eq("line_id", lineIdToQuery).eq("shift_id", queryShiftId).eq("date", queryDate).maybeSingle(),
1111
- supabase.from(metricsTable).select("efficiency").eq("line_id", lineIdToQuery).eq("shift_id", queryShiftId).eq("date", queryDate)
1083
+ supabase.from(lineMetricsTable).select("*").eq("line_id", lineIdToQuery).eq("shift_id", queryShiftId).eq("date", queryDate).maybeSingle()
1112
1084
  ]);
1113
1085
  if (lineResult.error) throw lineResult.error;
1114
1086
  if (!lineResult.data) {
1115
1087
  throw new Error(`Line ${lineIdToQuery} not found.`);
1116
1088
  }
1117
1089
  if (metricsResult.error) throw metricsResult.error;
1118
- if (performanceResult.error) throw performanceResult.error;
1119
1090
  const lineData = lineResult.data;
1120
1091
  const metrics2 = metricsResult.data;
1121
- const performanceData = performanceResult.data;
1122
- const underperformingWorkspaces = memoizedEfficiencyFilter(performanceData || [], 10, 70);
1123
- const validWorkspaces = memoizedEfficiencyFilter(performanceData || [], 10);
1124
- const underperformingCount = underperformingWorkspaces.length;
1125
- const totalValidWorkspaces = validWorkspaces.length;
1126
- const avgEfficiencyFromPerf = memoizedAverageEfficiency(performanceData || [], 10);
1127
1092
  return {
1128
1093
  line_id: lineData.id,
1129
1094
  line_name: lineData.line_name,
@@ -1134,13 +1099,12 @@ var dashboardService = {
1134
1099
  date: queryDate,
1135
1100
  shift_id: queryShiftId,
1136
1101
  metrics: {
1137
- avg_efficiency: avgEfficiencyFromPerf > 0 ? avgEfficiencyFromPerf : metrics2?.avg_efficiency ?? 0,
1138
- // Use performance data first, fallback to line metrics
1102
+ avg_efficiency: metrics2?.avg_efficiency ?? 0,
1139
1103
  avg_cycle_time: metrics2?.avg_cycle_time || 0,
1140
1104
  current_output: metrics2?.current_output || 0,
1141
1105
  ideal_output: metrics2?.ideal_output || metrics2?.line_threshold || 0,
1142
1106
  total_workspaces: metrics2?.total_workspaces ?? workspaceConfig.totalWorkspaces ?? 42,
1143
- underperforming_workspaces: underperformingCount,
1107
+ underperforming_workspaces: metrics2?.underperforming_workspaces ?? 0,
1144
1108
  line_threshold: metrics2?.line_threshold || 0,
1145
1109
  threshold_pph: metrics2?.threshold_pph || 0,
1146
1110
  shift_start: metrics2?.shift_start || shiftConfig.dayShift?.startTime || "06:00",
@@ -2025,14 +1989,17 @@ var authOTPService = {
2025
1989
  const { error } = await supabase.auth.signInWithOtp({
2026
1990
  email,
2027
1991
  options: {
2028
- shouldCreateUser: true,
2029
- // Creates user if doesn't exist
1992
+ shouldCreateUser: false,
1993
+ // Only allow existing users to log in
2030
1994
  emailRedirectTo: void 0
2031
1995
  // Disable magic link redirect
2032
1996
  }
2033
1997
  });
2034
1998
  if (error) {
2035
1999
  console.error("Error sending OTP:", error);
2000
+ if (error.message.toLowerCase().includes("signups not allowed") || error.message.toLowerCase().includes("signup") || error.message.toLowerCase().includes("not allowed")) {
2001
+ error.message = "You don't have an account with us. Please contact the Optifye team for more details.";
2002
+ }
2036
2003
  }
2037
2004
  return { error };
2038
2005
  },
@@ -2107,7 +2074,7 @@ var authRateLimitService = {
2107
2074
  };
2108
2075
  var isMixpanelInitialized = false;
2109
2076
  var currentUserProperties;
2110
- var initializeCoreMixpanel = (token, debug, trackPageView) => {
2077
+ var initializeCoreMixpanel = (token, debugOrOptions, trackPageViewArg) => {
2111
2078
  if (!token) {
2112
2079
  console.warn("Mixpanel token not provided for initialization. Mixpanel will not be enabled.");
2113
2080
  return;
@@ -2116,15 +2083,51 @@ var initializeCoreMixpanel = (token, debug, trackPageView) => {
2116
2083
  console.warn("Mixpanel already initialized. Ignoring subsequent initialization.");
2117
2084
  return;
2118
2085
  }
2119
- mixpanel__default.default.init(token, {
2086
+ let debug;
2087
+ let trackPageView;
2088
+ let sessionOpts = {};
2089
+ if (typeof debugOrOptions === "boolean" || debugOrOptions === void 0) {
2090
+ debug = debugOrOptions;
2091
+ trackPageView = trackPageViewArg;
2092
+ } else {
2093
+ const opts = debugOrOptions;
2094
+ ({ debug, trackPageView, ...sessionOpts } = opts);
2095
+ }
2096
+ const initOptions = {
2120
2097
  debug: debug ?? process.env.NODE_ENV === "development",
2121
- // Keep env var as fallback if not explicitly passed
2122
2098
  track_pageview: trackPageView ?? true,
2123
- // Default to true if not specified in config
2124
2099
  persistence: "localStorage"
2100
+ };
2101
+ if (sessionOpts.recordSessionsPercent !== void 0) {
2102
+ initOptions.record_sessions_percent = sessionOpts.recordSessionsPercent;
2103
+ } else {
2104
+ initOptions.record_sessions_percent = 1;
2105
+ }
2106
+ if (sessionOpts.recordIdleTimeoutMs !== void 0) {
2107
+ initOptions.record_idle_timeout_ms = sessionOpts.recordIdleTimeoutMs;
2108
+ }
2109
+ if (sessionOpts.recordHeatmapData !== void 0) {
2110
+ initOptions.record_heatmap_data = sessionOpts.recordHeatmapData;
2111
+ } else {
2112
+ initOptions.record_heatmap_data = true;
2113
+ }
2114
+ if (sessionOpts.recordCanvas !== void 0) {
2115
+ initOptions.record_canvas = sessionOpts.recordCanvas;
2116
+ }
2117
+ if (sessionOpts.recordBlockSelector !== void 0) {
2118
+ initOptions.record_block_selector = sessionOpts.recordBlockSelector;
2119
+ }
2120
+ if (sessionOpts.recordMaskTextSelector !== void 0) {
2121
+ initOptions.record_mask_text_selector = sessionOpts.recordMaskTextSelector;
2122
+ }
2123
+ Object.keys(sessionOpts).forEach((key) => {
2124
+ if (!(key in initOptions)) {
2125
+ initOptions[key] = sessionOpts[key];
2126
+ }
2125
2127
  });
2128
+ mixpanel__default.default.init(token, initOptions);
2126
2129
  isMixpanelInitialized = true;
2127
- console.log("Mixpanel initialized in dashboard-core.");
2130
+ console.log("Mixpanel initialized in dashboard-core with Session Replay support.");
2128
2131
  };
2129
2132
  var trackCorePageView = (pageName, properties) => {
2130
2133
  if (!isMixpanelInitialized) return;
@@ -2140,6 +2143,46 @@ var trackCoreEvent = (eventName, properties) => {
2140
2143
  };
2141
2144
  mixpanel__default.default.track(eventName, mergedProps);
2142
2145
  };
2146
+ var startCoreSessionRecording = () => {
2147
+ try {
2148
+ if (!isMixpanelInitialized) return;
2149
+ if (typeof mixpanel__default.default.start_session_recording === "function") {
2150
+ mixpanel__default.default.start_session_recording();
2151
+ }
2152
+ } catch (err) {
2153
+ console.error("[Mixpanel] Unable to start session recording:", err);
2154
+ }
2155
+ };
2156
+ var stopCoreSessionRecording = () => {
2157
+ try {
2158
+ if (!isMixpanelInitialized) return;
2159
+ if (typeof mixpanel__default.default.stop_session_recording === "function") {
2160
+ mixpanel__default.default.stop_session_recording();
2161
+ }
2162
+ } catch (err) {
2163
+ console.error("[Mixpanel] Unable to stop session recording:", err);
2164
+ }
2165
+ };
2166
+ var getCoreSessionRecordingProperties = () => {
2167
+ try {
2168
+ if (!isMixpanelInitialized) return {};
2169
+ if (typeof mixpanel__default.default.get_session_recording_properties === "function") {
2170
+ return mixpanel__default.default.get_session_recording_properties() || {};
2171
+ }
2172
+ } catch {
2173
+ }
2174
+ return {};
2175
+ };
2176
+ var getCoreSessionReplayUrl = () => {
2177
+ try {
2178
+ if (!isMixpanelInitialized) return null;
2179
+ if (typeof mixpanel__default.default.get_session_replay_url === "function") {
2180
+ return mixpanel__default.default.get_session_replay_url();
2181
+ }
2182
+ } catch {
2183
+ }
2184
+ return null;
2185
+ };
2143
2186
  var identifyCoreUser = (userId, userProperties) => {
2144
2187
  if (!isMixpanelInitialized) return;
2145
2188
  mixpanel__default.default.identify(userId);
@@ -2191,8 +2234,9 @@ var SSEChatClient = class {
2191
2234
  thread_id: threadId,
2192
2235
  user_id: userId,
2193
2236
  company_id: context.companyId,
2194
- line_id: context.lineId,
2195
- shift_id: context.shiftId
2237
+ shift_id: context.shiftId,
2238
+ // Send all_lines if available, otherwise fall back to single line_id
2239
+ ...context.allLines && context.allLines.length > 0 ? { all_lines: context.allLines } : { line_id: context.lineId }
2196
2240
  }),
2197
2241
  signal: controller.signal,
2198
2242
  // Don't include credentials since the API returns Access-Control-Allow-Origin: *
@@ -16694,25 +16738,40 @@ var createMotionComponent = /* @__PURE__ */ createMotionComponentFactory({
16694
16738
 
16695
16739
  // ../../node_modules/framer-motion/dist/es/render/components/motion/proxy.mjs
16696
16740
  var motion = /* @__PURE__ */ createDOMMotionComponentProxy(createMotionComponent);
16697
- var LoadingSpinner = ({
16741
+ var OptifyeLogoLoader = ({
16698
16742
  size = "md",
16699
16743
  message,
16700
16744
  className
16701
16745
  }) => {
16702
16746
  const sizeClasses = {
16703
- sm: "w-5 h-5",
16704
- md: "w-8 h-8",
16705
- lg: "w-12 h-12"
16747
+ sm: "w-10",
16748
+ // 40px
16749
+ md: "w-16",
16750
+ // 64px
16751
+ lg: "w-24"
16752
+ // 96px
16706
16753
  };
16707
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `flex flex-col items-center justify-center p-4 ${className || ""}`, children: [
16708
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${sizeClasses[size]} animate-spin`, children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "w-full h-full text-[var(--primary-DEFAULT)]", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
16709
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
16710
- /* @__PURE__ */ jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
16711
- ] }) }),
16712
- message && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 text-gray-600 text-sm font-medium", children: message })
16713
- ] });
16754
+ return /* @__PURE__ */ jsxRuntime.jsxs(
16755
+ "div",
16756
+ {
16757
+ role: "status",
16758
+ "aria-label": "Loading",
16759
+ className: `flex flex-col items-center justify-center p-4 ${className || ""}`.trim(),
16760
+ children: [
16761
+ /* @__PURE__ */ jsxRuntime.jsx(
16762
+ "img",
16763
+ {
16764
+ src: "/optifye-logo.png",
16765
+ alt: "Optifye Logo",
16766
+ className: `${sizeClasses[size]} h-auto animate-pulse select-none pointer-events-none`
16767
+ }
16768
+ ),
16769
+ message && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 text-gray-600 text-sm font-medium text-center", children: message })
16770
+ ]
16771
+ }
16772
+ );
16714
16773
  };
16715
- var LoadingSpinner_default = LoadingSpinner;
16774
+ var OptifyeLogoLoader_default = OptifyeLogoLoader;
16716
16775
  var LoadingPage = ({
16717
16776
  message = "Loading Dashboard...",
16718
16777
  subMessage = "Please wait while we prepare your data",
@@ -16726,29 +16785,17 @@ var LoadingPage = ({
16726
16785
  return () => clearTimeout(timeout);
16727
16786
  }, [message]);
16728
16787
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full w-full items-center justify-center bg-slate-50 ${className || ""}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center space-y-6 text-center", children: [
16729
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "lg", message: void 0 }),
16730
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
16731
- /* @__PURE__ */ jsxRuntime.jsx(
16732
- motion.h3,
16733
- {
16734
- className: "text-xl font-semibold text-gray-800",
16735
- initial: { opacity: 0, y: 10 },
16736
- animate: { opacity: 1, y: 0 },
16737
- transition: { delay: 0.1, duration: 0.3 },
16738
- children: message
16739
- }
16740
- ),
16741
- subMessage && /* @__PURE__ */ jsxRuntime.jsx(
16742
- motion.p,
16743
- {
16744
- className: "mt-2 text-base text-gray-600",
16745
- initial: { opacity: 0 },
16746
- animate: { opacity: 1 },
16747
- transition: { delay: 0.2, duration: 0.3 },
16748
- children: subMessage
16749
- }
16750
- )
16751
- ] })
16788
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg", message }),
16789
+ subMessage && /* @__PURE__ */ jsxRuntime.jsx(
16790
+ motion.p,
16791
+ {
16792
+ className: "mt-2 text-base text-gray-600",
16793
+ initial: { opacity: 0 },
16794
+ animate: { opacity: 1 },
16795
+ transition: { delay: 0.2, duration: 0.3 },
16796
+ children: subMessage
16797
+ }
16798
+ )
16752
16799
  ] }) });
16753
16800
  };
16754
16801
  var LoadingPage_default = LoadingPage;
@@ -18593,7 +18640,7 @@ var VideoGridView = React19__namespace.default.memo(({
18593
18640
  }, [cropping]);
18594
18641
  const veryLowEfficiencyWorkspaces = React19.useMemo(() => {
18595
18642
  return new Set(
18596
- workspaces.filter((w) => w.efficiency < 50 && w.efficiency >= 10).map((w) => w.workspace_name)
18643
+ workspaces.filter((w) => w.efficiency < 50 && w.efficiency >= 10).map((w) => `${w.line_id}_${w.workspace_name}`)
18597
18644
  );
18598
18645
  }, [workspaces]);
18599
18646
  const filteredWorkspaces = React19.useMemo(() => {
@@ -18729,7 +18776,7 @@ var VideoGridView = React19__namespace.default.memo(({
18729
18776
  }).map((workspace) => {
18730
18777
  const workspaceId = workspace.workspace_uuid || workspace.workspace_name;
18731
18778
  const isVisible = visibleWorkspaces.has(workspaceId);
18732
- const isVeryLowEfficiency = veryLowEfficiencyWorkspaces.has(workspace.workspace_name);
18779
+ const isVeryLowEfficiency = veryLowEfficiencyWorkspaces.has(`${workspace.line_id}_${workspace.workspace_name}`);
18733
18780
  const workspaceCropping = getWorkspaceCropping(workspace.workspace_name);
18734
18781
  return /* @__PURE__ */ jsxRuntime.jsx(
18735
18782
  "div",
@@ -19899,20 +19946,23 @@ var LineHistoryCalendar = ({
19899
19946
  } else {
19900
19947
  calendar.push({
19901
19948
  date: currentDate,
19902
- dayShift: { avg_efficiency: 0, underperforming_workspaces: 0, total_workspaces: 0 },
19903
- nightShift: { avg_efficiency: 0, underperforming_workspaces: 0, total_workspaces: 0 }
19949
+ dayShift: { avg_efficiency: 0, underperforming_workspaces: 0, total_workspaces: 0, hasData: false },
19950
+ nightShift: { avg_efficiency: 0, underperforming_workspaces: 0, total_workspaces: 0, hasData: false }
19904
19951
  });
19905
19952
  }
19906
19953
  }
19907
19954
  return calendar;
19908
19955
  }, [data, month, year, configuredTimezone]);
19909
- const getPerformanceColor = (efficiency, date) => {
19956
+ const hasRealData = (shift) => {
19957
+ if (shift.hasData !== void 0) return shift.hasData;
19958
+ return shift.total_workspaces > 0 || shift.avg_efficiency > 0 || shift.underperforming_workspaces > 0;
19959
+ };
19960
+ const getPerformanceColor = (efficiency, date, hasData) => {
19910
19961
  const istNow = todayInZone;
19911
19962
  const nowString = `${istNow.getFullYear()}-${String(istNow.getMonth() + 1).padStart(2, "0")}-${String(istNow.getDate()).padStart(2, "0")}`;
19912
19963
  const dateString = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
19913
- if (date.getDay() === 0) return "bg-gray-300 dark:bg-gray-600";
19914
19964
  if (dateString > nowString) return "bg-gray-200 dark:bg-gray-700";
19915
- if (efficiency < 10) return "bg-gray-300 dark:bg-gray-600";
19965
+ if (!hasData) return "bg-gray-300 dark:bg-gray-600";
19916
19966
  return efficiency >= 75 ? "bg-green-500 dark:bg-green-600" : "bg-red-500 dark:bg-red-600";
19917
19967
  };
19918
19968
  const isCurrentDate = (date) => {
@@ -19931,7 +19981,7 @@ var LineHistoryCalendar = ({
19931
19981
  const istNow = todayInZone;
19932
19982
  const nowString = `${istNow.getFullYear()}-${String(istNow.getMonth() + 1).padStart(2, "0")}-${String(istNow.getDate()).padStart(2, "0")}`;
19933
19983
  const dateString = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, "0")}-${String(date.getDate()).padStart(2, "0")}`;
19934
- if (dateString > nowString || date.getDay() === 0) return null;
19984
+ if (dateString > nowString) return null;
19935
19985
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-black/80 rounded-lg p-2 text-white opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs space-y-1", children: [
19936
19986
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
19937
19987
  "Efficiency: ",
@@ -19952,14 +20002,14 @@ var LineHistoryCalendar = ({
19952
20002
  if (!shiftData) return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full border border-gray-100 dark:border-gray-700 rounded-lg bg-gray-50 dark:bg-gray-800" });
19953
20003
  const isToday = isCurrentDate(day.date instanceof Date ? day.date : new Date(day.date));
19954
20004
  const isFuture = isFutureDate(day.date instanceof Date ? day.date : new Date(day.date));
19955
- const isInactive = (shiftData.avg_efficiency || 0) < 10;
20005
+ const hasData = hasRealData(shiftData);
19956
20006
  const dateObj = day.date instanceof Date ? day.date : new Date(day.date);
19957
20007
  return /* @__PURE__ */ jsxRuntime.jsx(
19958
20008
  "div",
19959
20009
  {
19960
- className: `group h-full ${isFuture || isInactive ? "cursor-not-allowed" : "cursor-pointer hover:opacity-90"}`,
20010
+ className: `group h-full ${isFuture || !hasData ? "cursor-not-allowed" : "cursor-pointer hover:opacity-90"}`,
19961
20011
  onClick: () => {
19962
- if (!isFuture && !isInactive) {
20012
+ if (!isFuture && hasData) {
19963
20013
  const dateObj2 = day.date instanceof Date ? day.date : new Date(day.date);
19964
20014
  const year2 = dateObj2.getFullYear();
19965
20015
  const month2 = String(dateObj2.getMonth() + 1).padStart(2, "0");
@@ -19984,15 +20034,15 @@ var LineHistoryCalendar = ({
19984
20034
  }
19985
20035
  },
19986
20036
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `
19987
- ${getPerformanceColor(shiftData.avg_efficiency || 0, dateObj)}
20037
+ ${getPerformanceColor(shiftData.avg_efficiency || 0, dateObj, hasData)}
19988
20038
  rounded-lg h-full p-2 relative
19989
20039
  ${isToday ? "ring-2 ring-blue-500 dark:ring-blue-400 ring-offset-2 dark:ring-offset-gray-800 shadow-md" : ""}
19990
20040
  `, children: [
19991
20041
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `
19992
- text-base font-medium text-white flex items-center
20042
+ text-base font-medium ${hasData ? "text-white" : "text-gray-500"} flex items-center
19993
20043
  ${isToday ? "bg-blue-500 dark:bg-blue-600 rounded-full w-7 h-7 justify-center" : ""}
19994
20044
  `, children: dateObj.getDate() }),
19995
- !isFuture && !isInactive && renderStats(shiftData, dateObj)
20045
+ !isFuture && hasData && renderStats(shiftData, dateObj)
19996
20046
  ] })
19997
20047
  }
19998
20048
  );
@@ -21090,6 +21140,10 @@ var WorkspaceHistoryCalendar = ({
21090
21140
  const { dateTimeConfig } = useDashboardConfig();
21091
21141
  const configuredTimezone = dateTimeConfig?.defaultTimezone || "Asia/Kolkata";
21092
21142
  const [animationComplete, setAnimationComplete] = React19.useState(false);
21143
+ const hasRealData = (shift) => {
21144
+ if (shift.hasData !== void 0) return shift.hasData;
21145
+ return shift.efficiency > 0 || shift.output > 0 || shift.cycleTime > 0 || shift.pph > 0 || shift.idealOutput > 0 || shift.idleTime > 0;
21146
+ };
21093
21147
  React19.useEffect(() => {
21094
21148
  setAnimationComplete(false);
21095
21149
  const timer = setTimeout(() => {
@@ -21142,10 +21196,14 @@ var WorkspaceHistoryCalendar = ({
21142
21196
  istNow.setHours(0, 0, 0, 0);
21143
21197
  const compareDate = new Date(date);
21144
21198
  compareDate.setHours(0, 0, 0, 0);
21145
- if (date.getDay() === 0 || compareDate > istNow) {
21199
+ if (compareDate > istNow) {
21146
21200
  return [];
21147
21201
  }
21148
- return [day.dayShift, day.nightShift];
21202
+ const shiftData = selectedShift === "day" ? day.dayShift : day.nightShift;
21203
+ if (hasRealData(shiftData)) {
21204
+ return [shiftData];
21205
+ }
21206
+ return [];
21149
21207
  });
21150
21208
  if (validShifts.length === 0) return null;
21151
21209
  const badShiftsCount = validShifts.filter((shift) => shift.efficiency < 75).length;
@@ -21158,7 +21216,7 @@ var WorkspaceHistoryCalendar = ({
21158
21216
  badDaysCount: badShiftsCount,
21159
21217
  totalDays: validShifts.length
21160
21218
  };
21161
- }, [data, month, year, configuredTimezone]);
21219
+ }, [data, month, year, configuredTimezone, selectedShift]);
21162
21220
  const handleDayClick = React19.useCallback((day, shift) => {
21163
21221
  if (!day || isFutureDate(day.date)) return;
21164
21222
  const year2 = day.date.getFullYear();
@@ -21197,13 +21255,13 @@ var WorkspaceHistoryCalendar = ({
21197
21255
  compareDate.setHours(0, 0, 0, 0);
21198
21256
  return compareDate > istNow;
21199
21257
  }, [configuredTimezone]);
21200
- const getPerformanceColor = React19.useCallback((efficiency, date) => {
21258
+ const getPerformanceColor = React19.useCallback((efficiency, date, hasData) => {
21201
21259
  const istNow = getTimeInZoneAsDate(configuredTimezone);
21202
21260
  istNow.setHours(0, 0, 0, 0);
21203
21261
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
21204
21262
  compareDate.setHours(0, 0, 0, 0);
21205
- if (compareDate.getDay() === 0) return "bg-gray-300";
21206
21263
  if (compareDate > istNow) return "bg-gray-200";
21264
+ if (!hasData) return "bg-gray-300";
21207
21265
  if (efficiency >= 80) return "bg-[#00AB45]/90";
21208
21266
  if (efficiency >= 70) return "bg-[#FFB020]/90";
21209
21267
  return "bg-[#E34329]/90";
@@ -21212,7 +21270,7 @@ var WorkspaceHistoryCalendar = ({
21212
21270
  const istNow = getTimeInZoneAsDate(configuredTimezone);
21213
21271
  const compareDate = dateFnsTz.toZonedTime(date, configuredTimezone);
21214
21272
  compareDate.setHours(0, 0, 0, 0);
21215
- if (compareDate > istNow || compareDate.getDay() === 0) return null;
21273
+ if (compareDate > istNow || !hasRealData(shift)) return null;
21216
21274
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 bg-black/80 rounded-lg p-2 text-white opacity-0 group-hover:opacity-100 transition-all duration-200 ease-in-out", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs space-y-1", children: [
21217
21275
  /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
21218
21276
  "Efficiency: ",
@@ -21264,25 +21322,26 @@ var WorkspaceHistoryCalendar = ({
21264
21322
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `h-full border border-gray-200 rounded-lg ${bgColor} ${animationComplete ? "transition-all duration-300 ease-in-out" : ""} cursor-not-allowed opacity-60`, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: `text-base font-medium ${textColor} ${isToday ? "text-blue-500" : ""}`, children: dayNumber }) }) });
21265
21323
  }
21266
21324
  const shiftData = selectedShift === "day" ? day.dayShift : day.nightShift;
21325
+ const hasData = hasRealData(shiftData);
21267
21326
  return /* @__PURE__ */ jsxRuntime.jsx(
21268
21327
  "div",
21269
21328
  {
21270
- className: `group h-full ${animationComplete ? "transition-all duration-300 ease-in-out" : ""} ${!isFuture && animationComplete ? "cursor-pointer hover:opacity-90 hover:scale-105" : "cursor-not-allowed"}`,
21271
- onClick: () => !isFuture && handleDayClick(day, selectedShift),
21329
+ className: `group h-full ${animationComplete ? "transition-all duration-300 ease-in-out" : ""} ${!isFuture && hasData && animationComplete ? "cursor-pointer hover:opacity-90 hover:scale-105" : "cursor-not-allowed"}`,
21330
+ onClick: () => !isFuture && hasData && handleDayClick(day, selectedShift),
21272
21331
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `
21273
- ${getPerformanceColor(shiftData.efficiency, day.date)}
21332
+ ${getPerformanceColor(shiftData.efficiency, day.date, hasData)}
21274
21333
  rounded-lg h-full p-2 relative ${animationComplete ? "transition-all duration-300 ease-in-out" : ""} shadow-sm
21275
21334
  ${isToday ? "ring-2 ring-blue-500 ring-offset-2 shadow-md" : ""}
21276
21335
  `, children: [
21277
21336
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `
21278
- text-base font-medium text-white flex items-center ${animationComplete ? "transition-all duration-300 ease-in-out" : ""}
21337
+ text-base font-medium ${hasData ? "text-white" : "text-gray-500"} flex items-center ${animationComplete ? "transition-all duration-300 ease-in-out" : ""}
21279
21338
  ${isToday ? "bg-blue-500 rounded-full w-7 h-7 justify-center" : ""}
21280
21339
  `, children: day.date.getDate() }),
21281
- !isFuture && animationComplete && renderStats(shiftData, day.date)
21340
+ !isFuture && hasData && animationComplete && renderStats(shiftData, day.date)
21282
21341
  ] })
21283
21342
  }
21284
21343
  );
21285
- }, [selectedShift, isCurrentDate, isFutureDate, getPerformanceColor, handleDayClick, year, month, configuredTimezone, animationComplete]);
21344
+ }, [selectedShift, isCurrentDate, isFutureDate, getPerformanceColor, handleDayClick, year, month, configuredTimezone, animationComplete, hasRealData]);
21286
21345
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `calendar-wrapper space-y-6 ${className || ""} ${animationComplete ? "animation-complete" : ""}`, children: [
21287
21346
  /* @__PURE__ */ jsxRuntime.jsx("style", { dangerouslySetInnerHTML: { __html: styles } }),
21288
21347
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1 border border-gray-200 rounded-lg p-1 bg-gray-50", children: [
@@ -21320,7 +21379,10 @@ var WorkspaceHistoryCalendar = ({
21320
21379
  ] }),
21321
21380
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "calendar-container bg-white rounded-xl shadow-sm border border-gray-100 p-6 transition-all duration-200 ease-in-out", children: [
21322
21381
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mb-6", children: [
21323
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "font-semibold text-gray-900 text-lg", children: "Monthly Summary" }),
21382
+ /* @__PURE__ */ jsxRuntime.jsxs("h3", { className: "font-semibold text-gray-900 text-lg", children: [
21383
+ "Monthly Summary - ",
21384
+ selectedShift === "day" ? "Day Shift" : "Night Shift"
21385
+ ] }),
21324
21386
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 mt-1", children: "Overview of monthly performance metrics" })
21325
21387
  ] }),
21326
21388
  monthlyMetrics ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4", children: [
@@ -22056,10 +22118,7 @@ var LoadingOverlay = ({
22056
22118
  className: `fixed inset-0 z-[100] flex items-center justify-center bg-black/30 backdrop-blur-sm ${className || ""}`,
22057
22119
  "aria-modal": "true",
22058
22120
  role: "dialog",
22059
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center space-y-3 rounded-lg bg-white p-8 shadow-xl", children: [
22060
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "md" }),
22061
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-base font-medium text-gray-700", children: message })
22062
- ] })
22121
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col items-center space-y-3 rounded-lg bg-white p-8 shadow-xl", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message }) })
22063
22122
  }
22064
22123
  );
22065
22124
  };
@@ -22884,20 +22943,6 @@ var S3ClipsService = class {
22884
22943
  return videos;
22885
22944
  }
22886
22945
  };
22887
- var LoadingSpinner2 = ({
22888
- size = "md",
22889
- message = "Loading..."
22890
- }) => {
22891
- const sizeClasses = {
22892
- sm: "w-4 h-4",
22893
- md: "w-6 h-6",
22894
- lg: "w-8 h-8"
22895
- };
22896
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center justify-center", children: [
22897
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `${sizeClasses[size]} border-2 border-t-blue-500 border-r-blue-500 border-b-gray-200 border-l-gray-200 rounded-full animate-spin mb-2` }),
22898
- message && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-gray-600 text-sm", children: message })
22899
- ] });
22900
- };
22901
22946
  var BottlenecksContent = ({
22902
22947
  workspaceId,
22903
22948
  workspaceName,
@@ -23416,7 +23461,7 @@ var BottlenecksContent = ({
23416
23461
  ] });
23417
23462
  }
23418
23463
  if (isLoading && allVideos.length === 0) {
23419
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow p-4 flex items-center justify-center h-[calc(100vh-12rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner2, { size: "lg", message: "Loading clips..." }) });
23464
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow p-4 flex items-center justify-center h-[calc(100vh-12rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading clips..." }) });
23420
23465
  }
23421
23466
  if (error) {
23422
23467
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-4 flex flex-col items-center justify-center h-[calc(100vh-12rem)] text-center", children: [
@@ -23594,7 +23639,7 @@ var BottlenecksContent = ({
23594
23639
  }
23595
23640
  )
23596
23641
  ] }),
23597
- isLoading && allVideos.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-[calc(100%-4rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner2, { size: "md", message: "Loading clips..." }) }) : allVideos.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-[calc(100%-4rem)]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
23642
+ isLoading && allVideos.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-[calc(100%-4rem)]", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading clips..." }) }) : allVideos.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center h-[calc(100%-4rem)]", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center p-8", children: [
23598
23643
  /* @__PURE__ */ jsxRuntime.jsx("svg", { className: "w-16 h-16 text-gray-300 mx-auto mb-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5, d: "M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" }) }),
23599
23644
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-xl font-medium text-gray-700 mb-2", children: "No Clips Found" }),
23600
23645
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-500", children: "There were no video clips found for this workspace today." })
@@ -25284,11 +25329,8 @@ var LoadingState = ({
25284
25329
  className = ""
25285
25330
  }) => {
25286
25331
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `flex h-full w-full items-center justify-center bg-gray-50/50 ${className}`, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center space-y-4 text-center", children: [
25287
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size }),
25288
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
25289
- /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-medium text-gray-900", children: message }),
25290
- subMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-600", children: subMessage })
25291
- ] })
25332
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size, message }),
25333
+ subMessage && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-gray-600", children: subMessage })
25292
25334
  ] }) });
25293
25335
  };
25294
25336
  var LoadingSkeleton = ({
@@ -25315,10 +25357,7 @@ var LoadingSkeleton = ({
25315
25357
  /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-6 w-1/3" }),
25316
25358
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
25317
25359
  /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-64 w-full" }),
25318
- showLoadingIndicator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white/80 rounded-lg p-3 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "animate-spin h-6 w-6 text-blue-500", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
25319
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
25320
- /* @__PURE__ */ jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
25321
- ] }) }) })
25360
+ showLoadingIndicator && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white/80 rounded-lg p-3 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm" }) }) })
25322
25361
  ] })
25323
25362
  ] });
25324
25363
  case "table":
@@ -25369,10 +25408,7 @@ var LoadingInline = ({
25369
25408
  size = "sm",
25370
25409
  className = ""
25371
25410
  }) => {
25372
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `inline-flex items-center space-x-2 ${className}`, children: [
25373
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size }),
25374
- message && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-600", children: message })
25375
- ] });
25411
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `inline-flex items-center space-x-2 ${className}`, children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size, message }) });
25376
25412
  };
25377
25413
  var DEFAULT_HLS_CONFIG = {
25378
25414
  maxBufferLength: 15,
@@ -25601,7 +25637,7 @@ var ThreadSidebar = ({
25601
25637
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: "text-lg font-semibold text-gray-900", children: "Chat History" }),
25602
25638
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-500 mt-1", children: "Your previous conversations" })
25603
25639
  ] }),
25604
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto min-h-0", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxRuntime.jsxs(
25640
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-y-auto min-h-0", children: isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center p-8", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm" }) }) : threads.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-gray-500 text-sm", children: "No conversations yet" }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-2", children: threads.map((thread) => /* @__PURE__ */ jsxRuntime.jsxs(
25605
25641
  "div",
25606
25642
  {
25607
25643
  onClick: () => onSelectThread(thread.id),
@@ -25612,7 +25648,7 @@ var ThreadSidebar = ({
25612
25648
  /* @__PURE__ */ jsxRuntime.jsx("h3", { className: `text-sm font-medium truncate ${activeThreadId === thread.id ? "text-blue-900" : "text-gray-900"}`, children: thread.title || "Untitled Chat" }),
25613
25649
  /* @__PURE__ */ jsxRuntime.jsx("p", { className: `text-xs mt-0.5 ${activeThreadId === thread.id ? "text-blue-700" : "text-gray-500"}`, children: formatDate(thread.created_at) })
25614
25650
  ] }),
25615
- deletingId === thread.id ? /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm", className: "flex-shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(
25651
+ deletingId === thread.id ? /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm", className: "flex-shrink-0" }) : /* @__PURE__ */ jsxRuntime.jsx(
25616
25652
  "button",
25617
25653
  {
25618
25654
  onClick: (e) => handleDelete(e, thread.id),
@@ -25770,6 +25806,12 @@ var AIAgentView = () => {
25770
25806
  const lineId = getLineIdFromPath();
25771
25807
  const { shiftId } = getCurrentShift(dateTimeConfig.defaultTimezone || "Asia/Kolkata", shiftConfig);
25772
25808
  const companyId = entityConfig.companyId || "default-company-id";
25809
+ const configuredLineIds = getConfiguredLineIds(entityConfig);
25810
+ const lineDisplayNames = getAllLineDisplayNames(entityConfig);
25811
+ const allLines = configuredLineIds.map((id3) => ({
25812
+ id: id3,
25813
+ name: lineDisplayNames[id3] || `Line ${id3.substring(0, 8)}`
25814
+ }));
25773
25815
  const ACTIVE_THREAD_STORAGE_KEY = `ai-agent-active-thread-${lineId}`;
25774
25816
  React19.useLayoutEffect(() => {
25775
25817
  const savedThreadId = localStorage.getItem(ACTIVE_THREAD_STORAGE_KEY);
@@ -25940,7 +25982,8 @@ var AIAgentView = () => {
25940
25982
  {
25941
25983
  companyId,
25942
25984
  lineId,
25943
- shiftId
25985
+ shiftId,
25986
+ allLines
25944
25987
  },
25945
25988
  {
25946
25989
  onThreadCreated: (threadId) => {
@@ -26587,6 +26630,13 @@ var AIAgentView = () => {
26587
26630
  console.error("Bar chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
26588
26631
  return null;
26589
26632
  }
26633
+ if (!Array.isArray(args.data)) {
26634
+ console.error("Bar chart data must be an array, got:", typeof args.data, args.data);
26635
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26636
+ "Error: Chart data must be an array. Received: ",
26637
+ typeof args.data
26638
+ ] }) }, `bar-error-${key}`);
26639
+ }
26590
26640
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26591
26641
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26592
26642
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -26624,6 +26674,13 @@ var AIAgentView = () => {
26624
26674
  console.error("Line chart missing required parameters:", { data: !!args.data, x_field: !!args.x_field, y_field: !!args.y_field });
26625
26675
  return null;
26626
26676
  }
26677
+ if (!Array.isArray(args.data)) {
26678
+ console.error("Line chart data must be an array, got:", typeof args.data, args.data);
26679
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26680
+ "Error: Chart data must be an array. Received: ",
26681
+ typeof args.data
26682
+ ] }) }, `line-error-${key}`);
26683
+ }
26627
26684
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-64", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.LineChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26628
26685
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26629
26686
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -26665,6 +26722,13 @@ var AIAgentView = () => {
26665
26722
  console.error("Available args:", Object.keys(args));
26666
26723
  return null;
26667
26724
  }
26725
+ if (!Array.isArray(args.data)) {
26726
+ console.error("Pie chart data must be an array, got:", typeof args.data, args.data);
26727
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26728
+ "Error: Chart data must be an array. Received: ",
26729
+ typeof args.data
26730
+ ] }) }, `pie-error-${key}`);
26731
+ }
26668
26732
  const pieData = args.data.map((item) => ({
26669
26733
  name: item[args.label_field],
26670
26734
  value: item[args.value_field]
@@ -26684,6 +26748,13 @@ var AIAgentView = () => {
26684
26748
  console.error("Comparison table missing required data");
26685
26749
  return null;
26686
26750
  }
26751
+ if (!Array.isArray(args.data)) {
26752
+ console.error("Comparison table data must be an array, got:", typeof args.data, args.data);
26753
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26754
+ "Error: Table data must be an array. Received: ",
26755
+ typeof args.data
26756
+ ] }) }, `table-error-${key}`);
26757
+ }
26687
26758
  const columns = args.columns || Object.keys(args.data[0] || {});
26688
26759
  let sortedData = [...args.data];
26689
26760
  if (args.sort_by && columns.includes(args.sort_by)) {
@@ -26723,6 +26794,13 @@ var AIAgentView = () => {
26723
26794
  });
26724
26795
  return null;
26725
26796
  }
26797
+ if (!Array.isArray(args.data)) {
26798
+ console.error("Multi-line chart data must be an array, got:", typeof args.data, args.data);
26799
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26800
+ "Error: Chart data must be an array. Received: ",
26801
+ typeof args.data
26802
+ ] }) }, `multi-line-error-${key}`);
26803
+ }
26726
26804
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.LineChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26727
26805
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26728
26806
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -26776,6 +26854,13 @@ var AIAgentView = () => {
26776
26854
  });
26777
26855
  return null;
26778
26856
  }
26857
+ if (!Array.isArray(args.data)) {
26858
+ console.error("Stacked bar chart data must be an array, got:", typeof args.data, args.data);
26859
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26860
+ "Error: Chart data must be an array. Received: ",
26861
+ typeof args.data
26862
+ ] }) }, `stacked-bar-error-${key}`);
26863
+ }
26779
26864
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.BarChart, { data: args.data, margin: CHART_STYLES.margin, children: [
26780
26865
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26781
26866
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -26828,6 +26913,13 @@ var AIAgentView = () => {
26828
26913
  });
26829
26914
  return null;
26830
26915
  }
26916
+ if (!Array.isArray(args.data)) {
26917
+ console.error("Dual-axis chart data must be an array, got:", typeof args.data, args.data);
26918
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
26919
+ "Error: Chart data must be an array. Received: ",
26920
+ typeof args.data
26921
+ ] }) }, `dual-axis-error-${key}`);
26922
+ }
26831
26923
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
26832
26924
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26833
26925
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -26915,6 +27007,13 @@ var AIAgentView = () => {
26915
27007
  });
26916
27008
  return null;
26917
27009
  }
27010
+ if (!Array.isArray(args.data)) {
27011
+ console.error("Scatter plot data must be an array, got:", typeof args.data, args.data);
27012
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
27013
+ "Error: Chart data must be an array. Received: ",
27014
+ typeof args.data
27015
+ ] }) }, `scatter-error-${key}`);
27016
+ }
26918
27017
  const groupedData = args.data.reduce((acc, item) => {
26919
27018
  const group = item[args.group_field];
26920
27019
  if (!acc[group]) {
@@ -26978,6 +27077,13 @@ var AIAgentView = () => {
26978
27077
  });
26979
27078
  return null;
26980
27079
  }
27080
+ if (!Array.isArray(args.data)) {
27081
+ console.error("Combo chart data must be an array, got:", typeof args.data, args.data);
27082
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
27083
+ "Error: Chart data must be an array. Received: ",
27084
+ typeof args.data
27085
+ ] }) }, `combo-error-${key}`);
27086
+ }
26981
27087
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
26982
27088
  /* @__PURE__ */ jsxRuntime.jsx(recharts.CartesianGrid, { ...CHART_STYLES.grid }),
26983
27089
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -27052,6 +27158,13 @@ var AIAgentView = () => {
27052
27158
  });
27053
27159
  return null;
27054
27160
  }
27161
+ if (!Array.isArray(args.data)) {
27162
+ console.error("Area chart data must be an array, got:", typeof args.data, args.data);
27163
+ return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-red-500 text-sm", children: [
27164
+ "Error: Chart data must be an array. Received: ",
27165
+ typeof args.data
27166
+ ] }) }, `area-error-${key}`);
27167
+ }
27055
27168
  return /* @__PURE__ */ jsxRuntime.jsx(ChartWrapper, { title: args.title, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full h-80", children: /* @__PURE__ */ jsxRuntime.jsx(recharts.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxRuntime.jsxs(recharts.ComposedChart, { data: args.data, margin: { ...CHART_STYLES.margin, bottom: 80 }, children: [
27056
27169
  /* @__PURE__ */ jsxRuntime.jsx("defs", { children: /* @__PURE__ */ jsxRuntime.jsxs("linearGradient", { id: "colorGradient", x1: "0", y1: "0", x2: "0", y2: "1", children: [
27057
27170
  /* @__PURE__ */ jsxRuntime.jsx("stop", { offset: "5%", stopColor: CHART_COLORS.primary, stopOpacity: 0.8 }),
@@ -27296,7 +27409,13 @@ var AIAgentView = () => {
27296
27409
  {
27297
27410
  className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
27298
27411
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
27299
- message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
27412
+ message.role === "assistant" ? message.id === -1 ? /* @__PURE__ */ jsxRuntime.jsx(
27413
+ "div",
27414
+ {
27415
+ className: "formatted-content",
27416
+ dangerouslySetInnerHTML: { __html: formatMessage(message.content) }
27417
+ }
27418
+ ) : renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
27300
27419
  message.id === -1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
27301
27420
  ] })
27302
27421
  }
@@ -27326,7 +27445,13 @@ var AIAgentView = () => {
27326
27445
  className: `relative px-5 py-4 rounded-2xl shadow-sm ${message.role === "user" ? "bg-blue-600 text-white max-w-[85%] ml-auto" : "bg-white border border-gray-200/80 max-w-full"}`,
27327
27446
  children: [
27328
27447
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${message.role === "user" ? "text-white" : "text-gray-800"}`, children: [
27329
- message.role === "assistant" ? renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
27448
+ message.role === "assistant" ? message.id === -1 ? /* @__PURE__ */ jsxRuntime.jsx(
27449
+ "div",
27450
+ {
27451
+ className: "formatted-content",
27452
+ dangerouslySetInnerHTML: { __html: formatMessage(message.content) }
27453
+ }
27454
+ ) : renderAssistantContent(message.content) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap leading-relaxed", children: message.content }),
27330
27455
  message.id === -1 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-block w-0.5 h-4 bg-gray-400 animate-pulse ml-0.5" })
27331
27456
  ] }),
27332
27457
  message.role === "assistant" && message.id !== -1 && /* @__PURE__ */ jsxRuntime.jsx(
@@ -28348,7 +28473,7 @@ var HelpView = ({
28348
28473
  disabled: isSubmitting,
28349
28474
  className: "px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2 shadow-sm text-sm",
28350
28475
  children: isSubmitting ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
28351
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { className: "h-4 w-4" }),
28476
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm" }),
28352
28477
  "Submitting..."
28353
28478
  ] }) : "Submit Ticket"
28354
28479
  }
@@ -28533,7 +28658,7 @@ function HomeView({
28533
28658
  ) }) }),
28534
28659
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 overflow-y-auto sm:overflow-hidden relative", children: [
28535
28660
  lineSelectorComponent && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute right-3 top-2 sm:right-6 sm:top-3 z-30", children: lineSelectorComponent }),
28536
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: isDataLoading && hasInitialDataLoaded && memoizedWorkspaceMetrics.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 sm:px-6 lg:px-8 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSkeleton, { type: "workspace-card", count: 8, className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4" }) }) : memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
28661
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-full sm:h-full min-h-[calc(100vh-80px)] sm:min-h-0", children: isDataLoading || !hasInitialDataLoaded ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "px-3 sm:px-6 lg:px-8 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSkeleton, { type: "workspace-card", count: 8, className: "grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4" }) }) : memoizedWorkspaceMetrics.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx(
28537
28662
  motion.div,
28538
28663
  {
28539
28664
  initial: { opacity: 0, scale: 0.98 },
@@ -30160,7 +30285,7 @@ var ProfileView = () => {
30160
30285
  }
30161
30286
  };
30162
30287
  if (authLoading || loading) {
30163
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "lg" }) });
30288
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg" }) });
30164
30289
  }
30165
30290
  if (!user) {
30166
30291
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center min-h-screen", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-center", children: [
@@ -30317,7 +30442,7 @@ var ProfileView = () => {
30317
30442
  ] })
30318
30443
  ] }),
30319
30444
  isEditing && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-6 flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(Button2, { variant: "outline", onClick: handleSaveProfile, disabled: loading, children: loading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30320
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm", className: "mr-2" }),
30445
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm", className: "mr-2" }),
30321
30446
  "Saving..."
30322
30447
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30323
30448
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "h-4 w-4 mr-2" }),
@@ -30381,7 +30506,7 @@ var ProfileView = () => {
30381
30506
  disabled: loading,
30382
30507
  className: "flex items-center gap-2 text-red-600 hover:text-red-700 border-red-200 hover:border-red-300",
30383
30508
  children: loading ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30384
- /* @__PURE__ */ jsxRuntime.jsx(LoadingSpinner_default, { size: "sm", className: "mr-2" }),
30509
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm", className: "mr-2" }),
30385
30510
  "Signing out..."
30386
30511
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
30387
30512
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.LogOut, { className: "h-4 w-4" }),
@@ -31828,7 +31953,7 @@ var SKUList = ({
31828
31953
  }) => {
31829
31954
  if (isLoading) {
31830
31955
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white rounded-xl shadow-sm border border-gray-200 p-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-center items-center", children: [
31831
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600" }),
31956
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md" }),
31832
31957
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-3 text-gray-600", children: "Loading SKUs..." })
31833
31958
  ] }) });
31834
31959
  }
@@ -31914,7 +32039,7 @@ var TargetsViewUI = ({
31914
32039
  skuRequired = false
31915
32040
  }) => {
31916
32041
  if (isLoading) {
31917
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-screen bg-gray-50", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-8 h-8 animate-spin text-blue-600" }) }) });
32042
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-screen bg-gray-50", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "lg", message: "Loading targets..." }) }) });
31918
32043
  }
31919
32044
  return /* @__PURE__ */ jsxRuntime.jsxs("main", { className: "min-h-screen flex-1 bg-gray-50", children: [
31920
32045
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white px-8 py-6 shadow-sm border-b border-gray-200/80", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between relative", children: [
@@ -32016,7 +32141,7 @@ var TargetsViewUI = ({
32016
32141
  className: `ml-6 inline-flex items-center px-4 py-2 text-sm font-medium rounded-lg transition-all duration-200
32017
32142
  ${savingLines[lineId] ? "bg-gray-100 text-gray-400 cursor-not-allowed" : "bg-blue-600 text-white hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500"}`,
32018
32143
  children: savingLines[lineId] ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
32019
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "w-4 h-4 mr-2 animate-spin" }),
32144
+ /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "sm", className: "mr-2" }),
32020
32145
  "Saving..."
32021
32146
  ] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
32022
32147
  /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { className: "w-4 h-4 mr-2" }),
@@ -33154,13 +33279,7 @@ var WorkspaceDetailView = ({
33154
33279
  ] }) }, i)) }),
33155
33280
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white rounded-lg p-6 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "animate-pulse", children: [
33156
33281
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-6 w-40 bg-gray-200 rounded mb-4" }),
33157
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-64 bg-gray-100 rounded relative overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bg-white/80 rounded-lg p-4 shadow-sm", children: [
33158
- /* @__PURE__ */ jsxRuntime.jsxs("svg", { className: "animate-spin h-8 w-8 text-blue-500", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [
33159
- /* @__PURE__ */ jsxRuntime.jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }),
33160
- /* @__PURE__ */ jsxRuntime.jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })
33161
- ] }),
33162
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm text-gray-600 mt-2", children: "Loading chart data..." })
33163
- ] }) }) })
33282
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-64 bg-gray-100 rounded relative overflow-hidden", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute inset-0 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bg-white/80 rounded-lg p-4 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsx(OptifyeLogoLoader_default, { size: "md", message: "Loading chart data..." }) }) }) })
33164
33283
  ] }) })
33165
33284
  ] })
33166
33285
  ] })
@@ -34054,7 +34173,6 @@ exports.LoadingInline = LoadingInline;
34054
34173
  exports.LoadingOverlay = LoadingOverlay_default;
34055
34174
  exports.LoadingPage = LoadingPage_default;
34056
34175
  exports.LoadingSkeleton = LoadingSkeleton;
34057
- exports.LoadingSpinner = LoadingSpinner_default;
34058
34176
  exports.LoadingState = LoadingState;
34059
34177
  exports.LoginPage = LoginPage;
34060
34178
  exports.LoginView = LoginView_default;
@@ -34062,6 +34180,7 @@ exports.MainLayout = MainLayout;
34062
34180
  exports.MetricCard = MetricCard_default;
34063
34181
  exports.NoWorkspaceData = NoWorkspaceData;
34064
34182
  exports.OptifyeAgentClient = OptifyeAgentClient;
34183
+ exports.OptifyeLogoLoader = OptifyeLogoLoader_default;
34065
34184
  exports.OutputProgressChart = OutputProgressChart;
34066
34185
  exports.PageHeader = PageHeader;
34067
34186
  exports.PieChart = PieChart4;
@@ -34146,6 +34265,8 @@ exports.getCompanyMetricsTableName = getCompanyMetricsTableName;
34146
34265
  exports.getConfigurableShortWorkspaceDisplayName = getConfigurableShortWorkspaceDisplayName;
34147
34266
  exports.getConfigurableWorkspaceDisplayName = getConfigurableWorkspaceDisplayName;
34148
34267
  exports.getConfiguredLineIds = getConfiguredLineIds;
34268
+ exports.getCoreSessionRecordingProperties = getCoreSessionRecordingProperties;
34269
+ exports.getCoreSessionReplayUrl = getCoreSessionReplayUrl;
34149
34270
  exports.getCurrentShift = getCurrentShift;
34150
34271
  exports.getCurrentTimeInZone = getCurrentTimeInZone;
34151
34272
  exports.getDashboardHeaderTimeInZone = getDashboardHeaderTimeInZone;
@@ -34197,6 +34318,8 @@ exports.resetCoreMixpanel = resetCoreMixpanel;
34197
34318
  exports.resetSubscriptionManager = resetSubscriptionManager;
34198
34319
  exports.s3VideoPreloader = s3VideoPreloader;
34199
34320
  exports.skuService = skuService;
34321
+ exports.startCoreSessionRecording = startCoreSessionRecording;
34322
+ exports.stopCoreSessionRecording = stopCoreSessionRecording;
34200
34323
  exports.storeWorkspaceMapping = storeWorkspaceMapping;
34201
34324
  exports.streamProxyConfig = streamProxyConfig;
34202
34325
  exports.throttledReloadDashboard = throttledReloadDashboard;