import { z } from "zod";
import { customEnumErrorHandler } from "./util";

export const LanguageSchema = z.enum(
  [
    "english",
    "english_1k",
    "english_5k",
    "english_10k",
    "english_25k",
    "english_450k",
    "english_commonly_misspelled",
    "english_contractions",
    "english_doubleletter",
    "english_shakespearean",
    "english_old",
    "english_medical",
    "spanish",
    "spanish_1k",
    "spanish_10k",
    "spanish_650k",
    "french",
    "french_1k",
    "french_2k",
    "french_10k",
    "french_600k",
    "french_bitoduc",
    "nepali",
    "nepali_1k",
    "nepali_romanized",
    "sanskrit",
    "sanskrit_roman",
    "santali",
    "azerbaijani",
    "azerbaijani_1k",
    "arabic",
    "arabic_10k",
    "arabic_egypt",
    "arabic_egypt_1k",
    "arabic_morocco",
    "malagasy",
    "malagasy_1k",
    "malay",
    "malay_1k",
    "mongolian",
    "mongolian_10k",
    "kannada",
    "korean",
    "korean_1k",
    "korean_5k",
    "khmer",
    "chinese_simplified",
    "chinese_simplified_1k",
    "chinese_simplified_5k",
    "chinese_simplified_10k",
    "chinese_simplified_50k",
    "chinese_traditional",
    "chinese_traditional_1k",
    "chinese_traditional_5k",
    "chinese_traditional_10k",
    "chinese_traditional_50k",
    "russian",
    "russian_1k",
    "russian_5k",
    "russian_10k",
    "russian_25k",
    "russian_50k",
    "russian_375k",
    "russian_contractions",
    "russian_contractions_1k",
    "russian_abbreviations",
    "ukrainian",
    "ukrainian_1k",
    "ukrainian_10k",
    "ukrainian_50k",
    "ukrainian_endings",
    "ukrainian_latynka",
    "ukrainian_latynka_1k",
    "ukrainian_latynka_10k",
    "ukrainian_latynka_50k",
    "ukrainian_latynka_endings",
    "portuguese",
    "portuguese_acentos_e_cedilha",
    "portuguese_1k",
    "portuguese_3k",
    "portuguese_5k",
    "portuguese_320k",
    "portuguese_550k",
    "indonesian",
    "indonesian_1k",
    "indonesian_10k",
    "kurdish_central",
    "kurdish_central_2k",
    "kurdish_central_4k",
    "german",
    "german_1k",
    "german_10k",
    "german_250k",
    "swiss_german",
    "swiss_german_1k",
    "swiss_german_2k",
    "afrikaans",
    "afrikaans_1k",
    "afrikaans_10k",
    "georgian",
    "tamil",
    "tamil_1k",
    "tanglish",
    "tamil_old",
    "telugu",
    "telugu_1k",
    "greek",
    "greek_1k",
    "greek_5k",
    "greek_10k",
    "greek_25k",
    "greeklish",
    "greeklish_1k",
    "greeklish_5k",
    "greeklish_10k",
    "greeklish_25k",
    "turkish",
    "turkish_1k",
    "turkish_5k",
    "irish",
    "irish_1k",
    "italian",
    "italian_1k",
    "italian_7k",
    "italian_60k",
    "italian_280k",
    "friulian",
    "latin",
    "galician",
    "thai",
    "thai_1k",
    "thai_5k",
    "thai_10k",
    "thai_20k",
    "thai_50k",
    "thai_60k",
    "polish",
    "polish_2k",
    "polish_5k",
    "polish_10k",
    "polish_20k",
    "polish_40k",
    "polish_200k",
    "czech",
    "czech_1k",
    "czech_10k",
    "slovak",
    "slovak_1k",
    "slovak_10k",
    "slovenian",
    "slovenian_1k",
    "slovenian_5k",
    "croatian",
    "croatian_1k",
    "dutch",
    "dutch_1k",
    "dutch_10k",
    "filipino",
    "filipino_1k",
    "danish",
    "danish_1k",
    "danish_10k",
    "hungarian",
    "hungarian_1k",
    "hungarian_2k",
    "norwegian_bokmal",
    "norwegian_bokmal_1k",
    "norwegian_bokmal_5k",
    "norwegian_bokmal_10k",
    "norwegian_bokmal_150k",
    "norwegian_bokmal_600k",
    "norwegian_nynorsk",
    "norwegian_nynorsk_1k",
    "norwegian_nynorsk_5k",
    "norwegian_nynorsk_10k",
    "norwegian_nynorsk_100k",
    "norwegian_nynorsk_400k",
    "hebrew",
    "hebrew_1k",
    "hebrew_5k",
    "hebrew_10k",
    "icelandic",
    "icelandic_1k",
    "romanian",
    "romanian_1k",
    "romanian_5k",
    "romanian_10k",
    "romanian_25k",
    "romanian_50k",
    "romanian_100k",
    "romanian_200k",
    "lorem_ipsum",
    "finnish",
    "finnish_1k",
    "finnish_10k",
    "estonian",
    "estonian_1k",
    "estonian_5k",
    "estonian_10k",
    "udmurt",
    "welsh",
    "welsh_1k",
    "persian",
    "persian_1k",
    "persian_5k",
    "persian_20k",
    "persian_romanized",
    "marathi",
    "kazakh",
    "kazakh_1k",
    "vietnamese",
    "vietnamese_1k",
    "vietnamese_5k",
    "jyutping",
    "pinyin",
    "pinyin_1k",
    "pinyin_10k",
    "hausa",
    "hausa_1k",
    "swedish",
    "swedish_1k",
    "swedish_diacritics",
    "serbian_latin",
    "serbian_latin_10k",
    "serbian",
    "serbian_10k",
    "yoruba_1k",
    "swahili_1k",
    "maori_1k",
    "catalan",
    "catalan_1k",
    "lojban_gismu",
    "lojban_cmavo",
    "lithuanian",
    "lithuanian_1k",
    "lithuanian_3k",
    "bulgarian",
    "bulgarian_1k",
    "bulgarian_latin",
    "bulgarian_latin_1k",
    "bangla",
    "bangla_letters",
    "bangla_10k",
    "bosnian",
    "bosnian_4k",
    "toki_pona",
    "toki_pona_ku_suli",
    "toki_pona_ku_lili",
    "esperanto",
    "esperanto_1k",
    "esperanto_10k",
    "esperanto_25k",
    "esperanto_36k",
    "esperanto_x_sistemo",
    "esperanto_x_sistemo_1k",
    "esperanto_x_sistemo_10k",
    "esperanto_x_sistemo_25k",
    "esperanto_x_sistemo_36k",
    "esperanto_h_sistemo",
    "esperanto_h_sistemo_1k",
    "esperanto_h_sistemo_10k",
    "esperanto_h_sistemo_25k",
    "esperanto_h_sistemo_36k",
    "kyrgyz",
    "kyrgyz_1k",
    "urdu",
    "urdu_1k",
    "urdu_5k",
    "urdu_roman",
    "urdish",
    "albanian",
    "albanian_1k",
    "shona",
    "shona_1k",
    "armenian",
    "armenian_1k",
    "armenian_western",
    "armenian_western_1k",
    "myanmar_burmese",
    "japanese_hiragana",
    "japanese_katakana",
    "japanese_romaji",
    "japanese_romaji_1k",
    "sinhala",
    "latvian",
    "latvian_1k",
    "maltese",
    "maltese_1k",
    "twitch_emotes",
    "git",
    "pig_latin",
    "hindi",
    "hindi_1k",
    "hinglish",
    "gujarati",
    "gujarati_1k",
    "macedonian",
    "macedonian_1k",
    "macedonian_10k",
    "macedonian_75k",
    "belarusian",
    "belarusian_1k",
    "belarusian_5k",
    "belarusian_10k",
    "belarusian_25k",
    "belarusian_50k",
    "belarusian_100k",
    "belarusian_lacinka",
    "belarusian_lacinka_1k",
    "tatar",
    "tatar_1k",
    "tatar_5k",
    "tatar_9k",
    "tatar_crimean",
    "tatar_crimean_1k",
    "tatar_crimean_5k",
    "tatar_crimean_10k",
    "tatar_crimean_15k",
    "tatar_crimean_cyrillic",
    "tatar_crimean_cyrillic_1k",
    "tatar_crimean_cyrillic_5k",
    "tatar_crimean_cyrillic_10k",
    "tatar_crimean_cyrillic_15k",
    "uzbek",
    "uzbek_1k",
    "uzbek_70k",
    "malayalam",
    "amharic",
    "amharic_1k",
    "amharic_5k",
    "oromo",
    "oromo_1k",
    "oromo_5k",
    "wordle",
    "league_of_legends",
    "wordle_1k",
    "typing_of_the_dead",
    "yiddish",
    "frisian",
    "frisian_1k",
    "pashto",
    "euskera",
    "klingon",
    "klingon_1k",
    "quenya",
    "occitan",
    "occitan_1k",
    "occitan_2k",
    "occitan_5k",
    "occitan_10k",
    "bashkir",
    "zulu",
    "kabyle",
    "kabyle_1k",
    "kabyle_2k",
    "kabyle_5k",
    "kabyle_10k",
    "hawaiian",
    "hawaiian_1k",
    "code_python",
    "code_python_1k",
    "code_python_2k",
    "code_python_5k",
    "code_fsharp",
    "code_c",
    "code_csharp",
    "code_css",
    "code_c++",
    "code_dart",
    "code_brainfck",
    "code_javascript",
    "code_javascript_1k",
    "code_javascript_react",
    "code_jule",
    "code_julia",
    "code_haskell",
    "code_html",
    "code_nim",
    "code_nix",
    "code_pascal",
    "code_java",
    "code_kotlin",
    "code_go",
    "code_rockstar",
    "code_rust",
    "code_ruby",
    "code_r",
    "code_r_2k",
    "code_swift",
    "code_scala",
    "code_bash",
    "code_powershell",
    "code_lua",
    "code_luau",
    "code_latex",
    "code_typst",
    "code_matlab",
    "code_sql",
    "code_perl",
    "code_php",
    "code_vim",
    "code_vimscript",
    "code_opencl",
    "code_visual_basic",
    "code_arduino",
    "code_systemverilog",
    "code_elixir",
    "code_gleam",
    "code_zig",
    "code_gdscript",
    "code_gdscript_2",
    "code_assembly",
    "code_v",
    "code_ook",
    "code_typescript",
    "code_ocaml",
    "code_odin",
    "xhosa",
    "xhosa_3k",
    "tibetan",
    "tibetan_1k",
    "code_cobol",
    "code_clojure",
    "code_common_lisp",
    "code_erlang",
    "docker_file",
    "code_fortran",
    "viossa",
    "viossa_njutro",
    "code_abap",
    "code_abap_1k",
    "code_yoptascript",
    "code_cuda",
    "kinyarwanda",
    "pokemon_1k",
    "kokanu",
    "likanu",
  ],
  {
    errorMap: customEnumErrorHandler("Must be a supported language"),
  },
);

export type Language = z.infer<typeof LanguageSchema>;

export const LanguageObjectSchema = z
  .object({
    name: LanguageSchema,
    rightToLeft: z.boolean().optional(),
    noLazyMode: z.boolean().optional(),
    ligatures: z.boolean().optional(),
    orderedByFrequency: z.boolean().optional(),
    words: z.array(z.string()).min(1),
    additionalAccents: z
      .array(z.tuple([z.string().min(1), z.string().min(1)]))
      .optional(),
    bcp47: z.string().optional(),
    originalPunctuation: z.boolean().optional(),
  })
  .strict();
export type LanguageObject = z.infer<typeof LanguageObjectSchema>;
