import type { Translations } from '@payloadcms/translations'

import type { Permissions, User } from '../../auth/index.js'
import type { SanitizedCollectionConfig } from '../../collections/config/types.d.ts'
import type { SanitizedGlobalConfig } from '../../globals/config/types.d.ts'
import type { PayloadRequest } from '../../types/index.d.ts'

export type AdminViewConfig = {
  Component: AdminViewComponent
  /** Whether the path should be matched exactly or as a prefix */
  exact?: boolean
  path: string
  sensitive?: boolean
  strict?: boolean
}

export type AdminViewProps = {
  canAccessAdmin?: boolean
  user: User | null | undefined
}

export type AdminViewComponent = React.ComponentType<AdminViewProps>

export type AdminView = AdminViewComponent | AdminViewConfig

export type EditViewProps = {
  collectionSlug?: string
  globalSlug?: string
}

export type InitPageResult = {
  collectionConfig?: SanitizedCollectionConfig
  cookies: Map<string, string>
  docID?: string
  globalConfig?: SanitizedGlobalConfig
  locale: Locale
  permissions: Permissions
  req: PayloadRequest
  translations: Translations
}

export type ServerSideEditViewProps = {
  initPageResult: InitPageResult
  routeSegments: string[]
  searchParams: { [key: string]: string | string[] | undefined }
}
