export interface DeviceProperties {
  hostname: string | null
  ip: string | null
  subnet: string | null
  vendor: string | null
  model: string | null
  role: string | null
  vlan: string | null
  notes: string | null
  status: 'unknown' | 'online' | 'offline' | 'degraded'
}

export interface DiagramNode {
  id: string
  type: string
  label: string
  position: { x: number; y: number }
  properties: DeviceProperties
  nodeType?: string
  style?: { width?: number; height?: number } | null
  parentId?: string | null
}

export interface DiagramEdge {
  id: string
  source: string
  target: string
  label: string | null
  connectionType: string
  speed: string | null
  notes: string | null
  routing?: 'curved' | 'step' | 'orthogonal' | null
}

export interface DeviceTypeResponse {
  id: string
  slug: string
  label: string
  category: string
  is_system: boolean
  account_id: string
  sort_order: number
  created_at: string
}

export interface DeviceTypeCreate {
  slug: string
  label: string
  category: string
  sort_order?: number
}

export interface NetworkDiagramResponse {
  id: string
  account_id: string
  name: string
  client_name: string | null
  asset_name: string | null
  description: string | null
  nodes: DiagramNode[]
  edges: DiagramEdge[]
  thumbnail_url: string | null
  is_archived: boolean
  created_by: string | null
  created_at: string
  updated_at: string
}

export interface NetworkDiagramListItem {
  id: string
  name: string
  client_name: string | null
  description: string | null
  node_count: number
  category_counts: Record<string, number>
  thumbnail_url?: string | null
  created_by: string | null
  created_at: string
  updated_at: string
}

export interface NetworkDiagramCreate {
  name: string
  client_name?: string | null
  asset_name?: string | null
  description?: string | null
  nodes?: DiagramNode[]
  edges?: DiagramEdge[]
}

export interface NetworkDiagramUpdate {
  name?: string
  client_name?: string | null
  asset_name?: string | null
  description?: string | null
  nodes?: DiagramNode[]
  edges?: DiagramEdge[]
}

export interface AIGenerateRequest {
  description: string
  client_name?: string | null
  mode: 'replace' | 'merge'
  existingBounds?: { minX: number; maxX: number; minY: number; maxY: number } | null
}

export interface AIGenerateResponse {
  nodes: DiagramNode[]
  edges: DiagramEdge[]
  suggestedName: string | null
  notes: string | null
}

export interface DiagramImportData {
  schemaVersion: number
  name: string
  client_name?: string | null
  description?: string | null
  nodes: DiagramNode[]
  edges: DiagramEdge[]
}

export interface DiagramImportResponse {
  diagram: NetworkDiagramResponse
  warnings: string[]
}

export interface GroupNodeData {
  label: string
  groupType: 'subnet' | 'vlan' | 'site' | 'dmz' | 'custom'
  [key: string]: unknown
}

export interface DiagramExportResponse {
  schemaVersion: number
  name: string
  client_name: string | null
  description: string | null
  nodes: DiagramNode[]
  edges: DiagramEdge[]
  exportedAt: string
}
