package eu.kanade.tachiyomi.animeextension.all.javguru

import eu.kanade.tachiyomi.animesource.model.AnimeFilter
import eu.kanade.tachiyomi.animesource.model.AnimeFilterList

fun getFilters() = AnimeFilterList(
    AnimeFilter.Header("Only One Filter Works at a time!!"),
    AnimeFilter.Header("Ignored With Text Search!!"),
    TagFilter(),
    CategoryFilter(),
    AnimeFilter.Separator(),
    ActressFilter(),
    ActorFilter(),
    StudioFilter(),
    MakerFilter(),
)

class UriPartFilter(val name: String, val urlPart: String)

abstract class UriPartFilters(name: String, private val tags: List<UriPartFilter>) :
    AnimeFilter.Select<String>(name, tags.map { it.name }.toTypedArray()) {
    fun toUrlPart() = tags[state].urlPart
}

class TagFilter : UriPartFilters("Tags", TAGS)

class CategoryFilter : UriPartFilters("Categories", CATEGORIES)

abstract class TextFilter(name: String, private val urlSubDirectory: String) : AnimeFilter.Text(name) {
    fun toUrlPart() = state.trim()
        .lowercase()
        .replace(SPECIAL_CHAR_REGEX, "-")
        .replace(TRAILING_HIPHEN_REGEX, "")
        .let { "/$urlSubDirectory/$it/" }

    companion object {
        private val SPECIAL_CHAR_REGEX = "[^a-z0-9]+".toRegex()
        private val TRAILING_HIPHEN_REGEX = "-+$".toRegex()
    }
}

class ActressFilter : TextFilter("Actress", "actress")

class ActorFilter : TextFilter("Actor", "actor")

class StudioFilter : TextFilter("Studio", "studio")

class MakerFilter : TextFilter("Maker", "maker")

fun <T> AnimeFilter<T>.toUrlPart(): String? {
    return when (this) {
        is TagFilter -> this.toUrlPart()
        is CategoryFilter -> this.toUrlPart()
        is ActressFilter -> this.toUrlPart()
        is ActorFilter -> this.toUrlPart()
        is StudioFilter -> this.toUrlPart()
        is MakerFilter -> this.toUrlPart()
        else -> null
    }
}

