export type Json =
  | string
  | number
  | boolean
  | null
  | { [key: string]: Json | undefined }
  | Json[]

export type Database = {
  // Allows to automatically instantiate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "14.5"
  }
  public: {
    Tables: {
      attendance: {
        Row: {
          check_in_at: string
          check_in_lat: number | null
          check_in_lng: number | null
          check_out_at: string | null
          check_out_lat: number | null
          check_out_lng: number | null
          created_at: string
          created_by: string | null
          duty_post_id: string | null
          face_photo_url: string | null
          guard_id: string
          id: string
          location: string | null
          method: Database["public"]["Enums"]["attendance_method"]
          notes: string | null
          qr_code: string | null
          shift: string | null
          status: Database["public"]["Enums"]["attendance_status"]
          updated_at: string
        }
        Insert: {
          check_in_at?: string
          check_in_lat?: number | null
          check_in_lng?: number | null
          check_out_at?: string | null
          check_out_lat?: number | null
          check_out_lng?: number | null
          created_at?: string
          created_by?: string | null
          duty_post_id?: string | null
          face_photo_url?: string | null
          guard_id: string
          id?: string
          location?: string | null
          method?: Database["public"]["Enums"]["attendance_method"]
          notes?: string | null
          qr_code?: string | null
          shift?: string | null
          status?: Database["public"]["Enums"]["attendance_status"]
          updated_at?: string
        }
        Update: {
          check_in_at?: string
          check_in_lat?: number | null
          check_in_lng?: number | null
          check_out_at?: string | null
          check_out_lat?: number | null
          check_out_lng?: number | null
          created_at?: string
          created_by?: string | null
          duty_post_id?: string | null
          face_photo_url?: string | null
          guard_id?: string
          id?: string
          location?: string | null
          method?: Database["public"]["Enums"]["attendance_method"]
          notes?: string | null
          qr_code?: string | null
          shift?: string | null
          status?: Database["public"]["Enums"]["attendance_status"]
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "attendance_duty_post_id_fkey"
            columns: ["duty_post_id"]
            isOneToOne: false
            referencedRelation: "duty_posts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "attendance_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      contact_messages: {
        Row: {
          created_at: string
          email: string
          id: string
          message: string
          name: string
        }
        Insert: {
          created_at?: string
          email: string
          id?: string
          message: string
          name: string
        }
        Update: {
          created_at?: string
          email?: string
          id?: string
          message?: string
          name?: string
        }
        Relationships: []
      }
      duty_posts: {
        Row: {
          address: string | null
          client_name: string | null
          contact_person: string | null
          contact_phone: string | null
          created_at: string
          created_by: string | null
          geofence_radius_m: number
          id: string
          latitude: number | null
          longitude: number | null
          name: string
          notes: string | null
          status: string
          supervisor_id: string | null
          updated_at: string
        }
        Insert: {
          address?: string | null
          client_name?: string | null
          contact_person?: string | null
          contact_phone?: string | null
          created_at?: string
          created_by?: string | null
          geofence_radius_m?: number
          id?: string
          latitude?: number | null
          longitude?: number | null
          name: string
          notes?: string | null
          status?: string
          supervisor_id?: string | null
          updated_at?: string
        }
        Update: {
          address?: string | null
          client_name?: string | null
          contact_person?: string | null
          contact_phone?: string | null
          created_at?: string
          created_by?: string | null
          geofence_radius_m?: number
          id?: string
          latitude?: number | null
          longitude?: number | null
          name?: string
          notes?: string | null
          status?: string
          supervisor_id?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      duty_rosters: {
        Row: {
          created_at: string
          created_by: string | null
          duty_post_id: string | null
          guard_id: string
          id: string
          location: string | null
          notes: string | null
          shift_date: string
          shift_end: string
          shift_start: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          duty_post_id?: string | null
          guard_id: string
          id?: string
          location?: string | null
          notes?: string | null
          shift_date: string
          shift_end: string
          shift_start: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          duty_post_id?: string | null
          guard_id?: string
          id?: string
          location?: string | null
          notes?: string | null
          shift_date?: string
          shift_end?: string
          shift_start?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "duty_rosters_duty_post_id_fkey"
            columns: ["duty_post_id"]
            isOneToOne: false
            referencedRelation: "duty_posts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "duty_rosters_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      guard_locations: {
        Row: {
          accuracy: number | null
          battery: number | null
          guard_id: string
          heading: number | null
          latitude: number
          longitude: number
          speed: number | null
          updated_at: string
        }
        Insert: {
          accuracy?: number | null
          battery?: number | null
          guard_id: string
          heading?: number | null
          latitude: number
          longitude: number
          speed?: number | null
          updated_at?: string
        }
        Update: {
          accuracy?: number | null
          battery?: number | null
          guard_id?: string
          heading?: number | null
          latitude?: number
          longitude?: number
          speed?: number | null
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "guard_locations_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: true
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      incident_reports: {
        Row: {
          attachments: Json
          created_at: string
          description: string
          duty_post_id: string | null
          guard_id: string | null
          id: string
          location: string | null
          occurred_at: string
          reporter_id: string
          resolution_notes: string | null
          resolved_at: string | null
          resolved_by: string | null
          severity: string
          status: string
          title: string
          updated_at: string
        }
        Insert: {
          attachments?: Json
          created_at?: string
          description: string
          duty_post_id?: string | null
          guard_id?: string | null
          id?: string
          location?: string | null
          occurred_at?: string
          reporter_id: string
          resolution_notes?: string | null
          resolved_at?: string | null
          resolved_by?: string | null
          severity?: string
          status?: string
          title: string
          updated_at?: string
        }
        Update: {
          attachments?: Json
          created_at?: string
          description?: string
          duty_post_id?: string | null
          guard_id?: string | null
          id?: string
          location?: string | null
          occurred_at?: string
          reporter_id?: string
          resolution_notes?: string | null
          resolved_at?: string | null
          resolved_by?: string | null
          severity?: string
          status?: string
          title?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "incident_reports_duty_post_id_fkey"
            columns: ["duty_post_id"]
            isOneToOne: false
            referencedRelation: "duty_posts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "incident_reports_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      inventory_items: {
        Row: {
          assigned_guard_id: string | null
          assigned_post_id: string | null
          category: string
          condition: Database["public"]["Enums"]["inventory_condition"]
          created_at: string
          id: string
          name: string
          notes: string | null
          purchase_date: string | null
          quantity: number
          serial_number: string | null
          status: Database["public"]["Enums"]["inventory_status"]
          updated_at: string
        }
        Insert: {
          assigned_guard_id?: string | null
          assigned_post_id?: string | null
          category?: string
          condition?: Database["public"]["Enums"]["inventory_condition"]
          created_at?: string
          id?: string
          name: string
          notes?: string | null
          purchase_date?: string | null
          quantity?: number
          serial_number?: string | null
          status?: Database["public"]["Enums"]["inventory_status"]
          updated_at?: string
        }
        Update: {
          assigned_guard_id?: string | null
          assigned_post_id?: string | null
          category?: string
          condition?: Database["public"]["Enums"]["inventory_condition"]
          created_at?: string
          id?: string
          name?: string
          notes?: string | null
          purchase_date?: string | null
          quantity?: number
          serial_number?: string | null
          status?: Database["public"]["Enums"]["inventory_status"]
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "inventory_items_assigned_guard_id_fkey"
            columns: ["assigned_guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "inventory_items_assigned_post_id_fkey"
            columns: ["assigned_post_id"]
            isOneToOne: false
            referencedRelation: "duty_posts"
            referencedColumns: ["id"]
          },
        ]
      }
      leave_requests: {
        Row: {
          created_at: string
          created_by: string | null
          days: number
          end_date: string
          guard_id: string
          id: string
          leave_type: Database["public"]["Enums"]["leave_type"]
          reason: string | null
          reviewed_at: string | null
          reviewer_id: string | null
          reviewer_note: string | null
          start_date: string
          status: Database["public"]["Enums"]["leave_status"]
          updated_at: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          days: number
          end_date: string
          guard_id: string
          id?: string
          leave_type?: Database["public"]["Enums"]["leave_type"]
          reason?: string | null
          reviewed_at?: string | null
          reviewer_id?: string | null
          reviewer_note?: string | null
          start_date: string
          status?: Database["public"]["Enums"]["leave_status"]
          updated_at?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          days?: number
          end_date?: string
          guard_id?: string
          id?: string
          leave_type?: Database["public"]["Enums"]["leave_type"]
          reason?: string | null
          reviewed_at?: string | null
          reviewer_id?: string | null
          reviewer_note?: string | null
          start_date?: string
          status?: Database["public"]["Enums"]["leave_status"]
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "leave_requests_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      motorcycles: {
        Row: {
          assigned_guard_id: string | null
          created_at: string
          created_by: string | null
          id: string
          model: string | null
          notes: string | null
          odometer_km: number
          registration_number: string
          status: string
          updated_at: string
        }
        Insert: {
          assigned_guard_id?: string | null
          created_at?: string
          created_by?: string | null
          id?: string
          model?: string | null
          notes?: string | null
          odometer_km?: number
          registration_number: string
          status?: string
          updated_at?: string
        }
        Update: {
          assigned_guard_id?: string | null
          created_at?: string
          created_by?: string | null
          id?: string
          model?: string | null
          notes?: string | null
          odometer_km?: number
          registration_number?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "motorcycles_assigned_guard_id_fkey"
            columns: ["assigned_guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      patrol_logs: {
        Row: {
          created_at: string
          created_by: string
          distance_km: number | null
          end_odometer: number | null
          ended_at: string | null
          fuel_liters: number | null
          guard_id: string | null
          id: string
          incidents: string | null
          motorcycle_id: string
          notes: string | null
          route_id: string | null
          start_odometer: number | null
          started_at: string
          status: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          created_by: string
          distance_km?: number | null
          end_odometer?: number | null
          ended_at?: string | null
          fuel_liters?: number | null
          guard_id?: string | null
          id?: string
          incidents?: string | null
          motorcycle_id: string
          notes?: string | null
          route_id?: string | null
          start_odometer?: number | null
          started_at?: string
          status?: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          created_by?: string
          distance_km?: number | null
          end_odometer?: number | null
          ended_at?: string | null
          fuel_liters?: number | null
          guard_id?: string | null
          id?: string
          incidents?: string | null
          motorcycle_id?: string
          notes?: string | null
          route_id?: string | null
          start_odometer?: number | null
          started_at?: string
          status?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "patrol_logs_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "patrol_logs_motorcycle_id_fkey"
            columns: ["motorcycle_id"]
            isOneToOne: false
            referencedRelation: "motorcycles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "patrol_logs_route_id_fkey"
            columns: ["route_id"]
            isOneToOne: false
            referencedRelation: "patrol_routes"
            referencedColumns: ["id"]
          },
        ]
      }
      patrol_routes: {
        Row: {
          active: boolean
          checkpoints: Json
          created_at: string
          created_by: string | null
          description: string | null
          estimated_duration_minutes: number | null
          id: string
          name: string
          updated_at: string
        }
        Insert: {
          active?: boolean
          checkpoints?: Json
          created_at?: string
          created_by?: string | null
          description?: string | null
          estimated_duration_minutes?: number | null
          id?: string
          name: string
          updated_at?: string
        }
        Update: {
          active?: boolean
          checkpoints?: Json
          created_at?: string
          created_by?: string | null
          description?: string | null
          estimated_duration_minutes?: number | null
          id?: string
          name?: string
          updated_at?: string
        }
        Relationships: []
      }
      profiles: {
        Row: {
          created_at: string
          full_name: string | null
          id: string
          phone: string | null
          updated_at: string
        }
        Insert: {
          created_at?: string
          full_name?: string | null
          id: string
          phone?: string | null
          updated_at?: string
        }
        Update: {
          created_at?: string
          full_name?: string | null
          id?: string
          phone?: string | null
          updated_at?: string
        }
        Relationships: []
      }
      qr_posts: {
        Row: {
          created_at: string
          created_by: string | null
          id: string
          name: string
          notes: string | null
          payload: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          created_by?: string | null
          id?: string
          name: string
          notes?: string | null
          payload: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          created_by?: string | null
          id?: string
          name?: string
          notes?: string | null
          payload?: string
          updated_at?: string
        }
        Relationships: []
      }
      salary_sheets: {
        Row: {
          basic: number
          created_at: string
          deduction: number
          duty_hours: number
          guard_id: string
          id: string
          month: string
          notes: string | null
          ot: number
          updated_at: string
        }
        Insert: {
          basic?: number
          created_at?: string
          deduction?: number
          duty_hours?: number
          guard_id: string
          id?: string
          month: string
          notes?: string | null
          ot?: number
          updated_at?: string
        }
        Update: {
          basic?: number
          created_at?: string
          deduction?: number
          duty_hours?: number
          guard_id?: string
          id?: string
          month?: string
          notes?: string | null
          ot?: number
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "salary_sheets_guard_id_fkey"
            columns: ["guard_id"]
            isOneToOne: false
            referencedRelation: "security_guards"
            referencedColumns: ["id"]
          },
        ]
      }
      security_guards: {
        Row: {
          address: string | null
          created_at: string
          created_by: string | null
          date_joined: string
          date_of_birth: string | null
          email: string | null
          emergency_contact_name: string | null
          emergency_contact_phone: string | null
          employee_id: string
          full_name: string
          id: string
          national_id: string | null
          notes: string | null
          phone: string | null
          status: string
          updated_at: string
          updated_by: string | null
        }
        Insert: {
          address?: string | null
          created_at?: string
          created_by?: string | null
          date_joined?: string
          date_of_birth?: string | null
          email?: string | null
          emergency_contact_name?: string | null
          emergency_contact_phone?: string | null
          employee_id: string
          full_name: string
          id?: string
          national_id?: string | null
          notes?: string | null
          phone?: string | null
          status?: string
          updated_at?: string
          updated_by?: string | null
        }
        Update: {
          address?: string | null
          created_at?: string
          created_by?: string | null
          date_joined?: string
          date_of_birth?: string | null
          email?: string | null
          emergency_contact_name?: string | null
          emergency_contact_phone?: string | null
          employee_id?: string
          full_name?: string
          id?: string
          national_id?: string | null
          notes?: string | null
          phone?: string | null
          status?: string
          updated_at?: string
          updated_by?: string | null
        }
        Relationships: []
      }
      sos_alerts: {
        Row: {
          accuracy: number | null
          created_at: string
          id: string
          lat: number | null
          lng: number | null
          message: string | null
          resolved_at: string | null
          resolved_by: string | null
          status: string
          updated_at: string
          user_id: string
        }
        Insert: {
          accuracy?: number | null
          created_at?: string
          id?: string
          lat?: number | null
          lng?: number | null
          message?: string | null
          resolved_at?: string | null
          resolved_by?: string | null
          status?: string
          updated_at?: string
          user_id: string
        }
        Update: {
          accuracy?: number | null
          created_at?: string
          id?: string
          lat?: number | null
          lng?: number | null
          message?: string | null
          resolved_at?: string | null
          resolved_by?: string | null
          status?: string
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      supervisor_locations: {
        Row: {
          accuracy: number | null
          battery: number | null
          heading: number | null
          latitude: number
          longitude: number
          speed: number | null
          updated_at: string
          user_id: string
        }
        Insert: {
          accuracy?: number | null
          battery?: number | null
          heading?: number | null
          latitude: number
          longitude: number
          speed?: number | null
          updated_at?: string
          user_id: string
        }
        Update: {
          accuracy?: number | null
          battery?: number | null
          heading?: number | null
          latitude?: number
          longitude?: number
          speed?: number | null
          updated_at?: string
          user_id?: string
        }
        Relationships: []
      }
      supervisor_visits: {
        Row: {
          created_at: string
          duty_post_id: string
          id: string
          latitude: number | null
          longitude: number | null
          notes: string | null
          rating: number | null
          status: Database["public"]["Enums"]["visit_status"]
          supervisor_id: string | null
          updated_at: string
          visited_at: string
        }
        Insert: {
          created_at?: string
          duty_post_id: string
          id?: string
          latitude?: number | null
          longitude?: number | null
          notes?: string | null
          rating?: number | null
          status?: Database["public"]["Enums"]["visit_status"]
          supervisor_id?: string | null
          updated_at?: string
          visited_at?: string
        }
        Update: {
          created_at?: string
          duty_post_id?: string
          id?: string
          latitude?: number | null
          longitude?: number | null
          notes?: string | null
          rating?: number | null
          status?: Database["public"]["Enums"]["visit_status"]
          supervisor_id?: string | null
          updated_at?: string
          visited_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "supervisor_visits_duty_post_id_fkey"
            columns: ["duty_post_id"]
            isOneToOne: false
            referencedRelation: "duty_posts"
            referencedColumns: ["id"]
          },
        ]
      }
      user_roles: {
        Row: {
          created_at: string
          id: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Insert: {
          created_at?: string
          id?: string
          role: Database["public"]["Enums"]["app_role"]
          user_id: string
        }
        Update: {
          created_at?: string
          id?: string
          role?: Database["public"]["Enums"]["app_role"]
          user_id?: string
        }
        Relationships: []
      }
    }
    Views: {
      [_ in never]: never
    }
    Functions: {
      auto_checkout_expired_shifts: { Args: never; Returns: number }
      has_any_role: {
        Args: {
          _roles: Database["public"]["Enums"]["app_role"][]
          _user_id: string
        }
        Returns: boolean
      }
      has_role: {
        Args: {
          _role: Database["public"]["Enums"]["app_role"]
          _user_id: string
        }
        Returns: boolean
      }
    }
    Enums: {
      app_role:
        | "super_admin"
        | "company_admin"
        | "ops_manager"
        | "supervisor"
        | "guard"
        | "client"
        | "admin"
        | "security_officer"
      attendance_method: "qr" | "gps" | "manual" | "face"
      attendance_status: "checked_in" | "checked_out" | "flagged"
      inventory_condition: "new" | "good" | "fair" | "poor" | "damaged"
      inventory_status:
        | "available"
        | "assigned"
        | "maintenance"
        | "retired"
        | "lost"
      leave_status: "pending" | "approved" | "rejected" | "cancelled"
      leave_type: "casual" | "sick" | "annual" | "unpaid" | "other"
      visit_status: "ok" | "issue" | "critical"
    }
    CompositeTypes: {
      [_ in never]: never
    }
  }
}

type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">

type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]

export type Tables<
  DefaultSchemaTableNameOrOptions extends
    | keyof (DefaultSchema["Tables"] & DefaultSchema["Views"])
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
        DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? (DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"] &
      DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Views"])[TableName] extends {
      Row: infer R
    }
    ? R
    : never
  : DefaultSchemaTableNameOrOptions extends keyof (DefaultSchema["Tables"] &
        DefaultSchema["Views"])
    ? (DefaultSchema["Tables"] &
        DefaultSchema["Views"])[DefaultSchemaTableNameOrOptions] extends {
        Row: infer R
      }
      ? R
      : never
    : never

export type TablesInsert<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Insert: infer I
    }
    ? I
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Insert: infer I
      }
      ? I
      : never
    : never

export type TablesUpdate<
  DefaultSchemaTableNameOrOptions extends
    | keyof DefaultSchema["Tables"]
    | { schema: keyof DatabaseWithoutInternals },
  TableName extends DefaultSchemaTableNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"]
    : never = never,
> = DefaultSchemaTableNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaTableNameOrOptions["schema"]]["Tables"][TableName] extends {
      Update: infer U
    }
    ? U
    : never
  : DefaultSchemaTableNameOrOptions extends keyof DefaultSchema["Tables"]
    ? DefaultSchema["Tables"][DefaultSchemaTableNameOrOptions] extends {
        Update: infer U
      }
      ? U
      : never
    : never

export type Enums<
  DefaultSchemaEnumNameOrOptions extends
    | keyof DefaultSchema["Enums"]
    | { schema: keyof DatabaseWithoutInternals },
  EnumName extends DefaultSchemaEnumNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"]
    : never = never,
> = DefaultSchemaEnumNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[DefaultSchemaEnumNameOrOptions["schema"]]["Enums"][EnumName]
  : DefaultSchemaEnumNameOrOptions extends keyof DefaultSchema["Enums"]
    ? DefaultSchema["Enums"][DefaultSchemaEnumNameOrOptions]
    : never

export type CompositeTypes<
  PublicCompositeTypeNameOrOptions extends
    | keyof DefaultSchema["CompositeTypes"]
    | { schema: keyof DatabaseWithoutInternals },
  CompositeTypeName extends PublicCompositeTypeNameOrOptions extends {
    schema: keyof DatabaseWithoutInternals
  }
    ? keyof DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"]
    : never = never,
> = PublicCompositeTypeNameOrOptions extends {
  schema: keyof DatabaseWithoutInternals
}
  ? DatabaseWithoutInternals[PublicCompositeTypeNameOrOptions["schema"]]["CompositeTypes"][CompositeTypeName]
  : PublicCompositeTypeNameOrOptions extends keyof DefaultSchema["CompositeTypes"]
    ? DefaultSchema["CompositeTypes"][PublicCompositeTypeNameOrOptions]
    : never

export const Constants = {
  public: {
    Enums: {
      app_role: [
        "super_admin",
        "company_admin",
        "ops_manager",
        "supervisor",
        "guard",
        "client",
        "admin",
        "security_officer",
      ],
      attendance_method: ["qr", "gps", "manual", "face"],
      attendance_status: ["checked_in", "checked_out", "flagged"],
      inventory_condition: ["new", "good", "fair", "poor", "damaged"],
      inventory_status: [
        "available",
        "assigned",
        "maintenance",
        "retired",
        "lost",
      ],
      leave_status: ["pending", "approved", "rejected", "cancelled"],
      leave_type: ["casual", "sick", "annual", "unpaid", "other"],
      visit_status: ["ok", "issue", "critical"],
    },
  },
} as const
