<commit_before>/* eslint-disable  no-var */
/* eslint-disable  vars-on-top */
/* eslint-disable  no-use-before-define */
function klaroOnload() {
  var klaro = document.querySelector('#klaro div.klaro')
  if (!klaro || klaro.querySelector('a') === null) {
    return
  }
  if (klaro !== document.body.firstElementChild) {
    document.body.insertBefore(klaro, document.body.firstElementChild)
    document.body.style.overflowY = 'hidden'
  }
  const getNextFocusableElement = function (element, step) {
    var elements = Array.prototype.slice.call(
      klaro.querySelectorAll('a:not([disabled]), button:not([disabled]), input:not([disabled])')
    )
    if (!elements) return null

    elements = elements.filter((e) => window.getComputedStyle(e).display !== 'none')
    for (var i = 0; i < elements.length; i++) {
      if (elements[i] === element) {
        if (i < elements.length - step) {
          return elements[i + step]
        }
        return elements[0]
      }
    }
    return elements[0]
  }

  const resetActiveLI = function _resetActiveLI() {
    var elements = Array.prototype.slice.call(klaro.querySelectorAll('li.active'))
    if (!elements) return
    elements.forEach((e) => e.classList.remove('active'))
  }
  // eslint-disable-next-line no-shadow
  const handleKeydown = (event) => {
    if (!klaro || klaro.querySelector('a') === null) {
      window.removeEventListener('keydown', handleKeydown)
      document.body.style.overflowY = 'auto'
      return
    }
    if (event.key === 'Tab') {
      const nextElement = getNextFocusableElement(event.target, event.shiftKey ? -1 : 1)
      if (nextElement) {
        event.preventDefault()
        nextElement.focus()
        resetActiveLI()
        if (nextElement.tagName === 'INPUT') {
          nextElement.parentElement.closest('li').classList.add('active')
        }
      }
    } else if (event.key === 'Escape') {
      const closeButton = klaro.querySelector('div.klaro .cookie-modal button.hide')
      if (closeButton) {
        closeButton.click()
      }
    }
  }
  window.addEventListener('keydown', handleKeydown)

  const config = { childList: true, subtree: true }
  const callback = function (mutationsList) {
    for (const mutation of mutationsList) {
      if (mutation.type === 'childList') {
        if (mutation.addedNodes.length > 0) {
          for (const node of mutation.addedNodes) {
            if (node.nodeType === 1) {
              if (node.classList.contains('cookie-modal')) {
                var inputs = Array.prototype.slice.call(node.querySelectorAll('input'))
                for (const input of inputs) {
                  input.setAttribute('tabindex', '0')
                }
              }
            }
          }
        } else if (mutation.removedNodes.length > 0) {
          for (const node of mutation.removedNodes) {
            if (node.nodeType === 1) {
              if (node.classList.contains('cn-body')) {
                window.removeEventListener('keydown', handleKeydown)<commit_msg>Reset scroll behind klaro also when modal 2 is removed<commit_after>/* eslint-disable  no-var */
/* eslint-disable  vars-on-top */
/* eslint-disable  no-use-before-define */
function klaroOnload() {
  var klaro = document.querySelector('#klaro div.klaro')
  if (!klaro || klaro.querySelector('a') === null) {
    return
  }
  if (klaro !== document.body.firstElementChild) {
    document.body.insertBefore(klaro, document.body.firstElementChild)
    document.body.style.overflowY = 'hidden'
  }
  const getNextFocusableElement = function (element, step) {
    var elements = Array.prototype.slice.call(
      klaro.querySelectorAll('a:not([disabled]), button:not([disabled]), input:not([disabled])')
    )
    if (!elements) return null

    elements = elements.filter((e) => window.getComputedStyle(e).display !== 'none')
    for (var i = 0; i < elements.length; i++) {
      if (elements[i] === element) {
        if (i < elements.length - step) {
          return elements[i + step]
        }
        return elements[0]
      }
    }
    return elements[0]
  }

  const resetActiveLI = function _resetActiveLI() {
    var elements = Array.prototype.slice.call(klaro.querySelectorAll('li.active'))
    if (!elements) return
    elements.forEach((e) => e.classList.remove('active'))
  }
  // eslint-disable-next-line no-shadow
  const handleKeydown = (event) => {
    if (!klaro || klaro.querySelector('a') === null) {
      window.removeEventListener('keydown', handleKeydown)
      document.body.style.overflowY = 'auto'
      return
    }
    if (event.key === 'Tab') {
      const nextElement = getNextFocusableElement(event.target, event.shiftKey ? -1 : 1)
      if (nextElement) {
        event.preventDefault()
        nextElement.focus()
        resetActiveLI()
        if (nextElement.tagName === 'INPUT') {
          nextElement.parentElement.closest('li').classList.add('active')
        }
      }
    } else if (event.key === 'Escape') {
      const closeButton = klaro.querySelector('div.klaro .cookie-modal button.hide')
      if (closeButton) {
        closeButton.click()
      }
    }
  }
  window.addEventListener('keydown', handleKeydown)

  const config = { childList: true, subtree: true }
  const callback = function (mutationsList) {
    for (const mutation of mutationsList) {
      if (mutation.type === 'childList') {
        if (mutation.addedNodes.length > 0) {
          for (const node of mutation.addedNodes) {
            if (node.nodeType === 1) {
              if (node.classList.contains('cookie-modal')) {
                var inputs = Array.prototype.slice.call(node.querySelectorAll('input'))
                for (const input of inputs) {
                  input.setAttribute('tabindex', '0')
                }
              }
            }
          }
        } else if (mutation.removedNodes.length > 0) {
          for (const node of mutation.removedNodes) {
            if (node.nodeType === 1) {
              if (node.classList.contains('cn-body') || node.classList.contains('cookie-modal')) {
                window.removeEventListener('keydown', handleKeydown)
{'fraction_non_alphanumeric': 0.14115535248041775, 'fraction_numerical': 0.003426892950391645, 'mean_word_length': 2.5448235974551765, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1259318', 'n_tokens_mistral': 1803, 'n_tokens_neox': 1806, 'n_words': 369}