// Compile-time checks only (`npm run typecheck`), never imported at runtime. Each
// `@ts-expect-error` fails the typecheck if the mismatched answer shape ever stops being an error.
import { setDirectAnswerPreset } from "./answer-preset";
import { TAnswerPresetSet } from "./types";

type TExampleStorePreset = { days: string[]; day: string };

export const WELL_TYPED_PRESETS: TAnswerPresetSet<TExampleStorePreset> = {
  1: setDirectAnswerPreset(undefined, "Days", "checkbox", (storePreset) => storePreset.days),
  2: setDirectAnswerPreset(undefined, "Day", "radio", (storePreset) => storePreset.day),
  3: setDirectAnswerPreset(undefined, "Count", "text", () => 3),
  4: setDirectAnswerPreset(undefined, "Skipped", "checkbox", () => null),
};

export const MISMATCHED_PRESETS: TAnswerPresetSet<TExampleStorePreset> = {
  // @ts-expect-error a list answer on a text question
  1: setDirectAnswerPreset(undefined, "Count", "text", (storePreset) => storePreset.days),
  // @ts-expect-error a list answer on a radio question
  2: setDirectAnswerPreset(undefined, "Day", "radio", (storePreset) => storePreset.days),
  // @ts-expect-error a single value on a checkbox question
  3: setDirectAnswerPreset(undefined, "Days", "checkbox", (storePreset) => storePreset.day),
  // @ts-expect-error a raw object literal with a mismatched answer shape
  4: {
    questionLabel: "Days",
    questionType: "checkbox",
    answerDependency: "directAnswer",
    answer: () => "Tuesday",
  },
};
