function removeEmptyParagraphs() {
  const paragraphs = document.querySelectorAll('p')
  paragraphs.forEach((paragraph) => {
    if (!paragraph.textContent.trim() && !paragraph.querySelector('i')) {
      paragraph.remove()
    }
  })
}

// removeEmptyParagraphs();

document.addEventListener('DOMContentLoaded', function () {
  if ('ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0) {
    const navDropdowns = document.querySelectorAll('.nav-dropdown')

    navDropdowns.forEach(function (dropdown) {
      const dropdownLink = dropdown.querySelector('a')
      const dropdownIcon = dropdown.querySelector('svg')
      const dropdownList = dropdown.querySelector('.nav-dropdown-list')

      let clickCount = 0

      dropdownLink.addEventListener('click', function (event) {
        if (dropdownList) {
          event.preventDefault()
          clickCount++

          if (clickCount % 2 === 1) {
            dropdownList.classList.add('visible', 'opacity-100')
          } else {
            window.location.href = dropdownLink.getAttribute('href')
          }
        }
      })

      dropdownIcon.addEventListener('click', function (event) {
        // If the dropdown is already open, clicking
        // on the icon should close it. Otherwise
        // clicking on the icon should open it.
        console.log('clickCount', clickCount)
        event.preventDefault()
        event.stopPropagation()
        dropdown.classList.toggle('active')
        dropdownList.classList.toggle('visible')
        dropdownList.classList.toggle('opacity-100')
      })
    })
  }
})