val TAGS = listOf(
    UriPartFilter("", "/"),
    UriPartFilter("Solowork", "/tag/solowork/"),
    UriPartFilter("Creampie", "/tag/creampie/"),
    UriPartFilter("Big tits", "/tag/big-tits/"),
    UriPartFilter("Beautiful Girl", "/tag/beautiful-girl/"),
    UriPartFilter("Married Woman", "/tag/married-woman/"),
    UriPartFilter("Amateur", "/tag/amateur/"),
    UriPartFilter("Digital Mosaic", "/tag/digital-mosaic/"),
    UriPartFilter("Slut", "/tag/slut/"),
    UriPartFilter("Mature Woman", "/tag/mature-woman/"),
    UriPartFilter("Cuckold", "/tag/cuckold/"),
    UriPartFilter("3P", "/tag/3p/"),
    UriPartFilter("Slender", "/tag/slender/"),
    UriPartFilter("Blow", "/tag/blow/"),
    UriPartFilter("Squirting", "/tag/squirting/"),
    UriPartFilter("Drama", "/tag/drama/"),
    UriPartFilter("Nasty", "/tag/nasty/"),
    UriPartFilter("Hardcore", "/tag/hardcore/"),
    UriPartFilter("School Girls", "/tag/school-girls/"),
    UriPartFilter("4P", "/tag/4p/"),
    UriPartFilter("Titty fuck", "/tag/titty-fuck/"),
    UriPartFilter("Cowgirl", "/tag/cowgirl/"),
    UriPartFilter("Incest", "/tag/incest/"),
    UriPartFilter("Facials", "/tag/facials/"),
    UriPartFilter("breasts", "/tag/breasts/"),
    UriPartFilter("abuse", "/tag/abuse/"),
    UriPartFilter("Risky Mosaic", "/tag/risky-mosaic/"),
    UriPartFilter("Debut Production", "/tag/debut-production/"),
    UriPartFilter("Older sister", "/tag/older-sister/"),
    UriPartFilter("Huge Butt", "/tag/huge-butt/"),
    UriPartFilter("4HR+", "/tag/4hr/"),
    UriPartFilter("Affair", "/tag/affair/"),
    UriPartFilter("Kiss", "/tag/kiss/"),
    UriPartFilter("Deep Throating", "/tag/deep-throating/"),
    UriPartFilter("Documentary", "/tag/documentary/"),
    UriPartFilter("Mini", "/tag/mini/"),
    UriPartFilter("Entertainer", "/tag/entertainer/"),
    UriPartFilter("Dirty Words", "/tag/dirty-words/"),
    UriPartFilter("Cosplay", "/tag/cosplay/"),
    UriPartFilter("POV", "/tag/pov/"),
    UriPartFilter("Shaved", "/tag/shaved/"),
    UriPartFilter("butt", "/tag/butt/"),
    UriPartFilter("OL", "/tag/ol/"),
    UriPartFilter("Tits", "/tag/tits/"),
    UriPartFilter("Promiscuity", "/tag/promiscuity/"),
    UriPartFilter("Restraint", "/tag/restraint/"),
    UriPartFilter("Gal", "/tag/gal/"),
    UriPartFilter("planning", "/tag/planning/"),
    UriPartFilter("Subjectivity", "/tag/subjectivity/"),
    UriPartFilter("Handjob", "/tag/handjob/"),
    UriPartFilter("Uniform", "/tag/uniform/"),
    UriPartFilter("Sister", "/tag/sister/"),
    UriPartFilter("Humiliation", "/tag/humiliation/"),
    UriPartFilter("Prostitutes", "/tag/prostitutes/"),
    UriPartFilter("School Uniform", "/tag/school-uniform/"),
    UriPartFilter("Rape", "/tag/rape/"),
    UriPartFilter("Lesbian", "/tag/lesbian/"),
    UriPartFilter("Anal", "/tag/anal/"),
    UriPartFilter("Image video", "/tag/image-video/"),
    UriPartFilter("Pantyhose", "/tag/pantyhose/"),
    UriPartFilter("Other fetish", "/tag/other-fetish/"),
    UriPartFilter("Female College Student", "/tag/female-college-student/"),
    UriPartFilter("Female teacher", "/tag/female-teacher/"),
    UriPartFilter("Bukkake", "/tag/bukkake/"),
    UriPartFilter("Training", "/tag/training/"),
    UriPartFilter("Cum", "/tag/cum/"),
    UriPartFilter("Masturbation", "/tag/masturbation/"),
    UriPartFilter("Sweat", "/tag/sweat/"),
    UriPartFilter("Omnibus", "/tag/omnibus/"),
    UriPartFilter("Best", "/tag/best/"),
    UriPartFilter("Lotion", "/tag/lotion/"),
    UriPartFilter("Girl", "/tag/girl/"),
    UriPartFilter("Submissive Men", "/tag/submissive-men/"),
    UriPartFilter("Outdoors", "/tag/outdoors/"),
    UriPartFilter("Beauty Shop", "/tag/beauty-shop/"),
    UriPartFilter("Busty fetish", "/tag/busty-fetish/"),
    UriPartFilter("Toy", "/tag/toy/"),
    UriPartFilter("Urination", "/tag/urination/"),
    UriPartFilter("huge cock", "/tag/huge-cock/"),
    UriPartFilter("Gangbang", "/tag/gangbang/"),
    UriPartFilter("Massage", "/tag/massage/"),
    UriPartFilter("Tall", "/tag/tall/"),
    UriPartFilter("Hot Spring", "/tag/hot-spring/"),
    UriPartFilter("virgin man", "/tag/virgin-man/"),
    UriPartFilter("Various Professions", "/tag/various-professions/"),
    UriPartFilter("Bride", "/tag/bride/"),
    UriPartFilter("Leg Fetish", "/tag/leg-fetish/"),
    UriPartFilter("Young wife", "/tag/young-wife/"),
    UriPartFilter("Maid", "/tag/maid/"),
    UriPartFilter("BBW", "/tag/bbw/"),
    UriPartFilter("SM", "/tag/sm/"),
    UriPartFilter("Restraints", "/tag/restraints/"),
    UriPartFilter("Lesbian Kiss", "/tag/lesbian-kiss/"),
    UriPartFilter("Voyeur", "/tag/voyeur/"),
    UriPartFilter("Mother", "/tag/mother/"),
    UriPartFilter("Evil", "/tag/evil/"),
    UriPartFilter("Underwear", "/tag/underwear/"),
    UriPartFilter("Nurse", "/tag/nurse/"),
    UriPartFilter("Glasses", "/tag/glasses/"),
    UriPartFilter("Lingerie", "/tag/lingerie/"),
    UriPartFilter("Drug", "/tag/drug/"),
    UriPartFilter("Nampa", "/tag/nampa/"),
    UriPartFilter("School Swimsuit", "/tag/school-swimsuit/"),
    UriPartFilter("Stepmother", "/tag/stepmother/"),
    UriPartFilter("Sailor suit", "/tag/sailor-suit/"),
    UriPartFilter("Prank", "/tag/prank/"),
    UriPartFilter("Cunnilingus", "/tag/cunnilingus/"),
    UriPartFilter("Electric Massager", "/tag/electric-massager/"),
    UriPartFilter("Molester", "/tag/molester/"),
    UriPartFilter("Black Actor", "/tag/black-actor/"),
    UriPartFilter("Ultra-Huge Tits", "/tag/ultra-huge-tits/"),
    UriPartFilter("Original Collaboration", "/tag/original-collaboration/"),
    UriPartFilter("Confinement", "/tag/confinement/"),
    UriPartFilter("Shotacon", "/tag/shotacon/"),
    UriPartFilter("Footjob", "/tag/footjob/"),
    UriPartFilter("Female Boss", "/tag/female-boss/"),
    UriPartFilter("Female investigator", "/tag/female-investigator/"),
    UriPartFilter("Swimsuit", "/tag/swimsuit/"),
    UriPartFilter("Bloomers", "/tag/bloomers/"),
    UriPartFilter("Facesitting", "/tag/facesitting/"),
    UriPartFilter("Kimono", "/tag/kimono/"),
    UriPartFilter("Mourning", "/tag/mourning/"),
    UriPartFilter("White Actress", "/tag/white-actress/"),
    UriPartFilter("Acme · Orgasm", "/tag/acme-%c2%b7-orgasm/"),
    UriPartFilter("Sun tan", "/tag/sun-tan/"),
    UriPartFilter("Finger Fuck", "/tag/finger-fuck/"),
    UriPartFilter("Transsexual", "/tag/transsexual/"),
    UriPartFilter("Blu-ray", "/tag/blu-ray/"),
    UriPartFilter("VR", "/tag/vr/"),
    UriPartFilter("Cross Dressing", "/tag/cross-dressing/"),
    UriPartFilter("Soapland", "/tag/soapland/"),
    UriPartFilter("Fan Appreciation", "/tag/fan-appreciation/"),
    UriPartFilter("AV Actress", "/tag/av-actress/"),
    UriPartFilter("School Stuff", "/tag/school-stuff/"),
    UriPartFilter("Love", "/tag/love/"),
    UriPartFilter("Close Up", "/tag/close-up/"),
    UriPartFilter("Submissive Woman", "/tag/submissive-woman/"),
    UriPartFilter("Mini Skirt", "/tag/mini-skirt/"),
    UriPartFilter("Impromptu Sex", "/tag/impromptu-sex/"),
    UriPartFilter("Vibe", "/tag/vibe/"),
    UriPartFilter("Bitch", "/tag/bitch/"),
    UriPartFilter("Enema", "/tag/enema/"),
    UriPartFilter("Hypnosis", "/tag/hypnosis/"),
    UriPartFilter("Childhood Friend", "/tag/childhood-friend/"),
    UriPartFilter("Erotic Wear", "/tag/erotic-wear/"),
    UriPartFilter("Tutor", "/tag/tutor/"),
    UriPartFilter("Male Squirting", "/tag/male-squirting/"),
    UriPartFilter("Bath", "/tag/bath/"),
    UriPartFilter("Conceived", "/tag/conceived/"),
    UriPartFilter("Stewardess", "/tag/stewardess/"),
    UriPartFilter("Sport", "/tag/sport/"),
    UriPartFilter("Bunny Girl", "/tag/bunny-girl/"),
    UriPartFilter("Piss Drinking", "/tag/piss-drinking/"),
    UriPartFilter("Shibari", "/tag/shibari/"),
    UriPartFilter("Couple", "/tag/couple/"),
    UriPartFilter("Anchorwoman", "/tag/anchorwoman/"),
    UriPartFilter("Delusion", "/tag/delusion/"),
    UriPartFilter("69", "/tag/69/"),
    UriPartFilter("Secretary", "/tag/secretary/"),
    UriPartFilter("Idol", "/tag/idol/"),
    UriPartFilter("Elder Male", "/tag/elder-male/"),
    UriPartFilter("Cervix", "/tag/cervix/"),
    UriPartFilter("Leotard", "/tag/leotard/"),
    UriPartFilter("Miss", "/tag/miss/"),
    UriPartFilter("Back", "/tag/back/"),
    UriPartFilter("blog", "/tag/blog/"),
    UriPartFilter("virgin", "/tag/virgin/"),
    UriPartFilter("Female Doctor", "/tag/female-doctor/"),
    UriPartFilter("No Bra", "/tag/no-bra/"),
    UriPartFilter("Tsundere", "/tag/tsundere/"),
    UriPartFilter("Race Queen", "/tag/race-queen/"),
    UriPartFilter("Multiple Story", "/tag/multiple-story/"),
    UriPartFilter("Widow", "/tag/widow/"),
    UriPartFilter("Actress Best", "/tag/actress-best/"),
    UriPartFilter("Bondage", "/tag/bondage/"),
    UriPartFilter("Muscle", "/tag/muscle/"),
    UriPartFilter("User Submission", "/tag/user-submission/"),
    UriPartFilter("Breast Milk", "/tag/breast-milk/"),
    UriPartFilter("Sexy", "/tag/sexy/"),
    UriPartFilter("Travel", "/tag/travel/"),
    UriPartFilter("Knee Socks", "/tag/knee-socks/"),
    UriPartFilter("Date", "/tag/date/"),
    UriPartFilter("For Women", "/tag/for-women/"),
    UriPartFilter("Premature Ejaculation", "/tag/premature-ejaculation/"),
    UriPartFilter("Hi-Def", "/tag/hi-def/"),
    UriPartFilter("Time Stop", "/tag/time-stop/"),
    UriPartFilter("Subordinates / Colleagues", "/tag/subordinates-colleagues/"),
    UriPartFilter("Adopted Daughter", "/tag/adopted-daughter/"),
    UriPartFilter("Instructor", "/tag/instructor/"),
    UriPartFilter("Catgirl", "/tag/catgirl/"),
    UriPartFilter("Body Conscious", "/tag/body-conscious/"),
    UriPartFilter("Fighting Action", "/tag/fighting-action/"),
    UriPartFilter("Featured Actress", "/tag/featured-actress/"),
    UriPartFilter("Hostess", "/tag/hostess/"),
    UriPartFilter("Dead Drunk", "/tag/dead-drunk/"),
    UriPartFilter("Landlady", "/tag/landlady/"),
    UriPartFilter("Business Attire", "/tag/business-attire/"),
    UriPartFilter("Dildo", "/tag/dildo/"),
    UriPartFilter("Reversed Role", "/tag/reversed-role/"),
    UriPartFilter("Foreign Objects", "/tag/foreign-objects/"),
    UriPartFilter("Athlete", "/tag/athlete/"),
    UriPartFilter("Aunt", "/tag/aunt/"),
    UriPartFilter("Model", "/tag/model/"),
    UriPartFilter("Big Breasts", "/tag/big-breasts/"),
    UriPartFilter("Oversea Import", "/tag/oversea-import/"),
    UriPartFilter("Drinking Party", "/tag/drinking-party/"),
    UriPartFilter("Booth Girl", "/tag/booth-girl/"),
    UriPartFilter("Car Sex", "/tag/car-sex/"),
    UriPartFilter("Blowjob", "/tag/blowjob/"),
    UriPartFilter("Other Asian", "/tag/other-asian/"),
    UriPartFilter("Special Effects", "/tag/special-effects/"),
    UriPartFilter("Spanking", "/tag/spanking/"),
    UriPartFilter("Club Activities / Manager", "/tag/club-activities-manager/"),
    UriPartFilter("Naked Apron", "/tag/naked-apron/"),
    UriPartFilter("Fantasy", "/tag/fantasy/"),
    UriPartFilter("Female Warrior", "/tag/female-warrior/"),
    UriPartFilter("Anime Characters", "/tag/anime-characters/"),
    UriPartFilter("Sex Conversion / Feminized", "/tag/sex-conversion-feminized/"),
    UriPartFilter("Flexible", "/tag/flexible/"),
    UriPartFilter("Schoolgirl", "/tag/schoolgirl/"),
    UriPartFilter("Long Boots", "/tag/long-boots/"),
    UriPartFilter("No Undies", "/tag/no-undies/"),
    UriPartFilter("Immediate Oral", "/tag/immediate-oral/"),
    UriPartFilter("Hospital / Clinic", "/tag/hospital-clinic/"),
    UriPartFilter("Dance", "/tag/dance/"),
    UriPartFilter("Breast Peeker", "/tag/breast-peeker/"),
    UriPartFilter("Waitress", "/tag/waitress/"),
    UriPartFilter("Futanari", "/tag/futanari/"),
    UriPartFilter("Rolling Back Eyes / Fainting", "/tag/rolling-back-eyes-fainting/"),
    UriPartFilter("Hotel", "/tag/hotel/"),
    UriPartFilter("Exposure", "/tag/exposure/"),
    UriPartFilter("Torture", "/tag/torture/"),
    UriPartFilter("Office Lady", "/tag/office-lady/"),
    UriPartFilter("Masturbation Support", "/tag/masturbation-support/"),
    UriPartFilter("facial", "/tag/facial/"),
    UriPartFilter("Egg Vibrator", "/tag/egg-vibrator/"),
    UriPartFilter("Fisting", "/tag/fisting/"),
    UriPartFilter("Vomit", "/tag/vomit/"),
    UriPartFilter("Orgy", "/tag/orgy/"),
    UriPartFilter("Cruel Expression", "/tag/cruel-expression/"),
    UriPartFilter("Doll", "/tag/doll/"),
    UriPartFilter("Loose Socks", "/tag/loose-socks/"),
    UriPartFilter("Best of 2021", "/tag/best-of-2021/"),
    UriPartFilter("Reserved Role", "/tag/reserved-role/"),
    UriPartFilter("Best of 2019", "/tag/best-of-2019/"),
    UriPartFilter("Mother-in-law", "/tag/mother-in-law/"),
    UriPartFilter("Gay", "/tag/gay/"),
    UriPartFilter("Swingers", "/tag/swingers/"),
    UriPartFilter("Best of 2020", "/tag/best-of-2020/"),
    UriPartFilter("Mistress", "/tag/mistress/"),
    UriPartFilter("Shame", "/tag/shame/"),
    UriPartFilter("Yukata", "/tag/yukata/"),
    UriPartFilter("Best of 2017", "/tag/best-of-2017/"),
    UriPartFilter("Best of 2018", "/tag/best-of-2018/"),
    UriPartFilter("Nose Hook", "/tag/nose-hook/"),
)

val CATEGORIES = listOf(
    UriPartFilter("", "/"),
    UriPartFilter("1080p", "/category/1080p/"),
    UriPartFilter("4K", "/category/4k/"),
    UriPartFilter("Amateur", "/category/amateur/"),
    UriPartFilter("Blog", "/category/blog/"),
    UriPartFilter("Decensored", "/category/decensored/"),
    UriPartFilter("English subbed JAV", "/category/english-subbed/"),
    UriPartFilter("FC2", "/category/fc2/"),
    UriPartFilter("HD", "/category/hd/"),
    UriPartFilter("Idol", "/category/idol/"),
    UriPartFilter("JAV", "/category/jav/"),
    UriPartFilter("LEGACY", "/category/legacy/"),
    UriPartFilter("UNCENSORED", "/category/jav-uncensored/"),
    UriPartFilter("VR AV", "/category/vr-av/"),
)
