// Step Library Types

export interface StepCommand {
  label: string
  command: string
  command_type?: string
}

export interface StepContent {
  instructions: string
  help_text?: string
  commands?: StepCommand[]
  group_label?: string
}

export interface Step {
  id: string
  title: string
  step_type: 'decision' | 'action' | 'solution'
  content: StepContent
  visibility: 'private' | 'team' | 'public'
  category_id?: string
  category_name?: string
  tags: string[]
  usage_count: number
  rating_average: number
  rating_count: number
  helpful_yes: number
  helpful_no: number
  is_featured: boolean
  is_verified: boolean
  is_flow_synced: boolean
  source_tree_name: string | null
  created_by: string
  author_name?: string
  created_at: string
  updated_at: string
}

export interface StepListItem {
  id: string
  title: string
  step_type: string
  visibility: string
  category_id?: string
  category_name?: string
  tags: string[]
  usage_count: number
  rating_average: number
  rating_count: number
  is_featured: boolean
  is_flow_synced: boolean
  source_tree_name: string | null
  created_by: string
  author_name?: string
  created_at: string
}

export interface StepCategory {
  id: string
  name: string
  description?: string
  display_order: number
  account_id?: string
  is_active: boolean
}

export interface StepCategoryListItem {
  id: string
  name: string
  description?: string
  display_order: number
  is_active: boolean
}

export interface StepCategoryCreate {
  name: string
  description?: string
}

export interface StepCategoryUpdate {
  name?: string
  description?: string
}

export interface StepCategoryListParams {
  include_inactive?: boolean
}

export interface StepListParams {
  visibility?: 'private' | 'team' | 'public'
  category_id?: string
  tags?: string[]
  min_rating?: number
  step_type?: 'decision' | 'action' | 'solution'
  sort_by?: 'recent' | 'popular' | 'highest_rated' | 'most_used'
  limit?: number
  offset?: number
}

export interface PopularTag {
  tag: string
  count: number
}

export interface StepCreate {
  title: string
  step_type: 'decision' | 'action' | 'solution'
  content: StepContent
  visibility: 'private' | 'team' | 'public'
  category_id?: string
  tags?: string[]
}

export interface StepUpdate {
  title?: string
  step_type?: 'decision' | 'action' | 'solution'
  content?: StepContent
  visibility?: 'private' | 'team' | 'public'
  category_id?: string
  tags?: string[]
}

export interface RatingCreate {
  rating: number
  review_text?: string
  was_helpful?: boolean
  session_id?: string
}

export interface RatingUpdate {
  rating?: number
  review_text?: string
}

export interface Rating {
  id: string
  step_id: string
  user_id: string
  rating: number
  review_text?: string
  verified_use: boolean
  helpful_yes: number
  helpful_no: number
  created_at: string
  updated_at: string
  user_name?: string
}

// Review is an alias for Rating
export type Review = Rating
