<commit_before>import React, {useRef, useEffect, useMemo} from 'react'
import PropTypes from 'prop-types'
import ReactDOMServer from 'react-dom/server'
import ReactFullCalendar from '@fullcalendar/react'
import resourceTimelinePlugin from '@fullcalendar/resource-timeline'
import moment from 'moment'
import 'twix'
import '!style-loader!css-loader!@fullcalendar/core/main.css'
import '!style-loader!css-loader!@fullcalendar/timeline/main.css'
import '!style-loader!css-loader!@fullcalendar/resource-timeline/main.css'
import {FormattedValue} from 'tocco-ui'
import {consoleLogger} from 'tocco-util'
import Tooltip from 'tooltip.js'
import {injectIntl, intlShape} from 'react-intl'
import interactionPlugin from '@fullcalendar/interaction'

import NavigationFullCalendar from '../NavigationFullCalendar'
import StyledFullCalendar from './StyledFullCalendar'
import Conflict from '../Conflict'
import {getFormattedTime} from '../../utils/time'

const getLicense = () => {
  const licence = process.env.FULL_CALENDAR_LICENCE
  if (licence) {
    return licence
  }
  consoleLogger.logWarning('This Version runs with the NonCommercial FullCalendar license.')
  return 'CC-Attribution-NonCommercial-NoDerivatives' // noncommercial license
}

const MONDAY = 1

const FullCalendar = ({
  resources,
  events,
  onDateRangeChange,
  isLoading,
  onRefresh,
  onCalendarRemove,
  onCalendarRemoveAll,
  locale,
  onEventClick,
  intl
}) => {
  const calendarEl = useRef(null)
  const wrapperEl = useRef(null)

  useEffect(() => {
    moment.locale(locale)
    changeRange()
  }, [])

  useEffect(() => {
    addDeselectAllButton()
  })

  useEffect(() => {
    const calendar = calendarEl.current.calendar
    calendar.batchRendering(() => {
      const eventSources = calendar.getEventSources()
      eventSources.forEach(eS => eS.remove())
      calendar.addEventSource(events)
    })
  }, [JSON.stringify(events)])

  useEffect(() => {
    const calendar = calendarEl.current.calendar
    calendar.batchRendering(() => {
      const loadedResources = calendar.getResources()
      loadedResources.forEach(l => {
        const contains = resources.find(r => l.id === r.id)
        if (!contains) {
          l.remove()
        }
      })

      resources.forEach(r => {
        const contains = loadedResources.find(l => l.id === r.id)
        if (!contains) {
          calendar.addResource(r)
        }
      })
    })
  }, [JSON.stringify(resources)])

  const addDeselectAllButton = () => {
    const firstHeaderNode = document.querySelectorAll('.fc-widget-header')[0]
    if (firstHeaderNode) {
      const checkbox = document.createElement('INPUT')
      checkbox.type = 'checkbox'
      if (resources.length > 0) {
        checkbox.checked = 'checked'
      }
      checkbox.className = 'remove-all-checkbox'
      checkbox.style.visibility = resources.length > 0 ? 'visible' : 'hidden'
      checkbox.onclick = onCalendarRemoveAll

      firstHeaderNode.innerHTML = ''
      firstHeaderNode.appendChild(checkbox)<commit_msg>fix(scheduler): imprive querySelector with boundary<commit_after>import React, {useRef, useEffect, useMemo} from 'react'
import PropTypes from 'prop-types'
import ReactDOMServer from 'react-dom/server'
import ReactFullCalendar from '@fullcalendar/react'
import resourceTimelinePlugin from '@fullcalendar/resource-timeline'
import moment from 'moment'
import 'twix'
import '!style-loader!css-loader!@fullcalendar/core/main.css'
import '!style-loader!css-loader!@fullcalendar/timeline/main.css'
import '!style-loader!css-loader!@fullcalendar/resource-timeline/main.css'
import {FormattedValue} from 'tocco-ui'
import {consoleLogger} from 'tocco-util'
import Tooltip from 'tooltip.js'
import {injectIntl, intlShape} from 'react-intl'
import interactionPlugin from '@fullcalendar/interaction'

import NavigationFullCalendar from '../NavigationFullCalendar'
import StyledFullCalendar from './StyledFullCalendar'
import Conflict from '../Conflict'
import {getFormattedTime} from '../../utils/time'

const getLicense = () => {
  const licence = process.env.FULL_CALENDAR_LICENCE
  if (licence) {
    return licence
  }
  consoleLogger.logWarning('This Version runs with the NonCommercial FullCalendar license.')
  return 'CC-Attribution-NonCommercial-NoDerivatives' // noncommercial license
}

const MONDAY = 1

const FullCalendar = ({
  resources,
  events,
  onDateRangeChange,
  isLoading,
  onRefresh,
  onCalendarRemove,
  onCalendarRemoveAll,
  locale,
  onEventClick,
  intl
}) => {
  const calendarEl = useRef(null)
  const wrapperEl = useRef(null)

  useEffect(() => {
    moment.locale(locale)
    changeRange()
  }, [])

  useEffect(() => {
    addDeselectAllButton()
  })

  useEffect(() => {
    const calendar = calendarEl.current.calendar
    calendar.batchRendering(() => {
      const eventSources = calendar.getEventSources()
      eventSources.forEach(eS => eS.remove())
      calendar.addEventSource(events)
    })
  }, [JSON.stringify(events)])

  useEffect(() => {
    const calendar = calendarEl.current.calendar
    calendar.batchRendering(() => {
      const loadedResources = calendar.getResources()
      loadedResources.forEach(l => {
        const contains = resources.find(r => l.id === r.id)
        if (!contains) {
          l.remove()
        }
      })

      resources.forEach(r => {
        const contains = loadedResources.find(l => l.id === r.id)
        if (!contains) {
          calendar.addResource(r)
        }
      })
    })
  }, [JSON.stringify(resources)])

  const addDeselectAllButton = () => {
    const firstHeaderNode = wrapperEl.current.querySelectorAll('.fc-widget-header')[0]
    if (firstHeaderNode) {
      const checkbox = document.createElement('INPUT')
      checkbox.type = 'checkbox'
      if (resources.length > 0) {
        checkbox.checked = 'checked'
      }
      checkbox.className = 'remove-all-checkbox'
      checkbox.style.visibility = resources.length > 0 ? 'visible' : 'hidden'
      checkbox.onclick = onCalendarRemoveAll

      firstHeaderNode.innerHTML = ''
      firstHeaderNode.appendChild(checkbox)
{'fraction_non_alphanumeric': 0.12465146793505003, 'fraction_numerical': 0.0013121207151057896, 'mean_word_length': 3.719814241486068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, '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': '2013612', 'n_tokens_mistral': 1812, 'n_tokens_neox': 1770, 'n_words': 375}