{% load i18n %}
{% translate "Opens a new window" as new_window %}
<div class="fr-container fr-mb-4w">
  <div class="fr-share" id="share-{{ block.id }}">
    <p class="fr-share__title">{% translate "Share this page" %}</p>
    <ul class="fr-btns-group">
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_facebook %}
        <li>
          {% translate "Share on Facebook" as share_facebook %}
          <a class="fr-btn--facebook fr-btn"
             target="_blank"
             rel="noopener"
             title="{{ share_facebook }} - {{ new_window }}"
             id="share-{{ block.id }}-facebook"
             onclick="window.open(this.href,'{{ share_facebook }}','toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=450'); event.preventDefault();"
             href="https://www.facebook.com/sharer.php?u={{ request.build_absolute_uri }}">{{ share_facebook }}</a>
        </li>
      {% endif %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_twitter %}
        <li>
          {% translate "Share on X (previously Twitter)" as share_twitter %}
          <a class="fr-btn--twitter-x fr-btn"
             target="_blank"
             rel="noopener"
             title="{{ share_twitter }} - {{ new_window }}"
             id="share-{{ block.id }}-twitter"
             onclick="window.open(this.href,'Partager sur X (anciennement Twitter)','toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=420'); event.preventDefault();"
             href="https://twitter.com/intent/tweet?url={{ request.build_absolute_uri }}&text={{ page.title|urlencode }}">
            {{ share_twitter }}
          </a>
        </li>
      {% endif %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_linkedin %}
        <li>
          {% translate "Share on LinkedIn" as share_linkedin %}
          <a class="fr-btn--linkedin fr-btn"
             target="_blank"
             rel="noopener"
             title="{{ share_linkedin }} - {{ new_window }}"
             id="share-{{ block.id }}-linkedin"
             onclick="window.open(this.href,'Partager sur LinkedIn','toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=yes,width=550,height=550'); event.preventDefault();"
             href="https://www.linkedin.com/shareArticle?url={{ request.build_absolute_uri }}&title={{ page.title|urlencode }}">
            {{ share_linkedin }}
          </a>
        </li>
      {% endif %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_email %}
        <li>
          {% translate "Share via email" as share_email %}
          <a class="fr-btn--mail fr-btn"
             target="_blank"
             rel="noopener external"
             title="{{ share_email }} - {{ new_window }}"
             id="share-{{ block.id }}-email"
             href="mailto:?subject={{ page.title|urlencode }}&body={{ page.title|urlencode }} {{ request.build_absolute_uri }}">
            {{ share_email }}
          </a>
        </li>
      {% endif %}
      {% if settings.sites_conformes_content_manager.CmsDsfrConfig.share_links_clipboard %}
        <li>
          {% translate "Page URL copied to clipboard." as copied_to_clipboard %}
          <button class="fr-btn--copy fr-btn"
                  id="share-{{ block.id }}-clipboard"
                  onclick="navigator.clipboard.writeText(window.location).then(function() {alert('{{ copied_to_clipboard }}')});">
            {% translate "Copy to clipboard" %}
          </button>
        </li>
      {% endif %}
    </ul>
  </div>
</div>
