import { type PaginationParams } from '@material-hu/hooks/useHuPagination';

import { type SegmentationExpressionPayload } from '@material-hu/components/composed-components/audience/types';

export const librariesKeys = {
  all: () => ['hu-knowledge-libraries'],
  welcomeConfig: () => [...librariesKeys.all(), 'welcome-config'] as const,
  article: {
    all: () => [...librariesKeys.all(), 'article'],
    byId: (id?: number) => [...librariesKeys.article.all(), id],
    tree: (id?: number) => [...librariesKeys.article.byId(id), 'tree'],
    childrenTree: (id?: number) => [
      ...librariesKeys.article.all(),
      id,
      'children-tree',
    ],
    rootList: () => [...librariesKeys.article.all(), 'list'],
    search: (pagination: Partial<PaginationParams>) => [
      ...librariesKeys.article.all(),
      'search',
      pagination,
    ],
    icons: (id?: number) => [...librariesKeys.article.byId(id), 'icons'],
  },
  audience: {
    all: () => [...librariesKeys.all(), 'audience'],
    count: (expression?: SegmentationExpressionPayload | null) => [
      ...librariesKeys.audience.all(),
      'count',
      expression,
    ],
    selectedCollaborators: () => [
      ...librariesKeys.audience.all(),
      'selected-collaborators',
    ],
  },
};
