from django.contrib.auth import views as auth_views
from django.urls import path, re_path

from . import views as v

UUID = "[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}"

urlpatterns = [
    # Home
    re_path(r"^$", v.index, name="index"),
    # Login
    re_path(r"^login", v.login, name="login"),
    re_path(r"^logout", v.logout, name="logout"),
    re_path(r"^register", v.register, name="register"),
    # Built-In views
    path(
        "password_reset/",
        auth_views.PasswordResetView.as_view(template_name="static/password_reset_form.html"),
        name="password_reset",
    ),
    path(
        "password_reset/done/",
        auth_views.PasswordResetDoneView.as_view(template_name="static/password_reset_done.html"),
        name="password_reset_done",
    ),
    path(
        "reset/<uidb64>/<token>/",
        auth_views.PasswordResetConfirmView.as_view(
            template_name="static/password_reset_confirm.html"
        ),
        name="password_reset_confirm",
    ),
    path(
        "reset/done/",
        auth_views.PasswordResetCompleteView.as_view(
            template_name="static/password_reset_complete.html"
        ),
        name="password_reset_complete",
    ),
    # Top level urls
    re_path(r"^package$", v.packages, name="packages"),
    re_path(r"^compound$", v.compounds, name="compounds"),
    re_path(r"^rule$", v.rules, name="rules"),
    re_path(r"^reaction$", v.reactions, name="reactions"),
    re_path(r"^pathway$", v.pathways, name="pathways"),
    re_path(r"^scenario$", v.scenarios, name="scenarios"),
    re_path(r"^model$", v.models, name="model"),
    re_path(r"^user$", v.users, name="users"),
    re_path(r"^group$", v.groups, name="groups"),
    re_path(r"^search$", v.search, name="search"),
    re_path(r"^predict$", v.predict_pathway, name="predict_pathway"),
    re_path(r"^batch-predict$", v.batch_predict_pathway, name="batch_predict_pathway"),
    # User Detail
    re_path(rf"^user/(?P<user_uuid>{UUID})", v.user, name="user"),
    # Group Detail
    re_path(rf"^group/(?P<group_uuid>{UUID})$", v.group, name="group detail"),
    # "in package" urls
    re_path(rf"^package/(?P<package_uuid>{UUID})$", v.package, name="package detail"),
    # Compound
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/compound$",
        v.package_compounds,
        name="package compound list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/compound/(?P<compound_uuid>{UUID})$",
        v.package_compound,
        name="package compound detail",
    ),
    # Compound Structure
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/compound/(?P<compound_uuid>{UUID})/structure$",
        v.package_compound_structures,
        name="package compound structure list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/compound/(?P<compound_uuid>{UUID})/structure/(?P<structure_uuid>{UUID})$",
        v.package_compound_structure,
        name="package compound structure detail",
    ),
    # Rule
    re_path(rf"^package/(?P<package_uuid>{UUID})/rule$", v.package_rules, name="package rule list"),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/rule/(?P<rule_uuid>{UUID})$",
        v.package_rule,
        name="package rule detail",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/simple-ambit-rule/(?P<rule_uuid>{UUID})$",
        v.package_rule,
        name="package rule detail",
    ),
    # re_path(
    #     rf"^package/(?P<package_uuid>{UUID})/simple-rdkit-rule/(?P<rule_uuid>{UUID})$",
    #     v.package_rule,
    #     name="package rule detail",
    # ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/parallel-rule/(?P<rule_uuid>{UUID})$",
        v.package_rule,
        name="package rule detail",
    ),
    # re_path(
    #     rf"^package/(?P<package_uuid>{UUID})/sequential-rule/(?P<rule_uuid>{UUID})$",
    #     v.package_rule,
    #     name="package rule detail",
    # ),
    # EnzymeLinks
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/rule/(?P<rule_uuid>{UUID})/enzymelink/(?P<enzymelink_uuid>{UUID})$",
        v.package_rule_enzymelink,
        name="package rule enzymelink detail",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/simple-ambit-rule/(?P<rule_uuid>{UUID})/enzymelink/(?P<enzymelink_uuid>{UUID})$",
        v.package_rule_enzymelink,
        name="package rule enzymelink detail",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/parallel-rule/(?P<rule_uuid>{UUID})/enzymelink/(?P<enzymelink_uuid>{UUID})$",
        v.package_rule_enzymelink,
        name="package rule enzymelink detail",
    ),
    # Reaction
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/reaction$",
        v.package_reactions,
        name="package reaction list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/reaction/(?P<reaction_uuid>{UUID})$",
        v.package_reaction,
        name="package reaction detail",
    ),
    # # Pathway
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway$",
        v.package_pathways,
        name="package pathway list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway/(?P<pathway_uuid>{UUID})$",
        v.package_pathway,
        name="package pathway detail",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/predict$",
        v.package_predict_pathway,
        name="package predict pathway",
    ),
    # Pathway Nodes
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway/(?P<pathway_uuid>{UUID})/node$",
        v.package_pathway_nodes,
        name="package pathway node list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway/(?P<pathway_uuid>{UUID})/node/(?P<node_uuid>{UUID})$",
        v.package_pathway_node,
        name="package pathway node detail",
    ),
    # Pathway Edges
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway/(?P<pathway_uuid>{UUID})/edge$",
        v.package_pathway_edges,
        name="package pathway edge list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/pathway/(?P<pathway_uuid>{UUID})/edge/(?P<edge_uuid>{UUID})$",
        v.package_pathway_edge,
        name="package pathway edge detail",
    ),
    # Scenario
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/scenario$",
        v.package_scenarios,
        name="package scenario list",
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/scenario/(?P<scenario_uuid>{UUID})$",
        v.package_scenario,
        name="package scenario detail",
    ),
    # Model
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/model$", v.package_models, name="package model list"
    ),
    re_path(
        rf"^package/(?P<package_uuid>{UUID})/model/(?P<model_uuid>{UUID})$",
        v.package_model,
        name="package model detail",
    ),
    re_path(r"^setting$", v.settings, name="settings"),
    re_path(rf"^setting/(?P<setting_uuid>{UUID})", v.setting, name="setting"),
    re_path(r"^indigo/info$", v.indigo, name="indigo_info"),
    re_path(r"^indigo/aromatize$", v.aromatize, name="indigo_aromatize"),
    re_path(r"^indigo/dearomatize$", v.dearomatize, name="indigo_dearomatize"),
    re_path(r"^indigo/layout$", v.layout, name="indigo_layout"),
    re_path(r"^depict$", v.depict, name="depict"),
    path("jobs", v.jobs, name="jobs"),
    path("jobs/<uuid:job_uuid>", v.job, name="job detail"),
    # OAuth Stuff
    path("o/userinfo/", v.userinfo, name="oauth_userinfo"),
    # Static Pages
    re_path(r"^terms$", v.static_terms_of_use, name="terms_of_use"),
    re_path(r"^privacy$", v.static_privacy_policy, name="privacy_policy"),
    re_path(r"^cookie-policy$", v.static_cookie_policy, name="cookie_policy"),
    re_path(r"^about$", v.static_about_us, name="about_us"),
    re_path(r"^contact$", v.static_contact_support, name="contact_support"),
    re_path(r"^careers$", v.static_careers, name="careers"),
    re_path(r"^cite$", v.static_cite, name="cite"),
]
