package eu.kanade.tachiyomi.extension.es.vcpvmp

import eu.kanade.tachiyomi.annotations.Nsfw
import eu.kanade.tachiyomi.source.Source
import eu.kanade.tachiyomi.source.SourceFactory
import eu.kanade.tachiyomi.source.model.Filter

@Nsfw
class VCPVMPFactory : SourceFactory {
    override fun createSources(): List<Source> = listOf(
        VCP(),
        VMP()
    )
}

class VCP : VCPVMP("VCP", "https://vercomicsporno.com")

class VMP : VCPVMP("VMP", "https://vermangasporno.com") {
    override val pageListSelector = "div.comicimg img:last-child:not([alt^=banner])"

    // Array.from(document.querySelectorAll('div.tagcloud a.tag-cloud-link'))
    // .map(a => `Pair("${a.innerText}", "${a.href.replace('https://vermangasporno.com/genero/', '')}")`).join(',\n')
    // from https://vermangasporno.com/
    private class Genre : UriPartFilter(
        "Filtrar por generos",
        arrayOf(
            Pair("Ver todos", ""),
            Pair("Ahegao", "ahegao"),
            Pair("Anal", "anal"),
            Pair("Big Ass", "big-ass"),
            Pair("Big Breasts", "big-breasts"),
            Pair("Blowjob", "blowjob"),
            Pair("Cheating", "cheating"),
            Pair("Colegiala", "colegiala"),
            Pair("Fullcolor", "fullcolor"),
            Pair("Group", "group"),
            Pair("Incest", "incest"),
            Pair("loli", "loli"),
            Pair("Lolicon", "lolicon"),
            Pair("Milf", "milf"),
            Pair("Nakadashi", "nakadashi"),
            Pair("Paizuri", "paizuri"),
            Pair("Schoolgirl Uniform", "schoolgirl-uniform"),
            Pair("Sole Female", "sole-female"),
            Pair("Stockings", "stockings"),
            Pair("Tetona", "tetona"),
            Pair("Tetonas", "tetonas")
        )
    )

