import * as firebase from "firebase/app" ; /**
 * Collections
 */ export type FirebaseCollections = { cubes : FirebaseCubeState ; terminals : TerminalState ; apps : AppsState ; } ; /**
 * Dashboard
 */ export interface FirebaseCubeState { status : "online" | "offline" ; statusChangedAt ? : Date | undefined ; essentialSystemInfo ? : EssentialSystemInfo | undefined ; fullSystemInfoJson ? : string | undefined ; } /**
 * System Infos
 */ export const EssentialSystemInfo = ( o ) => { return { ... o } as const ; } ; export interface EssentialSystemInfo extends ReturnType < typeof EssentialSystemInfo > { } export const CubeSystemInfo = ( o ) => { return { ... o } as const ; } ; export interface CubeSystemInfo extends ReturnType < typeof CubeSystemInfo > { } /**
 * Terminal
 */ export const TerminalState = ( o ) => { return { ... o } as const ; } ; export interface TerminalState extends ReturnType < typeof TerminalState > { } export const TerminalCommandExecution = ( o ) => { return { ... o } as const ; } ; export interface TerminalCommandExecution extends ReturnType < typeof TerminalCommandExecution > { } /**
 * Apps
 */ export type Apps = { rpiDemos : AppState ; video : AppState ; cubemap : AppState ; paint : PaintAppState ; debug : AppState ; sparkle : AppState ; sprinkles : AppState ; particles : AppState ; particleFlow : AppState ; tilt : AppState ; maze : AppState ; } ; export type AppNames = keyof Apps ; export type AppStates = Apps [ AppNames ] ; export const AppsState = ( o ) => { return { ... o } as const ; } ; export interface AppsState extends ReturnType < typeof AppsState > { } export const AppExecution = ( o ) => { return { ... o } as const ; } ; export interface AppExecution extends ReturnType < typeof AppExecution > { } /**
 * App States
 */ export const AppState = ( o ) => ( { ... o } as const ) ; export interface AppState extends ReturnType < typeof AppState > { } export const PaintAppState = ( o ) => ( { ... o } as const ) ; export interface PaintAppState extends ReturnType < typeof PaintAppState > { } /**
 * App Commands
 */ export type AppsCommands = StartAppCommand | StopAppCommand | UpdateAppState ; export const StartAppCommand = ( o ) => ( { kind : "start-app" , ... o } as const ) ; export interface StartAppCommand extends ReturnType < typeof StartAppCommand > { } export const StopAppCommand = ( o ) => ( { kind : "stop-app" , ... o } as const ) ; export interface StopAppCommand extends ReturnType < typeof StopAppCommand > { } export const UpdateAppState = ( o ) => ( { kind : "update-app-state" , ... o } as const ) ; export interface UpdateAppState extends ReturnType < typeof UpdateAppState > { } /**
 * Utils
 */ export const dataConverter = { toFirestore ( value ) { if ( value === null || value === undefined ) return value ; if ( value instanceof Uint8Array ) { return firebase . firestore . Blob . fromUint8Array ( value ) ; } else if ( Array . isArray ( value ) ) { return value . map ( o => dataConverter . toFirestore ( o ) ) ; } else if ( typeof value == "object" ) { return Object . entries ( value ) . map ( k => [ k [ 0 ] , dataConverter . toFirestore ( k [ 1 ] ) ] as const ) . reduce ( ( accum , curr ) => ( { ... accum , [ curr [ 0 ] ] : curr [ 1 ] } ) , { } ) ; } return value ; } , fromFirestore ( snapshot , options ) { const data = snapshot . data ( options ) ! ; return fromFirestoreValue ( data ) ; } , } ; const fromFirestoreValue = ( value ) : any => { if ( value === null || value === undefined ) return value ; if ( value instanceof firebase . firestore . Blob ) { return value . toUint8Array ( ) ; } else if ( Array . isArray ( value ) ) { return value . map ( o => fromFirestoreValue ( o ) ) ; } else if ( typeof value == "object" ) { return Object . entries ( value ) . map ( k => [ k [ 0 ] , fromFirestoreValue ( k [ 1 ] ) ] as const ) . reduce ( ( accum , curr ) => ( { ... accum , [ curr [ 0 ] ] : curr [ 1 ] } ) , { } ) ; } return value ; } ;