import type {
    FetchNicoTagsParams,
    FetchMaterialsParams,
    FetchPostsParams,
    FetchTagsParams,
    MaterialFilter,
} from '@/types'

export const postsKeys = {
    root:     ['posts'] as const,
    index:    (p: FetchPostsParams) => ['posts', 'index', p] as const,
    show:     (id: string) => ['posts', id] as const,
    related:  (id: string) => ['related', id] as const,
    changes:  (p: { post?: string; tag?: string; page: number; limit: number }) =>
		  ['posts', 'changes', p] as const }

export const gekanatorKeys = {
    root:      ['gekanator'] as const,
    posts:     () => ['gekanator', 'posts'] as const,
    questions: () => ['gekanator', 'questions'] as const,
    extraQuestions: (gameId: number, nonce: string) =>
		       ['gekanator', 'games', gameId, 'extra-questions', nonce] as const }

export const tagsKeys = {
    root:         ['tags'] as const,
    index:        (p: FetchTagsParams) => ['tags', 'index', p] as const,
    nicoRoot:     ['tags', 'nico'] as const,
    nicoIndex:    (p: FetchNicoTagsParams) => ['tags', 'nico', 'index', p] as const,
    show:         (name: string) => ['tags', name] as const,
    changes:      (p: { id?: string; page: number; limit: number }) =>
		      ['tags', 'changes', p] as const,
    deerjikists:  (id: string) => ['tags', 'deerjikists', id] as const }

export const materialsKeys = {
    root:         ['materials'] as const,
    index:        (p: FetchMaterialsParams) => ['materials', 'index', p] as const,
    changes:      (p: {
	materialId?: string
	tag?:        string
	eventType?:  string
	page:        number
	limit:       number
    }) => ['materials', 'changes', p] as const,
    byTagName:     (name: string, materialFilter: MaterialFilter) =>
		      ['materials', 'tag', name, materialFilter] as const,
    show:         (id: string) => ['materials', id] as const,
    suppressions: () => ['materials', 'suppressions'] as const,
    tree:         (p: {
	parentId?:       number | null
	materialFilter:  MaterialFilter
    }) => ['materials', 'tree', p] as const,
    unclassified: (p: { page?: number; limit?: number } = { }) =>
		      ['materials', 'unclassified', p] as const}

export const wikiKeys = {
    root:   ['wiki'] as const,
    index:  (p: { title?: string }) => ['wiki', 'index', p] as const,
    show:   (title: string, p: { version?: string }) => ['wiki', title, p] as const }