    // Array.from(document.querySelectorAll('form select#cat option.level-0')).map(a => `Pair("${a.innerText}", "${a.value}")`).join(',\n')
    // from https://vermangasporno.com/
    private class Category : UriPartFilter(
        "Filtrar por categoría",
        arrayOf(
            Pair("Ver todos", ""),
            Pair("3×3 Eyes", "1325"),
            Pair("Accel World", "175"),
            Pair("Aikatsu!", "1983"),
            Pair("Akame ga Kill!", "2235"),
            Pair("Akaruku Tanoshiku Kimochiyoku", "2268"),
            Pair("Amagami", "1194"),
            Pair("Amagi Brilliant Park", "209"),
            Pair("Amano Megumi ha Sukidarake!", "888"),
            Pair("Ane Doki", "1121"),
            Pair("Angel Beats!", "176"),
            Pair("Ano Hi Mita Hana no Namae wo Bokutachi wa Mada Shiranai", "1097"),
            Pair("Another", "177"),
            Pair("Ansatsu Kyoushitsu", "2"),
            Pair("Aoi Hana", "1256"),
            Pair("Aquarion EVOL", "2089"),
            Pair("Arcana Heart", "934"),
            Pair("Arslan senki", "2068"),
            Pair("Asobi ni Iku yo!", "1280"),
            Pair("Azur Lane", "2076"),
            Pair("Baka to Test to Shoukanjuu", "1202"),
            Pair("Baka to Test to Shoukanjuu | Autor: Kurosawa Kiyotaka", "1201"),
            Pair("Bakemonogatari", "931"),
            Pair("Bakuman", "1259"),
            Pair("BanG Dream!", "1863"),
            Pair("Batman", "184"),
            Pair("bijin onna joushi takizawa-san", "2104"),
            Pair("Bishoujo Senshi Sailor Moon", "745"),
            Pair("Bleach", "82"),
            Pair("Blend S", "2102"),
            Pair("Blood+", "189"),
            Pair("Boku no Hero Academia", "245"),
            Pair("Boku wa tomodachi ga sukunai", "674"),
            Pair("Bokutachi wa Benkyou ga Dekinai", "2180"),
            Pair("Boruto", "2071"),
            Pair("Capcom", "251"),
            Pair("Charlotte", "1444"),
            Pair("Clannad", "102"),
            Pair("Claymore", "170"),
            Pair("Code Geass", "171"),
            Pair("Cyberbots", "981"),
            Pair("Dagashi Kashi", "733"),
            Pair("Danganronpa", "92"),
            Pair("Danmachi", "1042"),
            Pair("Darker than Black", "995"),
            Pair("Darker than Black: The Black Contractor", "1086"),
            Pair("Darkstalkers", "1996"),
            Pair("Date A Live", "670"),
            Pair("Dead Or Alive", "233"),
            Pair("Deadman Wonderland", "900"),
            Pair("Denpa Onna to Seishun Otoko", "952"),
            Pair("Dokidoki! Precure", "1919"),
            Pair("Dr. Slump", "977"),
            Pair("Dragon Quest", "3"),
            Pair("dragon quest iii", "239"),
            Pair("Dragonball", "4"),
            Pair("Dragon’s Crown", "1064"),
            Pair("DREAM C CLUB", "941"),
            Pair("Dungeon Ni Deai O Motomeru No Wa Machigatteiru Darou Ka", "226"),
            Pair("Dungeon ni Deai wo Motomeru no wa Machigatteiru Darou ka", "127"),
            Pair("Dungeon Travelers", "1951"),
            Pair("Dynasty Warriors", "1885"),
            Pair("Enen no Shouboutai", "2169"),
            Pair("Eromanga Sensei", "901"),
            Pair("Evangelion", "172"),
            Pair("Fairy Tail", "348"),
            Pair("Fantasy Earth Zero", "1433"),
            Pair("Fate Kaleid Liner Prisma Illya", "237"),
            Pair("Fate Stay Night", "235"),
            Pair("Fate/Grand Order", "891"),
            Pair("Fate/hollow ataraxia", "1294"),
            Pair("Fate/stay night", "722"),
            Pair("Final Fantasy", "591"),
            Pair("Final Figh", "1215"),
            Pair("Freezing", "190"),
            Pair("Full Metal Daemon: Muramasa", "122"),
            Pair("Full Metal Panic", "167"),
            Pair("Fullmetal Alchemist", "118"),
            Pair("Furry", "1972"),
            Pair("Gabriel Dropout", "884"),
            Pair("Gakkou Gurashi!", "1047"),
            Pair("Gate: Jieitai Kano Chi nite Kaku Tatakaeri", "761"),
            Pair("Gate: Jieitai Kanochi nite", "241"),
            Pair("Gate: Jieitai Kanochi nite Kaku Tatakaeri", "243"),
            Pair("Gegege no Kitarou", "1862"),
            Pair("Getsuyoubi no Tawawa", "250"),
            Pair("Ghost In The Shell", "1898"),
            Pair("Girls und Panzer", "904"),
            Pair("Goblin Slayer", "2143"),
            Pair("Gochuumon wa Usagi Desu ka?", "5"),
            Pair("Golden Kamuy", "2227"),
            Pair("Gotoubun no Hanayome", "2251"),
            Pair("Granblue Fantasy", "257"),
            Pair("Grisaia no Kajitsu", "6"),
            Pair("Guilty Gear", "727"),
            Pair("Gundam 00", "857"),
            Pair("Gundam Build Divers", "2137"),
            Pair("Gundam Build Fighters", "7"),
            Pair("Gundam SEED Destiny", "103"),
            Pair("Hanasaku Iroha", "1104"),
            Pair("Hanayamata", "1947"),
            Pair("Hatsujou no Genri", "2139"),
            Pair("Hatsukoi Delusion", "1930"),
            Pair("Hayate no Gotoku!", "595"),
            Pair("He Is My Master", "104"),
            Pair("Hentai Ouji to Warawanai Neko.", "8"),
            Pair("Hibike! Euphonium", "9"),
            Pair("Highschool Dead", "168"),
            Pair("Highschool DxD", "105"),
            Pair("Highschool of the Dead", "937"),
            Pair("Himouto! Umaru-chan", "1039"),
            Pair("Hokenshitsu no Shinigami", "1105"),
            Pair("Honkai Gakuen", "2165"),
            Pair("Hyperdimension Neptunia", "1567"),
            Pair("Ichigo 100%", "151"),
            Pair("Incesto", "182"),
            Pair("Infinite Stratos", "786"),
            Pair("Isekai Maou to Shoukan Shoujo no Dorei Majutsu", "2170"),
            Pair("K-ON", "150"),
            Pair("Kaguya Luna", "2249"),
            Pair("Kaguya-sama wa Kokurasetai", "2157"),
            Pair("Kaichou wa Maid-sama!", "1129"),
            Pair("Kaiten Mutenmaru", "911"),
            Pair("Kami Nomi zo Shiru Sekai", "1091"),
            Pair("Kämpfer", "1120"),
            Pair("Kangoku Gakuen", "1036"),
            Pair("Kanon", "65"),
            Pair("Kantai Collection: KanColle", "10"),
            Pair("Kara no Kyoukai", "731"),
            Pair("Kenichi", "96"),
            Pair("Keroro Gunsou", "11"),
            Pair("Kidou Senshi Gundam 00", "960"),
            Pair("Kill la Kill", "1851"),
            Pair("Kimetsu no Yaiba", "2149"),
            Pair("Kimi ni Todoke", "1127"),
            Pair("Kimi no Na wa", "2147"),
            Pair("KimiKiss", "1182"),
            Pair("King of fighter", "155"),
            Pair("King of Fighters", "788"),
            Pair("Kiratto Pri Chan", "2182"),
            Pair("Kobayashi-san-chi no Maid Dragon", "299"),
            Pair("Koihime Musou", "1188"),
            Pair("Kono Subarashii Sekai Ni Syukufuku O", "259"),
            Pair("Kono Subarashii Sekai ni Syukufuku o!", "853"),
            Pair("Konosuba!", "2128"),
            Pair("Kurogane no Linebarrels", "1150"),
            Pair("Kyoukai Senjou no Horizon", "660"),
            Pair("Ladies Versus Butlers", "204"),
            Pair("Little Witch Academia", "2127"),
            Pair("Love Hina", "94"),
            Pair("Love Live Sunshine", "207"),
            Pair("Love Live!", "716"),
            Pair("Love Live! School Idol Project", "12"),
            Pair("Love Plus", "1013"),
            Pair("Lucky Star", "893"),
            Pair("Macross Frontier", "157"),
            Pair("Mahou Sensei Negima", "61"),
            Pair("Mahou Sensei Negima!", "1331"),
            Pair("Mahou Shoujo Lyrical Nanoha", "13"),
            Pair("Mahouka Koukou no Rettousei", "93"),
            Pair("Mai-Otome", "2271"),
            Pair("Maji de Watashi ni Koi Shinasai!", "1218"),
            Pair("Maria-sama ga Miteru", "902"),
            Pair("Mayo Chiki!", "137"),
            Pair("Medaka Box", "615"),
            Pair("Minecraft", "2098"),
            Pair("Mirai Nikki", "1138"),
            Pair("Mitsuboshi Colors", "2307"),
            Pair("Mobile Suit Gundam Tekketsu No Orphans", "297"),
            Pair("Mondaiji-tachi ga Isekai Kara Kuru Sou Desu yo?", "1403"),
            Pair("Monster Hunter", "1742"),
            Pair("Monster Musume no Iru Nichijou", "683"),
            Pair("Moyashimon", "1509"),
            Pair("Musaigen no Phantom World", "298"),
            Pair("Nagi no Asukara", "1830"),
            Pair("Nanatsu no Taizai", "2299"),
            Pair("Naruto", "14"),
            Pair("Nazo no Kanojo X", "1247"),
            Pair("Neon Genesis Evangelion", "62"),
            Pair("Nisekoi", "246"),
            Pair("Nyan Koi!", "978"),
            Pair("Oboro Muramasa", "1116"),
            Pair("Ojousama to Maid no Midarana Seikatsu", "1931"),
            Pair("Okusan", "998"),
            Pair("One Piece", "68"),
            Pair("One Punch Man", "188"),
            Pair("Onegai Teacher", "1076"),
            Pair("Ookami to Koushinryou", "958"),
            Pair("Ookami-san to Shichinin no Nakama-tachi", "1244"),
            Pair("Ore no Imouto ga Konna ni Kawaii Wake ga Nai", "328"),
            Pair("Original", "15"),
            Pair("Oshiete! Galko-chan", "2136"),
            Pair("Overlord", "686"),
            Pair("Overwatch", "260"),
            Pair("Panty & Stocking with Garterbelt", "1176"),
            Pair("Papa no Iu Koto o Kikinasai!", "976"),
            Pair("Parasyte", "1911"),
            Pair("Persona 3", "255"),
            Pair("Persona 4", "953"),
            Pair("Persona 5", "2265"),
            Pair("Pokemon", "148"),
            Pair("Princess crown", "983"),
            Pair("Princess Lover!", "1175"),
            Pair("Prison School", "164"),
            Pair("Psycho-Pass", "2275"),
            Pair("Puella Magi Madoka Magica", "948"),
            Pair("Queen’s Blade", "656"),
            Pair("Ragnarok Online", "1243"),
            Pair("Rakudai Kishi no Cavalry", "765"),
            Pair("Rakuen Tsuihou -Expelled from Paradise-", "1045"),
            Pair("Ranma 1/2", "767"),
            Pair("Re:Zero kara Hajimeru Isekai Seikatsu", "161"),
            Pair("Real Drive", "261"),
            Pair("Rebuild of evangelion", "149"),
            Pair("Renkin San-kyuu Magical? Pokaan", "737"),
            Pair("Resident Evil", "1118"),
            Pair("Rockman DASH", "1242"),
            Pair("Rokka no Yuusha", "1600"),
            Pair("Rosario + Vampire", "1204"),
            Pair("Rosario Vampire", "234"),
            Pair("Rozen Maiden", "1240"),
            Pair("Rurouni Kenshin", "1520"),
            Pair("Saber Marionette", "73"),
            Pair("Saenai Heroine no Sodatekata", "926"),
            Pair("Sailor Moon", "186"),
            Pair("Saint Seiya", "66"),
            Pair("Saki", "258"),
            Pair("School Rumble", "191"),
            Pair("Sekirei", "180"),
            Pair("Sekiro: Shadows Die Twice", "2152"),
            Pair("Serial Experiments Lain", "1498"),
            Pair("Seto No Hanayome", "219"),
            Pair("Shadowverse", "1957"),
            Pair("Shantae", "1050"),
            Pair("Shijou Saikyou no Deshi Kenichi", "1144"),
            Pair("Shingeki no Kyojin", "169"),
            Pair("Shingetsutan Tsukihime", "16"),
            Pair("Shinmai Fukei Kiruko-san", "2207"),
            Pair("Shinmai Maou no Testament", "17"),
            Pair("Shinra Bansho", "18"),
            Pair("Shinrabansho", "2063"),
            Pair("Shinrabanshou", "1979"),
            Pair("Shinryaku! Ika Musume", "1160"),
            Pair("shirokuma cafe", "2074"),
            Pair("Shitsuke Ai", "1630"),
            Pair("Shokugeki no Soma", "152"),
            Pair("Smile Precure", "858"),
            Pair("Smile PreCure!", "1841"),
            Pair("SNK", "252"),
            Pair("Sora no Otoshimono", "20"),
            Pair("Soul Eater", "158"),
            Pair("Space Dandy", "1826"),
            Pair("Spice and wolf", "154"),
            Pair("Spider-man", "2140"),
            Pair("Star Twinkle PreCure", "2310"),
            Pair("Steins;Gate", "992"),
            Pair("Street Fighter", "101"),
            Pair("Strike Witches", "642"),
            Pair("Subarashii Sekai ni Shukufuku wo!", "739"),
            Pair("Suite Precure♪", "145"),
            Pair("Super Sonico", "1102"),
            Pair("Super Street Fighter IV", "802"),
            Pair("Suzumiya Haruhi No Yuuutsu", "314"),
            Pair("Sword art online", "147"),
            Pair("taimanin asagi", "1869"),
            Pair("Taimanin Yukikaze", "826"),
            Pair("Tales of the Abyss", "1148"),
            Pair("Tamako Market", "770"),
            Pair("Tate no Yuusha no Nariagari", "2184"),
            Pair("Teen Titans", "21"),
            Pair("Tengen Toppa Gurren Lagann", "1190"),
            Pair("Tengen Toppa Gurren-Lagann", "100"),
            Pair("Tera", "2215"),
            Pair("TERA The Exiled Realm of Arborea", "2214"),
            Pair("Terra Formars", "2073"),
            Pair("The iDOLM@STER", "22"),
            Pair("the loud house", "2054"),
            Pair("The OneChanbara", "1053"),
            Pair("The Seven Deadly Sins", "620"),
            Pair("To Love-Ru", "23"),
            Pair("To Love-Ru Darkness", "1135"),
            Pair("Toaru Kagaku no Railgun", "769"),
            Pair("Toaru Majutsu no Index", "741"),
            Pair("ToHeart", "1164"),
            Pair("ToHeart2", "905"),
            Pair("ToHeart2 AnotherDays", "97"),
            Pair("Tokyo 7th Sisters", "762"),
            Pair("Tokyo Ghoul", "864"),
            Pair("Tonari no Seki-kun", "1768"),
            Pair("Toradora", "192"),
            Pair("Toradora!", "1152"),
            Pair("Touhou Project", "24"),
            Pair("Traducción Exclusiva", "2285"),
            Pair("Tsujou Kougeki ga Zentai Kougeki de 2-kai Kougeki no Okaasan wa Suki desu ka?", "2131"),
            Pair("Tsukihime", "877"),
            Pair("Uchuu no Stellvia", "715"),
            Pair("Utawarerumono", "1905"),
            Pair("Uzaki-chan wa Asobitai!", "2146"),
            Pair("Valkyria Chronicles", "1084"),
            Pair("Vampire savior", "982"),
            Pair("Vocaloid", "912"),
            Pair("Watashi ga Motenai no wa Dou Kangaetemo Omaera ga Warui!", "1032"),
            Pair("Witch Craft Works", "552"),
            Pair("Witchblade", "1302"),
            Pair("Wizard of Oz", "723"),
            Pair("Yahari Ore no Seishun Love Come wa Machigatteiru", "967"),
            Pair("Yakitate!! Japan", "1409"),
            Pair("yatterman", "984"),
            Pair("Yotsubato!", "1429"),
            Pair("Yu-Gi-Oh! ZEXAL", "196"),
            Pair("Yuru Yuri", "25"),
            Pair("YuruYuri", "894"),
            Pair("Zegapain", "1330"),
            Pair("Zero no Tsukaima", "26"),
            Pair("Zettai Junpaku Mahou Shoujo", "1918"),
            Pair("Zettai Karen Children", "1417"),
            Pair("Zoids Shinseiki Zero", "153"),
            Pair("Zombieland Saga", "2059")
        )
    )
}

open class UriPartFilter(displayName: String, private val vals: Array<Pair<String, String>>) :
    Filter.Select<String>(displayName, vals.map { it.first }.toTypedArray()) {
    fun toUriPart() = vals[state].second
}
