@zonetrix/shared 2.4.1 → 2.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Database } from 'firebase/database';
2
+
1
3
  /**
2
4
  * Centralized type definitions for the Seat Map Studio packages
3
5
  */
@@ -18,6 +20,7 @@ interface SeatData {
18
20
  price?: number;
19
21
  seatNumber?: string;
20
22
  floorId?: string;
23
+ size?: number;
21
24
  }
22
25
  /**
23
26
  * Section configuration for creating seat groups
@@ -31,6 +34,7 @@ interface SectionConfig {
31
34
  price?: number;
32
35
  color?: string;
33
36
  locked?: boolean;
37
+ [key: string]: unknown;
34
38
  }
35
39
  /**
36
40
  * Row pricing structure for section-based pricing
@@ -128,6 +132,7 @@ interface SerializedSeat {
128
132
  seatNumber?: string;
129
133
  price?: number;
130
134
  floorId?: string;
135
+ size?: number;
131
136
  }
132
137
  /**
133
138
  * Serialized section for JSON export/import
@@ -196,10 +201,44 @@ interface ValidationResult {
196
201
  warnings: string[];
197
202
  }
198
203
 
204
+ interface ConfigInput {
205
+ version?: string;
206
+ metadata?: {
207
+ name?: string;
208
+ createdAt?: string;
209
+ updatedAt?: string;
210
+ };
211
+ canvas?: {
212
+ width?: number;
213
+ height?: number;
214
+ backgroundColor?: string;
215
+ };
216
+ colors?: Record<string, string>;
217
+ seats?: Array<{
218
+ id?: string;
219
+ position?: {
220
+ x?: number;
221
+ y?: number;
222
+ };
223
+ shape?: string;
224
+ state?: string;
225
+ }>;
226
+ sections?: Array<{
227
+ id?: string;
228
+ name?: string;
229
+ config?: unknown;
230
+ }>;
231
+ stages?: Array<{
232
+ id?: string;
233
+ config?: {
234
+ label?: string;
235
+ };
236
+ }>;
237
+ }
199
238
  /**
200
239
  * Validates a seat map configuration
201
240
  */
202
- declare function validateSeatMapConfig(config: any): ValidationResult;
241
+ declare function validateSeatMapConfig(config: ConfigInput | null | undefined): ValidationResult;
203
242
  /**
204
243
  * Generates a unique ID for seat map objects
205
244
  */
