import streamlit as st
from utils.widgets import html_expander
from utils.translations import _

from .graphes import (
    lancer_visualisation_ihh_ics,
    lancer_visualisation_ihh_ivc
)


def interface_visualisations(G_temp, G_temp_ivc):
    st.markdown(f"# {str(_('pages.visualisations.title'))}")
    html_expander(f"{str(_('pages.visualisations.help'))}", content="\n".join(_("pages.visualisations.help_content")), open_by_default=False, details_class="details_introduction")
    st.markdown("---")

    st.markdown(f"""## {str(_("pages.visualisations.ihh_criticality"))}

{str(_("pages.visualisations.ihh_criticality_desc"))}
""")
    if st.button(str(_("buttons.run")), key="btn_ihh_ics"):
        try:
            lancer_visualisation_ihh_ics(G_temp)
        except Exception as e:
            st.error(f"{str(_('errors.ihh_criticality_error'))} {e}")

    st.markdown(f"""## {str(_("pages.visualisations.ihh_ivc"))}

{str(_("pages.visualisations.ihh_ivc_desc"))}
""")

    if st.button(str(_("buttons.run")), key="btn_ihh_ivc"):
        try:
            lancer_visualisation_ihh_ivc(G_temp_ivc)
        except Exception as e:
            st.error(f"{str(_('errors.ihh_ivc_error'))} {e}")
