import { Domain, ScalarAny } from '@things-factory/shell'
import { User } from '@things-factory/auth-base'
import { ObjectType, Field, InputType, Int, ID } from 'type-graphql'
import { RobotArm } from '../robotarm/robotarm-type'
import { TrackingCamera } from '../tracking-camera/tracking-camera-type'
import { TrackableObject, TrackableObjectStateInput } from '../trackable-object/trackable-object-type'

// type TrackingWorkspace {
//   id: String
//   name: String
//   domain: Domain
//   description: String
//   type: String
//   endpoint: String
//   active: Boolean
//   params: Object
//   checkVideoStream: Boolean
//   detectionMethod: String
//   robotArms: [RobotArm]
//   trackingCameras: [TrackingCamera]
//   trackableObjects: [TrackableObject]
//   updater: User
//   creator: User
//   updatedAt: String
//   createdAt: String
// }
@ObjectType()
export class TrackingWorkspace {
  @Field(type => ID, { nullable: true })
  id?: string

  @Field()
  name: string

  @Field(type => Domain)
  domain: Domain

  @Field({ nullable: true })
  description?: string

  @Field({ nullable: true })
  type?: string

  @Field({ nullable: true })
  endpoint?: string

  @Field(type => Boolean, { nullable: true })
  active: boolean

  // TODO: check object
  @Field(type => ScalarAny, { nullable: true })
  params?: any

  @Field(type => Boolean, { nullable: true })
  checkVideoStream?: boolean

  @Field({ nullable: true })
  detectionMethod?: string

  @Field(type => [RobotArm], { nullable: true })
  robotArms?: RobotArm[]

  @Field(type => [TrackingCamera], { nullable: true })
  trackingCameras?: TrackingCamera[]

  @Field(type => [TrackableObject], { nullable: true })
  trackableObjects?: TrackableObject[]

  @Field(type => User, { nullable: true })
  updater: User

  @Field(type => User, { nullable: true })
  creator: User

  @Field({ nullable: true })
  updatedAt: string

  @Field({ nullable: true })
  createdAt: string
}

// type TrackingWorkspaceList {
//   items: [TrackingWorkspace]
//   total: Int
// }
@ObjectType()
export class TrackingWorkspaceList {
  @Field(type => [TrackingWorkspace])
  items: TrackingWorkspace[]

  @Field(type => Int)
  total: number
}

// input TrackingWorkspaceStateInput {
//   id: String!
//   state: TrackableObjectStateInput
// }
@InputType()
export class TrackingWorkspaceStateInput {
  @Field(type => ID, { nullable: true })
  id?: string

  @Field(type => TrackableObjectStateInput, { nullable: true })
  state?: TrackableObjectStateInput
}

// input TrackingWorkspaceStatusInput {
//   objectStatus: [TrackingWorkspaceStateInput]
// }
@InputType()
export class TrackingWorkspaceStatusInput {
  @Field(type => [TrackingWorkspaceStateInput], { nullable: true })
  objectStatus?: TrackingWorkspaceStateInput[]
}