@@ -475,4 +514,224 @@ declare function deriveSeatArraysFromStates(states: FirebaseSeatStates, currentU
475
514
  */
476
515
  declare function createIndexUpdates(seatMapId: string, eventId: number, subEventId: number): Record<string, boolean>;
477
516
 
478
- export { type AlignmentGuide, type BookingSelection, type CanvasConfig, type CanvasState, type ColorSettings, DEFAULT_COLORS, type EditorMode, type FirebaseCanvasConfig, type FirebaseConfigResult, type FirebaseHookOptions, type FirebaseIndexEntry, FirebasePaths, type FirebasePosition, type FirebaseSeat, type FirebaseSeatMap, type FirebaseSeatMapConfig, type FirebaseSeatMapMeta, type FirebaseSeatState, type FirebaseSeatStateEntry, type FirebaseSeatStateValue, type FirebaseSeatStates, type FirebaseSeatStatesResult, type FirebaseStage, type ObjectConfig, type ObjectType, type RowPricing, type SeatData, type SeatMapConfig, type SeatMapMetadata, type SeatShape, type SeatState, type SectionConfig, type SerializedSeat, type SerializedSection, type SerializedStage, type StageConfig, type Tool, type ValidationResult, applySeatStateOverrides, calculateAvailableSeats, calculateCapacity, calculateSeatPrice, cloneConfig, createDefaultConfig, createIndexUpdates, decodeSeatId, deriveSeatArraysFromStates, downloadConfigAsFile, encodeSeatId, exportConfigAsJSON, extractSeatStates, formatDate, fromFirebaseSeatMap, fromFirebaseState, generateId, getSelectedSeats, importConfigFromJSON, toFirebaseSeatMap, toFirebaseState, updateConfigTimestamp, validateSeatMapConfig };
517
+ /**
518
+ * Firebase client singleton for the viewer package
519
+ * This allows the host application to initialize Firebase once
520
+ * and the viewer to use the same instance
521
+ */
522
+
523
+ /**
524
+ * Initialize the Firebase database instance for the viewer
525
+ * This should be called by the host application after Firebase is initialized
526
+ *
527
+ * @example
528
+ * ```tsx
529
+ * import { initializeApp } from 'firebase/app';
530
+ * import { getDatabase } from 'firebase/database';
531
+ * import { initializeFirebaseForViewer } from '@zonetrix/viewer';
532
+ *
533
+ * const app = initializeApp(firebaseConfig);
534
+ * const db = getDatabase(app);
535
+ * initializeFirebaseForViewer(db);
536
+ * ```
537
+ */
538
+ declare function initializeFirebaseForViewer(database: Database): void;
539
+ /**
540
+ * Get the Firebase database instance
541
+ * @throws Error if Firebase hasn't been initialized
542
+ */
543
+ declare function getFirebaseDatabase(): Database;
544
+ /**
545
+ * Check if Firebase has been initialized for the viewer
546
+ */
547
+ declare function isFirebaseInitialized(): boolean;
548
+ /**
549
+ * Clear the Firebase database instance (useful for testing)
550
+ */
551
+ declare function clearFirebaseInstance(): void;
552
+
553
+ /**
554
+ * Hook for real-time seat state updates from Firebase
555
+ * Uses useSyncExternalStore for stable snapshot handling
556
+ * Supports user-aware seat state derivation
557
+ */
558
+
559
+ interface UseFirebaseSeatStatesOptions {
560
+ /** The seat map ID to subscribe to */
561
+ seatMapId: string | null;
562
+ /** Current user ID for user-aware state derivation */
563
+ currentUserId?: string;
564
+ /** Whether the subscription is enabled (default: true) */
565
+ enabled?: boolean;
566
+ /** Callback when states change */
567
+ onStateChange?: (states: FirebaseSeatStates) => void;
568
+ /** Callback on error */
569
+ onError?: (error: Error) => void;
570
+ }
571
+ interface UseFirebaseSeatStatesResult {
572
+ /** Current seat states map */
573
+ states: FirebaseSeatStates | null;
574
+ /** Whether initial load is in progress */
575
+ loading: boolean;
576
+ /** Any error that occurred */
577
+ error: Error | null;
578
+ /** Timestamp of last update */
579
+ lastUpdated: number | null;
580
+ /** Seats reserved by current user (show as selected) */
581
+ myReservedSeats: string[];
582
+ /** Seats reserved by other users (show as reserved) */
583
+ otherReservedSeats: string[];
584
+ /** Seats unavailable for everyone */
585
+ unavailableSeats: string[];
586
+ /** @deprecated Use otherReservedSeats instead */
587
+ reservedSeats: string[];
588
+ }
589
+ /**
590
+ * Subscribe to real-time seat state updates from Firebase
591
+ * Uses useSyncExternalStore for stable snapshot handling
592
+ *
593
+ * @example
594
+ * ```tsx
595
+ * const { myReservedSeats, otherReservedSeats, unavailableSeats, loading } = useFirebaseSeatStates({
596
+ * seatMapId: '123',
597
+ * currentUserId: 'user-abc',
598
+ * });
599
+ *
600
+ * return (
601
+ * <SeatMapViewer
602
+ * config={config}
603
+ * myReservedSeats={myReservedSeats}
604
+ * reservedSeats={otherReservedSeats}
605
+ * unavailableSeats={unavailableSeats}
606
+ * />
607
+ * );
608
+ * ```
609
+ */
610
+ declare function useFirebaseSeatStates(options: UseFirebaseSeatStatesOptions): UseFirebaseSeatStatesResult;
611
+
612
+ /**
613
+ * Hook for loading seat map configuration from Firebase
614
+ * Optionally subscribes to design changes
615
+ */
616
+
617
+ interface UseFirebaseConfigOptions {
618
+ /** The seat map ID to load */
619
+ seatMapId: string | null;
620
+ /** Whether loading is enabled (default: true) */
621
+ enabled?: boolean;
622
+ /** Subscribe to design changes in real-time (default: false) */
623
+ subscribeToChanges?: boolean;
624
+ /** Callback when config loads or changes */
625
+ onConfigLoad?: (config: SeatMapConfig) => void;
626
+ /** Callback on error */
627
+ onError?: (error: Error) => void;
628
+ }
629
+ interface UseFirebaseConfigResult {
630
+ /** The loaded configuration */
631
+ config: SeatMapConfig | null;
632
+ /** Whether loading is in progress */
633
+ loading: boolean;
634
+ /** Any error that occurred */
635
+ error: Error | null;
636
+ /** Manually refetch the config */
637
+ refetch: () => Promise<void>;
638
+ }
639
+ /**
640
+ * Load seat map configuration from Firebase
641
+ *
642
+ * @example
643
+ * ```tsx
644
+ * // One-time load
645
+ * const { config, loading, error } = useFirebaseConfig({
646
+ * seatMapId: '123',
647
+ * });
648
+ *
649
+ * // With real-time design updates (for admin/editor preview)
650
+ * const { config } = useFirebaseConfig({
651
+ * seatMapId: '123',
652
+ * subscribeToChanges: true,
653
+ * });
654
+ * ```
655
+ */
656
+ declare function useFirebaseConfig(options: UseFirebaseConfigOptions): UseFirebaseConfigResult;
657
+
658
+ /**
659
+ * Combined hook for loading seat map config and subscribing to real-time state updates
660
+ * This is the recommended hook for most use cases
661
+ * Supports user-aware seat state derivation
662
+ */
663
+
664
+ interface UseRealtimeSeatMapOptions {
665
+ /** The seat map ID to load and subscribe to */
666
+ seatMapId: string | null;
667
+ /** Current user ID for user-aware state derivation */
668
+ userId?: string;
669
+ /** Whether the hook is enabled (default: true) */
670
+ enabled?: boolean;
671
+ /** Subscribe to design changes in real-time (default: false) */
672
+ subscribeToDesignChanges?: boolean;
673
+ /** Callback when config loads */
674
+ onConfigLoad?: (config: SeatMapConfig) => void;
675
+ /** Callback when seat states change */
676
+ onStateChange?: (states: FirebaseSeatStates) => void;
677
+ /** Callback on any error */
678
+ onError?: (error: Error) => void;
679
+ }
680
+ interface UseRealtimeSeatMapResult {
681
+ /** The seat map configuration */
682
+ config: SeatMapConfig | null;
683
+ /** Whether initial loading is in progress */
684
+ loading: boolean;
685
+ /** Any error that occurred */
686
+ error: Error | null;
687
+ /** Seats reserved by current user (show as selected) */
688
+ myReservedSeats: string[];
689
+ /** Seats reserved by other users (show as reserved) */
690
+ otherReservedSeats: string[];
691
+ /** Seats unavailable for everyone */
692
+ unavailableSeats: string[];
693
+ /** @deprecated Use otherReservedSeats instead */
694
+ reservedSeats: string[];
695
+ /** Raw seat states map */
696
+ seatStates: FirebaseSeatStates | null;
697
+ /** Timestamp of last state update */
698
+ lastUpdated: number | null;
699
+ /** Manually refetch the config */
700
+ refetch: () => Promise<void>;
701
+ }
702
+ /**
703
+ * Combined hook for loading config and subscribing to real-time seat states
704
+ *
705
+ * @example
706
+ * ```tsx
707
+ * import { useRealtimeSeatMap, SeatMapViewer } from '@zonetrix/viewer';
708
+ *
709
+ * function BookingPage({ seatMapId, userId }) {
710
+ * const {
711
+ * config,
712
+ * myReservedSeats,
713
+ * otherReservedSeats,
714
+ * unavailableSeats,
715
+ * loading,
716
+ * error
717
+ * } = useRealtimeSeatMap({ seatMapId, userId });
718
+ *
719
+ * if (loading) return <LoadingSpinner />;
720
+ * if (error) return <ErrorMessage error={error} />;
721
+ * if (!config) return null;
722
+ *
723
+ * return (
724
+ * <SeatMapViewer
725
+ * config={config}
726
+ * myReservedSeats={myReservedSeats}
727
+ * reservedSeats={otherReservedSeats}
728
+ * unavailableSeats={unavailableSeats}
729
+ * onSeatSelect={handleSeatSelect}
730
+ * />
731
+ * );
732
+ * }
733
+ * ```
734
+ */
735
+ declare function useRealtimeSeatMap(options: UseRealtimeSeatMapOptions): UseRealtimeSeatMapResult;
736
+
737
+ export { type AlignmentGuide, type BookingSelection, type CanvasConfig, type CanvasState, type ColorSettings, DEFAULT_COLORS, type EditorMode, type FirebaseCanvasConfig, type FirebaseConfigResult, type FirebaseHookOptions, type FirebaseIndexEntry, FirebasePaths, type FirebasePosition, type FirebaseSeat, type FirebaseSeatMap, type FirebaseSeatMapConfig, type FirebaseSeatMapMeta, type FirebaseSeatState, type FirebaseSeatStateEntry, type FirebaseSeatStateValue, type FirebaseSeatStates, type FirebaseSeatStatesResult, type FirebaseStage, type ObjectConfig, type ObjectType, type RowPricing, type SeatData, type SeatMapConfig, type SeatMapMetadata, type SeatShape, type SeatState, type SectionConfig, type SerializedSeat, type SerializedSection, type SerializedStage, type StageConfig, type Tool, type UseFirebaseConfigOptions, type UseFirebaseConfigResult, type UseFirebaseSeatStatesOptions, type UseFirebaseSeatStatesResult, type UseRealtimeSeatMapOptions, type UseRealtimeSeatMapResult, type ValidationResult, applySeatStateOverrides, calculateAvailableSeats, calculateCapacity, calculateSeatPrice, clearFirebaseInstance, cloneConfig, createDefaultConfig, createIndexUpdates, decodeSeatId, deriveSeatArraysFromStates, downloadConfigAsFile, encodeSeatId, exportConfigAsJSON, extractSeatStates, formatDate, fromFirebaseSeatMap, fromFirebaseState, generateId, getFirebaseDatabase, getSelectedSeats, importConfigFromJSON, initializeFirebaseForViewer, isFirebaseInitialized, toFirebaseSeatMap, toFirebaseState, updateConfigTimestamp, useFirebaseConfig, useFirebaseSeatStates, useRealtimeSeatMap, validateSeatMapConfig };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { Database } from 'firebase/database';
2
+
1
3
  /**
2
4
  * Centralized type definitions for the Seat Map Studio packages
3
5
  */
@@ -18,6 +20,7 @@ interface SeatData {
18
20
  price?: number;
19
21
  seatNumber?: string;
20
22
  floorId?: string;
23
+ size?: number;
21
24
  }
22
25
  /**
23
26
  * Section configuration for creating seat groups
@@ -31,6 +34,7 @@ interface SectionConfig {
31
34
  price?: number;
32
35
  color?: string;
33
36
  locked?: boolean;
37
+ [key: string]: unknown;
34
38
  }
35
39
  /**
36
40
  * Row pricing structure for section-based pricing
@@ -128,6 +132,7 @@ interface SerializedSeat {
128
132
  seatNumber?: string;
129
133
  price?: number;
130
134
  floorId?: string;
135
+ size?: number;
131
136
  }
132
137
  /**
133
138
  * Serialized section for JSON export/import
@@ -196,10 +201,44 @@ interface ValidationResult {
196
201
  warnings: string[];
197
202
  }
198
203
 
204
+ interface ConfigInput {
205
+ version?: string;
206
+ metadata?: {
207
+ name?: string;
208
+ createdAt?: string;
209
+ updatedAt?: string;
210
+ };
211
+ canvas?: {
212
+ width?: number;
213
+ height?: number;
214
+ backgroundColor?: string;
215
+ };
216
+ colors?: Record<string, string>;
217
+ seats?: Array<{
218
+ id?: string;
219
+ position?: {
220
+ x?: number;
221
+ y?: number;
222
+ };
223
+ shape?: string;
224
+ state?: string;
225
+ }>;
226
+ sections?: Array<{
227
+ id?: string;
228
+ name?: string;
229
+ config?: unknown;
230
+ }>;
231
+ stages?: Array<{
232
+ id?: string;
233
+ config?: {
234
+ label?: string;
235
+ };
236
+ }>;
237
+ }
199
238
  /**
200
239
  * Validates a seat map configuration
201
240
  */
202
- declare function validateSeatMapConfig(config: any): ValidationResult;
241
+ declare function validateSeatMapConfig(config: ConfigInput | null | undefined): ValidationResult;
203
242
  /**
204
243
  * Generates a unique ID for seat map objects
205
244
  */
@@ -475,4 +514,224 @@ declare function deriveSeatArraysFromStates(states: FirebaseSeatStates, currentU
475
514
  */
476
515
  declare function createIndexUpdates(seatMapId: string, eventId: number, subEventId: number): Record<string, boolean>;
477
516
 
478
- export { type AlignmentGuide, type BookingSelection, type CanvasConfig, type CanvasState, type ColorSettings, DEFAULT_COLORS, type EditorMode, type FirebaseCanvasConfig, type FirebaseConfigResult, type FirebaseHookOptions, type FirebaseIndexEntry, FirebasePaths, type FirebasePosition, type FirebaseSeat, type FirebaseSeatMap, type FirebaseSeatMapConfig, type FirebaseSeatMapMeta, type FirebaseSeatState, type FirebaseSeatStateEntry, type FirebaseSeatStateValue, type FirebaseSeatStates, type FirebaseSeatStatesResult, type FirebaseStage, type ObjectConfig, type ObjectType, type RowPricing, type SeatData, type SeatMapConfig, type SeatMapMetadata, type SeatShape, type SeatState, type SectionConfig, type SerializedSeat, type SerializedSection, type SerializedStage, type StageConfig, type Tool, type ValidationResult, applySeatStateOverrides, calculateAvailableSeats, calculateCapacity, calculateSeatPrice, cloneConfig, createDefaultConfig, createIndexUpdates, decodeSeatId, deriveSeatArraysFromStates, downloadConfigAsFile, encodeSeatId, exportConfigAsJSON, extractSeatStates, formatDate, fromFirebaseSeatMap, fromFirebaseState, generateId, getSelectedSeats, importConfigFromJSON, toFirebaseSeatMap, toFirebaseState, updateConfigTimestamp, validateSeatMapConfig };
517
+ /**
518
+ * Firebase client singleton for the viewer package
519
+ * This allows the host application to initialize Firebase once
520
+ * and the viewer to use the same instance
521
+ */
522
+
523
+ /**
524
+ * Initialize the Firebase database instance for the viewer
525
+ * This should be called by the host application after Firebase is initialized
526
+ *
527
+ * @example
528
+ * ```tsx
529
+ * import { initializeApp } from 'firebase/app';
530
+ * import { getDatabase } from 'firebase/database';
531
+ * import { initializeFirebaseForViewer } from '@zonetrix/viewer';
532
+ *
533
+ * const app = initializeApp(firebaseConfig);
534
+ * const db = getDatabase(app);
535
+ * initializeFirebaseForViewer(db);
536
+ * ```
537
+ */
538
+ declare function initializeFirebaseForViewer(database: Database): void;
539
+ /**
540
+ * Get the Firebase database instance
541
+ * @throws Error if Firebase hasn't been initialized
542
+ */
543
+ declare function getFirebaseDatabase(): Database;
544
+ /**
545
+ * Check if Firebase has been initialized for the viewer
546
+ */
547
+ declare function isFirebaseInitialized(): boolean;
548
+ /**
549
+ * Clear the Firebase database instance (useful for testing)
550
+ */
551
+ declare function clearFirebaseInstance(): void;
552
+
553
+ /**
554
+ * Hook for real-time seat state updates from Firebase
555
+ * Uses useSyncExternalStore for stable snapshot handling
556
+ * Supports user-aware seat state derivation
557
+ */
558
+
559
+ interface UseFirebaseSeatStatesOptions {
560
+ /** The seat map ID to subscribe to */
561
+ seatMapId: string | null;
562
+ /** Current user ID for user-aware state derivation */
563
+ currentUserId?: string;
564
+ /** Whether the subscription is enabled (default: true) */
565
+ enabled?: boolean;
566
+ /** Callback when states change */
567
+ onStateChange?: (states: FirebaseSeatStates) => void;
568
+ /** Callback on error */
569
+ onError?: (error: Error) => void;
570
+ }
571
+ interface UseFirebaseSeatStatesResult {
572
+ /** Current seat states map */
573
+ states: FirebaseSeatStates | null;
574
+ /** Whether initial load is in progress */
575
+ loading: boolean;
576
+ /** Any error that occurred */
577
+ error: Error | null;
578
+ /** Timestamp of last update */
579
+ lastUpdated: number | null;
580
+ /** Seats reserved by current user (show as selected) */
581
+ myReservedSeats: string[];
582
+ /** Seats reserved by other users (show as reserved) */
583
+ otherReservedSeats: string[];
584
+ /** Seats unavailable for everyone */
585
+ unavailableSeats: string[];
586
+ /** @deprecated Use otherReservedSeats instead */
587
+ reservedSeats: string[];
588
+ }
589
+ /**
590
+ * Subscribe to real-time seat state updates from Firebase
591
+ * Uses useSyncExternalStore for stable snapshot handling
592
+ *
593
+ * @example
594
+ * ```tsx
595
+ * const { myReservedSeats, otherReservedSeats, unavailableSeats, loading } = useFirebaseSeatStates({
596
+ * seatMapId: '123',
597
+ * currentUserId: 'user-abc',
598
+ * });
599
+ *
600
+ * return (
601
+ * <SeatMapViewer
602
+ * config={config}
603
+ * myReservedSeats={myReservedSeats}
604
+ * reservedSeats={otherReservedSeats}
605
+ * unavailableSeats={unavailableSeats}
606
+ * />
607
+ * );
608
+ * ```
609
+ */
610
+ declare function useFirebaseSeatStates(options: UseFirebaseSeatStatesOptions): UseFirebaseSeatStatesResult;
611
+
612
+ /**
613
+ * Hook for loading seat map configuration from Firebase
614
+ * Optionally subscribes to design changes
615
+ */
616
+
617
+ interface UseFirebaseConfigOptions {
618
+ /** The seat map ID to load */
619
+ seatMapId: string | null;
620
+ /** Whether loading is enabled (default: true) */
621
+ enabled?: boolean;
622
+ /** Subscribe to design changes in real-time (default: false) */
623
+ subscribeToChanges?: boolean;
624
+ /** Callback when config loads or changes */
625
+ onConfigLoad?: (config: SeatMapConfig) => void;
626
+ /** Callback on error */
627
+ onError?: (error: Error) => void;
628
+ }
629
+ interface UseFirebaseConfigResult {
630
+ /** The loaded configuration */
631
+ config: SeatMapConfig | null;
632
+ /** Whether loading is in progress */
633
+ loading: boolean;
634
+ /** Any error that occurred */
635
+ error: Error | null;
636
+ /** Manually refetch the config */
637
+ refetch: () => Promise<void>;
638
+ }
639
+ /**
640
+ * Load seat map configuration from Firebase
641
+ *
642
+ * @example
643
+ * ```tsx
644
+ * // One-time load
645
+ * const { config, loading, error } = useFirebaseConfig({
646
+ * seatMapId: '123',
647
+ * });
648
+ *
649
+ * // With real-time design updates (for admin/editor preview)
650
+ * const { config } = useFirebaseConfig({
651
+ * seatMapId: '123',
652
+ * subscribeToChanges: true,
653
+ * });
654
+ * ```
655
+ */
656
+ declare function useFirebaseConfig(options: UseFirebaseConfigOptions): UseFirebaseConfigResult;
657
+
658
+ /**
659
+ * Combined hook for loading seat map config and subscribing to real-time state updates
660
+ * This is the recommended hook for most use cases
661
+ * Supports user-aware seat state derivation
662
+ */
663
+
664
+ interface UseRealtimeSeatMapOptions {
665
+ /** The seat map ID to load and subscribe to */
666
+ seatMapId: string | null;
667
+ /** Current user ID for user-aware state derivation */
668
+ userId?: string;
669
+ /** Whether the hook is enabled (default: true) */
670
+ enabled?: boolean;
671
+ /** Subscribe to design changes in real-time (default: false) */
672
+ subscribeToDesignChanges?: boolean;
673
+ /** Callback when config loads */
674
+ onConfigLoad?: (config: SeatMapConfig) => void;
675
+ /** Callback when seat states change */
676
+ onStateChange?: (states: FirebaseSeatStates) => void;
677
+ /** Callback on any error */
678
+ onError?: (error: Error) => void;
679
+ }
680
+ interface UseRealtimeSeatMapResult {
681
+ /** The seat map configuration */
682
+ config: SeatMapConfig | null;
683
+ /** Whether initial loading is in progress */
684
+ loading: boolean;
685
+ /** Any error that occurred */
686
+ error: Error | null;
687
+ /** Seats reserved by current user (show as selected) */
688
+ myReservedSeats: string[];
689
+ /** Seats reserved by other users (show as reserved) */
690
+ otherReservedSeats: string[];
691
+ /** Seats unavailable for everyone */
692
+ unavailableSeats: string[];
693
+ /** @deprecated Use otherReservedSeats instead */
694
+ reservedSeats: string[];
695
+ /** Raw seat states map */
696
+ seatStates: FirebaseSeatStates | null;
697
+ /** Timestamp of last state update */
698
+ lastUpdated: number | null;
699
+ /** Manually refetch the config */
700
+ refetch: () => Promise<void>;
701
+ }
702
+ /**
703
+ * Combined hook for loading config and subscribing to real-time seat states
704
+ *
705
+ * @example
706
+ * ```tsx
707
+ * import { useRealtimeSeatMap, SeatMapViewer } from '@zonetrix/viewer';
708
+ *
709
+ * function BookingPage({ seatMapId, userId }) {
710
+ * const {
711
+ * config,
712
+ * myReservedSeats,
713
+ * otherReservedSeats,
714
+ * unavailableSeats,
715
+ * loading,
716
+ * error
717
+ * } = useRealtimeSeatMap({ seatMapId, userId });
718
+ *
719
+ * if (loading) return <LoadingSpinner />;
720
+ * if (error) return <ErrorMessage error={error} />;
721
+ * if (!config) return null;
722
+ *
723
+ * return (
724
+ * <SeatMapViewer
725
+ * config={config}
726
+ * myReservedSeats={myReservedSeats}
727
+ * reservedSeats={otherReservedSeats}
728
+ * unavailableSeats={unavailableSeats}
729
+ * onSeatSelect={handleSeatSelect}
730
+ * />
731
+ * );
732
+ * }
733
+ * ```
734
+ */
735
+ declare function useRealtimeSeatMap(options: UseRealtimeSeatMapOptions): UseRealtimeSeatMapResult;
736
+
737
+ export { type AlignmentGuide, type BookingSelection, type CanvasConfig, type CanvasState, type ColorSettings, DEFAULT_COLORS, type EditorMode, type FirebaseCanvasConfig, type FirebaseConfigResult, type FirebaseHookOptions, type FirebaseIndexEntry, FirebasePaths, type FirebasePosition, type FirebaseSeat, type FirebaseSeatMap, type FirebaseSeatMapConfig, type FirebaseSeatMapMeta, type FirebaseSeatState, type FirebaseSeatStateEntry, type FirebaseSeatStateValue, type FirebaseSeatStates, type FirebaseSeatStatesResult, type FirebaseStage, type ObjectConfig, type ObjectType, type RowPricing, type SeatData, type SeatMapConfig, type SeatMapMetadata, type SeatShape, type SeatState, type SectionConfig, type SerializedSeat, type SerializedSection, type SerializedStage, type StageConfig, type Tool, type UseFirebaseConfigOptions, type UseFirebaseConfigResult, type UseFirebaseSeatStatesOptions, type UseFirebaseSeatStatesResult, type UseRealtimeSeatMapOptions, type UseRealtimeSeatMapResult, type ValidationResult, applySeatStateOverrides, calculateAvailableSeats, calculateCapacity, calculateSeatPrice, clearFirebaseInstance, cloneConfig, createDefaultConfig, createIndexUpdates, decodeSeatId, deriveSeatArraysFromStates, downloadConfigAsFile, encodeSeatId, exportConfigAsJSON, extractSeatStates, formatDate, fromFirebaseSeatMap, fromFirebaseState, generateId, getFirebaseDatabase, getSelectedSeats, importConfigFromJSON, initializeFirebaseForViewer, isFirebaseInitialized, toFirebaseSeatMap, toFirebaseState, updateConfigTimestamp, useFirebaseConfig, useFirebaseSeatStates, useRealtimeSeatMap, validateSeatMapConfig };