@optifye/dashboard-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,3529 @@
1
+ import * as _supabase_supabase_js from '@supabase/supabase-js';
2
+ import { SupabaseClient as SupabaseClient$1, Session, User, AuthError } from '@supabase/supabase-js';
3
+ import { LucideProps, Share2, Download } from 'lucide-react';
4
+ import * as React$1 from 'react';
5
+ import React__default, { ReactNode } from 'react';
6
+ import * as querystring from 'querystring';
7
+ import { ClassValue } from 'clsx';
8
+ import * as react_jsx_runtime from 'react/jsx-runtime';
9
+ import * as SelectPrimitive from '@radix-ui/react-select';
10
+ import { Modifiers } from 'react-day-picker';
11
+ import html2canvas from 'html2canvas';
12
+
13
+ interface LineInfo {
14
+ line_id: string;
15
+ line_name: string;
16
+ company_id: string;
17
+ company_name: string;
18
+ factory_id: string;
19
+ factory_name: string;
20
+ shift_id: number;
21
+ date: string;
22
+ metrics: {
23
+ avg_efficiency: number;
24
+ avg_cycle_time: number;
25
+ current_output: number;
26
+ ideal_output: number;
27
+ total_workspaces: number;
28
+ underperforming_workspaces: number;
29
+ underperforming_workspace_names: string[];
30
+ underperforming_workspace_uuids: string[];
31
+ output_array: number[];
32
+ line_threshold: number;
33
+ threshold_pph?: number;
34
+ shift_start?: string;
35
+ shift_end?: string;
36
+ last_updated?: string;
37
+ poorest_performing_workspaces?: PoorPerformingWorkspace[];
38
+ };
39
+ }
40
+ interface PoorPerformingWorkspace {
41
+ workspace_name: string;
42
+ efficiency: number;
43
+ action_count: number;
44
+ action_threshold: number;
45
+ }
46
+ interface WorkspaceMetrics {
47
+ company_id: string;
48
+ line_id: string;
49
+ shift_id: number;
50
+ date: string;
51
+ workspace_uuid: string | null;
52
+ workspace_name: string;
53
+ action_count: number;
54
+ pph: number;
55
+ performance_score: 0 | 1 | 2;
56
+ avg_cycle_time: number;
57
+ trend: 0 | 1 | 2;
58
+ predicted_output: number;
59
+ efficiency: number;
60
+ action_threshold: number;
61
+ }
62
+ interface WorkspaceDetailedMetrics {
63
+ line_id: string;
64
+ line_name: string;
65
+ workspace_name: string;
66
+ workspace_id: string;
67
+ company_id: string;
68
+ company_name: string;
69
+ date: string;
70
+ shift_id: number;
71
+ action_name: string;
72
+ shift_start: string;
73
+ shift_end: string;
74
+ shift_type: string;
75
+ pph_threshold: number;
76
+ target_output: number;
77
+ avg_pph: number;
78
+ avg_cycle_time: number;
79
+ ideal_cycle_time: number;
80
+ avg_efficiency: number;
81
+ total_actions: number;
82
+ hourly_action_counts: number[];
83
+ workspace_rank: number;
84
+ total_workspaces: number;
85
+ ideal_output_until_now: number;
86
+ output_difference: number;
87
+ compliance_efficiency?: number;
88
+ sop_check?: Record<string, number>;
89
+ }
90
+ interface DashboardKPIs {
91
+ underperformingWorkers: {
92
+ current: number;
93
+ total: number;
94
+ change: number;
95
+ };
96
+ efficiency: {
97
+ value: number;
98
+ change: number;
99
+ };
100
+ outputProgress: {
101
+ current: number;
102
+ target: number;
103
+ change: number;
104
+ idealOutput: number;
105
+ };
106
+ qualityCompliance: {
107
+ value: number;
108
+ change: number;
109
+ };
110
+ avgCycleTime: {
111
+ value: number;
112
+ change: number;
113
+ };
114
+ }
115
+
116
+ interface ThemeColorValue {
117
+ DEFAULT: string;
118
+ foreground?: string;
119
+ [key: string]: string | undefined;
120
+ }
121
+ interface ThemeConfig {
122
+ primary?: ThemeColorValue;
123
+ secondary?: ThemeColorValue;
124
+ accent?: ThemeColorValue;
125
+ [key: string]: ThemeColorValue | Record<string, string> | string | undefined;
126
+ }
127
+ interface AuthConfig {
128
+ /** Name of the table storing user profiles/roles, if applicable */
129
+ userProfileTable?: string;
130
+ /** Column name in the profile table that stores the user's role */
131
+ roleColumn?: string;
132
+ /** Default path to redirect to after login (app can override) */
133
+ defaultLoginRedirect?: string;
134
+ /** Default path to redirect to after logout (app can override) */
135
+ defaultLogoutRedirect?: string;
136
+ }
137
+ interface AnalyticsConfig {
138
+ mixpanelToken?: string;
139
+ mixpanelDebug?: boolean;
140
+ mixpanelTrackPageView?: boolean;
141
+ }
142
+ interface DashboardConfig {
143
+ supabaseUrl: string;
144
+ supabaseKey: string;
145
+ apiBaseUrl?: string;
146
+ theme?: ThemeConfig;
147
+ analyticsConfig?: AnalyticsConfig;
148
+ dateTimeConfig?: DateTimeConfig;
149
+ authConfig?: AuthConfig;
150
+ databaseConfig?: DatabaseConfig;
151
+ entityConfig?: EntityConfig;
152
+ shiftConfig?: ShiftConfig;
153
+ workspaceConfig?: WorkspaceConfig;
154
+ endpoints?: EndpointsConfig;
155
+ edgeFunctionBaseUrl?: string;
156
+ /** Feature flags or other arbitrary app-specific config */
157
+ featureFlags?: Record<string, boolean>;
158
+ /** Generic object to allow any other custom config values needed by the app or overrides */
159
+ customConfig?: Record<string, unknown>;
160
+ }
161
+ interface DatabaseConfig {
162
+ schema?: string;
163
+ tables?: {
164
+ lines?: string;
165
+ lineMetrics?: string;
166
+ actions?: string;
167
+ workspaces?: string;
168
+ actionThresholds?: string;
169
+ lineThresholds?: string;
170
+ shiftConfigurations?: string;
171
+ qualityMetrics?: string;
172
+ };
173
+ }
174
+ interface EntityConfig {
175
+ companyId?: string;
176
+ factoryId?: string;
177
+ defaultLineId?: string;
178
+ secondaryLineId?: string;
179
+ factoryViewId?: string;
180
+ /** Optional mapping of line IDs to their display names */
181
+ lineNames?: Record<string, string>;
182
+ }
183
+ interface ShiftConfig {
184
+ dayShift?: {
185
+ id?: number;
186
+ startTime?: string;
187
+ endTime?: string;
188
+ };
189
+ nightShift?: {
190
+ id?: number;
191
+ startTime?: string;
192
+ endTime?: string;
193
+ };
194
+ transitionPeriodMinutes?: number;
195
+ }
196
+ interface WorkspaceConfig {
197
+ displayNames?: Record<string, string>;
198
+ specialWorkspaces?: {
199
+ startId?: number;
200
+ endId?: number;
201
+ /** Number of recent readings to display for special workspaces' hourly/minute-by-minute charts */
202
+ hourlyReadingsCount?: number;
203
+ };
204
+ totalWorkspaces?: number;
205
+ }
206
+ interface EndpointsConfig {
207
+ whatsapp?: string;
208
+ worstPerformingWorkspaces?: string;
209
+ }
210
+ interface DateTimeConfig {
211
+ defaultTimezone?: string;
212
+ defaultLocale?: string;
213
+ dateFormatOptions?: Intl.DateTimeFormatOptions;
214
+ timeFormatOptions?: Intl.DateTimeFormatOptions;
215
+ dateTimeFormatOptions?: Intl.DateTimeFormatOptions;
216
+ }
217
+
218
+ interface BasePerformanceMetric {
219
+ id: string;
220
+ workspace_id: string;
221
+ date: string;
222
+ shift: string;
223
+ target: number;
224
+ actual: number;
225
+ created_at: string;
226
+ updated_at: string;
227
+ }
228
+ interface BaseLineMetric {
229
+ id: string;
230
+ line_id: string;
231
+ date: string;
232
+ shift: string;
233
+ target: number;
234
+ actual: number;
235
+ created_at: string;
236
+ updated_at: string;
237
+ }
238
+ interface OverviewWorkspaceMetric {
239
+ workspace_id: string;
240
+ date: string;
241
+ total_target: number;
242
+ total_actual: number;
243
+ efficiency: number;
244
+ shift_metrics: {
245
+ shift: string;
246
+ target: number;
247
+ actual: number;
248
+ efficiency: number;
249
+ }[];
250
+ }
251
+ interface OverviewLineMetric {
252
+ line_id: string;
253
+ date: string;
254
+ total_target: number;
255
+ total_actual: number;
256
+ efficiency: number;
257
+ shift_metrics: {
258
+ shift: string;
259
+ target: number;
260
+ actual: number;
261
+ efficiency: number;
262
+ }[];
263
+ }
264
+ type MetricsError = {
265
+ message: string;
266
+ code?: string;
267
+ };
268
+
269
+ type SupabaseClient = SupabaseClient$1;
270
+
271
+ interface AuthUser {
272
+ id: string;
273
+ email?: string;
274
+ role?: string;
275
+ }
276
+
277
+ /**
278
+ * Represents an operator assigned to a workspace
279
+ */
280
+ interface OperatorInfo {
281
+ id: string;
282
+ name: string;
283
+ skill_level?: 'beginner' | 'intermediate' | 'expert';
284
+ shift_id?: number | string;
285
+ workspace_id?: string;
286
+ efficiency?: number;
287
+ position?: string;
288
+ experience_months?: number;
289
+ photo_url?: string;
290
+ last_training_date?: string;
291
+ }
292
+
293
+ /**
294
+ * Data for a single shift in the history calendar
295
+ */
296
+ interface ShiftHistoryData {
297
+ shiftId: number | string;
298
+ date: string;
299
+ efficiency: number;
300
+ target: number;
301
+ actual: number;
302
+ performanceScore?: 0 | 1 | 2;
303
+ }
304
+ /**
305
+ * Aggregated data for a single day in the history calendar
306
+ */
307
+ interface DayHistoryData {
308
+ date: string;
309
+ shifts: ShiftHistoryData[];
310
+ avgEfficiency: number;
311
+ totalTarget: number;
312
+ totalActual: number;
313
+ overallPerformance?: 0 | 1 | 2;
314
+ }
315
+ /**
316
+ * Properties for calendar components displaying historical data
317
+ */
318
+ interface HistoryCalendarProps {
319
+ entityId: string;
320
+ data: DayHistoryData[];
321
+ selectedDate?: string;
322
+ onDateChange?: (date: string) => void;
323
+ onShiftSelect?: (date: string, shiftId: number | string) => void;
324
+ showEfficiencyLabels?: boolean;
325
+ className?: string;
326
+ }
327
+ /**
328
+ * Generic summary data for a single day to be displayed on a history calendar.
329
+ * This can be extended or used as a base for more specific day data types.
330
+ */
331
+ interface DaySummaryData {
332
+ date: string;
333
+ efficiency?: number;
334
+ target?: number;
335
+ actual?: number;
336
+ performanceScore?: 0 | 1 | 2;
337
+ isInactive?: boolean;
338
+ shifts?: ShiftSummaryData[];
339
+ [key: string]: any;
340
+ }
341
+ /**
342
+ * Generic summary data for a single shift within a day.
343
+ */
344
+ interface ShiftSummaryData {
345
+ shiftId: string | number;
346
+ efficiency?: number;
347
+ target?: number;
348
+ actual?: number;
349
+ performanceScore?: 0 | 1 | 2;
350
+ [key: string]: any;
351
+ }
352
+
353
+ /** Represents a URL path */
354
+ type RoutePath = string;
355
+ interface TrackingEventProperties {
356
+ source: string;
357
+ [key: string]: any;
358
+ }
359
+ interface NavItemTrackingEvent {
360
+ name: string;
361
+ properties: TrackingEventProperties;
362
+ }
363
+ interface NavItem {
364
+ /** Unique key for the navigation item */
365
+ key: string;
366
+ /** The URL path or a dynamic path generator function */
367
+ path: RoutePath | ((params: Record<string, string | number>) => RoutePath);
368
+ /** Label for the navigation item */
369
+ label: string;
370
+ /** Icon component from lucide-react */
371
+ icon?: React.ComponentType<LucideProps>;
372
+ /** Optional feature flag to control visibility */
373
+ featureFlag?: string;
374
+ /** Optional tracking event configuration */
375
+ trackingEvent?: NavItemTrackingEvent | ((params: Record<string, string | number>) => NavItemTrackingEvent);
376
+ /** Optional parameters for dynamic paths or tracking events */
377
+ params?: Record<string, string | number>;
378
+ /** Optional sub-navigation items for dropdowns or nested menus */
379
+ subItems?: NavItem[];
380
+ /** Function to determine if the item is active, receives current pathname and query */
381
+ isActive?: (pathname: string, query: Record<string, any>) => boolean;
382
+ }
383
+ interface SideNavBarProps {
384
+ /** Array of navigation items to display */
385
+ navItems: NavItem[];
386
+ /** Optional logo element to display at the top */
387
+ logo?: React.ReactNode;
388
+ /** Additional CSS class for the container */
389
+ className?: string;
390
+ /** Current pathname, to be provided by the router context or parent */
391
+ currentPathname: string;
392
+ /** Current query parameters */
393
+ currentQuery?: Record<string, any>;
394
+ }
395
+
396
+ interface BreadcrumbItem {
397
+ label: string;
398
+ path?: RoutePath;
399
+ icon?: any;
400
+ }
401
+ interface ProfileMenuItem {
402
+ key: string;
403
+ label: string;
404
+ path?: RoutePath;
405
+ onClick?: () => void;
406
+ icon?: any;
407
+ isDivider?: boolean;
408
+ featureFlag?: string;
409
+ }
410
+ interface UserProfileConfig {
411
+ showAvatar?: boolean;
412
+ showName?: boolean;
413
+ showRole?: boolean;
414
+ dropdownItems?: ProfileMenuItem[];
415
+ logoutButtonText?: string;
416
+ customAvatar?: React.ReactNode;
417
+ }
418
+ interface PageHeaderProps {
419
+ /** The main title of the page */
420
+ title: string;
421
+ /** Optional array of breadcrumb items */
422
+ breadcrumbs?: BreadcrumbItem[];
423
+ /** Optional React node for actions (e.g., buttons, filters) on the right side */
424
+ actions?: React.ReactNode;
425
+ /** Whether to display the DateTimeDisplay component */
426
+ showDateTime?: boolean;
427
+ /** Configuration for the user profile section. If undefined, no user profile section is shown. */
428
+ userProfileConfig?: UserProfileConfig;
429
+ /** Additional CSS classes for the main header container */
430
+ className?: string;
431
+ /** Optional logo to display on the left, usually for mobile or specific layouts */
432
+ headerLogo?: React.ReactNode;
433
+ /** Stickiness of the header */
434
+ sticky?: boolean;
435
+ }
436
+
437
+ /**
438
+ * Represents the current operational shift information.
439
+ */
440
+ type CurrentShiftResult = {
441
+ /**
442
+ * Identifier for the shift.
443
+ * Typically 0 for Day shift, 1 for Night shift, based on default configuration.
444
+ */
445
+ shiftId: 0 | 1;
446
+ /**
447
+ * The operational date associated with the shift, in YYYY-MM-DD format.
448
+ */
449
+ date: string;
450
+ };
451
+ /**
452
+ * Type definitions for the Shifts management functionality
453
+ */
454
+ /**
455
+ * Represents a break period with start and end times
456
+ */
457
+ interface Break {
458
+ /** Break start time in HH:MM format */
459
+ startTime: string;
460
+ /** Break end time in HH:MM format */
461
+ endTime: string;
462
+ /** Duration of the break in minutes */
463
+ duration: number;
464
+ }
465
+ /**
466
+ * Represents day or night shift time configuration
467
+ */
468
+ interface ShiftTime {
469
+ /** Shift start time in HH:MM format */
470
+ startTime: string;
471
+ /** Shift end time in HH:MM format */
472
+ endTime: string;
473
+ /** Array of breaks during this shift */
474
+ breaks: Break[];
475
+ }
476
+ /**
477
+ * Represents a complete shift configuration for a line
478
+ */
479
+ interface LineShiftConfig {
480
+ /** Line ID */
481
+ id: string;
482
+ /** Line name for display */
483
+ name: string;
484
+ /** Day shift configuration */
485
+ dayShift: ShiftTime;
486
+ /** Night shift configuration */
487
+ nightShift: ShiftTime;
488
+ /** Whether the line configuration panel is open/expanded */
489
+ isOpen: boolean;
490
+ /** Whether the configuration is currently being saved */
491
+ isSaving: boolean;
492
+ /** Whether the save operation was successful */
493
+ saveSuccess: boolean;
494
+ }
495
+ /**
496
+ * Map of line ID to shift hours configuration
497
+ */
498
+ interface ShiftHoursMap {
499
+ [key: string]: ShiftTime;
500
+ }
501
+ /**
502
+ * Props for BreakRow component
503
+ */
504
+ interface BreakRowProps {
505
+ /** Break configuration */
506
+ break: Break;
507
+ /** Index of this break in the list */
508
+ index: number;
509
+ /** Function to update break time */
510
+ onUpdate: (index: number, field: 'startTime' | 'endTime', value: string) => void;
511
+ /** Function to remove this break */
512
+ onRemove: (index: number) => void;
513
+ }
514
+ /**
515
+ * Props for the ShiftPanel component
516
+ */
517
+ interface ShiftPanelProps {
518
+ /** Title of the shift panel (e.g., "Day Shift", "Night Shift") */
519
+ title: string;
520
+ /** Icon to display next to the title */
521
+ icon: React.ReactNode;
522
+ /** Shift start time in HH:MM format */
523
+ startTime: string;
524
+ /** Shift end time in HH:MM format */
525
+ endTime: string;
526
+ /** Array of breaks during this shift */
527
+ breaks: Break[];
528
+ /** Function to handle start time changes */
529
+ onStartTimeChange: (value: string) => void;
530
+ /** Function to handle end time changes */
531
+ onEndTimeChange: (value: string) => void;
532
+ /** Function to update break times */
533
+ onBreakUpdate: (index: number, field: 'startTime' | 'endTime', value: string) => void;
534
+ /** Function to remove a break */
535
+ onBreakRemove: (index: number) => void;
536
+ /** Function to add a new break */
537
+ onBreakAdd: () => void;
538
+ /** Total shift hours after subtracting breaks */
539
+ shiftHours: number;
540
+ }
541
+ /**
542
+ * Props for the ShiftsView component
543
+ */
544
+ interface ShiftsViewProps {
545
+ /** Line configurations to display, or default to LINE_1_UUID if not provided */
546
+ lineIds?: string[];
547
+ /** Map of line IDs to line names, or use defaults if not provided */
548
+ lineNames?: Record<string, string>;
549
+ /** Company UUID for identifying the company */
550
+ companyUuid?: string;
551
+ /** Function called when back button is clicked */
552
+ onBackClick?: () => void;
553
+ /** Function to override default toast behavior (useful for testing or custom notifications) */
554
+ onToast?: (type: 'success' | 'error', message: string) => void;
555
+ /** Optional className for custom styling */
556
+ className?: string;
557
+ }
558
+
559
+ /**
560
+ * Represents a line with nested factory and company info.
561
+ */
562
+ interface SimpleLine {
563
+ id: string;
564
+ line_name: string;
565
+ factory_id: string;
566
+ factory_name: string;
567
+ company_id: string;
568
+ company_name: string;
569
+ }
570
+ interface WorkspaceMonthlyMetric {
571
+ date: string;
572
+ shift_id: number;
573
+ shift_type: string;
574
+ avg_efficiency: number;
575
+ total_output: number;
576
+ avg_cycle_time: number;
577
+ ideal_output: number;
578
+ avg_pph: number;
579
+ pph_threshold: number;
580
+ workspace_rank: number;
581
+ }
582
+ interface LineMonthlyMetric {
583
+ date: string;
584
+ shift_id: number;
585
+ avg_efficiency: number;
586
+ underperforming_workspaces: number;
587
+ total_workspaces: number;
588
+ }
589
+ interface UnderperformingWorkspace {
590
+ workspace_name: string;
591
+ workspace_uuid: string;
592
+ last_5_days: {
593
+ date: string;
594
+ performance_score: number;
595
+ }[];
596
+ }
597
+ interface UnderperformingWorkspaces {
598
+ dayShift: UnderperformingWorkspace[];
599
+ nightShift: UnderperformingWorkspace[];
600
+ }
601
+
602
+ interface QualityMetric {
603
+ workspace_id: string;
604
+ workspace_name: string;
605
+ compliance_efficiency: number;
606
+ sop_check: Record<string, number>;
607
+ total_output: number;
608
+ shift_id: number;
609
+ }
610
+ interface WorkspaceQualityData {
611
+ workspace_id: string;
612
+ workspace_name: string;
613
+ compliance_efficiency: number | null;
614
+ sop_check: Record<string, number> | null;
615
+ total_output: number | null;
616
+ line_id?: string;
617
+ }
618
+ interface QualityOverview {
619
+ overallCompliance: number;
620
+ underperformingWorkspaces: number;
621
+ totalWorkspaces: number;
622
+ topIssues: Array<{
623
+ check: string;
624
+ count: number;
625
+ percentage: number;
626
+ }>;
627
+ hourlyCompliance: number[];
628
+ }
629
+
630
+ interface Action {
631
+ id: string;
632
+ action_name: string;
633
+ company_id: string;
634
+ }
635
+
636
+ interface Workspace {
637
+ id: string;
638
+ line_id: string;
639
+ workspace_id: string;
640
+ action_id: string;
641
+ action_type?: 'assembly' | 'packaging';
642
+ action_pph_threshold: number | null;
643
+ action_cycle_time: number | null;
644
+ action_total_day_output: number | null;
645
+ }
646
+ interface ActionThreshold {
647
+ line_id: string;
648
+ shift_id: number;
649
+ action_id: string;
650
+ workspace_id: string;
651
+ date: string;
652
+ pph_threshold: number;
653
+ ideal_cycle_time: number;
654
+ total_day_output: number;
655
+ action_name: string | null;
656
+ updated_by: string;
657
+ created_at?: string;
658
+ last_updated?: string;
659
+ }
660
+ interface WorkspaceActionUpdate {
661
+ id: string;
662
+ action_id: string;
663
+ }
664
+ interface LineThreshold {
665
+ factory_id: string;
666
+ line_id: string;
667
+ date: string;
668
+ shift_id: number;
669
+ product_code: string;
670
+ threshold_day_output: number;
671
+ threshold_pph: number;
672
+ }
673
+ interface ShiftConfiguration {
674
+ id?: string;
675
+ lineId: string;
676
+ dayShift: {
677
+ startTime: string;
678
+ endTime: string;
679
+ breaks: {
680
+ startTime: string;
681
+ endTime: string;
682
+ duration: number;
683
+ }[];
684
+ };
685
+ nightShift: {
686
+ startTime: string;
687
+ endTime: string;
688
+ breaks: {
689
+ startTime: string;
690
+ endTime: string;
691
+ duration: number;
692
+ }[];
693
+ };
694
+ date: string;
695
+ updatedBy: string;
696
+ }
697
+ interface ShiftConfigurationRecord {
698
+ id: string;
699
+ line_id: string;
700
+ day_shift: object;
701
+ night_shift: object;
702
+ date: string;
703
+ updated_by: string;
704
+ created_at: string;
705
+ last_updated: string;
706
+ }
707
+
708
+ /**
709
+ * @deprecated Use DateDisplay from @optifye/dashboard-core instead
710
+ */
711
+ declare function formatISTDate(date?: Date, options?: Intl.DateTimeFormatOptions): string;
712
+ /**
713
+ * @deprecated Use DateDisplay from @optifye/dashboard-core instead
714
+ */
715
+ interface ISTDateProps {
716
+ }
717
+
718
+ /**
719
+ * @deprecated Use ISTTimer component from @optifye/dashboard-core/components/common directly
720
+ */
721
+ interface ISTTimerProps {
722
+ }
723
+
724
+ /**
725
+ * Props for the LeaderboardIndexView component
726
+ */
727
+ interface LeaderboardIndexViewProps {
728
+ /**
729
+ * Factory View identifier - used to add the factory view option to the lines list
730
+ */
731
+ factoryViewId?: string;
732
+ /**
733
+ * Company UUID to use when displaying factory view
734
+ */
735
+ companyUuid?: string;
736
+ /**
737
+ * Function to handle navigation to a specific line
738
+ */
739
+ onLineSelect?: (lineId: string) => void;
740
+ /**
741
+ * Optional className for custom styling
742
+ */
743
+ className?: string;
744
+ }
745
+ /**
746
+ * Props for the LeaderboardDetailView component
747
+ */
748
+ interface LeaderboardDetailViewProps {
749
+ /**
750
+ * Selected line ID to display the leaderboard for
751
+ */
752
+ lineId: string;
753
+ /**
754
+ * Optional date parameter to display metrics for a specific date
755
+ */
756
+ date?: string;
757
+ /**
758
+ * Optional shift parameter to display metrics for a specific shift
759
+ */
760
+ shift?: number;
761
+ /**
762
+ * Function to handle navigation back to the leaderboard index
763
+ */
764
+ onBackClick?: () => void;
765
+ /**
766
+ * Function to handle clicking on a workspace in the leaderboard
767
+ */
768
+ onWorkspaceClick?: (workspace: WorkspaceMetrics, rank: number) => void;
769
+ /**
770
+ * First line ID reference (Line 1)
771
+ */
772
+ line1Id?: string;
773
+ /**
774
+ * Second line ID reference (Line 2)
775
+ */
776
+ line2Id?: string;
777
+ /**
778
+ * Optional className for custom styling
779
+ */
780
+ className?: string;
781
+ }
782
+ /**
783
+ * Line option type for the leaderboard index
784
+ */
785
+ interface LeaderboardLineOption extends SimpleLine {
786
+ /**
787
+ * Unique identifier for the line
788
+ */
789
+ id: string;
790
+ }
791
+
792
+ /**
793
+ * Represents hourly performance metrics for a line
794
+ */
795
+ interface HourlyPerformance {
796
+ /** Hour of the day (0-23) */
797
+ hour: number;
798
+ /** Efficiency percentage for that hour */
799
+ efficiency: number;
800
+ }
801
+ /**
802
+ * Detailed snapshot of a production line
803
+ */
804
+ interface LineSnapshot {
805
+ /** Basic line details */
806
+ details: {
807
+ /** UUID of the line */
808
+ id: string;
809
+ /** Display name of the line */
810
+ line_name: string;
811
+ /** UUID of the parent factory */
812
+ factory_id: string;
813
+ /** Display name of the parent factory */
814
+ factory_name: string;
815
+ } | null;
816
+ /** Current output count for the line */
817
+ current_output: number;
818
+ /** Ideal/target output for the line */
819
+ ideal_output: number;
820
+ /** Average efficiency percentage */
821
+ avg_efficiency: number;
822
+ /** Total number of workspaces in the line */
823
+ total_workspaces: number;
824
+ /** Number of underperforming workspaces */
825
+ underperforming_workspaces: number;
826
+ /** Hourly performance data for recent hours */
827
+ last5Hours: HourlyPerformance[];
828
+ /** Product ID associated with this line */
829
+ productId: string;
830
+ }
831
+ /**
832
+ * Processed data for display in the factory view UI
833
+ */
834
+ interface LineDisplayData {
835
+ /** Display name of the line */
836
+ name: string;
837
+ /** Line metrics data */
838
+ metrics: LineInfo | null;
839
+ /** Loading state for this line */
840
+ isLoading: boolean;
841
+ /** Error state for this line */
842
+ error: MetricsError | null;
843
+ /** Last 5 hours of data for the line */
844
+ last5Hours: {
845
+ /** Hour of the day (0-23) */
846
+ hour: number;
847
+ /** Output count for that hour */
848
+ output: number;
849
+ /** Parts per hour metric */
850
+ pph: number;
851
+ /** Efficiency percentage */
852
+ efficiency: number;
853
+ /** Target/threshold for the hour */
854
+ target: number;
855
+ }[];
856
+ }
857
+ /**
858
+ * Configuration properties for the FactoryView component
859
+ */
860
+ interface FactoryViewProps {
861
+ /** UUID for line 1 */
862
+ line1Id: string;
863
+ /** UUID for line 2 */
864
+ line2Id: string;
865
+ /** Name of the factory to display in the header */
866
+ factoryName?: string;
867
+ /** Timezone to use for calculations - defaults to 'Asia/Kolkata' */
868
+ timezone?: string;
869
+ /** Shift configuration - defaults to 6am/6pm shifts */
870
+ shiftConfig?: ShiftConfig;
871
+ /** Optional product IDs to display for each line, keyed by line ID */
872
+ productIds?: Record<string, string>;
873
+ }
874
+
875
+ declare const DEFAULT_DATABASE_CONFIG: DatabaseConfig;
876
+ declare const DEFAULT_ENTITY_CONFIG: EntityConfig;
877
+ declare const DEFAULT_SHIFT_CONFIG: ShiftConfig;
878
+ declare const DEFAULT_WORKSPACE_CONFIG: WorkspaceConfig;
879
+ declare const DEFAULT_DATE_TIME_CONFIG: DateTimeConfig;
880
+ declare const DEFAULT_ENDPOINTS_CONFIG: EndpointsConfig;
881
+ declare const DEFAULT_THEME_CONFIG: ThemeConfig;
882
+ declare const DEFAULT_ANALYTICS_CONFIG: AnalyticsConfig;
883
+ declare const DEFAULT_AUTH_CONFIG: AuthConfig;
884
+ declare const LINE_1_UUID = "910a224b-0abc-459a-babb-4c899824cfe7";
885
+ declare const DEFAULT_CONFIG: Omit<DashboardConfig, 'supabaseUrl' | 'supabaseKey'>;
886
+
887
+ /**
888
+ * Standard action names used across the dashboard.
889
+ * These represent common operations or activities tracked in the system.
890
+ */
891
+ declare const ACTION_NAMES: {
892
+ /** Assembly operations */
893
+ readonly ASSEMBLY: "Assembly";
894
+ /** Packaging operations */
895
+ readonly PACKAGING: "Packaging";
896
+ /** Inspection operations */
897
+ readonly INSPECTION: "Inspection";
898
+ /** Testing operations */
899
+ readonly TESTING: "Testing";
900
+ /** Quality control operations */
901
+ readonly QUALITY_CONTROL: "Quality Control";
902
+ };
903
+ type ActionName = typeof ACTION_NAMES[keyof typeof ACTION_NAMES];
904
+
905
+ interface DashboardProviderProps {
906
+ config: Partial<DashboardConfig>;
907
+ children: React$1.ReactNode;
908
+ }
909
+ declare const DashboardProvider: React$1.FC<DashboardProviderProps>;
910
+ declare const useDashboardConfig: () => DashboardConfig;
911
+ declare const useTheme: () => ThemeConfig | undefined;
912
+ declare function useThemeConfig(): ThemeConfig;
913
+ declare function useAnalyticsConfig(): AnalyticsConfig;
914
+ declare function useDateTimeConfig(): DateTimeConfig;
915
+ declare function useAuthConfig(): AuthConfig;
916
+ declare function useDatabaseConfig(): DatabaseConfig;
917
+ declare function useEntityConfig(): EntityConfig;
918
+ declare function useShiftConfig(): ShiftConfig;
919
+ declare function useWorkspaceConfig(): WorkspaceConfig;
920
+ declare function useEndpointsConfig(): EndpointsConfig;
921
+ declare function useFeatureFlags(): Record<string, boolean>;
922
+ declare function useCustomConfig(): Record<string, unknown>;
923
+
924
+ interface AuthContextType {
925
+ session: Session | null;
926
+ user: AuthUser | null;
927
+ loading: boolean;
928
+ error: Error | null;
929
+ signOut: () => Promise<void>;
930
+ }
931
+ declare const useAuth: () => AuthContextType;
932
+ declare const AuthProvider: React__default.FC<{
933
+ children: React__default.ReactNode;
934
+ }>;
935
+
936
+ type ComponentOverride = React__default.ComponentType<any>;
937
+ type HookOverride = Function;
938
+ type PageOverride = React__default.ComponentType<any>;
939
+ interface OverridesMap {
940
+ components?: Record<string, ComponentOverride>;
941
+ hooks?: Record<string, HookOverride>;
942
+ pages?: Record<string, PageOverride>;
943
+ }
944
+ interface OverridesProviderProps {
945
+ overrides?: OverridesMap;
946
+ children: React__default.ReactNode;
947
+ }
948
+ declare const DashboardOverridesProvider: React__default.FC<OverridesProviderProps>;
949
+ /**
950
+ * Hook to get a component override by key, falling back to the default component if not overridden
951
+ * @param key Component key to look up in the overrides map
952
+ * @param Default Default component to use if no override is found
953
+ * @returns The overridden component or the default component
954
+ */
955
+ declare function useComponentOverride<TProps>(key: string, Default: React__default.ComponentType<TProps>): React__default.ComponentType<TProps>;
956
+ /**
957
+ * Hook to get a hook override by key, falling back to the default hook if not overridden
958
+ * @param key Hook key to look up in the overrides map
959
+ * @param Default Default hook to use if no override is found
960
+ * @returns The overridden hook or the default hook
961
+ */
962
+ declare function useHookOverride<T extends Function>(key: string, Default: T): T;
963
+ /**
964
+ * Hook to get a page override by key, falling back to the default page if not overridden
965
+ * @param key Page key to look up in the overrides map
966
+ * @param Default Default page to use if no override is found
967
+ * @returns The overridden page or the default page
968
+ */
969
+ declare function usePageOverride<TProps>(key: string, Default: React__default.ComponentType<TProps>): React__default.ComponentType<TProps>;
970
+ /**
971
+ * Hook to get all available overrides
972
+ * @returns The complete overrides map
973
+ */
974
+ declare function useOverrides(): OverridesMap;
975
+
976
+ declare const SupabaseProvider: React__default.FC<{
977
+ client: SupabaseClient$1;
978
+ children: ReactNode;
979
+ }>;
980
+ /**
981
+ * Hook to access the Supabase client within React components and other hooks.
982
+ * Must be used within a <SupabaseProvider>.
983
+ */
984
+ declare const useSupabase: () => SupabaseClient$1;
985
+
986
+ /**
987
+ * @hook useWorkspaceMetrics
988
+ * @summary Fetches and subscribes to overview metrics for a specific workspace.
989
+ *
990
+ * @description This hook retrieves aggregated performance metrics for a given workspace
991
+ * and establishes real-time subscriptions to update data when changes occur in the database.
992
+ * It fetches from both the company-specific metrics table and the overview workspace metrics view.
993
+ *
994
+ * @param {string} workspaceId - The unique identifier of the workspace to fetch metrics for.
995
+ *
996
+ * @returns {object} An object containing:
997
+ * @returns {OverviewWorkspaceMetric | null} workspaceMetrics - The overview metrics for the workspace, or null if not loaded/found.
998
+ * @returns {boolean} isLoading - True if metrics are currently being fetched, false otherwise.
999
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1000
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the metrics.
1001
+ */
1002
+ declare const useWorkspaceMetrics: (workspaceId: string) => {
1003
+ workspaceMetrics: OverviewWorkspaceMetric | null;
1004
+ isLoading: boolean;
1005
+ error: MetricsError | null;
1006
+ refetch: () => Promise<void>;
1007
+ };
1008
+ /**
1009
+ * @hook useLineMetrics
1010
+ * @summary Fetches and subscribes to overview metrics for a specific production line.
1011
+ *
1012
+ * @description This hook retrieves aggregated performance metrics for a given production line
1013
+ * and establishes real-time subscriptions to update data when changes occur in the database.
1014
+ * It fetches from both the base line metrics table and the overview line metrics view.
1015
+ *
1016
+ * @param {string} lineId - The unique identifier of the production line to fetch metrics for.
1017
+ *
1018
+ * @returns {object} An object containing:
1019
+ * @returns {OverviewLineMetric | null} lineMetrics - The overview metrics for the line, or null if not loaded/found.
1020
+ * @returns {boolean} isLoading - True if metrics are currently being fetched, false otherwise.
1021
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1022
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the metrics.
1023
+ */
1024
+ declare const useLineMetrics: (lineId: string) => {
1025
+ lineMetrics: OverviewLineMetric | null;
1026
+ isLoading: boolean;
1027
+ error: MetricsError | null;
1028
+ refetch: () => Promise<void>;
1029
+ };
1030
+ interface Metric {
1031
+ id: string;
1032
+ created_at: string;
1033
+ [key: string]: any;
1034
+ }
1035
+ /**
1036
+ * @hook useMetrics
1037
+ * @summary Generic hook for fetching and optionally subscribing to any metrics table.
1038
+ *
1039
+ * @template T - The type of metric data being fetched, must extend the base Metric interface.
1040
+ * @param {string} tableName - The name of the table to query. Use 'metrics' as a special case to fetch from the company-specific metrics table.
1041
+ * @param {object} [options] - Optional configuration for the query.
1042
+ * @param {Record<string, any>} [options.filter] - Optional filter criteria, each key-value pair will create an equals filter (e.g., {workspace_id: 'ws-123'}).
1043
+ * @param {boolean} [options.realtime] - Whether to set up real-time subscriptions to changes in the table.
1044
+ *
1045
+ * @returns {object} An object containing:
1046
+ * @returns {T[]} data - Array of fetched metrics data.
1047
+ * @returns {boolean} isLoading - True if data is currently being fetched, false otherwise.
1048
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1049
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the data.
1050
+ */
1051
+ declare const useMetrics: <T extends Metric>(tableName: string, options?: {
1052
+ filter?: Record<string, any>;
1053
+ realtime?: boolean;
1054
+ }) => {
1055
+ data: T[];
1056
+ isLoading: boolean;
1057
+ error: MetricsError | null;
1058
+ refetch: () => Promise<void>;
1059
+ };
1060
+
1061
+ /**
1062
+ * @hook useWorkspaceDetailedMetrics
1063
+ * @summary Fetches and subscribes to detailed real-time metrics for a specific workspace.
1064
+ *
1065
+ * @description This hook retrieves comprehensive performance data for a given workspace,
1066
+ * including current and historical metrics, action counts, and efficiency. It supports
1067
+ * fetching data for the current operational date/shift or for a specified override date/shift.
1068
+ * The hook also establishes real-time subscriptions to relevant database tables to update
1069
+ * metrics automatically when changes occur. Fallback logic is included to fetch the most
1070
+ * recent available data if no metrics are found for the exact current/specified period.
1071
+ *
1072
+ * @param {string} workspaceId - The unique identifier of the workspace to fetch metrics for.
1073
+ * @param {string} [date] - Optional. An ISO date string (YYYY-MM-DD) to fetch metrics for a specific date,
1074
+ * overriding the current operational date.
1075
+ * @param {number} [shiftId] - Optional. The ID of the shift to fetch metrics for, overriding the current shift.
1076
+ * Requires `dateOverride` to also be provided if used.
1077
+ *
1078
+ * @returns {object} An object containing:
1079
+ * @returns {WorkspaceDetailedMetrics | null} metrics - The detailed metrics for the workspace, or null if not loaded/found.
1080
+ * @returns {boolean} isLoading - True if metrics are currently being fetched, false otherwise.
1081
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1082
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the metrics.
1083
+ *
1084
+ * @example
1085
+ * const { metrics, isLoading, error } = useWorkspaceDetailedMetrics('ws-123');
1086
+ * if (isLoading) return <p>Loading detailed metrics...</p>;
1087
+ * if (error) return <p>Error: {error.message}</p>;
1088
+ * if (metrics) {
1089
+ * // Render workspace details using metrics object
1090
+ * }
1091
+ */
1092
+ declare const useWorkspaceDetailedMetrics: (workspaceId: string, date?: string, shiftId?: number) => {
1093
+ metrics: WorkspaceDetailedMetrics | null;
1094
+ isLoading: boolean;
1095
+ error: MetricsError | null;
1096
+ refetch: () => Promise<void>;
1097
+ };
1098
+
1099
+ /**
1100
+ * Options for initializing the useLineWorkspaceMetrics hook.
1101
+ */
1102
+ interface UseLineWorkspaceMetricsOptions {
1103
+ /** Specific date (YYYY-MM-DD) to fetch metrics for, overriding the current operational date. */
1104
+ initialDate?: string;
1105
+ /** Specific shift ID to fetch metrics for, overriding the current shift. */
1106
+ initialShiftId?: number;
1107
+ }
1108
+ /**
1109
+ * @hook useLineWorkspaceMetrics
1110
+ * @summary Fetches and subscribes to workspace metrics for a specific production line, date, and shift.
1111
+ *
1112
+ * @description This hook retrieves performance metrics for all workspaces associated with a given line.
1113
+ * It can be initialized with a specific date and shift, or it defaults to the current operational date and shift.
1114
+ * The hook establishes real-time subscriptions to update metrics when relevant changes occur in the database.
1115
+ * It also handles re-fetching data when the `lineId`, `initialDate`, or `initialShiftId` props change.
1116
+ *
1117
+ * @param {string} lineId - The unique identifier of the production line.
1118
+ * @param {UseLineWorkspaceMetricsOptions} [options] - Optional parameters to specify an initial date and shift.
1119
+ *
1120
+ * @returns {object} An object containing:
1121
+ * @returns {WorkspaceMetrics[]} workspaces - Array of workspace metrics data for the specified line.
1122
+ * @returns {boolean} loading - True if data is currently being fetched, false otherwise.
1123
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1124
+ * @returns {() => Promise<void>} refreshWorkspaces - A function to manually trigger a refetch of the workspace metrics.
1125
+ *
1126
+ * @example
1127
+ * // Fetch metrics for the current operational date/shift
1128
+ * const { workspaces, loading, error } = useLineWorkspaceMetrics('line-abc');
1129
+ *
1130
+ * // Fetch metrics for a specific past date and shift
1131
+ * const { workspaces: pastWorkspaces } = useLineWorkspaceMetrics('line-abc', {
1132
+ * initialDate: '2023-10-15',
1133
+ * initialShiftId: 1,
1134
+ * });
1135
+ */
1136
+ declare const useLineWorkspaceMetrics: (lineId: string, options?: UseLineWorkspaceMetricsOptions) => {
1137
+ workspaces: WorkspaceMetrics[];
1138
+ loading: boolean;
1139
+ error: MetricsError | null;
1140
+ refreshWorkspaces: () => Promise<void>;
1141
+ };
1142
+
1143
+ /**
1144
+ * @hook useHistoricWorkspaceMetrics
1145
+ * @summary Fetches historic detailed metrics for a specific workspace, date, and shift.
1146
+ *
1147
+ * @description This hook retrieves detailed performance data for a given workspace from a
1148
+ * specific past date and shift. It's designed for looking up historical records rather than
1149
+ * real-time data. The `hourly_action_counts` are animated on the initial successful fetch.
1150
+ * This hook relies on the `DashboardService` for data retrieval.
1151
+ *
1152
+ * @param {string} workspaceId - The unique identifier of the workspace.
1153
+ * @param {string} date - The specific date (YYYY-MM-DD) for which to fetch metrics. This is required.
1154
+ * @param {number} inputShiftId - The specific shift ID for which to fetch metrics. This is required.
1155
+ *
1156
+ * @returns {object} An object containing:
1157
+ * @returns {WorkspaceDetailedMetrics | null} metrics - The historic detailed metrics for the workspace, or null if not loaded/found or if parameters are missing.
1158
+ * @returns {boolean} isLoading - True if metrics are currently being fetched, false otherwise.
1159
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1160
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the historic metrics (note: animation currently does not re-run on manual refetch).
1161
+ *
1162
+ * @example
1163
+ * const { metrics, isLoading, error } = useHistoricWorkspaceMetrics('ws-001', '2023-10-15', 1);
1164
+ * if (isLoading) return <p>Loading historic data...</p>;
1165
+ * if (error) return <p>Error: {error.message}</p>;
1166
+ */
1167
+ declare const useHistoricWorkspaceMetrics: (workspaceId: string, date?: string, inputShiftId?: number) => {
1168
+ metrics: WorkspaceDetailedMetrics | null;
1169
+ isLoading: boolean;
1170
+ error: MetricsError | null;
1171
+ refetch: () => Promise<void>;
1172
+ };
1173
+
1174
+ /**
1175
+ * @hook useLineDetailedMetrics
1176
+ * @summary Fetches and subscribes to detailed metrics and information for a specific production line or the entire factory.
1177
+ *
1178
+ * @description This hook retrieves comprehensive data for a line, including its operational metrics and descriptive details.
1179
+ * It utilizes the `DashboardService` to fetch this information. If the special `lineIdFromProp` 'factory'
1180
+ * (or the configured `entityConfig.factoryViewId`) is provided, it fetches and aggregates data for the lines
1181
+ * configured as `entityConfig.defaultLineId` and `entityConfig.secondaryLineId` to provide a factory-level overview.
1182
+ * The hook also establishes real-time subscriptions to the line metrics table to update data automatically.
1183
+ *
1184
+ * @param {string} lineIdFromProp - The unique identifier of the production line. Use 'factory' (or the configured `factoryViewId`)
1185
+ * to get an aggregated factory view if `defaultLineId` and `secondaryLineId` are set in `entityConfig`.
1186
+ *
1187
+ * @returns {object} An object containing:
1188
+ * @returns {LineInfo | null} lineData - The detailed metrics and information for the line or factory view, or null if not loaded/found.
1189
+ * @returns {boolean} loading - True if data is currently being fetched, false otherwise.
1190
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1191
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the data.
1192
+ *
1193
+ * @example
1194
+ * // Fetch data for a specific line
1195
+ * const { lineData, loading, error } = useLineDetailedMetrics('line-123');
1196
+ *
1197
+ * // Fetch data for the factory view
1198
+ * const { lineData: factoryData, loading: factoryLoading } = useLineDetailedMetrics('factory');
1199
+ *
1200
+ * if (loading) return <p>Loading line details...</p>;
1201
+ * if (error) return <p>Error: {error.message}</p>;
1202
+ * if (lineData) {
1203
+ * // Render line details and metrics using lineData object
1204
+ * }
1205
+ */
1206
+ declare const useLineDetailedMetrics: (lineIdFromProp: string) => {
1207
+ lineData: LineInfo | null;
1208
+ loading: boolean;
1209
+ error: MetricsError | null;
1210
+ refetch: () => Promise<void>;
1211
+ };
1212
+
1213
+ /**
1214
+ * Represents a single entry in the workspace performance leaderboard
1215
+ */
1216
+ interface LeaderboardEntry {
1217
+ workspace_name: string;
1218
+ total_output: number;
1219
+ avg_pph: number;
1220
+ efficiency: number;
1221
+ workspace_id: string;
1222
+ rank: number;
1223
+ [key: string]: any;
1224
+ }
1225
+ /**
1226
+ * @hook useLeaderboardMetrics
1227
+ * @summary Fetches and subscribes to top-performing workspaces for a specific production line.
1228
+ *
1229
+ * @description This hook retrieves a ranked list of workspaces based on efficiency for a given
1230
+ * production line. It establishes real-time subscriptions to update the leaderboard when changes
1231
+ * occur in the database. The data is automatically refreshed at regular intervals (1 minute).
1232
+ *
1233
+ * @param {string} lineId - The unique identifier of the production line to fetch metrics for.
1234
+ * @param {number} [topCount=10] - The number of top performers to retrieve.
1235
+ *
1236
+ * @returns {object} An object containing:
1237
+ * @returns {LeaderboardEntry[]} topPerformers - Array of ranked workspace entries, sorted by efficiency.
1238
+ * @returns {boolean} isLoading - True if metrics are currently being fetched, false otherwise.
1239
+ * @returns {MetricsError | null} error - An error object if fetching failed, null otherwise.
1240
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch of the leaderboard.
1241
+ *
1242
+ * @example
1243
+ * const { topPerformers, isLoading, error } = useLeaderboardMetrics('line-123', 5);
1244
+ * if (isLoading) return <p>Loading leaderboard...</p>;
1245
+ * if (error) return <p>Error: {error.message}</p>;
1246
+ * return (
1247
+ * <div>
1248
+ * <h2>Top Performers</h2>
1249
+ * <ul>
1250
+ * {topPerformers.map(entry => (
1251
+ * <li key={entry.workspace_id}>
1252
+ * {entry.rank}. {entry.workspace_name} - Efficiency: {entry.efficiency}%
1253
+ * </li>
1254
+ * ))}
1255
+ * </ul>
1256
+ * </div>
1257
+ * );
1258
+ */
1259
+ declare const useLeaderboardMetrics: (lineId: string, topCount?: number) => {
1260
+ topPerformers: LeaderboardEntry[];
1261
+ isLoading: boolean;
1262
+ error: MetricsError | null;
1263
+ refetch: () => Promise<void>;
1264
+ };
1265
+
1266
+ /**
1267
+ * Props for the {@link useDashboardMetrics} hook.
1268
+ */
1269
+ interface UseDashboardMetricsProps {
1270
+ /**
1271
+ * The ID of the current line or special view (e.g., "factory") being observed.
1272
+ * This determines which line(s) to fetch metrics for.
1273
+ */
1274
+ lineId: string;
1275
+ /**
1276
+ * Optional callback invoked when underlying line metrics data might have changed,
1277
+ * suggesting that related components (like a Line KPI display) might need to refresh.
1278
+ */
1279
+ onLineMetricsUpdate?: () => void;
1280
+ }
1281
+ /**
1282
+ * Custom hook to fetch and subscribe to real-time dashboard metrics.
1283
+ *
1284
+ * This hook aggregates workspace-level performance data and overall line metrics.
1285
+ * It is designed to support views for individual lines or a consolidated "factory" view.
1286
+ * Data is fetched based on the operational date and current shift, derived from dashboard configuration.
1287
+ * The hook also implements a basic localStorage caching mechanism to provide an immediate initial state.
1288
+ * Real-time updates are subscribed to via Supabase for relevant tables.
1289
+ *
1290
+ * Configuration for Supabase, table names, entity IDs (for factory view), and date/time settings
1291
+ * are sourced from `DashboardConfigContext`.
1292
+ *
1293
+ * @param props - The properties for the hook, see {@link UseDashboardMetricsProps}.
1294
+ * @returns An object containing:
1295
+ * - `workspaceMetrics`: An array of `WorkspaceMetrics` for the targeted line(s).
1296
+ * - `lineMetrics`: An array of `OverviewLineMetric` for the targeted line(s).
1297
+ * - `isLoading`: Boolean indicating if the initial data fetch (or fetch after cache expiry) is in progress.
1298
+ * - `error`: A `MetricsError` object if an error occurred, otherwise `null`.
1299
+ * - `refetch`: A function to manually trigger a data refetch.
1300
+ *
1301
+ * @example
1302
+ * ```tsx
1303
+ * const MyDashboardView = ({ currentLineId }) => {
1304
+ * const { workspaceMetrics, lineMetrics, isLoading, error, refetch } = useDashboardMetrics({ lineId: currentLineId });
1305
+ *
1306
+ * if (isLoading) return <p>Loading dashboard data...</p>;
1307
+ * if (error) return <p>Error: {error.message}</p>;
1308
+ *
1309
+ * return (
1310
+ * <div>
1311
+ * <h2>Workspace Performance</h2>
1312
+ * {workspaceMetrics.map(ws => <div key={ws.workspace_uuid}>{ws.workspace_name}: {ws.efficiency}%</div>)}
1313
+ * <h2>Line Overview</h2>
1314
+ * {lineMetrics.map(line => <div key={line.line_id}>{line.line_id} Efficiency: {line.efficiency}%</div>)}
1315
+ * <button onClick={refetch}>Refresh Data</button>
1316
+ * </div>
1317
+ * );
1318
+ * }
1319
+ * ```
1320
+ */
1321
+ declare const useDashboardMetrics: ({ onLineMetricsUpdate, lineId }: UseDashboardMetricsProps) => {
1322
+ workspaceMetrics: WorkspaceMetrics[];
1323
+ lineMetrics: OverviewLineMetric[];
1324
+ isLoading: boolean;
1325
+ error: MetricsError | null;
1326
+ refetch: () => Promise<void>;
1327
+ };
1328
+
1329
+ /**
1330
+ * Props for the useLineKPIs hook.
1331
+ */
1332
+ type LineKPIsProps = {
1333
+ /**
1334
+ * The unique identifier of the production line.
1335
+ * Use 'factory' (or the configured `entityConfig.factoryViewId`) for an aggregated factory view.
1336
+ */
1337
+ lineId: string;
1338
+ };
1339
+ /**
1340
+ * @hook useLineKPIs
1341
+ * @summary Fetches and subscribes to Key Performance Indicators (KPIs) for a specific production line or factory view.
1342
+ *
1343
+ * @description This hook retrieves and calculates KPIs such as efficiency, output progress, and underperforming workers.
1344
+ * It leverages the `DashboardService` to first fetch detailed line information (via `getDetailedLineInfo`)
1345
+ * and then to calculate the KPIs (via `calculateKPIs`). For a 'factory' view (identified by `lineId` matching
1346
+ * `entityConfig.factoryViewId` or the string 'factory'), the service is expected to aggregate data from configured
1347
+ * primary (`entityConfig.defaultLineId`) and secondary (`entityConfig.secondaryLineId`) lines.
1348
+ * The hook implements localStorage caching for KPIs to provide a faster initial load and reduce redundant fetches.
1349
+ * Real-time subscriptions are established to relevant tables (`line_metrics` and the company-specific performance table)
1350
+ * to automatically update KPIs when underlying data changes.
1351
+ *
1352
+ * @param {LineKPIsProps} props - The properties for the hook.
1353
+ *
1354
+ * @returns {object} An object containing:
1355
+ * @returns {DashboardKPIs | null} kpis - The calculated KPIs for the line/factory, or null if not available.
1356
+ * @returns {boolean} isLoading - True if KPIs are currently being fetched (and not available from cache), false otherwise.
1357
+ * @returns {MetricsError | null} error - An error object if fetching or calculation failed, null otherwise.
1358
+ * @returns {() => Promise<void>} refetch - A function to manually trigger a refetch and recalculation of KPIs.
1359
+ *
1360
+ * @example
1361
+ * const { kpis, isLoading, error } = useLineKPIs({ lineId: 'line-xyz' });
1362
+ * if (isLoading && !kpis) return <p>Loading KPIs...</p>; // Show loading only if no cached KPIs
1363
+ * if (error) return <p>Error: {error.message}</p>;
1364
+ * if (kpis) {
1365
+ * // Render KPIs using kpis object
1366
+ * // e.g., <p>Efficiency: {kpis.efficiency.value}%</p>
1367
+ * }
1368
+ */
1369
+ declare const useLineKPIs: ({ lineId }: LineKPIsProps) => {
1370
+ kpis: DashboardKPIs | null;
1371
+ isLoading: boolean;
1372
+ error: MetricsError | null;
1373
+ refetch: () => Promise<void>;
1374
+ };
1375
+
1376
+ /**
1377
+ * Props for the {@link useRealtimeLineMetrics} hook.
1378
+ */
1379
+ interface UseRealtimeLineMetricsProps {
1380
+ /**
1381
+ * The ID of the line to fetch metrics for.
1382
+ * Can be a specific line UUID or a special identifier (e.g., "factory")
1383
+ * which will be resolved using `entityConfig.factoryViewId`.
1384
+ */
1385
+ lineId: string;
1386
+ /**
1387
+ * Optional date override in 'YYYY-MM-DD' format.
1388
+ * If not provided, the current operational date is used.
1389
+ */
1390
+ dateOverride?: string;
1391
+ /**
1392
+ * Optional shift ID override.
1393
+ * If not provided, the current operational shift is used.
1394
+ */
1395
+ shiftIdOverride?: number;
1396
+ /**
1397
+ * Optional callback function that is invoked when metrics are updated.
1398
+ * @param lineInfo - The updated line information or null if an error occurs or no data.
1399
+ */
1400
+ onMetricsUpdate?: (lineInfo: LineInfo | null) => void;
1401
+ }
1402
+ interface LineMetrics {
1403
+ line_id: string;
1404
+ shift_id: number;
1405
+ date: string;
1406
+ factory_id: string;
1407
+ avg_efficiency: number;
1408
+ avg_cycle_time: number;
1409
+ current_output: number;
1410
+ ideal_output: number;
1411
+ total_workspaces: number;
1412
+ underperforming_workspaces: number;
1413
+ underperforming_workspace_names: string[];
1414
+ underperforming_workspace_uuids: string[];
1415
+ output_array: number[];
1416
+ line_threshold: number;
1417
+ threshold_pph: number;
1418
+ shift_start: string;
1419
+ shift_end: string;
1420
+ last_updated: string;
1421
+ poorest_performing_workspaces?: PoorPerformingWorkspace[];
1422
+ }
1423
+ interface LineDetails {
1424
+ id: string;
1425
+ line_name: string;
1426
+ factory_id: string;
1427
+ factory: {
1428
+ id: string;
1429
+ factory_name: string;
1430
+ };
1431
+ }
1432
+ type RealtimeLineMetricsProps = {
1433
+ lineId: string;
1434
+ date?: string;
1435
+ shiftId?: number;
1436
+ onMetricsUpdate?: () => void;
1437
+ };
1438
+ /**
1439
+ * Custom hook to fetch and subscribe to real-time line metrics for a specified line or factory view.
1440
+ *
1441
+ * @param {object} props - Hook properties.
1442
+ * @param {string} props.lineId - The line ID to fetch metrics for.
1443
+ * @param {string} [props.date] - Optional date override in 'YYYY-MM-DD' format.
1444
+ * @param {number} [props.shiftId] - Optional shift ID override.
1445
+ * @param {Function} [props.onMetricsUpdate] - Optional callback when metrics are updated.
1446
+ *
1447
+ * @returns {object} An object containing:
1448
+ * - `metrics`: The current line metrics.
1449
+ * - `lineDetails`: Details about the line.
1450
+ * - `loading`: A boolean indicating if data is being fetched.
1451
+ * - `error`: Error object if an error occurred.
1452
+ * - `refreshMetrics`: Function to manually refresh metrics.
1453
+ */
1454
+ declare const useRealtimeLineMetrics: ({ lineId, date: urlDate, shiftId: urlShiftId, onMetricsUpdate }: RealtimeLineMetricsProps) => {
1455
+ metrics: LineMetrics | null;
1456
+ lineDetails: LineDetails | null;
1457
+ loading: boolean;
1458
+ error: MetricsError | null;
1459
+ refreshMetrics: () => Promise<void>;
1460
+ };
1461
+
1462
+ /**
1463
+ * @interface Target
1464
+ * @description Represents a generic target or goal.
1465
+ * This is a placeholder structure and should be refined based on actual data models.
1466
+ * @property {string} id - Unique identifier for the target.
1467
+ * @property {string} name - Name or description of the target.
1468
+ * @property {number} value - The target value.
1469
+ * @property {string} unit - Unit of the target value (e.g., 'pieces', '%', 'minutes').
1470
+ * @property {string} [entityId] - Optional ID of the entity this target applies to (e.g., workspace ID, line ID).
1471
+ * @property {'workspace' | 'line' | 'company' | string} [entityType] - Optional type of the entity.
1472
+ * @property {string} period - Time period for the target (e.g., 'daily', 'shift', 'hourly', specific date YYYY-MM-DD).
1473
+ * @property {string} [date] - Optional specific date for the target (YYYY-MM-DD).
1474
+ * @property {number | string} [shiftId] - Optional specific shift ID for the target.
1475
+ * @property {string} [createdAt] - Timestamp of creation (typically ISO string from DB).
1476
+ * @property {string} [updatedAt] - Timestamp of last update (typically ISO string from DB).
1477
+ * @property {string} [company_id] - Company ID this target belongs to. Used for filtering.
1478
+ * @property {Record<string, any>} [additionalDetails] - For any other custom fields.
1479
+ */
1480
+ interface Target {
1481
+ id: string;
1482
+ name: string;
1483
+ value: number;
1484
+ unit: string;
1485
+ entityId?: string;
1486
+ entityType?: 'workspace' | 'line' | 'company' | string;
1487
+ period: string;
1488
+ date?: string;
1489
+ shiftId?: number | string;
1490
+ createdAt?: string;
1491
+ updatedAt?: string;
1492
+ company_id?: string;
1493
+ additionalDetails?: Record<string, any>;
1494
+ }
1495
+ /**
1496
+ * @typedef UseTargetsOptions
1497
+ * @description Options for fetching targets.
1498
+ * @property {string} [entityId] - Filter targets for a specific entity ID.
1499
+ * @property {string} [entityType] - Filter targets for a specific entity type (e.g., 'workspace', 'line').
1500
+ * @property {string} [date] - Filter targets for a specific date.
1501
+ * @property {string | number} [shiftId] - Filter targets for a specific shift.
1502
+ * @property {string} [period] - Filter targets for a specific period (e.g., 'daily').
1503
+ */
1504
+ interface UseTargetsOptions {
1505
+ entityId?: string;
1506
+ entityType?: string;
1507
+ date?: string;
1508
+ shiftId?: string | number;
1509
+ period?: string;
1510
+ }
1511
+ /**
1512
+ * @hook useTargets
1513
+ * @summary Fetches target data based on specified filters.
1514
+ * @description This hook retrieves a list of targets from a table, which defaults to "${DEFAULT_TARGETS_TABLE_NAME}".
1515
+ * To make the table name configurable, \`databaseConfig.tables.targets\` would need to be defined in the \`DashboardConfig\` type
1516
+ * and then accessed via \`useDatabaseConfig()\`.\n * It filters targets based on the current \`companyId\` from \`entityConfig\` and any provided options \n * such as \`entityId\`, \`entityType\`, \`date\`, \`shiftId\`, or \`period\`.\n * Assumes the target table has a \`company_id\` column for filtering by the current company context.\n * Currently, this hook does not implement real-time subscriptions.\n * \n * @param {UseTargetsOptions} [options] - Optional filtering criteria for fetching targets.\n * \n * @returns {{ targets: Target[]; isLoading: boolean; error: MetricsError | null; refetch: () => Promise<void> }}\n * An object containing the array of targets, loading state, error state, and a refetch function.\n *
1517
+ * @example\n * const { targets, isLoading, error } = useTargets({ entityType: 'line', entityId: 'line-123' });\n * if (isLoading) return <p>Loading targets...</p>;\n * if (error) return <p>Error: {error.message}</p>;\n * // Render targets list\n */
1518
+ declare const useTargets: (options?: UseTargetsOptions) => {
1519
+ targets: Target[];
1520
+ isLoading: boolean;
1521
+ error: MetricsError | null;
1522
+ refetch: () => Promise<void>;
1523
+ };
1524
+
1525
+ /**
1526
+ * @interface ShiftData
1527
+ * @description Represents the data structure for a single shift configuration.
1528
+ * @property {string | number} id - Unique identifier for the shift.
1529
+ * @property {string} name - Name of the shift (e.g., "Day Shift", "Night Shift A").
1530
+ * @property {string} startTime - Start time of the shift (e.g., "07:00").
1531
+ * @property {string} endTime - End time of the shift (e.g., "19:00").
1532
+ * @property {string} [company_id] - Company ID this shift configuration belongs to.
1533
+ * @property {number[]} [daysOfWeek] - Optional array of numbers representing days of the week (e.g., [1,2,3,4,5] for Mon-Fri, where 0=Sun, 1=Mon,...).
1534
+ * @property {boolean} [isActive] - Whether the shift configuration is currently active.
1535
+ * @property {string} [createdAt] - Timestamp of creation.
1536
+ * @property {string} [updatedAt] - Timestamp of last update.
1537
+ */
1538
+ interface ShiftData$2 {
1539
+ id: string | number;
1540
+ name: string;
1541
+ startTime: string;
1542
+ endTime: string;
1543
+ company_id?: string;
1544
+ daysOfWeek?: number[];
1545
+ isActive?: boolean;
1546
+ createdAt?: string;
1547
+ updatedAt?: string;
1548
+ }
1549
+ /**
1550
+ * @hook useShifts
1551
+ * @summary Fetches shift configuration data for the current company.
1552
+ * @description This hook retrieves a list of shift configurations (like shift names, start/end times)
1553
+ * from a table (defaulting to "${DEFAULT_SHIFTS_TABLE_NAME}").
1554
+ * The table name can be configured via \`databaseConfig.tables.shiftConfigurations\` in the \`DashboardConfig\`
1555
+ * It automatically filters the shifts based on the current \`companyId\` from \`entityConfig\`
1556
+ * Assumes the shift configurations table has a \`company_id\` column.
1557
+ * This initial version does not implement real-time subscriptions.
1558
+ *
1559
+ * @returns {{ shifts: ShiftData[]; isLoading: boolean; error: MetricsError | null; refetch: () => Promise<void> }}
1560
+ * An object containing the array of shift configurations, loading state, error state, and a refetch function.
1561
+ *
1562
+ * @example
1563
+ * const { shifts, isLoading, error } = useShifts();
1564
+ * if (isLoading) return <p>Loading shift data...</p>;
1565
+ * if (error) return <p>Error: {error.message}</p>;
1566
+ * // Render shifts information
1567
+ */
1568
+ declare const useShifts: () => {
1569
+ shifts: ShiftData$2[];
1570
+ isLoading: boolean;
1571
+ error: MetricsError | null;
1572
+ refetch: () => Promise<void>;
1573
+ };
1574
+
1575
+ /**
1576
+ * @interface OperatorData
1577
+ * @description Represents data for an operator assigned to or active in a workspace.
1578
+ * This is a placeholder and should be adjusted based on the actual data model.
1579
+ * @property {string} id - Unique identifier for the operator record or assignment.
1580
+ * @property {string} operatorId - Identifier for the operator/employee (e.g., employee ID).
1581
+ * @property {string} operatorName - Name of the operator.
1582
+ * @property {string} workspaceId - ID of the workspace the operator is associated with.
1583
+ * @property {string} [company_id] - Company ID this record belongs to.
1584
+ * @property {string} [date] - Specific date of activity/assignment (YYYY-MM-DD).
1585
+ * @property {string | number} [shiftId] - Specific shift ID of activity/assignment.
1586
+ * @property {string} [loginTime] - Timestamp when the operator logged in or started.
1587
+ * @property {string} [logoutTime] - Timestamp when the operator logged out or ended.
1588
+ * @property {string} [role] - Operator's role or position, if applicable.
1589
+ * @property {string} [createdAt] - Record creation timestamp.
1590
+ */
1591
+ interface OperatorData {
1592
+ id: string;
1593
+ operatorId: string;
1594
+ operatorName: string;
1595
+ workspaceId: string;
1596
+ company_id?: string;
1597
+ date?: string;
1598
+ shiftId?: string | number;
1599
+ loginTime?: string;
1600
+ logoutTime?: string;
1601
+ role?: string;
1602
+ createdAt?: string;
1603
+ }
1604
+ /**
1605
+ * @typedef UseWorkspaceOperatorsOptions
1606
+ * @description Options for fetching workspace operators.
1607
+ * @property {string} [date] - Filter operators for a specific date.
1608
+ * @property {string | number} [shiftId] - Filter operators for a specific shift.
1609
+ */
1610
+ interface UseWorkspaceOperatorsOptions {
1611
+ date?: string;
1612
+ shiftId?: string | number;
1613
+ }
1614
+ /**
1615
+ * @hook useWorkspaceOperators
1616
+ * @summary Fetches operator data for a specific workspace, optionally filtered by date and shift.
1617
+ * @description This hook retrieves a list of operators associated with a given workspace.
1618
+ * It fetches from a table, which defaults to "${DEFAULT_OPERATORS_TABLE_NAME}".
1619
+ * To make the table name configurable, \`databaseConfig.tables.workspaceOperators\` would need to be defined in \`DashboardConfig\`.
1620
+ * Filters are applied for \`companyId\` (from \`entityConfig\`), the provided \`workspaceId\`, and optional \`date\` and \`shiftId\`
1621
+ * Assumes the table has \`company_id\` and \`workspace_id\` columns for filtering.
1622
+ * This initial version does not implement real-time subscriptions.
1623
+ *
1624
+ * @param {string} workspaceId - The unique identifier of the workspace for which to fetch operators. Required.
1625
+ * @param {UseWorkspaceOperatorsOptions} [options] - Optional filtering criteria for date and shift.
1626
+ *
1627
+ * @returns {{ operators: OperatorData[]; isLoading: boolean; error: MetricsError | null; refetch: () => Promise<void> }}
1628
+ * An object containing the array of operators, loading state, error state, and a refetch function.
1629
+ *
1630
+ * @example
1631
+ * const { operators, isLoading } = useWorkspaceOperators('ws-123', { date: '2023-10-15' });
1632
+ */
1633
+ declare const useWorkspaceOperators: (workspaceId: string, options?: UseWorkspaceOperatorsOptions) => {
1634
+ operators: OperatorData[];
1635
+ isLoading: boolean;
1636
+ error: MetricsError | null;
1637
+ refetch: () => Promise<void>;
1638
+ };
1639
+
1640
+ /**
1641
+ * @interface FactoryOverviewData
1642
+ * @description Represents aggregated overview metrics for the entire factory.
1643
+ * This is a placeholder and should align with the actual data available or calculated.
1644
+ * @property {string} [company_id] - Identifier of the company.
1645
+ * @property {string} [factoryId] - Identifier of the factory.
1646
+ * @property {string} date - The operational date for which these metrics apply (YYYY-MM-DD).
1647
+ * @property {string | number} shiftId - The shift identifier for which these metrics apply.
1648
+ * @property {number} totalOutput - Total output from all lines/workspaces in the factory.
1649
+ * @property {number} overallEfficiency - Average efficiency across the factory.
1650
+ * @property {number} totalWorkspacesActive - Number of workspaces that were active or reporting data.
1651
+ * @property {number} totalLinesActive - Number of production lines that were active.
1652
+ * @property {number} [alertsCritical] - Number of critical alerts in the factory.
1653
+ * @property {string} [lastUpdated] - Timestamp of when this overview was last generated/updated.
1654
+ */
1655
+ interface FactoryOverviewData {
1656
+ company_id?: string;
1657
+ factoryId?: string;
1658
+ date: string;
1659
+ shiftId: string | number;
1660
+ totalOutput: number;
1661
+ overallEfficiency: number;
1662
+ totalWorkspacesActive: number;
1663
+ totalLinesActive: number;
1664
+ alertsCritical?: number;
1665
+ lastUpdated?: string;
1666
+ }
1667
+ /**
1668
+ * @typedef UseFactoryOverviewOptions
1669
+ * @description Options for fetching factory overview metrics.
1670
+ * @property {string} [date] - Specific date (YYYY-MM-DD) to fetch overview for. Defaults to current operational date.
1671
+ * @property {string | number} [shiftId] - Specific shift ID. Defaults to current operational shift.
1672
+ * @property {string} [factoryId] - Specific factory ID, if the system supports multiple factories under one company config and this data is available per factory.
1673
+ */
1674
+ interface UseFactoryOverviewOptions {
1675
+ date?: string;
1676
+ shiftId?: string | number;
1677
+ factoryId?: string;
1678
+ }
1679
+ /**
1680
+ * @hook useFactoryOverviewMetrics
1681
+ * @summary Fetches aggregated overview metrics for the factory.
1682
+ * @description This hook retrieves factory-level summary data (e.g., total output, overall efficiency)
1683
+ * for a given date and shift (defaulting to current operational date/shift).
1684
+ * It fetches from a table, which defaults to "factory_daily_summary".
1685
+ * To make the table name configurable, `databaseConfig.tables.factoryOverviewMetrics` would need to be defined in `DashboardConfig`.
1686
+ * Filters are applied for `companyId` (from `entityConfig`) and optionally `factoryId` if provided and supported.
1687
+ * This initial version does not implement real-time subscriptions and assumes a pre-aggregated data source (one row per company/factory/date/shift).
1688
+ * For more complex calculations from raw data, a dedicated DashboardService method would be more appropriate.
1689
+ *
1690
+ * @param {UseFactoryOverviewOptions} [options] - Optional parameters to specify date, shift, or factoryId.
1691
+ *
1692
+ * @returns {{ factoryOverview: FactoryOverviewData | null; isLoading: boolean; error: MetricsError | null; refetch: () => Promise<void> }}
1693
+ * An object containing the factory overview data, loading state, error state, and a refetch function.
1694
+ *
1695
+ * @example
1696
+ * const { factoryOverview, isLoading } = useFactoryOverviewMetrics();
1697
+ * if (isLoading) return <p>Loading factory overview...</p>;
1698
+ * if (factoryOverview) {
1699
+ * // Render overview
1700
+ * }
1701
+ */
1702
+ declare const useFactoryOverviewMetrics: (options?: UseFactoryOverviewOptions) => {
1703
+ factoryOverview: FactoryOverviewData | null;
1704
+ isLoading: boolean;
1705
+ error: MetricsError | null;
1706
+ refetch: () => Promise<void>;
1707
+ };
1708
+
1709
+ /**
1710
+ * Interface for navigation method used across packages
1711
+ * Abstracts navigation implementation details from components
1712
+ */
1713
+ type NavigationMethod = (url: string, options?: any) => void;
1714
+
1715
+ /**
1716
+ * @interface WorkspaceNavigationParams
1717
+ * @description Defines the parameters for navigating to a workspace view.
1718
+ * @property {string} workspaceId - The unique identifier of the workspace.
1719
+ * @property {string} [date] - Optional ISO date string (YYYY-MM-DD) to specify the context date.
1720
+ * @property {string | number} [shift] - Optional shift ID or identifier for the context.
1721
+ * @property {string} [sourceType] - Optional analytics marker for the source of navigation.
1722
+ */
1723
+ interface WorkspaceNavigationParams {
1724
+ workspaceId: string;
1725
+ date?: string;
1726
+ shift?: string | number;
1727
+ sourceType?: string;
1728
+ }
1729
+ /**
1730
+ * @interface LineNavigationParams
1731
+ * @description Defines the parameters for navigating to a line (KPI) view.
1732
+ * @property {string} lineId - The unique identifier of the line.
1733
+ * @property {string} [date] - Optional ISO date string (YYYY-MM-DD) to specify the context date.
1734
+ * @property {string | number} [shift] - Optional shift ID or identifier for the context.
1735
+ * @property {string} [tab] - Optional identifier for a specific tab to activate on the line view.
1736
+ */
1737
+ interface LineNavigationParams {
1738
+ lineId: string;
1739
+ date?: string;
1740
+ shift?: string | number;
1741
+ tab?: string;
1742
+ }
1743
+ /**
1744
+ * @typedef EntityConfigShape
1745
+ * @description Shape of the entityConfig object expected from useDashboardConfig.
1746
+ * @property {string} [companyId] - The ID of the company.
1747
+ * @property {string} [defaultLineId] - The default line ID for the application.
1748
+ * @property {string} [secondaryLineId] - A secondary line ID, often used in factory views.
1749
+ * @property {string} [factoryViewId] - Identifier for the factory view (e.g., 'factory').
1750
+ */
1751
+ /**
1752
+ * @typedef NavigationHookReturn
1753
+ * @description The return type of the `useNavigation` hook, providing router state and navigation actions.
1754
+ * @property {string} pathname - Current route's pathname (e.g., '/workspace/123'). Directly from Next.js router.
1755
+ * @property {NextRouter['query']} query - Current route's query parameters as an object. Directly from Next.js router.
1756
+ * @property {boolean} isReady - True if Next.js router is initialized. Directly from Next.js router.
1757
+ * @property {string | undefined} activeLineId - ID of the current line. Derived from `router.query.lineId` if on a line view (e.g., '/kpis/:lineId'), otherwise falls back to `entityConfig.defaultLineId` (see {@link EntityConfigShape}).
1758
+ * @property {string | null} activeWorkspaceId - ID of the current workspace. Derived from `router.query.id` if on a workspace view (e.g., '/workspace/:id'), otherwise null.
1759
+ * @property {(path: string) => boolean} isActive - Checks if the given path matches the current route exactly (trailing slashes are normalized).
1760
+ * @property {(path: string) => boolean} isInSection - Checks if the current route starts with the given path (useful for parent section highlighting).
1761
+ * @property {boolean} isLineView - True if current path starts with '/kpis/' and `router.query.lineId` is present.
1762
+ * @property {boolean} isWorkspaceView - True if current path starts with '/workspace/' and `router.query.id` is present.
1763
+ * @property {() => void} goToDashboard - Navigates to the root dashboard page ('/').
1764
+ * @property {(params: WorkspaceNavigationParams) => void} goToWorkspace - Navigates to a workspace page, e.g., '/workspace/[workspaceId]'.
1765
+ * @property {(params: LineNavigationParams) => void} goToLine - Navigates to a line (KPI) page, e.g., '/kpis/[lineId]'.
1766
+ * @property {() => void} goToTargets - Navigates to the '/targets' page.
1767
+ * @property {() => void} goToShifts - Navigates to the '/shifts' page.
1768
+ * @property {() => void} goToLeaderboard - Navigates to the '/leaderboard' page.
1769
+ * @property {() => void} goToFactoryView - Navigates to the '/factory-view' page.
1770
+ * @property {(path: string, options?: NavigationOptions) => Promise<void>} navigate - Navigates to an arbitrary path with retry logic and optional tracking.
1771
+ */
1772
+ /**
1773
+ * @hook useNavigation
1774
+ * @summary Provides abstracted navigation utilities and current route state for the dashboard application.
1775
+ * @description This hook serves as a wrapper around the Next.js `useRouter` hook, offering a simplified API for common navigation tasks
1776
+ * and for accessing dashboard-specific route information. It helps maintain consistency in navigation logic and route patterns.
1777
+ * Assumed route patterns include: `/` (dashboard), `/workspace/[id]`, `/kpis/[lineId]`, `/targets`, `/shifts`, `/leaderboard`, `/factory-view`.
1778
+ * The `activeLineId` property has a fallback to `entityConfig.defaultLineId` when not on a specific line page, which implies a global default line context (see {@link EntityConfigShape} for expected structure).
1779
+ *
1780
+ * @returns {NavigationHookReturn} An object containing various navigation actions and properties related to the current route.
1781
+ *
1782
+ * @example
1783
+ * const navigation = useNavigation();
1784
+ * if (navigation.isActive('/dashboard')) {
1785
+ * console.log('Currently on the dashboard.');
1786
+ * }
1787
+ * navigation.goToWorkspace({ workspaceId: 'ws-abc' });
1788
+ */
1789
+ declare function useNavigation(customNavigate?: NavigationMethod): {
1790
+ pathname: string;
1791
+ query: querystring.ParsedUrlQuery;
1792
+ isReady: boolean;
1793
+ activeLineId: string | undefined;
1794
+ activeWorkspaceId: string | null;
1795
+ isActive: (path: string) => boolean;
1796
+ isInSection: (path: string) => boolean;
1797
+ isLineView: boolean;
1798
+ isWorkspaceView: boolean;
1799
+ goToDashboard: () => void;
1800
+ goToWorkspace: ({ workspaceId, date, shift, sourceType }: WorkspaceNavigationParams) => void;
1801
+ goToLine: ({ lineId, date, shift, tab }: LineNavigationParams) => void;
1802
+ goToTargets: () => void;
1803
+ goToShifts: () => void;
1804
+ goToLeaderboard: () => void;
1805
+ goToFactoryView: () => void;
1806
+ navigate: NavigationMethod;
1807
+ };
1808
+
1809
+ /**
1810
+ * @typedef GetWorkspaceNavigationParamsOptions
1811
+ * @description Options for the `getWorkspaceNavigationParams` method within the `useWorkspaceNavigation` hook.
1812
+ * @property {string} [date] - Specific ISO date string (YYYY-MM-DD). If provided, this date is used.
1813
+ * @property {string | number} [shift] - Specific shift ID or identifier.
1814
+ * @property {string} [sourceType] - Analytics marker for the source of navigation.
1815
+ * @property {boolean} [useCurrentDate] - If true and `date` is not provided, the current operational date will be used.
1816
+ */
1817
+ /**
1818
+ * @typedef WorkspaceNavigationHookReturn
1819
+ * @description Return type of the `useWorkspaceNavigation` hook.
1820
+ * @property {(workspaceId: string, options?: GetWorkspaceNavigationParamsOptions) => WorkspaceNavigationParams} getWorkspaceNavigationParams - Function to generate navigation parameters for a workspace.
1821
+ */
1822
+ /**
1823
+ * @hook useWorkspaceNavigation
1824
+ * @summary Provides a utility method to generate `WorkspaceNavigationParams`, with an option to use the current operational date.
1825
+ * @description This hook simplifies the creation of navigation parameters for workspaces. Its primary method,
1826
+ * `getWorkspaceNavigationParams`, allows specifying a date or opting to use the current operational date automatically.
1827
+ * It relies on `useDateTimeConfig` for timezone information needed to determine the current operational date.
1828
+ * See also the standalone {@link getWorkspaceNavigationParams} function for a version without automatic current date injection.
1829
+ *
1830
+ * @returns {WorkspaceNavigationHookReturn} An object containing the `getWorkspaceNavigationParams` method.
1831
+ *
1832
+ * @example
1833
+ * const { getWorkspaceNavigationParams } = useWorkspaceNavigation();
1834
+ * const navParamsCurrent = getWorkspaceNavigationParams('ws-123', { useCurrentDate: true });
1835
+ * // Assuming useNavigation() is available as navigation
1836
+ * // navigation.goToWorkspace(navParamsCurrent);
1837
+ *
1838
+ * const navParamsSpecific = getWorkspaceNavigationParams('ws-456', { date: '2023-01-15' });
1839
+ * // navigation.goToWorkspace(navParamsSpecific);
1840
+ */
1841
+ declare function useWorkspaceNavigation(): {
1842
+ getWorkspaceNavigationParams: (workspaceId: string, options?: {
1843
+ date?: string;
1844
+ shift?: string | number;
1845
+ sourceType?: string;
1846
+ useCurrentDate?: boolean;
1847
+ }) => WorkspaceNavigationParams;
1848
+ };
1849
+
1850
+ /**
1851
+ * @typedef {object} DateTimeConfigShape
1852
+ * @description Shape of the dateTimeConfig object expected from useDateTimeConfig.
1853
+ * @property {string} [defaultTimezone] - Default IANA timezone (e.g., 'America/New_York').
1854
+ * @property {string} [defaultLocale] - Default locale (e.g., 'en-US').
1855
+ * @property {Intl.DateTimeFormatOptions} [dateFormatOptions] - Intl options for date formatting.
1856
+ * @property {Intl.DateTimeFormatOptions} [timeFormatOptions] - Intl options for time formatting.
1857
+ * @property {Intl.DateTimeFormatOptions} [dateTimeFormatOptions] - Intl options for date-time formatting.
1858
+ */
1859
+ /**
1860
+ * @typedef {object} DateFormatterHookReturn
1861
+ * @description The return type of the `useDateFormatter` hook.
1862
+ * @property {(date: Date | string, formatString?: string) => string} formatDate - Formats a date.
1863
+ * If `formatString` is provided, uses date-fns `formatInTimeZone`. Otherwise, uses `Intl.DateTimeFormat` with configured options (see {@link DateTimeConfigShape}).
1864
+ * @property {(date: Date | string, formatString?: string) => string} formatTime - Formats a time.
1865
+ * If `formatString` is provided, uses date-fns `formatInTimeZone`. Otherwise, uses `Intl.DateTimeFormat` with configured options (see {@link DateTimeConfigShape}).
1866
+ * @property {(date: Date | string, formatString?: string) => string} formatDateTime - Formats a date and time.
1867
+ * If `formatString` is provided, uses date-fns `formatInTimeZone`. Otherwise, uses `Intl.DateTimeFormat` with configured options (see {@link DateTimeConfigShape}).
1868
+ * @property {() => Date} getNow - Returns the current Date object (represents a UTC timestamp).
1869
+ * @property {string} timezone - The default IANA timezone identifier used by the formatters (e.g., 'America/New_York'), defaults to 'UTC'.
1870
+ * @property {string} locale - The default locale string used by `Intl.DateTimeFormat` (e.g., 'en-US'), defaults to 'en-US'.
1871
+ */
1872
+ /**
1873
+ * @hook useDateFormatter
1874
+ * @summary Provides configured date and time formatting utilities.
1875
+ * @description This hook offers functions to format dates, times, and date-times according to the dashboard's
1876
+ * configuration obtained via `useDateTimeConfig()` (see {@link DateTimeConfigShape}). It can also use custom date-fns format strings.
1877
+ * All formatting functions handle both `Date` objects and ISO string inputs, and include basic validation.
1878
+ * If specific `dateFormatOptions`, `timeFormatOptions`, or `dateTimeFormatOptions` are not provided in the configuration,
1879
+ * sensible defaults are used for `Intl.DateTimeFormat`.
1880
+ *
1881
+ * @returns {DateFormatterHookReturn} An object with formatting functions and current timezone/locale settings.
1882
+ *
1883
+ * @example
1884
+ * const { formatDate, formatTime, timezone } = useDateFormatter();
1885
+ * const myDate = new Date();
1886
+ * console.log(formatDate(myDate)); // Formats using Intl.DateTimeFormat options from config or defaults
1887
+ * console.log(formatTime(myDate, 'HH:mm:ss zzz')); // Formats using date-fns string in configured timezone
1888
+ * console.log(`Current timezone: ${timezone}`);
1889
+ */
1890
+ declare function useDateFormatter(): {
1891
+ formatDate: (date: Date | string, formatString?: string) => string;
1892
+ formatTime: (date: Date | string, formatString?: string) => string;
1893
+ formatDateTime: (date: Date | string, formatString?: string) => string;
1894
+ getNow: () => Date;
1895
+ timezone: string;
1896
+ locale: string;
1897
+ };
1898
+
1899
+ interface FormatNumberOptions extends Intl.NumberFormatOptions {
1900
+ }
1901
+ interface UseFormatNumberResult {
1902
+ formatNumber: (value: number, options?: FormatNumberOptions) => string;
1903
+ }
1904
+ /**
1905
+ * Hook for number formatting with internationalization support
1906
+ */
1907
+ declare const useFormatNumber: () => UseFormatNumberResult;
1908
+
1909
+ declare const actionService: {
1910
+ getActionsByName(actionNames: string[], companyIdInput?: string): Promise<Action[]>;
1911
+ };
1912
+ type ActionService = typeof actionService;
1913
+
1914
+ declare const dashboardService: {
1915
+ getLineInfo(lineIdInput: string): Promise<LineInfo>;
1916
+ getWorkspacesData(lineIdInput?: string, dateProp?: string, shiftProp?: number): Promise<WorkspaceMetrics[]>;
1917
+ getWorkspaceDetailedMetrics(workspaceUuid: string, dateProp?: string, shiftIdProp?: number): Promise<WorkspaceDetailedMetrics | null>;
1918
+ calculateKPIs(lineInfo: LineInfo): DashboardKPIs;
1919
+ getAllLines(): Promise<SimpleLine[]>;
1920
+ getDetailedLineInfo(lineIdInput?: string, dateProp?: string, shiftProp?: number): Promise<LineInfo | null>;
1921
+ getWorkspaceMonthlyData(workspaceUuid: string, month: number, year: number): Promise<WorkspaceMonthlyMetric[]>;
1922
+ getLineMonthlyData(lineIdInput: string, month: number, year: number): Promise<LineMonthlyMetric[]>;
1923
+ getUnderperformingWorkspaces(lineIdInput: string, monthInput: number | undefined, yearInput: number | undefined): Promise<UnderperformingWorkspaces>;
1924
+ getSopViolations(): never[];
1925
+ };
1926
+ type DashboardService = typeof dashboardService;
1927
+
1928
+ declare function isValidLineInfoPayload(payload: any): payload is LineInfo;
1929
+ declare function isValidWorkspaceMetricsPayload(payload: any): payload is WorkspaceMetrics;
1930
+ declare function isValidWorkspaceDetailedMetricsPayload(payload: any): payload is WorkspaceDetailedMetrics;
1931
+ declare const realtimeService: {
1932
+ subscribeToLineInfo(lineId: string, shiftId: number, date: string, onDataUpdate: (data: LineInfo) => void): (() => void);
1933
+ subscribeToOverviewMetrics(lineId: string, shiftId: number, date: string, onDataUpdate: (data: WorkspaceMetrics[]) => void): (() => void);
1934
+ subscribeToWorkspaceDetailedMetrics(workspaceId: string, date: string, shiftId: number, onDataUpdate: (data: WorkspaceDetailedMetrics) => void): (() => void);
1935
+ };
1936
+ type RealtimeService = typeof realtimeService;
1937
+
1938
+ interface WhatsAppSendResult {
1939
+ success: boolean;
1940
+ messageId?: string;
1941
+ recipient?: string;
1942
+ error?: string;
1943
+ }
1944
+ /**
1945
+ * Factory function to create the WhatsApp service.
1946
+ * It configures the service based on the provided dashboard configuration.
1947
+ */
1948
+ declare const whatsappService: {
1949
+ sendWhatsAppTemplate(lineInfo: LineInfo, _recipientNumber?: string, formattedTime?: string): Promise<WhatsAppSendResult>;
1950
+ };
1951
+ type WhatsappService = typeof whatsappService;
1952
+
1953
+ declare const qualityService: {
1954
+ getWorkspaceQualityMetrics(workspaceId: string, date: string, shiftId: number): Promise<QualityMetric | null>;
1955
+ getLineQualityOverview(lineId: string, date: string, shiftId: number): Promise<QualityOverview | null>;
1956
+ };
1957
+ type QualityService = typeof qualityService;
1958
+
1959
+ declare const workspaceService: {
1960
+ getWorkspaces(lineId: string): Promise<Workspace[]>;
1961
+ updateWorkspaceAction(updates: WorkspaceActionUpdate[]): Promise<void>;
1962
+ updateActionThresholds(thresholds: ActionThreshold[]): Promise<void>;
1963
+ getActionThresholds(lineId: string, date: string, shiftId?: number): Promise<ActionThreshold[]>;
1964
+ updateLineThresholds(lineId: string, productId: string, workspaces: Workspace[], shiftId: number): Promise<void>;
1965
+ getShiftConfigurations(lineId: string): Promise<ShiftConfiguration[]>;
1966
+ updateShiftConfigurations(shiftConfig: ShiftConfiguration): Promise<void>;
1967
+ };
1968
+
1969
+ declare const authCoreService: {
1970
+ signInWithPassword(supabase: SupabaseClient$1, email: string, password: string): Promise<{
1971
+ user: User;
1972
+ session: Session;
1973
+ error: null;
1974
+ } | {
1975
+ user: null;
1976
+ session: null;
1977
+ error: AuthError;
1978
+ }>;
1979
+ signOut(supabase: SupabaseClient$1): Promise<{
1980
+ error: AuthError | null;
1981
+ }>;
1982
+ resetPasswordForEmail(supabase: SupabaseClient$1, email: string, redirectTo?: string): Promise<{
1983
+ error: AuthError | null;
1984
+ }>;
1985
+ updateUserPassword(supabase: SupabaseClient$1, newPassword: string): Promise<{
1986
+ user: User | null;
1987
+ error: AuthError | null;
1988
+ }>;
1989
+ getMappedAuthErrorMessage: (error: AuthError) => string;
1990
+ fetchCoreUserProfile(supabase: SupabaseClient$1, user: User, profileTable: string, roleColumn?: string): Promise<Partial<AuthUser>>;
1991
+ };
1992
+
1993
+ /**
1994
+ * Initializes Mixpanel with the provided token.
1995
+ * Should be called once from the application setup (e.g., within DashboardProvider)
1996
+ * when the token is available from configuration.
1997
+ * @param token - The Mixpanel project token.
1998
+ * @param debug - Optional. Enable Mixpanel debug mode.
1999
+ * @param trackPageView - Optional. Enable automatic page view tracking by Mixpanel.
2000
+ */
2001
+ declare const initializeCoreMixpanel: (token: string, debug?: boolean, trackPageView?: boolean) => void;
2002
+ declare const trackCorePageView: (pageName: string, properties?: Record<string, any>) => void;
2003
+ declare const trackCoreEvent: (eventName: string, properties?: Record<string, any>) => void;
2004
+ declare const identifyCoreUser: (userId: string, userProperties?: Record<string, any>) => void;
2005
+ declare const resetCoreMixpanel: () => void;
2006
+
2007
+ interface BottleneckVideo {
2008
+ id: string;
2009
+ src: string;
2010
+ timestamp: string;
2011
+ severity: 'low' | 'medium' | 'high';
2012
+ description: string;
2013
+ type: 'bottleneck' | 'low_value';
2014
+ originalUri: string;
2015
+ }
2016
+ interface S3ServiceConfig {
2017
+ region?: string;
2018
+ bucketName: string;
2019
+ signedUrlExpiresIn?: number;
2020
+ accessKeyId?: string;
2021
+ secretAccessKey?: string;
2022
+ sessionToken?: string;
2023
+ endpoint?: string;
2024
+ useAccelerateEndpoint?: boolean;
2025
+ customUserAgent?: string;
2026
+ useSimulatedMode?: boolean;
2027
+ publicBaseUrl?: string;
2028
+ }
2029
+ declare class S3Service {
2030
+ private s3Client;
2031
+ private bucketName;
2032
+ private signedUrlExpiresIn;
2033
+ private useSimulatedMode;
2034
+ private publicBaseUrl;
2035
+ constructor(config: S3ServiceConfig);
2036
+ /**
2037
+ * Check if service is in simulated mode
2038
+ */
2039
+ isSimulated(): boolean;
2040
+ /**
2041
+ * List S3 clips for a specific workspace and date
2042
+ */
2043
+ listS3Clips(workspaceId: string, date?: string): Promise<string[]>;
2044
+ /**
2045
+ * Generate mock S3 URIs for simulated mode
2046
+ */
2047
+ private generateMockS3Uris;
2048
+ /**
2049
+ * Generate a signed URL for an S3 URI
2050
+ */
2051
+ generateSignedS3Url(s3Uri: string): Promise<string | null>;
2052
+ /**
2053
+ * Parse simulated URI for demo mode
2054
+ */
2055
+ private parseSimulatedUri;
2056
+ /**
2057
+ * Parse S3 URI to extract information about the video
2058
+ */
2059
+ parseS3Uri(s3Uri: string): Omit<BottleneckVideo, 'id' | 'src'> | null;
2060
+ /**
2061
+ * Get all clips for a workspace on a specific date
2062
+ */
2063
+ getWorkspaceClips(workspaceId: string, date?: string): Promise<BottleneckVideo[]>;
2064
+ }
2065
+
2066
+ /**
2067
+ * Helper object for making authenticated API requests using Supabase auth token.
2068
+ * Assumes endpoints are relative to the apiBaseUrl configured in DashboardConfig.
2069
+ */
2070
+ declare const apiUtils: {
2071
+ /**
2072
+ * Generic fetch function to make authenticated API requests.
2073
+ *
2074
+ * @param supabase - The Supabase client instance.
2075
+ * @param config - The DashboardConfig containing apiBaseUrl.
2076
+ * @param relativeEndpoint - The API endpoint relative to apiBaseUrl (e.g., '/users/profile').
2077
+ * @param options - Standard Fetch API options.
2078
+ * @returns The parsed JSON response.
2079
+ * @throws Error if no auth token is available or if the API response is not ok.
2080
+ */
2081
+ fetch(supabase: SupabaseClient, config: Pick<DashboardConfig, "apiBaseUrl">, relativeEndpoint: string, options?: RequestInit): Promise<any>;
2082
+ /**
2083
+ * Makes a GET request.
2084
+ */
2085
+ get(supabase: SupabaseClient, config: Pick<DashboardConfig, "apiBaseUrl">, relativeEndpoint: string): Promise<any>;
2086
+ /**
2087
+ * Makes a POST request.
2088
+ */
2089
+ post(supabase: SupabaseClient, config: Pick<DashboardConfig, "apiBaseUrl">, relativeEndpoint: string, data: unknown): Promise<any>;
2090
+ /**
2091
+ * Makes a PUT request.
2092
+ */
2093
+ put(supabase: SupabaseClient, config: Pick<DashboardConfig, "apiBaseUrl">, relativeEndpoint: string, data: unknown): Promise<any>;
2094
+ /**
2095
+ * Makes a DELETE request.
2096
+ */
2097
+ delete(supabase: SupabaseClient, config: Pick<DashboardConfig, "apiBaseUrl">, relativeEndpoint: string): Promise<any>;
2098
+ };
2099
+
2100
+ /**
2101
+ * Merges the provided user configuration with the default configuration.
2102
+ * Ensures required fields (supabaseUrl, supabaseKey) are present.
2103
+ *
2104
+ * @param userConfig - The partial configuration provided by the user.
2105
+ * @returns The fully merged and validated DashboardConfig object.
2106
+ * @throws Error if required configuration fields are missing.
2107
+ */
2108
+ declare const mergeWithDefaultConfig: (userConfig: Partial<DashboardConfig>) => DashboardConfig;
2109
+
2110
+ /**
2111
+ * Calculates the operational date based on a specific time cutoff (e.g., 6 AM).
2112
+ * If the time is before the cutoff, it's considered the previous operational day.
2113
+ *
2114
+ * @param timezone - IANA timezone string (e.g., 'Asia/Kolkata') from config.
2115
+ * @param date - The date object to check (defaults to now).
2116
+ * @param shiftStartTime - The start time of the day shift (e.g., "06:00") from config, used to determine the day boundary.
2117
+ * @returns The operational date formatted as "yyyy-MM-dd".
2118
+ */
2119
+ declare const getOperationalDate: (timezone?: string, date?: Date, shiftStartTime?: string) => string;
2120
+ /**
2121
+ * @function formatTimeInZone
2122
+ * @summary Formats a time string in a specified timezone using date-fns.
2123
+ * @description Standalone utility function (not a hook) to format a date/time string or Date object
2124
+ * into a specified string format, for a given IANA timezone. Useful for server-side or non-React contexts.
2125
+ *
2126
+ * @param {Date | string} time - The date/time to format (Date object or ISO string).
2127
+ * @param {string} timezone - The IANA timezone identifier (e.g., 'America/New_York', 'Europe/London'). This parameter is required.
2128
+ * @param {string} [formatString='HH:mm:ss'] - Optional date-fns compatible format string. Defaults to 'HH:mm:ss'.
2129
+ * @returns {string} The formatted time string, or 'Invalid Date' if input is not a valid date.
2130
+ *
2131
+ * @example
2132
+ * formatTimeInZone(new Date(), 'America/Los_Angeles', 'hh:mm a z'); // e.g., "09:30 AM PDT"
2133
+ * formatTimeInZone('2023-01-01T12:00:00Z', 'Europe/Paris'); // e.g., "13:00:00"
2134
+ */
2135
+ declare function formatTimeInZone(time: Date | string, timezone: string, formatString?: string): string;
2136
+ /**
2137
+ * @function getCurrentTimeInZone
2138
+ * @summary Gets the current time, optionally formatted in a specified timezone.
2139
+ * @description Standalone utility function (not a hook). Returns the current `Date` object if no `formatString` is provided.
2140
+ * If `formatString` is given, returns the current time formatted as a string in the specified IANA timezone.
2141
+ *
2142
+ * @param {string} timezone - The IANA timezone identifier (e.g., 'America/New_York', 'Europe/London'). This parameter is required.
2143
+ * @param {string} [formatString] - Optional date-fns compatible format string.
2144
+ * @returns {string | Date} The formatted current time string if `formatString` is provided, otherwise the current `Date` object, or 'Invalid Date' if formatting an invalid date (should not occur with `new Date()`).
2145
+ *
2146
+ * @example
2147
+ * const dateObj = getCurrentTimeInZone('Europe/Berlin') as Date; // Get Date object
2148
+ * const timeStr = getCurrentTimeInZone('Europe/Berlin', 'HH:mm zzz'); // e.g., "18:30 CEST"
2149
+ */
2150
+ declare function getCurrentTimeInZone(timezone: string, formatString?: string): string | Date;
2151
+
2152
+ /**
2153
+ * Determines the current or most recent shift based on the current time and shift configuration.
2154
+ *
2155
+ * @param timezone - IANA timezone string (e.g., 'Asia/Kolkata') from config.
2156
+ * @param shiftConfig - The ShiftConfig object from the dashboard configuration.
2157
+ * @param now - The current date/time (optional, defaults to new Date()).
2158
+ * @returns An object containing the current shiftId (0 for day, 1 for night typically) and the operational date (YYYY-MM-DD).
2159
+ */
2160
+ declare const getCurrentShift: (timezone: string, shiftConfig?: ShiftConfig, now?: Date) => CurrentShiftResult;
2161
+ /**
2162
+ * Checks if the current time falls within a transition period around shift changes.
2163
+ *
2164
+ * @param timezone - IANA timezone string (e.g., 'Asia/Kolkata') from config.
2165
+ * @param shiftConfig - The ShiftConfig object from the dashboard configuration.
2166
+ * @param now - The current date/time (optional, defaults to new Date()).
2167
+ * @returns True if the current time is within the transition window, false otherwise.
2168
+ */
2169
+ declare const isTransitionPeriod: (timezone: string, shiftConfig?: ShiftConfig, now?: Date) => boolean;
2170
+
2171
+ /**
2172
+ * Utility functions for timezone-aware time calculations
2173
+ */
2174
+ /**
2175
+ * Format date and time in a specific timezone using Intl.DateTimeFormat
2176
+ * @param date - The date object to format
2177
+ * @param timezone - IANA timezone string
2178
+ * @param options - Intl.DateTimeFormat options (will merge with defaults from config later)
2179
+ * @param locale - Locale string (e.g., 'en-IN') (will use default from config later)
2180
+ * @returns Formatted date/time string
2181
+ */
2182
+ declare const formatDateTimeInZone: (date: Date, timezone: string, options?: Intl.DateTimeFormatOptions, locale?: string) => string;
2183
+ /**
2184
+ * Format date in a specific timezone
2185
+ * @param date - The date object to format (defaults to now)
2186
+ * @param timezone - IANA timezone string
2187
+ * @param options - Specific Intl.DateTimeFormat date options (will merge with defaults from config later)
2188
+ * @param locale - Locale string (will use default from config later)
2189
+ * @returns Formatted date string (e.g., '15 Jul 2024')
2190
+ */
2191
+ declare const formatDateInZone: (date: Date | undefined, timezone: string, options?: Omit<Intl.DateTimeFormatOptions, "timeZone" | "hour" | "minute" | "second">, locale?: string) => string;
2192
+ /**
2193
+ * Get days difference between a date and today in a specific timezone
2194
+ * @param compareDate - The date to compare against today (string or Date object)
2195
+ * @param timezone - IANA timezone string
2196
+ * @returns String description like 'Today', 'Yesterday', or 'X days ago'
2197
+ */
2198
+ declare const getDaysDifferenceInZone: (compareDate: string | Date, timezone: string) => string;
2199
+ /**
2200
+ * Get formatted time suitable for a dashboard header in a specific timezone
2201
+ * @param date - The date object to format (defaults to now)
2202
+ * @param timezone - IANA timezone string
2203
+ * @param timeOptions - Specific Intl.DateTimeFormat time options (will merge with defaults from config later)
2204
+ * @param locale - Locale string (will use default from config later)
2205
+ * @returns Formatted time string
2206
+ */
2207
+ declare const getDashboardHeaderTimeInZone: (date: Date | undefined, timezone: string, timeOptions?: Intl.DateTimeFormatOptions, // Allow overriding format
2208
+ locale?: string) => string;
2209
+
2210
+ /**
2211
+ * Gets the user-friendly display name for a workspace ID based on the configuration.
2212
+ *
2213
+ * @param workspaceId - The workspace ID (e.g., 'WS01').
2214
+ * @param workspaceConfig - The WorkspaceConfig object from the dashboard configuration.
2215
+ * @returns The display name from the config, or a fallback based on the ID.
2216
+ */
2217
+ declare const getConfigurableWorkspaceDisplayName: (workspaceId: string, workspaceConfig?: WorkspaceConfig) => string;
2218
+ /**
2219
+ * Gets a potentially shortened or specific part of the workspace display name.
2220
+ * (The logic here might need adjustment based on actual naming conventions used).
2221
+ *
2222
+ * @param workspaceId - The workspace ID (e.g., 'WS01').
2223
+ * @param workspaceConfig - The WorkspaceConfig object from the dashboard configuration.
2224
+ * @returns A potentially shortened name, or the full display name, or a fallback.
2225
+ */
2226
+ declare const getConfigurableShortWorkspaceDisplayName: (workspaceId: string, workspaceConfig?: WorkspaceConfig) => string;
2227
+
2228
+ /**
2229
+ * @internal
2230
+ * Generates a table name for company-specific metrics (e.g., workspace performance data).
2231
+ * This allows for data isolation per company if needed, by using company ID in the table name.
2232
+ *
2233
+ * @param companyId - The UUID of the company. If undefined, a generic fallback name is used.
2234
+ * @param prefix - The base prefix for the table name (e.g., 'workspace_performance', 'line_summary').
2235
+ * @returns The generated table name, typically in the format `prefix_company_id_with_underscores`.
2236
+ */
2237
+ declare const getCompanyMetricsTableName: (companyId: string | undefined, prefix?: string) => string;
2238
+ /**
2239
+ * Helper function to get the metrics table prefix based on company UUID.
2240
+ * This provides backward compatibility with legacy database schemas while
2241
+ * consolidating around a new standard structure.
2242
+ *
2243
+ * @param companyId - The UUID of the company
2244
+ * @returns The appropriate table prefix to use for metrics queries
2245
+ */
2246
+ declare const getMetricsTablePrefix: (companyId?: string) => string;
2247
+
2248
+ declare function cn(...inputs: ClassValue[]): string;
2249
+
2250
+ interface WorkspaceUrlMapping {
2251
+ urlName: string;
2252
+ workspaceId: string;
2253
+ workspaceName: string;
2254
+ }
2255
+ declare const toUrlFriendlyName: (workspaceName: string | undefined) => string;
2256
+ declare const fromUrlFriendlyName: (urlName: string) => string;
2257
+ declare const storeWorkspaceMapping: (mapping: WorkspaceUrlMapping) => void;
2258
+ declare const getWorkspaceFromUrl: (urlName: string) => WorkspaceUrlMapping | null;
2259
+ declare const getStoredWorkspaceMappings: () => Record<string, WorkspaceUrlMapping>;
2260
+
2261
+ declare const workspaceDisplayNames: Record<string, string>;
2262
+ declare const getWorkspaceDisplayName: (workspaceId: string) => string;
2263
+ declare const getShortWorkspaceDisplayName: (workspaceId: string) => string;
2264
+
2265
+ /**
2266
+ * Centralized workspace preferences manager
2267
+ * Contains functions to determine tab visibility and default tabs for workspaces
2268
+ */
2269
+ /**
2270
+ * Determines the default tab for a workspace
2271
+ * Returns 'overview' by default
2272
+ */
2273
+ declare const getDefaultTabForWorkspace: (workspaceId?: string, displayName?: string) => "overview" | "monthly_history";
2274
+ /**
2275
+ * Creates URL query parameters for workspace navigation that preserve tab preferences
2276
+ */
2277
+ declare const getWorkspaceNavigationParams: (workspaceId: string, displayName: string) => string;
2278
+
2279
+ /**
2280
+ * VideoPreloader – lightweight, URL-only video pre-loading helper.
2281
+ *
2282
+ * It keeps a Set-based cache of already processed URLs, runs a FIFO queue with a
2283
+ * maximum concurrency of two, and supports both regular file sources (e.g.
2284
+ * .mp4) as well as HLS playlists (.m3u8). For the latter it dynamically imports
2285
+ * `hls.js`, buffers a single fragment, and tears everything down afterwards.
2286
+ *
2287
+ * No S3 / presigned-URL logic should live here – keep this file focused on pure
2288
+ * URL pre-loading.
2289
+ */
2290
+ declare class VideoPreloader {
2291
+ /** URLs that have finished (or at least attempted) pre-loading. */
2292
+ private readonly cache;
2293
+ /** FIFO queue of pending URLs. */
2294
+ private queue;
2295
+ /** Currently running pre-load operations. */
2296
+ private active;
2297
+ preloadVideo: (url: string | null | undefined) => void;
2298
+ preloadVideos: (urls: (string | null | undefined)[]) => void;
2299
+ clear: () => void;
2300
+ private processQueue;
2301
+ private preloadUrlInternal;
2302
+ private bufferNative;
2303
+ private handleHls;
2304
+ private bufferHls;
2305
+ }
2306
+ declare const videoPreloader: VideoPreloader;
2307
+ declare const preloadVideoUrl: (url: string | null | undefined) => void;
2308
+ declare const preloadVideosUrl: (urls: (string | null | undefined)[]) => void;
2309
+
2310
+ declare const createSupabaseClient: (url: string, key: string) => _supabase_supabase_js.SupabaseClient<any, "public", any>;
2311
+ declare const getAnonClient: () => _supabase_supabase_js.SupabaseClient<any, "public", any>;
2312
+
2313
+ interface LoadingSpinnerProps {
2314
+ size?: 'sm' | 'md' | 'lg';
2315
+ message?: string;
2316
+ className?: string;
2317
+ }
2318
+ declare const LoadingSpinner: React__default.FC<LoadingSpinnerProps>;
2319
+
2320
+ declare function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>): react_jsx_runtime.JSX.Element;
2321
+
2322
+ declare const Select: React$1.FC<SelectPrimitive.SelectProps>;
2323
+ declare const SelectGroup: React$1.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React$1.RefAttributes<HTMLDivElement>>;
2324
+ declare const SelectValue: React$1.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React$1.RefAttributes<HTMLSpanElement>>;
2325
+ declare const SelectTrigger: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React$1.RefAttributes<HTMLButtonElement>, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
2326
+ declare const SelectScrollUpButton: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2327
+ declare const SelectScrollDownButton: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2328
+ declare const SelectContent: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2329
+ declare const SelectLabel: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2330
+ declare const SelectItem: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2331
+ declare const SelectSeparator: React$1.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
2332
+
2333
+ declare const Card: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
2334
+ declare const CardHeader: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
2335
+ declare const CardTitle: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLHeadingElement> & React$1.RefAttributes<HTMLParagraphElement>>;
2336
+ declare const CardDescription: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLParagraphElement> & React$1.RefAttributes<HTMLParagraphElement>>;
2337
+ declare const CardContent: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
2338
+ declare const CardFooter: React$1.ForwardRefExoticComponent<React$1.HTMLAttributes<HTMLDivElement> & React$1.RefAttributes<HTMLDivElement>>;
2339
+
2340
+ interface LoadingOverlayProps {
2341
+ isVisible: boolean;
2342
+ message?: string;
2343
+ className?: string;
2344
+ }
2345
+ declare const LoadingOverlay: React__default.FC<LoadingOverlayProps>;
2346
+
2347
+ interface LoadingPageProps {
2348
+ message?: string;
2349
+ subMessage?: string;
2350
+ className?: string;
2351
+ }
2352
+ declare const LoadingPage: React__default.FC<LoadingPageProps>;
2353
+
2354
+ interface TimeDisplayProps {
2355
+ className?: string;
2356
+ variant?: 'default' | 'minimal';
2357
+ }
2358
+ declare const TimeDisplay: React__default.FC<TimeDisplayProps>;
2359
+
2360
+ interface DateDisplayProps {
2361
+ className?: string;
2362
+ variant?: 'default' | 'minimal';
2363
+ }
2364
+ declare const DateDisplay: React__default.FC<DateDisplayProps>;
2365
+
2366
+ interface MetricCardProps {
2367
+ title: string;
2368
+ value: number | string;
2369
+ unit?: string;
2370
+ trend?: number | null;
2371
+ }
2372
+ declare const MetricCard: React__default.FC<MetricCardProps>;
2373
+
2374
+ interface DateTimeDisplayProps {
2375
+ className?: string;
2376
+ showDate?: boolean;
2377
+ showTime?: boolean;
2378
+ }
2379
+ declare const DateTimeDisplay: React__default.FC<DateTimeDisplayProps>;
2380
+
2381
+ declare const IconMap: {
2382
+ readonly info: React__default.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React__default.RefAttributes<SVGSVGElement>>;
2383
+ readonly warning: React__default.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React__default.RefAttributes<SVGSVGElement>>;
2384
+ readonly success: React__default.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React__default.RefAttributes<SVGSVGElement>>;
2385
+ readonly search: React__default.ForwardRefExoticComponent<Omit<LucideProps, "ref"> & React__default.RefAttributes<SVGSVGElement>>;
2386
+ };
2387
+ type IconKey = keyof typeof IconMap;
2388
+ interface EmptyStateMessageProps {
2389
+ iconType?: IconKey | React__default.ComponentType<LucideProps> | React__default.ReactNode;
2390
+ title: string;
2391
+ message?: string;
2392
+ actionButton?: {
2393
+ text: string;
2394
+ onClick: () => void;
2395
+ className?: string;
2396
+ };
2397
+ className?: string;
2398
+ titleClassName?: string;
2399
+ messageClassName?: string;
2400
+ iconClassName?: string;
2401
+ }
2402
+ declare const EmptyStateMessage: React__default.FC<EmptyStateMessageProps>;
2403
+
2404
+ interface WhatsAppShareButtonProps {
2405
+ /** The message text to pre-fill. It will be URL-encoded. */
2406
+ message: string;
2407
+ /** Optional phone number to pre-fill. Should include country code without '+' or spaces. */
2408
+ phoneNumber?: string;
2409
+ /** Text for the button. Defaults to "Share on WhatsApp". */
2410
+ buttonText?: string;
2411
+ /** Additional classes for the button. */
2412
+ className?: string;
2413
+ /** Props for the icon, if you want to customize it or pass a custom icon node. */
2414
+ iconProps?: React__default.ComponentProps<typeof Share2>;
2415
+ /** Custom icon node to replace the default. */
2416
+ customIcon?: React__default.ReactNode;
2417
+ /** Aria-label for the button for accessibility. */
2418
+ ariaLabel?: string;
2419
+ }
2420
+ declare const WhatsAppShareButton: React__default.FC<WhatsAppShareButtonProps>;
2421
+
2422
+ interface BaseHistoryCalendarProps {
2423
+ dailyData: Record<string, DaySummaryData>;
2424
+ displayMonth: Date;
2425
+ onMonthChange: (newMonth: Date) => void;
2426
+ onDateSelect?: (date: string, shiftId?: string | number) => void;
2427
+ renderDayCellContent: (params: {
2428
+ date: Date;
2429
+ daySummary?: DaySummaryData;
2430
+ selectedShiftSummary?: ShiftSummaryData;
2431
+ isToday: boolean;
2432
+ isFuture: boolean;
2433
+ isOutside: boolean;
2434
+ modifiers: Modifiers;
2435
+ }) => React__default.ReactElement | null;
2436
+ getPerformanceColor?: (params: {
2437
+ daySummary?: DaySummaryData;
2438
+ selectedShiftSummary?: ShiftSummaryData;
2439
+ date: Date;
2440
+ isFuture: boolean;
2441
+ isToday: boolean;
2442
+ isOutside: boolean;
2443
+ }) => string;
2444
+ selectedShiftId?: string | number;
2445
+ disableFutureDates?: boolean;
2446
+ highlightToday?: boolean;
2447
+ className?: string;
2448
+ dayCellClassName?: string | ((date: Date, modifiers: Modifiers) => string);
2449
+ }
2450
+ declare const BaseHistoryCalendar: React__default.FC<BaseHistoryCalendarProps>;
2451
+
2452
+ interface ShiftDisplayProps {
2453
+ className?: string;
2454
+ }
2455
+ declare const ShiftDisplay: React__default.FC<ShiftDisplayProps>;
2456
+
2457
+ /**
2458
+ * ISTTimer composes TimeDisplay and ShiftDisplay from within @optifye/dashboard-core.
2459
+ * Assumes DashboardProvider is configured with necessary dateTimeConfig and shiftConfig.
2460
+ */
2461
+ declare const ISTTimer: React__default.FC;
2462
+
2463
+ interface BarChartDataItem {
2464
+ name: string;
2465
+ [key: string]: string | number | undefined;
2466
+ }
2467
+ interface BarProps {
2468
+ dataKey: string;
2469
+ name?: string;
2470
+ fill?: string;
2471
+ radius?: number | [number, number, number, number];
2472
+ labelList?: boolean | React__default.ReactElement | object;
2473
+ [key: string]: any;
2474
+ }
2475
+ interface BarChartProps {
2476
+ data: BarChartDataItem[];
2477
+ bars: BarProps[];
2478
+ xAxisDataKey?: string;
2479
+ xAxisLabel?: string;
2480
+ yAxisLabel?: string;
2481
+ yAxisUnit?: string;
2482
+ tooltipFormatter?: (value: any, name: any, props: any) => React__default.ReactNode;
2483
+ legendPayload?: any[];
2484
+ layout?: 'horizontal' | 'vertical';
2485
+ className?: string;
2486
+ showGrid?: boolean;
2487
+ showLegend?: boolean;
2488
+ showTooltip?: boolean;
2489
+ responsive?: boolean;
2490
+ aspect?: number;
2491
+ [key: string]: any;
2492
+ }
2493
+ declare const BarChart: React__default.FC<BarChartProps>;
2494
+
2495
+ interface LineChartDataItem {
2496
+ name: string;
2497
+ [key: string]: string | number | undefined;
2498
+ }
2499
+ interface LineProps {
2500
+ dataKey: string;
2501
+ name?: string;
2502
+ stroke?: string;
2503
+ strokeWidth?: number;
2504
+ type?: 'basis' | 'basisClosed' | 'basisOpen' | 'linear' | 'linearClosed' | 'natural' | 'monotoneX' | 'monotoneY' | 'monotone' | 'step' | 'stepBefore' | 'stepAfter';
2505
+ dot?: boolean | {
2506
+ r?: number;
2507
+ [key: string]: any;
2508
+ };
2509
+ activeDot?: boolean | {
2510
+ r?: number;
2511
+ [key: string]: any;
2512
+ };
2513
+ labelList?: boolean | object;
2514
+ [key: string]: any;
2515
+ }
2516
+ interface LineChartProps {
2517
+ data: LineChartDataItem[];
2518
+ lines: LineProps[];
2519
+ xAxisDataKey?: string;
2520
+ xAxisLabel?: string;
2521
+ xAxisTickFormatter?: (value: any, index: number) => string;
2522
+ yAxisLabel?: string;
2523
+ yAxisUnit?: string;
2524
+ yAxisDomain?: [number | string, number | string];
2525
+ tooltipFormatter?: (value: any, name: any, props: any) => React__default.ReactNode;
2526
+ legendPayload?: any[];
2527
+ className?: string;
2528
+ showGrid?: boolean;
2529
+ showLegend?: boolean;
2530
+ showTooltip?: boolean;
2531
+ responsive?: boolean;
2532
+ aspect?: number;
2533
+ [key: string]: any;
2534
+ }
2535
+ declare const LineChart: React__default.FC<LineChartProps>;
2536
+
2537
+ interface OutputProgressChartProps {
2538
+ currentOutput: number;
2539
+ targetOutput: number;
2540
+ className?: string;
2541
+ }
2542
+ declare const OutputProgressChart: React__default.FC<OutputProgressChartProps>;
2543
+
2544
+ interface LargeOutputProgressChartProps {
2545
+ currentOutput: number;
2546
+ targetOutput: number;
2547
+ className?: string;
2548
+ }
2549
+ declare const LargeOutputProgressChart: React__default.FC<LargeOutputProgressChartProps>;
2550
+
2551
+ interface CycleTimeChartProps {
2552
+ data?: Array<{
2553
+ time: string;
2554
+ value: number;
2555
+ }>;
2556
+ className?: string;
2557
+ }
2558
+ /**
2559
+ * CycleTimeChart - A placeholder chart component for displaying cycle time data.
2560
+ * Note: The original source file was empty, so this is a minimal implementation
2561
+ * to satisfy the migration plan requirements.
2562
+ */
2563
+ declare const CycleTimeChart: React__default.FC<CycleTimeChartProps>;
2564
+
2565
+ interface CycleTimeOverTimeChartProps {
2566
+ data: number[];
2567
+ idealCycleTime: number;
2568
+ shiftStart: string;
2569
+ className?: string;
2570
+ }
2571
+ declare const CycleTimeOverTimeChart: React__default.FC<CycleTimeOverTimeChartProps>;
2572
+
2573
+ interface HourlyOutputChartProps {
2574
+ data: number[];
2575
+ pphThreshold: number;
2576
+ shiftStart: string;
2577
+ className?: string;
2578
+ }
2579
+ declare const HourlyOutputChart: React__default.FC<HourlyOutputChartProps>;
2580
+
2581
+ interface SOPComplianceChartProps {
2582
+ data?: number[];
2583
+ targetCompliance?: number;
2584
+ shiftStart: string;
2585
+ className?: string;
2586
+ }
2587
+ declare const SOPComplianceChart: React__default.FC<SOPComplianceChartProps>;
2588
+
2589
+ interface LinePdfExportButtonProps {
2590
+ /** The DOM element or a selector string for the element to capture. */
2591
+ targetElement: HTMLElement | string;
2592
+ /** The desired filename for the PDF, without the .pdf extension. Defaults to "line-export". */
2593
+ fileName?: string;
2594
+ /** Text for the button. Defaults to "Export Line as PDF". */
2595
+ buttonText?: string;
2596
+ /** Additional classes for the button. */
2597
+ className?: string;
2598
+ /** Props for the icon. */
2599
+ iconProps?: React__default.ComponentProps<typeof Download>;
2600
+ /** Custom icon node to replace the default. */
2601
+ customIcon?: React__default.ReactNode;
2602
+ /** Aria-label for the button. */
2603
+ ariaLabel?: string;
2604
+ /** Optional function to call before export starts. */
2605
+ onBeforeExport?: () => void;
2606
+ /** Optional function to call after export completes (successfully or not). */
2607
+ onAfterExport?: () => void;
2608
+ /** Optional options for html2canvas. */
2609
+ html2canvasOptions?: Partial<Parameters<typeof html2canvas>[1]>;
2610
+ /** Optional options for jsPDF. */
2611
+ jsPdfOptions?: {
2612
+ orientation?: 'p' | 'portrait' | 'l' | 'landscape';
2613
+ unit?: 'pt' | 'mm' | 'cm' | 'in';
2614
+ format?: string | number[];
2615
+ };
2616
+ }
2617
+ declare const LinePdfExportButton: React__default.FC<LinePdfExportButtonProps>;
2618
+
2619
+ interface ShiftData$1 {
2620
+ avg_efficiency: number;
2621
+ underperforming_workspaces: number;
2622
+ total_workspaces: number;
2623
+ }
2624
+ interface DayData$1 {
2625
+ date: Date | string;
2626
+ dayShift: ShiftData$1;
2627
+ nightShift: ShiftData$1;
2628
+ }
2629
+ interface LineHistoryCalendarProps {
2630
+ data: DayData$1[];
2631
+ month: number;
2632
+ year: number;
2633
+ lineId: string;
2634
+ selectedShift: 'day' | 'night';
2635
+ onDateSelect?: (date: string, shiftId: string) => void;
2636
+ className?: string;
2637
+ }
2638
+ declare const LineHistoryCalendar: React__default.FC<LineHistoryCalendarProps>;
2639
+
2640
+ interface PerformanceData {
2641
+ avg_efficiency: number;
2642
+ underperforming_workspaces: number;
2643
+ total_workspaces: number;
2644
+ compliance_percentage?: number;
2645
+ }
2646
+ interface WorkspacePerformance {
2647
+ workspace_name: string;
2648
+ workspace_uuid: string;
2649
+ avg_efficiency?: number;
2650
+ last_5_days: {
2651
+ date: string;
2652
+ performance_score: 0 | 1 | 2;
2653
+ efficiency?: number;
2654
+ }[];
2655
+ }
2656
+ interface LineMonthlyHistoryProps {
2657
+ month: number;
2658
+ year: number;
2659
+ monthlyData: {
2660
+ date: Date;
2661
+ dayShift: PerformanceData;
2662
+ nightShift: PerformanceData;
2663
+ }[];
2664
+ underperformingWorkspaces: {
2665
+ dayShift: WorkspacePerformance[];
2666
+ nightShift: WorkspacePerformance[];
2667
+ };
2668
+ lineId: string;
2669
+ onWorkspaceSelect?: (workspaceId: string, navigationParams?: Partial<WorkspaceNavigationParams> & {
2670
+ returnTo?: string;
2671
+ }) => void;
2672
+ onCalendarDateSelect?: (date: string, shiftId: string | number) => void;
2673
+ onCalendarMonthChange?: (newMonthDate: Date) => void;
2674
+ className?: string;
2675
+ }
2676
+ declare const LineMonthlyHistory: React__default.FC<LineMonthlyHistoryProps>;
2677
+
2678
+ interface LineWhatsAppShareProps {
2679
+ lineInfo: LineInfo;
2680
+ className?: string;
2681
+ }
2682
+ declare const LineWhatsAppShareButton: React__default.FC<LineWhatsAppShareProps>;
2683
+
2684
+ interface LinePdfGeneratorProps {
2685
+ lineInfo: LineInfo;
2686
+ workspaceData: WorkspaceMetrics[];
2687
+ className?: string;
2688
+ }
2689
+ declare const LinePdfGenerator: React__default.FC<LinePdfGeneratorProps>;
2690
+
2691
+ interface WorkspacePdfExportButtonProps {
2692
+ targetElement: HTMLElement | string;
2693
+ fileName?: string;
2694
+ buttonText?: string;
2695
+ className?: string;
2696
+ iconProps?: React__default.ComponentProps<typeof Download>;
2697
+ customIcon?: React__default.ReactNode;
2698
+ ariaLabel?: string;
2699
+ onBeforeExport?: () => void;
2700
+ onAfterExport?: () => void;
2701
+ html2canvasOptions?: Partial<Parameters<typeof html2canvas>[1]>;
2702
+ jsPdfOptions?: {
2703
+ orientation?: 'p' | 'portrait' | 'l' | 'landscape';
2704
+ unit?: 'pt' | 'mm' | 'cm' | 'in';
2705
+ format?: string | number[];
2706
+ };
2707
+ }
2708
+ declare const WorkspacePdfExportButton: React__default.FC<WorkspacePdfExportButtonProps>;
2709
+
2710
+ type KPITrend = 'up' | 'down' | 'neutral';
2711
+ interface KPICardProps {
2712
+ /**
2713
+ * The title or label for the KPI
2714
+ */
2715
+ title: string;
2716
+ /**
2717
+ * The primary value to display
2718
+ */
2719
+ value: string | number;
2720
+ /**
2721
+ * Optional trend direction ('up', 'down', 'neutral')
2722
+ */
2723
+ trend?: KPITrend;
2724
+ /**
2725
+ * Optional numerical change value (e.g., 5.2 for +5.2%)
2726
+ */
2727
+ change?: number;
2728
+ /**
2729
+ * Optional unit/suffix to display next to the value (e.g., '%', 'units')
2730
+ */
2731
+ suffix?: string;
2732
+ /**
2733
+ * Optional additional/secondary metric to display
2734
+ */
2735
+ secondaryMetric?: {
2736
+ label: string;
2737
+ value: string | number;
2738
+ suffix?: string;
2739
+ };
2740
+ /**
2741
+ * Optional status indicator
2742
+ */
2743
+ status?: {
2744
+ indicator?: React__default.ReactNode;
2745
+ tooltipText?: string;
2746
+ positive?: boolean;
2747
+ };
2748
+ /**
2749
+ * Whether this KPI is in a loading state
2750
+ */
2751
+ isLoading?: boolean;
2752
+ /**
2753
+ * Click handler for the card
2754
+ */
2755
+ onClick?: () => void;
2756
+ /**
2757
+ * Additional CSS classes for the component
2758
+ */
2759
+ className?: string;
2760
+ /**
2761
+ * Additional styling options
2762
+ */
2763
+ style?: {
2764
+ compact?: boolean;
2765
+ variant?: 'default' | 'filled' | 'outlined' | 'subtle';
2766
+ };
2767
+ /**
2768
+ * Whether to show output details indicator (for backward compatibility with src version)
2769
+ * @deprecated Use status prop instead
2770
+ */
2771
+ showOutputDetails?: boolean;
2772
+ /**
2773
+ * Output difference for determining indicator color (for backward compatibility with src version)
2774
+ * @deprecated Use status prop instead
2775
+ */
2776
+ outputDifference?: number;
2777
+ }
2778
+ /**
2779
+ * KPICard component
2780
+ *
2781
+ * Displays a single KPI metric with various configuration options including
2782
+ * trend indicators, secondary metrics, and status indicators.
2783
+ */
2784
+ declare const KPICard: React__default.FC<KPICardProps>;
2785
+
2786
+ interface WorkspaceCardProps {
2787
+ workspaceId: string;
2788
+ workspaceName: string;
2789
+ efficiency?: {
2790
+ value: number;
2791
+ trend?: KPITrend;
2792
+ };
2793
+ output?: {
2794
+ current: number;
2795
+ target?: number;
2796
+ unit?: string;
2797
+ };
2798
+ pph?: {
2799
+ value: number;
2800
+ target?: number;
2801
+ unit?: string;
2802
+ };
2803
+ cycleTime?: {
2804
+ value: number;
2805
+ target?: number;
2806
+ unit?: string;
2807
+ };
2808
+ operators?: Pick<OperatorInfo, 'id' | 'name' | 'photo_url'>[];
2809
+ status?: 'bottleneck' | 'lowEfficiency' | 'inactive' | 'normal';
2810
+ onCardClick?: (workspaceId: string) => void;
2811
+ headerActions?: React__default.ReactNode;
2812
+ footerContent?: React__default.ReactNode;
2813
+ chartData?: {
2814
+ type: 'line' | 'bar';
2815
+ data: LineChartDataItem[] | BarChartDataItem[];
2816
+ dataKey: string;
2817
+ xAxisKey?: string;
2818
+ };
2819
+ isLoading?: boolean;
2820
+ className?: string;
2821
+ metricCardClassName?: string;
2822
+ }
2823
+ declare const WorkspaceCard: React__default.FC<WorkspaceCardProps>;
2824
+
2825
+ interface ShiftData {
2826
+ efficiency: number;
2827
+ output: number;
2828
+ cycleTime: number;
2829
+ pph: number;
2830
+ pphThreshold: number;
2831
+ idealOutput: number;
2832
+ rank: number;
2833
+ }
2834
+ interface DayData {
2835
+ date: Date;
2836
+ dayShift: ShiftData;
2837
+ nightShift: ShiftData;
2838
+ }
2839
+ interface WorkspaceHistoryCalendarProps {
2840
+ data: DayData[];
2841
+ onDateSelect: (date: string) => void;
2842
+ month: number;
2843
+ year: number;
2844
+ workspaceId: string;
2845
+ selectedShift?: 'day' | 'night';
2846
+ onMonthNavigate?: (newMonth: number, newYear: number) => void;
2847
+ onShiftChange?: (shift: 'day' | 'night') => void;
2848
+ className?: string;
2849
+ }
2850
+ declare const WorkspaceHistoryCalendar: React__default.FC<WorkspaceHistoryCalendarProps>;
2851
+
2852
+ interface WorkspaceWhatsAppShareProps {
2853
+ workspace: WorkspaceDetailedMetrics;
2854
+ className?: string;
2855
+ }
2856
+ declare const WorkspaceWhatsAppShareButton: React__default.FC<WorkspaceWhatsAppShareProps>;
2857
+
2858
+ interface WorkspacePdfGeneratorProps {
2859
+ workspace: WorkspaceDetailedMetrics;
2860
+ className?: string;
2861
+ }
2862
+ declare const WorkspacePdfGenerator: React__default.FC<WorkspacePdfGeneratorProps>;
2863
+
2864
+ interface WorkspaceMetricCardsProps {
2865
+ workspace: WorkspaceDetailedMetrics;
2866
+ className?: string;
2867
+ }
2868
+ declare const WorkspaceMetricCards: React__default.FC<WorkspaceMetricCardsProps>;
2869
+
2870
+ /**
2871
+ * LiveTimer component that displays the current time in IST format
2872
+ * This is used in the workspace detail view to show real-time updates
2873
+ */
2874
+ declare const LiveTimer: React__default.FC;
2875
+
2876
+ /**
2877
+ * Types for BottlenecksContent component
2878
+ */
2879
+
2880
+ /**
2881
+ * Props for the BottlenecksContent component
2882
+ */
2883
+ interface BottlenecksContentProps {
2884
+ /**
2885
+ * ID of the workspace to fetch clips for
2886
+ */
2887
+ workspaceId: string;
2888
+ /**
2889
+ * Display name of the workspace
2890
+ */
2891
+ workspaceName: string;
2892
+ /**
2893
+ * Optional date to fetch clips for (defaults to current date)
2894
+ */
2895
+ date?: string;
2896
+ /**
2897
+ * Optional S3 service configuration
2898
+ */
2899
+ s3Config?: S3ServiceConfig;
2900
+ /**
2901
+ * Optional className for styling
2902
+ */
2903
+ className?: string;
2904
+ /**
2905
+ * Optional custom fetch function for clips
2906
+ */
2907
+ customFetchClips?: (workspaceId: string, date?: string) => Promise<BottleneckVideo[]>;
2908
+ }
2909
+ /**
2910
+ * Filter type for bottleneck clips
2911
+ */
2912
+ type BottleneckFilterType = 'all' | 'high' | 'medium' | 'low' | 'low_value';
2913
+ /**
2914
+ * Clip counts for each type/severity
2915
+ */
2916
+ interface ClipCounts {
2917
+ bottlenecks: number;
2918
+ lowValue: number;
2919
+ highSeverity: number;
2920
+ mediumSeverity: number;
2921
+ lowSeverity: number;
2922
+ total: number;
2923
+ }
2924
+
2925
+ /**
2926
+ * BottlenecksContent Component
2927
+ *
2928
+ * Displays video clips of bottlenecks and low-value activities for a workspace.
2929
+ * This component directly uses S3 to fetch and display videos without requiring an API endpoint.
2930
+ */
2931
+ declare const BottlenecksContent: React__default.FC<BottlenecksContentProps>;
2932
+
2933
+ interface WorkspacePosition {
2934
+ id: string;
2935
+ x: number;
2936
+ y: number;
2937
+ section: 'top' | 'middle-top' | 'middle-bottom' | 'bottom' | 'left-side';
2938
+ size?: 'normal' | 'large' | 'extra-large' | 'extra-wide' | 'rectangular-small' | 'conveyor';
2939
+ orientation?: 'right' | 'left';
2940
+ }
2941
+ interface WorkspaceGridItemProps {
2942
+ data: {
2943
+ workspace_id: string;
2944
+ workspace_name: string;
2945
+ efficiency: number;
2946
+ performance_score: number;
2947
+ trend_score: 0 | 1 | 2;
2948
+ avg_cycle_time: number;
2949
+ avg_pph: number;
2950
+ total_output: number;
2951
+ ideal_output: number;
2952
+ line_id: string;
2953
+ company_id: string;
2954
+ shift_id: number;
2955
+ date: string;
2956
+ };
2957
+ position: WorkspacePosition;
2958
+ isBottleneck?: boolean;
2959
+ isLowEfficiency?: boolean;
2960
+ isVeryLowEfficiency?: boolean;
2961
+ onHoverChange?: (isHovered: boolean) => void;
2962
+ }
2963
+ declare const Legend: () => react_jsx_runtime.JSX.Element;
2964
+ declare const WorkspaceGridItem: React__default.FC<WorkspaceGridItemProps>;
2965
+
2966
+ declare const DEFAULT_WORKSPACE_POSITIONS: WorkspacePosition[];
2967
+ declare const WORKSPACE_POSITIONS: WorkspacePosition[];
2968
+
2969
+ interface WorkspaceGridProps {
2970
+ workspaces: WorkspaceMetrics[];
2971
+ isPdfMode?: boolean;
2972
+ customWorkspacePositions?: typeof DEFAULT_WORKSPACE_POSITIONS;
2973
+ lineNames?: Record<string, string>;
2974
+ factoryView?: string;
2975
+ line2Uuid?: string;
2976
+ className?: string;
2977
+ videoSources?: {
2978
+ defaultHlsUrl?: string;
2979
+ workspaceHlsUrls?: Record<string, string>;
2980
+ mp4VideoMapping?: Record<string, string>;
2981
+ };
2982
+ }
2983
+ declare const WorkspaceGrid: React__default.FC<WorkspaceGridProps>;
2984
+
2985
+ interface TargetWorkspaceGridProps {
2986
+ lineId: string;
2987
+ selectedWorkspaces: string[];
2988
+ onWorkspaceSelect: (workspaceId: string) => void;
2989
+ previouslyAssignedWorkspaces?: string[];
2990
+ positions: WorkspacePosition[];
2991
+ lineNames?: Record<string, string>;
2992
+ className?: string;
2993
+ }
2994
+ declare const TargetWorkspaceGrid: React__default.FC<TargetWorkspaceGridProps>;
2995
+
2996
+ interface VideoGridViewProps {
2997
+ workspaces: WorkspaceMetrics[];
2998
+ selectedLine?: number;
2999
+ className?: string;
3000
+ lineIdMapping?: Record<string, string>;
3001
+ videoSources?: {
3002
+ defaultHlsUrl?: string;
3003
+ workspaceHlsUrls?: Record<string, string>;
3004
+ mp4VideoMapping?: Record<string, string>;
3005
+ };
3006
+ streamConfig?: {
3007
+ maxConcurrentInitializations?: number;
3008
+ staggerDelay?: number;
3009
+ initialPlayDelay?: number;
3010
+ maxPlayRetries?: number;
3011
+ maxFatalErrorRetries?: number;
3012
+ errorRetryBaseDelay?: number;
3013
+ maxErrorRetryDelay?: number;
3014
+ streamHealthCheckInterval?: number;
3015
+ debugCropRegions?: boolean;
3016
+ };
3017
+ hlsConfig?: Partial<Record<string, any>>;
3018
+ }
3019
+ /**
3020
+ * VideoGridView component for displaying a grid of workspace video streams
3021
+ * with efficiency metrics and controls.
3022
+ */
3023
+ declare const VideoGridView: React__default.FC<VideoGridViewProps>;
3024
+
3025
+ declare const GridComponentsPlaceholder: {};
3026
+
3027
+ interface KPIGridProps {
3028
+ /**
3029
+ * Child components (typically KPICard components)
3030
+ */
3031
+ children: React__default.ReactNode;
3032
+ /**
3033
+ * Layout orientation
3034
+ */
3035
+ layout?: 'row' | 'grid';
3036
+ /**
3037
+ * Number of columns for grid layout (default is responsive)
3038
+ */
3039
+ columns?: number | {
3040
+ sm?: number;
3041
+ md?: number;
3042
+ lg?: number;
3043
+ xl?: number;
3044
+ };
3045
+ /**
3046
+ * Spacing between items
3047
+ */
3048
+ gap?: 'none' | 'sm' | 'md' | 'lg';
3049
+ /**
3050
+ * Additional CSS classes
3051
+ */
3052
+ className?: string;
3053
+ }
3054
+ /**
3055
+ * KPIGrid component
3056
+ *
3057
+ * A layout component for arranging KPI cards in either a row or a grid.
3058
+ * Provides responsive behavior by default.
3059
+ */
3060
+ declare const KPIGrid: React__default.FC<KPIGridProps>;
3061
+
3062
+ interface KPIHeaderProps {
3063
+ /**
3064
+ * Main header title
3065
+ */
3066
+ title: string;
3067
+ /**
3068
+ * Optional subtitle or description
3069
+ */
3070
+ subtitle?: string;
3071
+ /**
3072
+ * Optional additional content to render in the header (e.g., actions, filters)
3073
+ */
3074
+ actions?: React__default.ReactNode;
3075
+ /**
3076
+ * Additional CSS classes for the container
3077
+ */
3078
+ className?: string;
3079
+ /**
3080
+ * Additional CSS classes for the title
3081
+ */
3082
+ titleClassName?: string;
3083
+ /**
3084
+ * Additional CSS classes for the subtitle
3085
+ */
3086
+ subtitleClassName?: string;
3087
+ /**
3088
+ * Additional CSS classes for the actions container
3089
+ */
3090
+ actionsClassName?: string;
3091
+ /**
3092
+ * Header size variant
3093
+ */
3094
+ size?: 'sm' | 'md' | 'lg';
3095
+ }
3096
+ /**
3097
+ * KPIHeader component
3098
+ *
3099
+ * A header component for KPI sections that displays a title,
3100
+ * optional subtitle, and optional action buttons.
3101
+ */
3102
+ declare const KPIHeader: React__default.FC<KPIHeaderProps>;
3103
+
3104
+ interface KPISectionProps {
3105
+ /**
3106
+ * The KPI data to display
3107
+ */
3108
+ kpis: DashboardKPIs;
3109
+ /**
3110
+ * Additional className for the container
3111
+ */
3112
+ className?: string;
3113
+ /**
3114
+ * Layout for the KPI cards
3115
+ * @default 'row'
3116
+ */
3117
+ layout?: 'row' | 'grid';
3118
+ /**
3119
+ * Columns for grid layout, passed to KPIGrid
3120
+ */
3121
+ gridColumns?: number | {
3122
+ sm?: number;
3123
+ md?: number;
3124
+ lg?: number;
3125
+ xl?: number;
3126
+ };
3127
+ /**
3128
+ * Gap for KPIGrid
3129
+ */
3130
+ gridGap?: 'none' | 'sm' | 'md' | 'lg';
3131
+ /**
3132
+ * Style variant for the KPICards
3133
+ * @default 'default'
3134
+ */
3135
+ cardVariant?: 'default' | 'filled' | 'outlined' | 'subtle';
3136
+ /**
3137
+ * Compact mode for KPICards
3138
+ * @default false
3139
+ */
3140
+ compactCards?: boolean;
3141
+ /**
3142
+ * Flag to use the original src layout (3 cards with specific styling)
3143
+ * @default false
3144
+ */
3145
+ useSrcLayout?: boolean;
3146
+ }
3147
+ /**
3148
+ * KPISection component
3149
+ *
3150
+ * Displays a section of KPI cards with different layouts and styles.
3151
+ * Compatible with the original src implementation while providing extended functionality.
3152
+ */
3153
+ declare const KPISection: React__default.FC<KPISectionProps>;
3154
+
3155
+ interface DashboardHeaderProps {
3156
+ lineTitle: string;
3157
+ className?: string;
3158
+ }
3159
+ /**
3160
+ * Header component for dashboard pages with title and timer
3161
+ */
3162
+ declare const DashboardHeader: React__default.MemoExoticComponent<({ lineTitle, className }: DashboardHeaderProps) => react_jsx_runtime.JSX.Element>;
3163
+
3164
+ interface NoWorkspaceDataProps {
3165
+ className?: string;
3166
+ }
3167
+ /**
3168
+ * Component to display when no workspace data is available
3169
+ */
3170
+ declare const NoWorkspaceData: React__default.MemoExoticComponent<({ className }: NoWorkspaceDataProps) => react_jsx_runtime.JSX.Element>;
3171
+
3172
+ /**
3173
+ * SideNavBar is a fixed implementation for the original src version,
3174
+ * hardcoded with specific routes and icons.
3175
+ * It does not use the navItems prop for backward compatibility.
3176
+ */
3177
+ declare const SideNavBar: React__default.FC<SideNavBarProps>;
3178
+
3179
+ declare const PageHeader: React__default.FC<PageHeaderProps>;
3180
+
3181
+ interface DashboardLayoutProps {
3182
+ children: React__default.ReactNode;
3183
+ pageTitle: string;
3184
+ navItems?: NavItem[];
3185
+ logo?: React__default.ReactNode;
3186
+ headerActions?: React__default.ReactNode;
3187
+ headerBreadcrumbs?: BreadcrumbItem[];
3188
+ headerUserProfileConfig?: UserProfileConfig;
3189
+ showHeaderDateTime?: boolean;
3190
+ isLoading?: boolean;
3191
+ error?: Error | string | null;
3192
+ currentPathname: string;
3193
+ currentQuery?: Record<string, any>;
3194
+ className?: string;
3195
+ contentClassName?: string;
3196
+ hideSideBar?: boolean;
3197
+ hideHeader?: boolean;
3198
+ }
3199
+ declare const DashboardLayout: React__default.FC<DashboardLayoutProps>;
3200
+
3201
+ interface MainLayoutProps {
3202
+ children: React__default.ReactNode;
3203
+ className?: string;
3204
+ navItems?: NavItem[];
3205
+ logo?: React__default.ReactNode;
3206
+ }
3207
+ declare const MainLayout: React__default.FC<MainLayoutProps>;
3208
+
3209
+ interface HeaderProps {
3210
+ className?: string;
3211
+ }
3212
+ declare const Header: React__default.FC<HeaderProps>;
3213
+
3214
+ declare const withAuth: <P extends object>(WrappedComponent: React$1.ComponentType<P>) => (props: P) => react_jsx_runtime.JSX.Element;
3215
+
3216
+ declare const DEFAULT_HLS_CONFIG: {
3217
+ maxBufferLength: number;
3218
+ maxMaxBufferLength: number;
3219
+ maxBufferSize: number;
3220
+ maxBufferHole: number;
3221
+ lowLatencyMode: boolean;
3222
+ enableWorker: boolean;
3223
+ backBufferLength: number;
3224
+ };
3225
+ interface SingleVideoStreamProps {
3226
+ /**
3227
+ * Workspace ID for the stream
3228
+ */
3229
+ workspaceId: string;
3230
+ /**
3231
+ * Workspace name used to determine the camera number
3232
+ */
3233
+ workspaceName: string;
3234
+ /**
3235
+ * Optional direct stream URL. If not provided, will be generated based on workspaceName and baseUrl
3236
+ */
3237
+ streamUrl?: string;
3238
+ /**
3239
+ * Base URL for HLS streams. Default is 'https://172.20.135.100:8443/'
3240
+ */
3241
+ baseUrl?: string;
3242
+ /**
3243
+ * Function to get camera URL based on workspace name. If not provided, default implementation is used.
3244
+ */
3245
+ getCameraStreamUrl?: (workspaceName: string, baseUrl: string) => string;
3246
+ /**
3247
+ * Optional handler for video click events
3248
+ */
3249
+ onVideoClick?: () => void;
3250
+ /**
3251
+ * Optional CSS class name
3252
+ */
3253
+ className?: string;
3254
+ /**
3255
+ * Maximum number of retry attempts for video playback. Default is 3.
3256
+ */
3257
+ maxPlayRetries?: number;
3258
+ /**
3259
+ * Initial delay before playing video (in ms). Default is 100.
3260
+ */
3261
+ initialPlayDelay?: number;
3262
+ /**
3263
+ * Custom HLS configuration to override defaults
3264
+ */
3265
+ hlsConfig?: Partial<typeof DEFAULT_HLS_CONFIG>;
3266
+ }
3267
+ /**
3268
+ * Default function to get camera number from workspace name
3269
+ */
3270
+ declare const getCameraNumber: (workspaceName: string) => number;
3271
+ /**
3272
+ * Default function to get camera URL based on workspace name
3273
+ */
3274
+ declare const getDefaultCameraStreamUrl: (workspaceName: string, baseUrl: string) => string;
3275
+ /**
3276
+ * SingleVideoStream component for displaying HLS video streams
3277
+ */
3278
+ declare const SingleVideoStream: React__default.FC<SingleVideoStreamProps>;
3279
+
3280
+ interface WorkspaceMonthlyDataFetcherProps {
3281
+ /**
3282
+ * The ID of the workspace to fetch monthly data for
3283
+ */
3284
+ workspaceId: string;
3285
+ /**
3286
+ * The month to fetch data for (0-based, where 0 = January)
3287
+ */
3288
+ selectedMonth: number;
3289
+ /**
3290
+ * The year to fetch data for
3291
+ */
3292
+ selectedYear: number;
3293
+ /**
3294
+ * Callback function that receives the loaded data
3295
+ */
3296
+ onDataLoaded: (data: any[]) => void;
3297
+ /**
3298
+ * Callback function that receives the loading state
3299
+ */
3300
+ onLoadingChange: (isLoading: boolean) => void;
3301
+ }
3302
+ /**
3303
+ * A non-visual component that fetches monthly workspace data and passes it to its parent via callbacks.
3304
+ */
3305
+ declare const WorkspaceMonthlyDataFetcher: React__default.FC<WorkspaceMonthlyDataFetcherProps>;
3306
+
3307
+ interface HomeViewProps {
3308
+ /**
3309
+ * UUID of the default line to display
3310
+ */
3311
+ defaultLineId: string;
3312
+ /**
3313
+ * UUID for the factory view
3314
+ */
3315
+ factoryViewId: string;
3316
+ /**
3317
+ * UUID for Line 1
3318
+ */
3319
+ line1Uuid: string;
3320
+ /**
3321
+ * UUID for Line 2
3322
+ */
3323
+ line2Uuid: string;
3324
+ /**
3325
+ * Names for each line, keyed by UUID
3326
+ */
3327
+ lineNames: Record<string, string>;
3328
+ /**
3329
+ * Optional video sources configuration
3330
+ */
3331
+ videoSources?: {
3332
+ workspaceHlsUrls?: Record<string, string>;
3333
+ mp4VideoMapping?: Record<string, string>;
3334
+ };
3335
+ /**
3336
+ * Optional factory name to display in the header
3337
+ */
3338
+ factoryName?: string;
3339
+ }
3340
+ /**
3341
+ * HomeView component - Main dashboard landing page showing factory overview with workspace grid
3342
+ */
3343
+ declare function HomeView({ defaultLineId, factoryViewId, line1Uuid, line2Uuid, lineNames, videoSources, factoryName }: HomeViewProps): React__default.ReactNode;
3344
+ declare const AuthenticatedHomeView: (props: HomeViewProps) => react_jsx_runtime.JSX.Element;
3345
+
3346
+ /**
3347
+ * FactoryView Component - Displays factory-level overview with metrics for each production line
3348
+ */
3349
+ declare const FactoryView: React__default.FC<FactoryViewProps>;
3350
+ declare const AuthenticatedFactoryView: (props: FactoryViewProps) => react_jsx_runtime.JSX.Element;
3351
+
3352
+ /**
3353
+ * LeaderboardIndexView component for displaying a list of lines that can be selected for the leaderboard
3354
+ */
3355
+ declare const LeaderboardIndexView: React__default.FC<LeaderboardIndexViewProps>;
3356
+
3357
+ /**
3358
+ * LeaderboardDetailView component for displaying a detailed leaderboard for a specific line
3359
+ */
3360
+ declare const LeaderboardDetailView: React__default.FC<LeaderboardDetailViewProps>;
3361
+
3362
+ interface TargetsViewProps {
3363
+ /** Line UUIDs to display and configure in the view */
3364
+ lineIds: string[];
3365
+ /** Line display names mapping (lineId to display name) */
3366
+ lineNames: Record<string, string>;
3367
+ /** Company UUID for fetching actions */
3368
+ companyId: string;
3369
+ /** Optional router instance for navigation */
3370
+ router?: {
3371
+ push: (path: string) => void;
3372
+ };
3373
+ /** Optional user ID for tracking who made changes */
3374
+ userId?: string;
3375
+ /** Callback when changes are saved */
3376
+ onSaveChanges?: (lineId: string) => void;
3377
+ }
3378
+
3379
+ /**
3380
+ * TargetsView component for managing production targets
3381
+ *
3382
+ * This component allows for configuring:
3383
+ * - Production targets (PPH, cycle time, day output)
3384
+ * - Action types per workspace
3385
+ * - Product codes
3386
+ * - Supports both day and night shifts
3387
+ */
3388
+ declare const TargetsView: React__default.FC<TargetsViewProps>;
3389
+
3390
+ declare const AuthenticatedTargetsView: (props: TargetsViewProps) => react_jsx_runtime.JSX.Element;
3391
+
3392
+ /**
3393
+ * ShiftsView component for managing day and night shift configurations
3394
+ */
3395
+ declare const ShiftsView: React__default.FC<ShiftsViewProps>;
3396
+
3397
+ interface KPIDetailViewProps {
3398
+ /**
3399
+ * The ID of the line to display details for
3400
+ */
3401
+ lineId: string;
3402
+ /**
3403
+ * Optional specific date to view (YYYY-MM-DD)
3404
+ */
3405
+ date?: string;
3406
+ /**
3407
+ * Optional shift ID (0 for day, 1 for night)
3408
+ */
3409
+ shift?: string | number;
3410
+ /**
3411
+ * Initial tab to show
3412
+ */
3413
+ tab?: string;
3414
+ /**
3415
+ * Month to display in monthly history (0-11)
3416
+ */
3417
+ month?: string | number;
3418
+ /**
3419
+ * Year to display in monthly history
3420
+ */
3421
+ year?: string | number;
3422
+ /**
3423
+ * Company ID (if not using the default)
3424
+ */
3425
+ companyId?: string;
3426
+ /**
3427
+ * Optional custom navigation handler
3428
+ * Default is Next.js router push
3429
+ */
3430
+ navigate?: NavigationMethod;
3431
+ /**
3432
+ * Optional custom class name for additional styling
3433
+ */
3434
+ className?: string;
3435
+ /**
3436
+ * Custom back link URL
3437
+ */
3438
+ backLinkUrl?: string;
3439
+ /**
3440
+ * Back button click handler
3441
+ */
3442
+ onBackClick?: () => void;
3443
+ }
3444
+
3445
+ /**
3446
+ * Main KPIDetailView component.
3447
+ * Shows efficiency metrics and KPIs for a specific line, including:
3448
+ * - Line output progress
3449
+ * - Underperforming workspaces count
3450
+ * - Average efficiency
3451
+ * - Poorest performing workspaces list
3452
+ * - Hourly output chart
3453
+ *
3454
+ * Also provides monthly history view with calendar and underperforming workspaces tracking.
3455
+ */
3456
+ declare const KPIDetailView: React__default.FC<KPIDetailViewProps>;
3457
+
3458
+ type TabType = 'overview' | 'monthly_history' | 'bottlenecks';
3459
+ type NavigationHandler = (url: string) => void;
3460
+ interface WorkspaceDetailViewProps {
3461
+ /**
3462
+ * Workspace ID to display
3463
+ */
3464
+ workspaceId: string;
3465
+ /**
3466
+ * Optional date string for viewing historical data
3467
+ * Format: YYYY-MM-DD
3468
+ */
3469
+ date?: string;
3470
+ /**
3471
+ * Optional shift ID for viewing historical data
3472
+ * 0 = Day shift, 1 = Night shift
3473
+ */
3474
+ shift?: number | string;
3475
+ /**
3476
+ * Optional parameter to indicate if coming from monthly view
3477
+ */
3478
+ fromMonthly?: boolean;
3479
+ /**
3480
+ * Optional parameter to indicate source type
3481
+ */
3482
+ sourceType?: 'lineMonthlyHistory' | string;
3483
+ /**
3484
+ * Optional display name override for the workspace
3485
+ */
3486
+ displayName?: string;
3487
+ /**
3488
+ * Optional default tab to show
3489
+ */
3490
+ defaultTab?: TabType;
3491
+ /**
3492
+ * Optional return URL for back navigation
3493
+ */
3494
+ returnUrl?: string;
3495
+ /**
3496
+ * Line IDs for reference (configurable to avoid hardcoded constants)
3497
+ */
3498
+ lineIds?: {
3499
+ line1?: string;
3500
+ line2?: string;
3501
+ };
3502
+ /**
3503
+ * Optional navigation handler override
3504
+ */
3505
+ onNavigate?: NavigationHandler;
3506
+ /**
3507
+ * Optional callback when a tab is changed
3508
+ */
3509
+ onTabChange?: (tab: TabType) => void;
3510
+ /**
3511
+ * Optional callback when calendar date is selected
3512
+ */
3513
+ onDateSelect?: (date: string, shift: 'day' | 'night') => void;
3514
+ /**
3515
+ * Optional className for styling
3516
+ */
3517
+ className?: string;
3518
+ /**
3519
+ * Optional prop for UI customization
3520
+ */
3521
+ showCycleTimeChart?: boolean;
3522
+ /**
3523
+ * Optional render props for custom header actions
3524
+ */
3525
+ renderHeaderActions?: (workspace: any) => ReactNode;
3526
+ }
3527
+ declare const WrappedComponent: (props: WorkspaceDetailViewProps) => react_jsx_runtime.JSX.Element;
3528
+
3529
+ export { ACTION_NAMES, type Action, type ActionName, type ActionService, type ActionThreshold, type AnalyticsConfig, type AuthConfig, AuthProvider, type AuthUser, AuthenticatedFactoryView, AuthenticatedHomeView, AuthenticatedTargetsView, BarChart, type BarChartDataItem, type BarChartProps, type BarProps, BaseHistoryCalendar, type BaseLineMetric, type BasePerformanceMetric, type BottleneckFilterType, type BottleneckVideo, BottlenecksContent, type BottlenecksContentProps, type BreadcrumbItem, type Break, type BreakRowProps, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, type ClipCounts, type ComponentOverride, type CurrentShiftResult, CycleTimeChart, type CycleTimeChartProps, CycleTimeOverTimeChart, type CycleTimeOverTimeChartProps, DEFAULT_ANALYTICS_CONFIG, DEFAULT_AUTH_CONFIG, DEFAULT_CONFIG, DEFAULT_DATABASE_CONFIG, DEFAULT_DATE_TIME_CONFIG, DEFAULT_ENDPOINTS_CONFIG, DEFAULT_ENTITY_CONFIG, DEFAULT_SHIFT_CONFIG, DEFAULT_THEME_CONFIG, DEFAULT_WORKSPACE_CONFIG, DEFAULT_WORKSPACE_POSITIONS, type DashboardConfig, DashboardHeader, type DashboardKPIs, DashboardLayout, type DashboardLayoutProps, DashboardOverridesProvider, DashboardProvider, type DashboardService, type DatabaseConfig, DateDisplay, type DateTimeConfig, DateTimeDisplay, type DayHistoryData, type DaySummaryData, EmptyStateMessage, type EndpointsConfig, type EntityConfig, type FactoryOverviewData, FactoryView, type FactoryViewProps, type FormatNumberOptions, GridComponentsPlaceholder, Header, type HeaderProps, type HistoryCalendarProps, HomeView, type HomeViewProps, type HookOverride, HourlyOutputChart, type HourlyOutputChartProps, type HourlyPerformance, type ISTDateProps, ISTTimer, type ISTTimerProps, KPICard, type KPICardProps, KPIDetailView, KPIGrid, type KPIGridProps, KPIHeader, type KPIHeaderProps, KPISection, type KPITrend, LINE_1_UUID, LargeOutputProgressChart, type LargeOutputProgressChartProps, LeaderboardDetailView, type LeaderboardDetailViewProps, type LeaderboardEntry, LeaderboardIndexView, type LeaderboardIndexViewProps, type LeaderboardLineOption, Legend, LineChart, type LineChartDataItem, type LineChartProps, type LineDetails, type LineDisplayData, LineHistoryCalendar, type LineHistoryCalendarProps, type LineInfo, type LineMetrics, LineMonthlyHistory, type LineMonthlyHistoryProps, type LineMonthlyMetric, type LineNavigationParams, LinePdfExportButton, type LinePdfExportButtonProps, LinePdfGenerator, type LinePdfGeneratorProps, type LineProps, type LineShiftConfig, type LineSnapshot, type LineThreshold, LineWhatsAppShareButton, type LineWhatsAppShareProps, LiveTimer, LoadingOverlay, LoadingPage, LoadingSpinner, MainLayout, type MainLayoutProps, type Metric, MetricCard, type MetricsError, type NavItem, type NavItemTrackingEvent, NoWorkspaceData, type OperatorData, type OperatorInfo, OutputProgressChart, type OutputProgressChartProps, type OverridesMap, type OverviewLineMetric, type OverviewWorkspaceMetric, PageHeader, type PageHeaderProps, type PageOverride, type PoorPerformingWorkspace, type ProfileMenuItem, type QualityMetric, type QualityOverview, type QualityService, type RealtimeService, type RoutePath, S3Service, type S3ServiceConfig, SOPComplianceChart, type SOPComplianceChartProps, Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue, type ShiftConfig, type ShiftConfiguration, type ShiftConfigurationRecord, type ShiftData$2 as ShiftData, ShiftDisplay, type ShiftHistoryData, type ShiftHoursMap, type ShiftPanelProps, type ShiftSummaryData, type ShiftTime, ShiftsView, type ShiftsViewProps, SideNavBar, type SideNavBarProps, type SimpleLine, SingleVideoStream, type SingleVideoStreamProps, Skeleton, type SupabaseClient, SupabaseProvider, type Target, TargetWorkspaceGrid, type TargetWorkspaceGridProps, TargetsView, type ThemeColorValue, type ThemeConfig, TimeDisplay, type TrackingEventProperties, type UnderperformingWorkspace, type UnderperformingWorkspaces, type UseDashboardMetricsProps, type UseFactoryOverviewOptions, type UseFormatNumberResult, type UseRealtimeLineMetricsProps, type UseTargetsOptions, type UseWorkspaceOperatorsOptions, type UserProfileConfig, VideoGridView, VideoPreloader, WORKSPACE_POSITIONS, type WhatsAppSendResult, WhatsAppShareButton, type WhatsappService, type Workspace, type WorkspaceActionUpdate, WorkspaceCard, type WorkspaceCardProps, type WorkspaceConfig, WrappedComponent as WorkspaceDetailView, type WorkspaceDetailedMetrics, WorkspaceGrid, WorkspaceGridItem, type WorkspaceGridItemProps, WorkspaceHistoryCalendar, WorkspaceMetricCards, type WorkspaceMetricCardsProps, type WorkspaceMetrics, WorkspaceMonthlyDataFetcher, type WorkspaceMonthlyDataFetcherProps, type WorkspaceMonthlyMetric, type WorkspaceNavigationParams, WorkspacePdfExportButton, type WorkspacePdfExportButtonProps, WorkspacePdfGenerator, type WorkspacePdfGeneratorProps, type WorkspacePosition, type WorkspaceQualityData, type WorkspaceUrlMapping, WorkspaceWhatsAppShareButton, type WorkspaceWhatsAppShareProps, actionService, apiUtils, authCoreService, cn, createSupabaseClient, dashboardService, formatDateInZone, formatDateTimeInZone, formatISTDate, formatTimeInZone, fromUrlFriendlyName, getAnonClient, getCameraNumber, getCompanyMetricsTableName, getConfigurableShortWorkspaceDisplayName, getConfigurableWorkspaceDisplayName, getCurrentShift, getCurrentTimeInZone, getDashboardHeaderTimeInZone, getDaysDifferenceInZone, getDefaultCameraStreamUrl, getDefaultTabForWorkspace, getMetricsTablePrefix, getOperationalDate, getShortWorkspaceDisplayName, getStoredWorkspaceMappings, getWorkspaceDisplayName, getWorkspaceFromUrl, getWorkspaceNavigationParams, identifyCoreUser, initializeCoreMixpanel, isTransitionPeriod, isValidLineInfoPayload, isValidWorkspaceDetailedMetricsPayload, isValidWorkspaceMetricsPayload, mergeWithDefaultConfig, preloadVideoUrl, preloadVideosUrl, qualityService, realtimeService, resetCoreMixpanel, storeWorkspaceMapping, toUrlFriendlyName, trackCoreEvent, trackCorePageView, useAnalyticsConfig, useAuth, useAuthConfig, useComponentOverride, useCustomConfig, useDashboardConfig, useDashboardMetrics, useDatabaseConfig, useDateFormatter, useDateTimeConfig, useEndpointsConfig, useEntityConfig, useFactoryOverviewMetrics, useFeatureFlags, useFormatNumber, useHistoricWorkspaceMetrics, useHookOverride, useLeaderboardMetrics, useLineDetailedMetrics, useLineKPIs, useLineMetrics, useLineWorkspaceMetrics, useMetrics, useNavigation, useOverrides, usePageOverride, useRealtimeLineMetrics, useShiftConfig, useShifts, useSupabase, useTargets, useTheme, useThemeConfig, useWorkspaceConfig, useWorkspaceDetailedMetrics, useWorkspaceMetrics, useWorkspaceNavigation, useWorkspaceOperators, videoPreloader, whatsappService, withAuth, workspaceDisplayNames, workspaceService };