<?xml version="1.0" encoding="UTF-8"?>
<faces-config version="4.0"
              xmlns="https://jakarta.ee/xml/ns/jakartaee"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="https://jakarta.ee/xml/ns/jakartaee https://jakarta.ee/xml/ns/jakartaee/web-facesconfig_4_0.xsd">

  <!-- Configuration générale -->
  <application>
    <!-- Configuration de la langue -->
    <locale-config>
      <default-locale>fr</default-locale>
      <supported-locale>en</supported-locale>
    </locale-config>

    <!-- Configuration des messages -->
    <message-bundle>messages</message-bundle>
    <resource-bundle>
      <base-name>messages</base-name>
      <var>msg</var>
    </resource-bundle>

    <!-- Configuration du système de navigation -->
    <navigation-handler>org.primefaces.application.DialogNavigationHandler</navigation-handler>
    <action-listener>org.primefaces.application.DialogActionListener</action-listener>
    <view-handler>org.primefaces.application.DialogViewHandler</view-handler>
  </application>

  <!-- Règles de navigation -->
  <navigation-rule>
    <!-- Navigation depuis la page d'index -->
    <from-view-id>/META-INF/resources/public/index.xhtml</from-view-id>

    <navigation-case>
      <from-outcome>services</from-outcome>
      <to-view-id>/META-INF/resources/private/services.xhtml</to-view-id>
      <redirect />
    </navigation-case>

    <navigation-case>
      <from-outcome>portfolio</from-outcome>
      <to-view-id>/META-INF/resources/private/portfolio.xhtml</to-view-id>
      <redirect />
    </navigation-case>

    <navigation-case>
      <from-outcome>contact</from-outcome>
      <to-view-id>/META-INF/resources/private/contact.xhtml</to-view-id>
      <redirect />
    </navigation-case>
  </navigation-rule>

  <!-- Navigation globale (accessible de partout) -->
  <navigation-rule>
    <navigation-case>
      <from-outcome>home</from-outcome>
      <to-view-id>/META-INF/resources/public/index.xhtml</to-view-id>
      <redirect />
    </navigation-case>

    <navigation-case>
      <from-outcome>mentions-legales</from-outcome>
      <to-view-id>/META-INF/resources/private/mentions-legales.xhtml</to-view-id>
      <redirect />
    </navigation-case>

    <navigation-case>
      <from-outcome>politique-confidentialite</from-outcome>
      <to-view-id>/META-INF/resources/private/politique-confidentialite.xhtml</to-view-id>
      <redirect />
    </navigation-case>
  </navigation-rule>

  <!-- Convertisseurs personnalisés -->
  <converter>
    <converter-id>projectConverter</converter-id>
    <converter-class>dev.lions.utils.converters.ProjectConverter</converter-class>
  </converter>

  <!-- Validateurs personnalisés -->
  <validator>
    <validator-id>emailValidator</validator-id>
    <validator-class>dev.lions.utils.validators.EmailValidator</validator-class>
  </validator>

  <!-- Gestionnaires d'événements du cycle de vie -->
  <lifecycle>
    <phase-listener>dev.lions.utils.listeners.DebugPhaseListener</phase-listener>
  </lifecycle>

  <!-- Configuration des ressources -->
  <resource-bundle>
    <base-name>application</base-name>
    <var>app</var>
  </resource-bundle>

</faces-config>