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: {
      comments: {
        Row: {
          content: string
          created_at: string
          id: string
          step_id: string
          trip_id: string
          user_id: string
          user_name: string
        }
        Insert: {
          content: string
          created_at?: string
          id?: string
          step_id: string
          trip_id?: string
          user_id?: string
          user_name?: string
        }
        Update: {
          content?: string
          created_at?: string
          id?: string
          step_id?: string
          trip_id?: string
          user_id?: string
          user_name?: string
        }
        Relationships: [
          {
            foreignKeyName: "comments_step_id_fkey"
            columns: ["step_id"]
            isOneToOne: false
            referencedRelation: "trip_steps"
            referencedColumns: ["id"]
          },
        ]
      }
      documents: {
        Row: {
          id: string
          mime_type: string | null
          name: string
          size_bytes: number | null
          step_id: string | null
          trip_id: string
          type: string
          uploaded_at: string
          uploaded_by: string | null
          url: string
        }
        Insert: {
          id?: string
          mime_type?: string | null
          name: string
          size_bytes?: number | null
          step_id?: string | null
          trip_id: string
          type: string
          uploaded_at?: string
          uploaded_by?: string | null
          url: string
        }
        Update: {
          id?: string
          mime_type?: string | null
          name?: string
          size_bytes?: number | null
          step_id?: string | null
          trip_id?: string
          type?: string
          uploaded_at?: string
          uploaded_by?: string | null
          url?: string
        }
        Relationships: [
          {
            foreignKeyName: "documents_step_id_fkey"
            columns: ["step_id"]
            isOneToOne: false
            referencedRelation: "trip_steps"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "documents_trip_id_fkey"
            columns: ["trip_id"]
            isOneToOne: false
            referencedRelation: "trips"
            referencedColumns: ["id"]
          },
        ]
      }
      invitations: {
        Row: {
          accepted_at: string | null
          accepted_by: string | null
          created_at: string
          email: string
          expires_at: string
          id: string
          planner_id: string
          status: string
          trip_id: string
        }
        Insert: {
          accepted_at?: string | null
          accepted_by?: string | null
          created_at?: string
          email: string
          expires_at?: string
          id?: string
          planner_id: string
          status?: string
          trip_id: string
        }
        Update: {
          accepted_at?: string | null
          accepted_by?: string | null
          created_at?: string
          email?: string
          expires_at?: string
          id?: string
          planner_id?: string
          status?: string
          trip_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "invitations_accepted_by_fkey"
            columns: ["accepted_by"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "invitations_planner_id_fkey"
            columns: ["planner_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "invitations_trip_id_fkey"
            columns: ["trip_id"]
            isOneToOne: false
            referencedRelation: "trips"
            referencedColumns: ["id"]
          },
        ]
      }
      profiles: {
        Row: {
          created_at: string
          email: string
          has_set_password: boolean | null
          id: string
          id_planner: string | null
          name: string
          role: string
        }
        Insert: {
          created_at?: string
          email: string
          has_set_password?: boolean | null
          id: string
          id_planner?: string | null
          name: string
          role: string
        }
        Update: {
          created_at?: string
          email?: string
          has_set_password?: boolean | null
          id?: string
          id_planner?: string | null
          name?: string
          role?: string
        }
        Relationships: [
          {
            foreignKeyName: "profiles_id_planner_fkey"
            columns: ["id_planner"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "profiles_id_planner_fkey"
            columns: ["id_planner"]
            isOneToOne: false
            referencedRelation: "profiles_safe"
            referencedColumns: ["id"]
          },
        ]
      }
      step_validations: {
        Row: {
          created_at: string
          status: string
          step_id: string
          traveler_id: string
          updated_at: string
        }
        Insert: {
          created_at?: string
          status?: string
          step_id: string
          traveler_id: string
          updated_at?: string
        }
        Update: {
          created_at?: string
          status?: string
          step_id?: string
          traveler_id?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "step_validations_step_id_fkey"
            columns: ["step_id"]
            isOneToOne: false
            referencedRelation: "trip_steps"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "step_validations_traveler_id_fkey"
            columns: ["traveler_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      trip_members: {
        Row: {
          created_at: string
          invitation_id: string | null
          joined_at: string
          source: string
          status: string
          trip_id: string
          updated_at: string
          user_id: string
        }
        Insert: {
          created_at?: string
          invitation_id?: string | null
          joined_at?: string
          source?: string
          status?: string
          trip_id: string
          updated_at?: string
          user_id: string
        }
        Update: {
          created_at?: string
          invitation_id?: string | null
          joined_at?: string
          source?: string
          status?: string
          trip_id?: string
          updated_at?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "trip_members_invitation_id_fkey"
            columns: ["invitation_id"]
            isOneToOne: false
            referencedRelation: "invitations"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "trip_members_trip_id_fkey"
            columns: ["trip_id"]
            isOneToOne: false
            referencedRelation: "trips"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "trip_members_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
        ]
      }
      trip_steps: {
        Row: {
          accommodation_name: string | null
          activity: string
          activity_type: string | null
          arrival_name: string | null
          break_purpose: string | null
          budget: string | null
          check_in_time: string | null
          check_out_time: string | null
          created_at: string
          cuisine_type: string | null
          day: number
          departure_name: string | null
          description: string | null
          distance: string | null
          end_time: string | null
          estimated_duration: string | null
          guide_name: string | null
          id: string
          image_path: string | null
          internal_notes: string | null
          is_published: boolean | null
          is_rejected: boolean | null
          is_validated: boolean | null
          validation_status: "pending" | "approved" | "rejected"
          link: string | null
          links: Json | null
          location: string
          price: number | null
          rating: number | null
          reference_number: string | null
          reservation_number: string | null
          restaurant_name: string | null
          room_type: string | null
          start_time: string | null
          step_type: string | null
          time: string
          transport_type: string | null
          trip_id: string
          updated_at: string
          walking_level: string | null
        }
        Insert: {
          accommodation_name?: string | null
          activity: string
          activity_type?: string | null
          arrival_name?: string | null
          break_purpose?: string | null
          budget?: string | null
          check_in_time?: string | null
          check_out_time?: string | null
          created_at?: string
          cuisine_type?: string | null
          day: number
          departure_name?: string | null
          description?: string | null
          distance?: string | null
          end_time?: string | null
          estimated_duration?: string | null
          guide_name?: string | null
          id?: string
          image_path?: string | null
          internal_notes?: string | null
          is_published?: boolean | null
          is_rejected?: boolean | null
          is_validated?: boolean | null
          validation_status?: "pending" | "approved" | "rejected"
          link?: string | null
          links?: Json | null
          location: string
          price?: number | null
          rating?: number | null
          reference_number?: string | null
          reservation_number?: string | null
          restaurant_name?: string | null
          room_type?: string | null
          start_time?: string | null
          step_type?: string | null
          time: string
          transport_type?: string | null
          trip_id: string
          updated_at?: string
          walking_level?: string | null
        }
        Update: {
          accommodation_name?: string | null
          activity?: string
          activity_type?: string | null
          arrival_name?: string | null
          break_purpose?: string | null
          budget?: string | null
          check_in_time?: string | null
          check_out_time?: string | null
          created_at?: string
          cuisine_type?: string | null
          day?: number
          departure_name?: string | null
          description?: string | null
          distance?: string | null
          end_time?: string | null
          estimated_duration?: string | null
          guide_name?: string | null
          id?: string
          image_path?: string | null
          internal_notes?: string | null
          is_published?: boolean | null
          is_rejected?: boolean | null
          is_validated?: boolean | null
          validation_status?: "pending" | "approved" | "rejected"
          link?: string | null
          links?: Json | null
          location?: string
          price?: number | null
          rating?: number | null
          reference_number?: string | null
          reservation_number?: string | null
          restaurant_name?: string | null
          room_type?: string | null
          start_time?: string | null
          step_type?: string | null
          time?: string
          transport_type?: string | null
          trip_id?: string
          updated_at?: string
          walking_level?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "trip_steps_trip_id_fkey"
            columns: ["trip_id"]
            isOneToOne: false
            referencedRelation: "trips"
            referencedColumns: ["id"]
          },
        ]
      }
      trips: {
        Row: {
          cover_url: string | null
          created_at: string
          destination: string
          end_date: string
          id: string
          planner_id: string
          start_date: string
          title: string
          traveler_email: string | null
          traveler_id: string | null
          traveler_name: string
          updated_at: string
        }
        Insert: {
          cover_url?: string | null
          created_at?: string
          destination: string
          end_date: string
          id?: string
          planner_id: string
          start_date: string
          title: string
          traveler_email?: string | null
          traveler_id?: string | null
          traveler_name: string
          updated_at?: string
        }
        Update: {
          cover_url?: string | null
          created_at?: string
          destination?: string
          end_date?: string
          id?: string
          planner_id?: string
          start_date?: string
          title?: string
          traveler_email?: string | null
          traveler_id?: string | null
          traveler_name?: string
          updated_at?: string
        }
        Relationships: [
          {
            foreignKeyName: "fk_trips_planners"
            columns: ["planner_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "fk_trips_planners"
            columns: ["planner_id"]
            isOneToOne: false
            referencedRelation: "profiles_safe"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "fk_trips_travelers"
            columns: ["traveler_id"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "fk_trips_travelers"
            columns: ["traveler_id"]
            isOneToOne: false
            referencedRelation: "profiles_safe"
            referencedColumns: ["id"]
          },
        ]
      }
    }
    Views: {
      trip_invitation_status: {
        Row: {
          accepted_at: string | null
          created_at: string
          email: string
          expires_at: string
          id: string
          status: string
          trip_id: string
        }
        Relationships: []
      }
      profiles_safe: {
        Row: {
          email: string | null
          has_set_password: boolean | null
          id: string | null
          id_planner: string | null
          name: string | null
          role: string | null
        }
        Insert: {
          email?: string | null
          has_set_password?: boolean | null
          id?: string | null
          id_planner?: string | null
          name?: string | null
          role?: string | null
        }
        Update: {
          email?: string | null
          has_set_password?: boolean | null
          id?: string | null
          id_planner?: string | null
          name?: string | null
          role?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "profiles_id_planner_fkey"
            columns: ["id_planner"]
            isOneToOne: false
            referencedRelation: "profiles"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "profiles_id_planner_fkey"
            columns: ["id_planner"]
            isOneToOne: false
            referencedRelation: "profiles_safe"
            referencedColumns: ["id"]
          },
        ]
      }
    }
    Functions: {
      accept_trip_invitation: { Args: never; Returns: string }
      assign_existing_traveler: {
        Args: { p_trip_id: string; p_traveler_id: string }
        Returns: string
      }
      check_trip_access: { Args: { trip_id_param: string }; Returns: boolean }
      check_trip_owner: { Args: { trip_id_param: string }; Returns: boolean }
      is_confirmed_user: { Args: never; Returns: boolean }
    }
    Enums: {
      [_ in never]: never
    }
    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: {},
  },
} as const
