import type {
  PersonalityDirectoryFilterGroup as PersonalityDirectoryFilterGroupValue,
  PersonalityQuizKind,
} from '@/shared/constants/personality';
import type { PersonalityAnswerValue } from '@/shared/types/personality';

export interface PersonalityQuizResultViewModel {
  readonly quizKind: PersonalityQuizKind;
  readonly quizId: string;
  readonly quizTitle: string;
  readonly weekOf: string | null;
  readonly personalityType: string | null;
  readonly quizAnswers: Record<number, PersonalityAnswerValue>;
  readonly score: number | null;
  readonly totalQuestions: number;
  readonly resultLabel: string | null;
  readonly resultPayload: unknown | null;
  readonly completedAt: string;
  readonly updatedAt: string;
}

export interface PersonalityQuizSubmission {
  readonly quizKind: PersonalityQuizKind;
  readonly quizId: string;
  readonly quizTitle: string;
  readonly personalityType?: string | null;
  readonly quizAnswers: Record<number, PersonalityAnswerValue>;
  readonly score?: number | null;
  readonly totalQuestions: number;
  readonly resultLabel?: string | null;
  readonly resultPayload?: unknown;
}

export type PersonalityQuizResultTab = 'overview' | 'relationships' | 'language';

export interface PersonalityQuizFeature {
  readonly id: string;
  readonly label: string;
  readonly description: string;
  readonly toneClass: string;
}

export interface PersonalityDimensionProgress {
  readonly dimension: 'EI' | 'SN' | 'TF' | 'JP';
  readonly label: string;
  readonly answeredCount: number;
  readonly totalCount: number;
  readonly current: boolean;
}

export interface PersonalityTypeBreakdownItem {
  readonly letter: string;
  readonly label: string;
  readonly fullLabel: string;
}

export interface PersonalityRelationshipTip {
  readonly type: string;
  readonly tip: string;
}

export interface PersonalityQuizWorkflowInput {
  readonly onResult?: (code: string, answers: Record<number, string>) => void | Promise<void>;
  readonly savedType?: string | null;
  readonly savedAnswers?: Record<number, string> | null;
  readonly questions?: readonly import('@/shared/constants/personalityCatalog').QuizQuestion[];
}

export type PersonalityDirectoryFilterGroup = PersonalityDirectoryFilterGroupValue;

export type PersonalityDirectorySection = 'overview' | 'relationships' | 'language';

export interface PersonalityDirectoryPage {
  readonly personalityTypes: readonly import('@/shared/constants/personalityCatalog').PersonalityType[];
  readonly filteredTypes: readonly import('@/shared/constants/personalityCatalog').PersonalityType[];
  readonly expandedType: string | null;
  readonly searchQuery: string;
  readonly filterGroup: PersonalityDirectoryFilterGroup;
  readonly expandedSections: Readonly<Record<string, PersonalityDirectorySection>>;
  readonly isLoading: boolean;
  readonly error: unknown;
  readonly groupDescription: string;
  readonly setSearchQuery: (query: string) => void;
  readonly setFilterGroup: (group: PersonalityDirectoryFilterGroup) => void;
  readonly toggleExpand: (code: string) => void;
  readonly getActiveSection: (code: string) => PersonalityDirectorySection;
  readonly setActiveSection: (code: string, section: PersonalityDirectorySection) => void;
  readonly clearFilters: () => void;
}
