import { AnyTypedQuizQuestion } from "./questionTypes/shared";

export type QuizStartpageType = "standard" | "expanded" | "centered" | null;

export type QuizStartpageAlignType = "left" | "right" | "center";

export type QuizType = "quiz" | "form" | null;

export type QuizResultsType = true | null;

export type QuizStep = "startpage" | "question" | "contactform";

export type QuizTheme =
  | "StandardTheme"
  | "StandardDarkTheme"
  | "PinkTheme"
  | "PinkDarkTheme"
  | "BlackWhiteTheme"
  | "crutch_FurnitureABC"
  | "OliveTheme"
  | "YellowTheme"
  | "GoldDarkTheme"
  | "PurpleTheme"
  | "BlueTheme"
  | "BlueDarkTheme"
  | "Design1"
  | "Design2"
  | "Design3"
  | "Design4"
  | "Design5"
  | "Design6"
  | "Design7"
  | "Design8"
  | "Design9"
  | "Design10";

export type FCField = {
  text: string;
  innerText: string;
  key: string;
  required: boolean;
  used: boolean;
};

export type Status = "start" | "stop" | "ai";

export type QuizSettingsConfig = {
  fp: boolean;
  rep: boolean;
  name: string;
  lim: number;
  due: number;
  delay: number;
  pausable: boolean;
  cfg: QuizConfig;
  status: Status;
  // Таймер вопросов
  questionTimerEnabled?: boolean;
};

export type QuizSettings = {
  questions: AnyTypedQuizQuestion[];
  settings: QuizSettingsConfig;
  cnt: number;
  recentlyCompleted: boolean;
  show_badge: boolean;
};

export interface QuizConfig {
  time_of_passing?: number;
  isUnSc?: boolean;
  spec: undefined | true;
  type: QuizType;
  noStartPage: boolean;
  startpageType: QuizStartpageType;
  score?: boolean;
  results: QuizResultsType;
  haveRoot: string | null;
  theme: QuizTheme;
  design: boolean;
  resultInfo: {
    when: "email" | "";
    share: boolean;
    replay: boolean;
    theme: string;
    reply: string;
    replname: string;
    showResultForm: "before" | "after";
  };
  startpage: {
    description: string;
    button: string;
    position: QuizStartpageAlignType;
    favIcon: string | null;
    logo: string | null;
    originalLogo: string | null;
    background: {
      type: null | "image" | "video";
      desktop: string | null;
      originalDesktop: string | null;
      mobile: string | null;
      originalMobile: string | null;
      video: string | null;
      cycle: boolean;
    };
  };
  formContact: {
    title: string;
    desc: string;
    fields: Record<FormContactFieldName, FormContactFieldData>;
    button: string;
  };
  info: {
    phonenumber: string;
    clickable: boolean;
    orgname: string;
    site: string;
    law?: string;
  };
  meta: string;
  antifraud?: boolean;
  showfc?: boolean;
  yandexMetricsNumber?: number;
  vkMetricsNumber?: number;
  backBlocked?: boolean;
  overTime?: {
    enabled: boolean;
    endsAt: number;
    description: string;
  };
}

export type FormContactFieldName = "name" | "email" | "phone" | "text" | "address";

export type FormContactFieldData = {
  text: string;
  innerText: string;
  key: string;
  required: boolean;
  used: boolean;
};

export interface QuizItems {
  description: string;
  id: number;
  page: number;
  required: boolean;
  title: string;
  type: string;
  content: unknown;
}
