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

export type Database = {
  // Allows to automatically instanciate createClient with right options
  // instead of createClient<Database, { PostgrestVersion: 'XX' }>(URL, KEY)
  __InternalSupabase: {
    PostgrestVersion: "12.2.3 (519615d)"
  }
  public: {
    Tables: {
      add_on_types: {
        Row: {
          auto_enable_conditions: Json | null
          category: string
          created_at: string | null
          description: string
          feature_flags: Json | null
          id: string
          is_active: boolean | null
          name: string
          price_cents: number
          pricing_type: string
          requires_setup: boolean | null
          slug: string
          sort_order: number | null
          updated_at: string | null
        }
        Insert: {
          auto_enable_conditions?: Json | null
          category?: string
          created_at?: string | null
          description: string
          feature_flags?: Json | null
          id?: string
          is_active?: boolean | null
          name: string
          price_cents: number
          pricing_type?: string
          requires_setup?: boolean | null
          slug: string
          sort_order?: number | null
          updated_at?: string | null
        }
        Update: {
          auto_enable_conditions?: Json | null
          category?: string
          created_at?: string | null
          description?: string
          feature_flags?: Json | null
          id?: string
          is_active?: boolean | null
          name?: string
          price_cents?: number
          pricing_type?: string
          requires_setup?: boolean | null
          slug?: string
          sort_order?: number | null
          updated_at?: string | null
        }
        Relationships: []
      }
      addon_types: {
        Row: {
          billing_type: string
          category: string
          created_at: string | null
          description: string | null
          features: Json | null
          icon_url: string | null
          id: string
          is_active: boolean | null
          name: string
          price_monthly: number | null
          price_one_time: number | null
          sort_order: number | null
        }
        Insert: {
          billing_type: string
          category: string
          created_at?: string | null
          description?: string | null
          features?: Json | null
          icon_url?: string | null
          id?: string
          is_active?: boolean | null
          name: string
          price_monthly?: number | null
          price_one_time?: number | null
          sort_order?: number | null
        }
        Update: {
          billing_type?: string
          category?: string
          created_at?: string | null
          description?: string | null
          features?: Json | null
          icon_url?: string | null
          id?: string
          is_active?: boolean | null
          name?: string
          price_monthly?: number | null
          price_one_time?: number | null
          sort_order?: number | null
        }
        Relationships: []
      }
      admin_settings: {
        Row: {
          description: string | null
          id: string
          setting_key: string
          setting_value: Json
          updated_at: string | null
          updated_by: string | null
        }
        Insert: {
          description?: string | null
          id?: string
          setting_key: string
          setting_value: Json
          updated_at?: string | null
          updated_by?: string | null
        }
        Update: {
          description?: string | null
          id?: string
          setting_key?: string
          setting_value?: Json
          updated_at?: string | null
          updated_by?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "admin_settings_updated_by_fkey"
            columns: ["updated_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
        ]
      }
      audit_logs: {
        Row: {
          action: string
          created_at: string | null
          id: string
          ip_address: unknown | null
          new_values: Json | null
          old_values: Json | null
          resource_id: string | null
          resource_type: string
          user_agent: string | null
          user_id: string | null
        }
        Insert: {
          action: string
          created_at?: string | null
          id?: string
          ip_address?: unknown | null
          new_values?: Json | null
          old_values?: Json | null
          resource_id?: string | null
          resource_type: string
          user_agent?: string | null
          user_id?: string | null
        }
        Update: {
          action?: string
          created_at?: string | null
          id?: string
          ip_address?: unknown | null
          new_values?: Json | null
          old_values?: Json | null
          resource_id?: string | null
          resource_type?: string
          user_agent?: string | null
          user_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "audit_logs_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
        ]
      }
      event_add_ons: {
        Row: {
          add_on_type_id: string
          created_at: string | null
          event_id: string
          expires_at: string | null
          id: string
          metadata: Json | null
          organization_id: string
          purchase_price_cents: number
          purchased_at: string | null
          status: string | null
          stripe_payment_intent_id: string | null
        }
        Insert: {
          add_on_type_id: string
          created_at?: string | null
          event_id: string
          expires_at?: string | null
          id?: string
          metadata?: Json | null
          organization_id: string
          purchase_price_cents: number
          purchased_at?: string | null
          status?: string | null
          stripe_payment_intent_id?: string | null
        }
        Update: {
          add_on_type_id?: string
          created_at?: string | null
          event_id?: string
          expires_at?: string | null
          id?: string
          metadata?: Json | null
          organization_id?: string
          purchase_price_cents?: number
          purchased_at?: string | null
          status?: string | null
          stripe_payment_intent_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "event_add_ons_add_on_type_id_fkey"
            columns: ["add_on_type_id"]
            isOneToOne: false
            referencedRelation: "add_on_types"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "event_add_ons_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "event_add_ons_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      event_addons: {
        Row: {
          addon_type_id: string | null
          amount_paid: number | null
          created_at: string | null
          event_id: string | null
          expires_at: string | null
          id: string
          purchase_date: string | null
          purchased_by: string | null
          settings: Json | null
          status: string | null
          stripe_payment_intent_id: string | null
          stripe_subscription_id: string | null
        }
        Insert: {
          addon_type_id?: string | null
          amount_paid?: number | null
          created_at?: string | null
          event_id?: string | null
          expires_at?: string | null
          id?: string
          purchase_date?: string | null
          purchased_by?: string | null
          settings?: Json | null
          status?: string | null
          stripe_payment_intent_id?: string | null
          stripe_subscription_id?: string | null
        }
        Update: {
          addon_type_id?: string | null
          amount_paid?: number | null
          created_at?: string | null
          event_id?: string | null
          expires_at?: string | null
          id?: string
          purchase_date?: string | null
          purchased_by?: string | null
          settings?: Json | null
          status?: string | null
          stripe_payment_intent_id?: string | null
          stripe_subscription_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "event_addons_addon_type_id_fkey"
            columns: ["addon_type_id"]
            isOneToOne: false
            referencedRelation: "addon_types"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "event_addons_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "event_addons_purchased_by_fkey"
            columns: ["purchased_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
        ]
      }
      events: {
        Row: {
          availability_display_mode: string | null
          availability_messages: Json | null
          availability_threshold: number | null
          category: string | null
          created_at: string | null
          created_by: string
          description: string | null
          end_time: string | null
          external_source: string | null
          id: string
          image_url: string | null
          is_featured: boolean | null
          is_public: boolean | null
          is_published: boolean | null
          low_stock_threshold: number | null
          organization_id: string
          scanner_lock_created_at: string | null
          scanner_lock_created_by: string | null
          scanner_lock_enabled: boolean | null
          scanner_pin_hash: string | null
          seating_map_id: string | null
          seating_type: string | null
          show_sold_out: boolean | null
          slug: string
          start_time: string
          title: string
          venue: string
          venue_id: string | null
        }
        Insert: {
          availability_display_mode?: string | null
          availability_messages?: Json | null
          availability_threshold?: number | null
          category?: string | null
          created_at?: string | null
          created_by: string
          description?: string | null
          end_time?: string | null
          external_source?: string | null
          id?: string
          image_url?: string | null
          is_featured?: boolean | null
          is_public?: boolean | null
          is_published?: boolean | null
          low_stock_threshold?: number | null
          organization_id: string
          scanner_lock_created_at?: string | null
          scanner_lock_created_by?: string | null
          scanner_lock_enabled?: boolean | null
          scanner_pin_hash?: string | null
          seating_map_id?: string | null
          seating_type?: string | null
          show_sold_out?: boolean | null
          slug: string
          start_time: string
          title: string
          venue: string
          venue_id?: string | null
        }
        Update: {
          availability_display_mode?: string | null
          availability_messages?: Json | null
          availability_threshold?: number | null
          category?: string | null
          created_at?: string | null
          created_by?: string
          description?: string | null
          end_time?: string | null
          external_source?: string | null
          id?: string
          image_url?: string | null
          is_featured?: boolean | null
          is_public?: boolean | null
          is_published?: boolean | null
          low_stock_threshold?: number | null
          organization_id?: string
          scanner_lock_created_at?: string | null
          scanner_lock_created_by?: string | null
          scanner_lock_enabled?: boolean | null
          scanner_pin_hash?: string | null
          seating_map_id?: string | null
          seating_type?: string | null
          show_sold_out?: boolean | null
          slug?: string
          start_time?: string
          title?: string
          venue?: string
          venue_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "events_created_by_fkey"
            columns: ["created_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "events_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "events_scanner_lock_created_by_fkey"
            columns: ["scanner_lock_created_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "events_seating_map_id_fkey"
            columns: ["seating_map_id"]
            isOneToOne: false
            referencedRelation: "seating_maps"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "events_venue_id_fkey"
            columns: ["venue_id"]
            isOneToOne: false
            referencedRelation: "venues"
            referencedColumns: ["id"]
          },
        ]
      }
      inventory_pools: {
        Row: {
          allocated_capacity: number | null
          created_at: string | null
          description: string | null
          id: string
          is_active: boolean | null
          name: string
          organization_id: string
          total_capacity: number
        }
        Insert: {
          allocated_capacity?: number | null
          created_at?: string | null
          description?: string | null
          id?: string
          is_active?: boolean | null
          name: string
          organization_id: string
          total_capacity: number
        }
        Update: {
          allocated_capacity?: number | null
          created_at?: string | null
          description?: string | null
          id?: string
          is_active?: boolean | null
          name?: string
          organization_id?: string
          total_capacity?: number
        }
        Relationships: [
          {
            foreignKeyName: "inventory_pools_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      organization_subscriptions: {
        Row: {
          add_on_type_id: string
          created_at: string | null
          current_period_end: string
          current_period_start: string
          id: string
          organization_id: string
          status: string | null
          stripe_customer_id: string | null
          stripe_subscription_id: string | null
          updated_at: string | null
        }
        Insert: {
          add_on_type_id: string
          created_at?: string | null
          current_period_end: string
          current_period_start: string
          id?: string
          organization_id: string
          status?: string | null
          stripe_customer_id?: string | null
          stripe_subscription_id?: string | null
          updated_at?: string | null
        }
        Update: {
          add_on_type_id?: string
          created_at?: string | null
          current_period_end?: string
          current_period_start?: string
          id?: string
          organization_id?: string
          status?: string | null
          stripe_customer_id?: string | null
          stripe_subscription_id?: string | null
          updated_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "organization_subscriptions_add_on_type_id_fkey"
            columns: ["add_on_type_id"]
            isOneToOne: false
            referencedRelation: "add_on_types"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "organization_subscriptions_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      organizations: {
        Row: {
          created_at: string | null
          id: string
          logo: string | null
          name: string
          platform_fee_fixed: number | null
          platform_fee_notes: string | null
          platform_fee_percentage: number | null
          platform_fee_type: string | null
          stripe_account_id: string | null
        }
        Insert: {
          created_at?: string | null
          id?: string
          logo?: string | null
          name: string
          platform_fee_fixed?: number | null
          platform_fee_notes?: string | null
          platform_fee_percentage?: number | null
          platform_fee_type?: string | null
          stripe_account_id?: string | null
        }
        Update: {
          created_at?: string | null
          id?: string
          logo?: string | null
          name?: string
          platform_fee_fixed?: number | null
          platform_fee_notes?: string | null
          platform_fee_percentage?: number | null
          platform_fee_type?: string | null
          stripe_account_id?: string | null
        }
        Relationships: []
      }
      payouts: {
        Row: {
          created_at: string | null
          event_id: string
          fee: number
          gross: number
          id: string
          net: number
          stripe_transfer_id: string | null
        }
        Insert: {
          created_at?: string | null
          event_id: string
          fee: number
          gross: number
          id?: string
          net: number
          stripe_transfer_id?: string | null
        }
        Update: {
          created_at?: string | null
          event_id?: string
          fee?: number
          gross?: number
          id?: string
          net?: number
          stripe_transfer_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "payouts_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
        ]
      }
      presale_code_ticket_types: {
        Row: {
          id: string
          presale_code_id: string
          ticket_type_id: string
        }
        Insert: {
          id?: string
          presale_code_id: string
          ticket_type_id: string
        }
        Update: {
          id?: string
          presale_code_id?: string
          ticket_type_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "presale_code_ticket_types_presale_code_id_fkey"
            columns: ["presale_code_id"]
            isOneToOne: false
            referencedRelation: "presale_codes"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "presale_code_ticket_types_ticket_type_id_fkey"
            columns: ["ticket_type_id"]
            isOneToOne: false
            referencedRelation: "ticket_types"
            referencedColumns: ["id"]
          },
        ]
      }
      presale_code_uses: {
        Row: {
          customer_email: string
          customer_session: string | null
          discount_applied: number | null
          id: string
          presale_code_id: string
          purchase_attempt_id: string | null
          ticket_quantity: number
          used_at: string | null
        }
        Insert: {
          customer_email: string
          customer_session?: string | null
          discount_applied?: number | null
          id?: string
          presale_code_id: string
          purchase_attempt_id?: string | null
          ticket_quantity: number
          used_at?: string | null
        }
        Update: {
          customer_email?: string
          customer_session?: string | null
          discount_applied?: number | null
          id?: string
          presale_code_id?: string
          purchase_attempt_id?: string | null
          ticket_quantity?: number
          used_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "presale_code_uses_presale_code_id_fkey"
            columns: ["presale_code_id"]
            isOneToOne: false
            referencedRelation: "presale_codes"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "presale_code_uses_purchase_attempt_id_fkey"
            columns: ["purchase_attempt_id"]
            isOneToOne: false
            referencedRelation: "purchase_attempts"
            referencedColumns: ["id"]
          },
        ]
      }
      presale_codes: {
        Row: {
          code: string
          created_at: string | null
          created_by: string | null
          current_uses: number | null
          description: string | null
          discount_type: string | null
          discount_value: number | null
          event_id: string
          expires_at: string | null
          id: string
          is_active: boolean | null
          max_uses: number | null
          max_uses_per_customer: number | null
          name: string
          starts_at: string | null
        }
        Insert: {
          code: string
          created_at?: string | null
          created_by?: string | null
          current_uses?: number | null
          description?: string | null
          discount_type?: string | null
          discount_value?: number | null
          event_id: string
          expires_at?: string | null
          id?: string
          is_active?: boolean | null
          max_uses?: number | null
          max_uses_per_customer?: number | null
          name: string
          starts_at?: string | null
        }
        Update: {
          code?: string
          created_at?: string | null
          created_by?: string | null
          current_uses?: number | null
          description?: string | null
          discount_type?: string | null
          discount_value?: number | null
          event_id?: string
          expires_at?: string | null
          id?: string
          is_active?: boolean | null
          max_uses?: number | null
          max_uses_per_customer?: number | null
          name?: string
          starts_at?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "presale_codes_created_by_fkey"
            columns: ["created_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "presale_codes_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
        ]
      }
      purchase_attempt_items: {
        Row: {
          id: string
          purchase_attempt_id: string
          quantity: number
          seat_id: string | null
          ticket_type_id: string
          total_price: number
          unit_price: number
        }
        Insert: {
          id?: string
          purchase_attempt_id: string
          quantity: number
          seat_id?: string | null
          ticket_type_id: string
          total_price: number
          unit_price: number
        }
        Update: {
          id?: string
          purchase_attempt_id?: string
          quantity?: number
          seat_id?: string | null
          ticket_type_id?: string
          total_price?: number
          unit_price?: number
        }
        Relationships: [
          {
            foreignKeyName: "purchase_attempt_items_purchase_attempt_id_fkey"
            columns: ["purchase_attempt_id"]
            isOneToOne: false
            referencedRelation: "purchase_attempts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "purchase_attempt_items_seat_id_fkey"
            columns: ["seat_id"]
            isOneToOne: false
            referencedRelation: "seats"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "purchase_attempt_items_ticket_type_id_fkey"
            columns: ["ticket_type_id"]
            isOneToOne: false
            referencedRelation: "ticket_types"
            referencedColumns: ["id"]
          },
        ]
      }
      purchase_attempts: {
        Row: {
          completed_at: string | null
          created_at: string | null
          event_id: string
          expires_at: string
          failure_reason: string | null
          id: string
          platform_fee: number
          purchaser_email: string
          purchaser_name: string | null
          refund_amount: number | null
          refund_completed_at: string | null
          refund_requested_at: string | null
          refund_status: string | null
          session_id: string
          status: string | null
          stripe_payment_intent_id: string | null
          total_amount: number
        }
        Insert: {
          completed_at?: string | null
          created_at?: string | null
          event_id: string
          expires_at: string
          failure_reason?: string | null
          id?: string
          platform_fee: number
          purchaser_email: string
          purchaser_name?: string | null
          refund_amount?: number | null
          refund_completed_at?: string | null
          refund_requested_at?: string | null
          refund_status?: string | null
          session_id: string
          status?: string | null
          stripe_payment_intent_id?: string | null
          total_amount: number
        }
        Update: {
          completed_at?: string | null
          created_at?: string | null
          event_id?: string
          expires_at?: string
          failure_reason?: string | null
          id?: string
          platform_fee?: number
          purchaser_email?: string
          purchaser_name?: string | null
          refund_amount?: number | null
          refund_completed_at?: string | null
          refund_requested_at?: string | null
          refund_status?: string | null
          session_id?: string
          status?: string | null
          stripe_payment_intent_id?: string | null
          total_amount?: number
        }
        Relationships: [
          {
            foreignKeyName: "purchase_attempts_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
        ]
      }
      refunds: {
        Row: {
          amount: number
          created_at: string | null
          id: string
          processed_at: string | null
          processed_by: string | null
          purchase_attempt_id: string | null
          reason: string | null
          status: string | null
          stripe_refund_id: string | null
          ticket_id: string | null
        }
        Insert: {
          amount: number
          created_at?: string | null
          id?: string
          processed_at?: string | null
          processed_by?: string | null
          purchase_attempt_id?: string | null
          reason?: string | null
          status?: string | null
          stripe_refund_id?: string | null
          ticket_id?: string | null
        }
        Update: {
          amount?: number
          created_at?: string | null
          id?: string
          processed_at?: string | null
          processed_by?: string | null
          purchase_attempt_id?: string | null
          reason?: string | null
          status?: string | null
          stripe_refund_id?: string | null
          ticket_id?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "refunds_processed_by_fkey"
            columns: ["processed_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "refunds_purchase_attempt_id_fkey"
            columns: ["purchase_attempt_id"]
            isOneToOne: false
            referencedRelation: "purchase_attempts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "refunds_ticket_id_fkey"
            columns: ["ticket_id"]
            isOneToOne: false
            referencedRelation: "tickets"
            referencedColumns: ["id"]
          },
        ]
      }
      scanner_unlock_attempts: {
        Row: {
          attempt_result: string
          attempted_by: string | null
          created_at: string | null
          device_info: string | null
          event_id: string
          id: string
          ip_address: string | null
          user_agent: string | null
        }
        Insert: {
          attempt_result: string
          attempted_by?: string | null
          created_at?: string | null
          device_info?: string | null
          event_id: string
          id?: string
          ip_address?: string | null
          user_agent?: string | null
        }
        Update: {
          attempt_result?: string
          attempted_by?: string | null
          created_at?: string | null
          device_info?: string | null
          event_id?: string
          id?: string
          ip_address?: string | null
          user_agent?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "scanner_unlock_attempts_attempted_by_fkey"
            columns: ["attempted_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "scanner_unlock_attempts_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
        ]
      }
      seating_maps: {
        Row: {
          created_at: string | null
          description: string | null
          id: string
          labeling_scheme: Json | null
          layout_data: Json
          name: string
          organization_id: string
          total_capacity: number
          venue_name: string
        }
        Insert: {
          created_at?: string | null
          description?: string | null
          id?: string
          labeling_scheme?: Json | null
          layout_data: Json
          name: string
          organization_id: string
          total_capacity?: number
          venue_name: string
        }
        Update: {
          created_at?: string | null
          description?: string | null
          id?: string
          labeling_scheme?: Json | null
          layout_data?: Json
          name?: string
          organization_id?: string
          total_capacity?: number
          venue_name?: string
        }
        Relationships: [
          {
            foreignKeyName: "seating_maps_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      seats: {
        Row: {
          created_at: string | null
          custom_label: string | null
          display_name: string | null
          id: string
          is_accessible: boolean | null
          is_available: boolean | null
          last_reserved_by: string | null
          notes: string | null
          reservation_count: number | null
          reserved_until: string | null
          row_name: string
          seat_in_row: number
          seat_number: string
          seat_position_at_table: number | null
          seat_type: string | null
          seating_map_id: string
          section: string
          table_number: number | null
          x_position: number | null
          y_position: number | null
        }
        Insert: {
          created_at?: string | null
          custom_label?: string | null
          display_name?: string | null
          id?: string
          is_accessible?: boolean | null
          is_available?: boolean | null
          last_reserved_by?: string | null
          notes?: string | null
          reservation_count?: number | null
          reserved_until?: string | null
          row_name: string
          seat_in_row: number
          seat_number: string
          seat_position_at_table?: number | null
          seat_type?: string | null
          seating_map_id: string
          section: string
          table_number?: number | null
          x_position?: number | null
          y_position?: number | null
        }
        Update: {
          created_at?: string | null
          custom_label?: string | null
          display_name?: string | null
          id?: string
          is_accessible?: boolean | null
          is_available?: boolean | null
          last_reserved_by?: string | null
          notes?: string | null
          reservation_count?: number | null
          reserved_until?: string | null
          row_name?: string
          seat_in_row?: number
          seat_number?: string
          seat_position_at_table?: number | null
          seat_type?: string | null
          seating_map_id?: string
          section?: string
          table_number?: number | null
          x_position?: number | null
          y_position?: number | null
        }
        Relationships: [
          {
            foreignKeyName: "seats_seating_map_id_fkey"
            columns: ["seating_map_id"]
            isOneToOne: false
            referencedRelation: "seating_maps"
            referencedColumns: ["id"]
          },
        ]
      }
      ticket_reservations: {
        Row: {
          created_at: string | null
          expires_at: string
          id: string
          quantity: number
          reserved_by: string
          reserved_for_purchase_id: string | null
          seat_id: string | null
          status: string | null
          ticket_type_id: string
        }
        Insert: {
          created_at?: string | null
          expires_at: string
          id?: string
          quantity: number
          reserved_by: string
          reserved_for_purchase_id?: string | null
          seat_id?: string | null
          status?: string | null
          ticket_type_id: string
        }
        Update: {
          created_at?: string | null
          expires_at?: string
          id?: string
          quantity?: number
          reserved_by?: string
          reserved_for_purchase_id?: string | null
          seat_id?: string | null
          status?: string | null
          ticket_type_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "ticket_reservations_seat_id_fkey"
            columns: ["seat_id"]
            isOneToOne: false
            referencedRelation: "seats"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "ticket_reservations_ticket_type_id_fkey"
            columns: ["ticket_type_id"]
            isOneToOne: false
            referencedRelation: "ticket_types"
            referencedColumns: ["id"]
          },
        ]
      }
      ticket_type_pool_allocations: {
        Row: {
          allocated_quantity: number
          created_at: string | null
          id: string
          inventory_pool_id: string
          ticket_type_id: string
        }
        Insert: {
          allocated_quantity: number
          created_at?: string | null
          id?: string
          inventory_pool_id: string
          ticket_type_id: string
        }
        Update: {
          allocated_quantity?: number
          created_at?: string | null
          id?: string
          inventory_pool_id?: string
          ticket_type_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "ticket_type_pool_allocations_inventory_pool_id_fkey"
            columns: ["inventory_pool_id"]
            isOneToOne: false
            referencedRelation: "inventory_pools"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "ticket_type_pool_allocations_ticket_type_id_fkey"
            columns: ["ticket_type_id"]
            isOneToOne: false
            referencedRelation: "ticket_types"
            referencedColumns: ["id"]
          },
        ]
      }
      ticket_types: {
        Row: {
          allows_partial_table: boolean | null
          created_at: string | null
          description: string | null
          event_id: string
          general_sale_start_time: string | null
          id: string
          is_active: boolean | null
          name: string
          presale_end_time: string | null
          presale_start_time: string | null
          price: number
          quantity_available: number | null
          quantity_sold: number | null
          requires_presale_code: boolean | null
          sale_end_time: string | null
          sale_start_time: string | null
          seating_map_id: string | null
          seating_section: string | null
          seats_per_unit: number | null
          selling_unit: string | null
          sort_order: number | null
        }
        Insert: {
          allows_partial_table?: boolean | null
          created_at?: string | null
          description?: string | null
          event_id: string
          general_sale_start_time?: string | null
          id?: string
          is_active?: boolean | null
          name: string
          presale_end_time?: string | null
          presale_start_time?: string | null
          price: number
          quantity_available?: number | null
          quantity_sold?: number | null
          requires_presale_code?: boolean | null
          sale_end_time?: string | null
          sale_start_time?: string | null
          seating_map_id?: string | null
          seating_section?: string | null
          seats_per_unit?: number | null
          selling_unit?: string | null
          sort_order?: number | null
        }
        Update: {
          allows_partial_table?: boolean | null
          created_at?: string | null
          description?: string | null
          event_id?: string
          general_sale_start_time?: string | null
          id?: string
          is_active?: boolean | null
          name?: string
          presale_end_time?: string | null
          presale_start_time?: string | null
          price?: number
          quantity_available?: number | null
          quantity_sold?: number | null
          requires_presale_code?: boolean | null
          sale_end_time?: string | null
          sale_start_time?: string | null
          seating_map_id?: string | null
          seating_section?: string | null
          seats_per_unit?: number | null
          selling_unit?: string | null
          sort_order?: number | null
        }
        Relationships: [
          {
            foreignKeyName: "ticket_types_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "ticket_types_seating_map_id_fkey"
            columns: ["seating_map_id"]
            isOneToOne: false
            referencedRelation: "seating_maps"
            referencedColumns: ["id"]
          },
        ]
      }
      tickets: {
        Row: {
          checked_in: boolean | null
          created_at: string | null
          event_id: string
          group_purchase_id: string | null
          id: string
          price: number
          purchase_attempt_id: string | null
          purchaser_email: string
          purchaser_name: string | null
          refund_amount: number | null
          refund_completed_at: string | null
          refund_reason: string | null
          refund_requested_at: string | null
          refund_status: string | null
          refunded_by: string | null
          scanned_at: string | null
          seat_id: string | null
          seat_number: string | null
          seat_position_in_group: number | null
          section: string | null
          stripe_refund_id: string | null
          table_number: number | null
          ticket_type_id: string | null
          uuid: string
        }
        Insert: {
          checked_in?: boolean | null
          created_at?: string | null
          event_id: string
          group_purchase_id?: string | null
          id?: string
          price: number
          purchase_attempt_id?: string | null
          purchaser_email: string
          purchaser_name?: string | null
          refund_amount?: number | null
          refund_completed_at?: string | null
          refund_reason?: string | null
          refund_requested_at?: string | null
          refund_status?: string | null
          refunded_by?: string | null
          scanned_at?: string | null
          seat_id?: string | null
          seat_number?: string | null
          seat_position_in_group?: number | null
          section?: string | null
          stripe_refund_id?: string | null
          table_number?: number | null
          ticket_type_id?: string | null
          uuid?: string
        }
        Update: {
          checked_in?: boolean | null
          created_at?: string | null
          event_id?: string
          group_purchase_id?: string | null
          id?: string
          price?: number
          purchase_attempt_id?: string | null
          purchaser_email?: string
          purchaser_name?: string | null
          refund_amount?: number | null
          refund_completed_at?: string | null
          refund_reason?: string | null
          refund_requested_at?: string | null
          refund_status?: string | null
          refunded_by?: string | null
          scanned_at?: string | null
          seat_id?: string | null
          seat_number?: string | null
          seat_position_in_group?: number | null
          section?: string | null
          stripe_refund_id?: string | null
          table_number?: number | null
          ticket_type_id?: string | null
          uuid?: string
        }
        Relationships: [
          {
            foreignKeyName: "tickets_event_id_fkey"
            columns: ["event_id"]
            isOneToOne: false
            referencedRelation: "events"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tickets_purchase_attempt_id_fkey"
            columns: ["purchase_attempt_id"]
            isOneToOne: false
            referencedRelation: "purchase_attempts"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tickets_refunded_by_fkey"
            columns: ["refunded_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tickets_seat_id_fkey"
            columns: ["seat_id"]
            isOneToOne: false
            referencedRelation: "seats"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "tickets_ticket_type_id_fkey"
            columns: ["ticket_type_id"]
            isOneToOne: false
            referencedRelation: "ticket_types"
            referencedColumns: ["id"]
          },
        ]
      }
      user_roles: {
        Row: {
          created_at: string | null
          granted_by: string | null
          id: string
          role: string
          user_id: string
        }
        Insert: {
          created_at?: string | null
          granted_by?: string | null
          id?: string
          role: string
          user_id: string
        }
        Update: {
          created_at?: string | null
          granted_by?: string | null
          id?: string
          role?: string
          user_id?: string
        }
        Relationships: [
          {
            foreignKeyName: "user_roles_granted_by_fkey"
            columns: ["granted_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "user_roles_user_id_fkey"
            columns: ["user_id"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
        ]
      }
      users: {
        Row: {
          created_at: string | null
          created_by: string | null
          email: string
          id: string
          is_active: boolean | null
          last_login: string | null
          name: string | null
          organization_id: string | null
          role: string | null
        }
        Insert: {
          created_at?: string | null
          created_by?: string | null
          email: string
          id?: string
          is_active?: boolean | null
          last_login?: string | null
          name?: string | null
          organization_id?: string | null
          role?: string | null
        }
        Update: {
          created_at?: string | null
          created_by?: string | null
          email?: string
          id?: string
          is_active?: boolean | null
          last_login?: string | null
          name?: string | null
          organization_id?: string | null
          role?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "users_created_by_fkey"
            columns: ["created_by"]
            isOneToOne: false
            referencedRelation: "users"
            referencedColumns: ["id"]
          },
          {
            foreignKeyName: "users_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
      venues: {
        Row: {
          address: string | null
          amenities: Json | null
          capacity: number | null
          created_at: string | null
          description: string | null
          id: string
          name: string
          organization_id: string
          phone: string | null
          type: string | null
          updated_at: string | null
          website: string | null
        }
        Insert: {
          address?: string | null
          amenities?: Json | null
          capacity?: number | null
          created_at?: string | null
          description?: string | null
          id?: string
          name: string
          organization_id: string
          phone?: string | null
          type?: string | null
          updated_at?: string | null
          website?: string | null
        }
        Update: {
          address?: string | null
          amenities?: Json | null
          capacity?: number | null
          created_at?: string | null
          description?: string | null
          id?: string
          name?: string
          organization_id?: string
          phone?: string | null
          type?: string | null
          updated_at?: string | null
          website?: string | null
        }
        Relationships: [
          {
            foreignKeyName: "venues_organization_id_fkey"
            columns: ["organization_id"]
            isOneToOne: false
            referencedRelation: "organizations"
            referencedColumns: ["id"]
          },
        ]
      }
    }
    Views: {
      platform_stats: {
        Row: {
          active_days_last_30: number | null
          active_organizers: number | null
          admin_users: number | null
          new_users_last_7_days: number | null
          total_events: number | null
          total_organizations: number | null
          total_revenue: number | null
          total_tickets_sold: number | null
          upcoming_events: number | null
        }
        Relationships: []
      }
    }
    Functions: {
      cleanup_expired_reservations: {
        Args: Record<PropertyKey, never>
        Returns: number
      }
      cleanup_expired_scanner_locks: {
        Args: Record<PropertyKey, never>
        Returns: undefined
      }
      disable_scanner_lock: {
        Args: { p_event_id: string }
        Returns: boolean
      }
      fix_users_without_organizations: {
        Args: Record<PropertyKey, never>
        Returns: undefined
      }
      get_available_addons: {
        Args: { p_organization_id: string; p_event_id?: string }
        Returns: {
          addon_id: string
          slug: string
          name: string
          description: string
          pricing_type: string
          price_cents: number
          category: string
          has_access: boolean
          purchased_at: string
        }[]
      }
      get_ticket_availability: {
        Args: { p_ticket_type_id: string }
        Returns: {
          available_quantity: number
          total_quantity: number
          reserved_quantity: number
          sold_quantity: number
        }[]
      }
      has_event_addon: {
        Args: { p_event_id: string; p_addon_slug: string }
        Returns: boolean
      }
      has_feature_access: {
        Args: {
          p_organization_id: string
          p_event_id: string
          p_feature_flag: string
        }
        Returns: boolean
      }
      has_subscription_addon: {
        Args: { p_organization_id: string; p_addon_slug: string }
        Returns: boolean
      }
      is_admin: {
        Args: { user_uuid?: string }
        Returns: boolean
      }
      is_ticket_type_available_for_presale: {
        Args: { p_ticket_type_id: string; p_presale_code_id?: string }
        Returns: boolean
      }
      make_user_admin: {
        Args: { user_email: string }
        Returns: undefined
      }
      record_presale_code_usage: {
        Args: {
          p_presale_code_id: string
          p_customer_email: string
          p_customer_session: string
          p_ticket_quantity: number
          p_discount_applied?: number
          p_purchase_attempt_id?: string
        }
        Returns: string
      }
      reserve_tickets: {
        Args: {
          p_ticket_type_id: string
          p_quantity: number
          p_reserved_by: string
          p_hold_minutes?: number
          p_seat_ids?: string[]
        }
        Returns: string
      }
      setup_scanner_lock: {
        Args: { p_event_id: string; p_pin_hash: string }
        Returns: boolean
      }
      validate_presale_code: {
        Args: {
          p_code: string
          p_event_id: string
          p_customer_email?: string
          p_customer_session?: string
        }
        Returns: {
          is_valid: boolean
          presale_code_id: string
          discount_type: string
          discount_value: number
          uses_remaining: number
          customer_uses_remaining: number
          error_message: string
        }[]
      }
      verify_scanner_pin: {
        Args: { p_event_id: string; p_pin_hash: string }
        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