<commit_before>import { showQuickPick } from 'bemuse/ui-dialogs'
import { useEffect } from 'react'

export const PreviewFileDropHandler: React.FC<{
  onDrop: (
    handle: FileSystemDirectoryHandle,
    selectedChartFilename: string
  ) => void
}> = (props) => {
  useEffect(() => {
    const onDragOver = (e: DragEvent) => {
      e.preventDefault()
    }
    const onDrop = async (e: DragEvent) => {
      e.preventDefault()
      const items = e.dataTransfer!.items
      if (items.length !== 1) {
        alert('Please drop only one folder.')
        return
      }
      const item = items[0]
      if (item.kind !== 'file') {
        alert('Please drop only a folder here.')
        return
      }
      if (!('getAsFileSystemHandle' in item)) {
        alert('Unsupported browser (sorry).')
        return
      }
      const handle = await item.getAsFileSystemHandle()!
      if (!handle || handle.kind !== 'directory') {
        alert('Please drop folder, not a file here.')
        return
      }
      await handle.requestPermission({ mode: 'read' })
      const chartFiles: { filename: string; label: string }[] = []
      for await (let [name] of handle) {
        if (/\.(bms|bme|bml|bmson)$/i.test(name)) {
          chartFiles.push({ filename: name, label: name })
        }
      }
      if (chartFiles.length === 0) {
        alert('No BMS/bmson files found in folder.')
        return
      }

      const selectedChartFile = await showQuickPick(chartFiles, {
        title: 'Select a chart file',
      })
      props.onDrop(handle, selectedChartFile.filename)
    }
    window.addEventListener('dragover', onDragOver)
    window.addEventListener('drop', onDrop)
    return () => {
      window.removeEventListener('dragover', onDragOver)
      window.removeEventListener('drop', onDrop)
    }
  }, [props.onDrop])
  return null
}
<commit_msg>Fix type error<commit_after>import { showQuickPick } from 'bemuse/ui-dialogs'
import { useEffect } from 'react'

export const PreviewFileDropHandler: React.FC<{
  onDrop: (
    handle: FileSystemDirectoryHandle,
    selectedChartFilename: string
  ) => void
}> = (props) => {
  useEffect(() => {
    const onDragOver = (e: DragEvent) => {
      e.preventDefault()
    }
    const onDrop = async (e: DragEvent) => {
      e.preventDefault()
      const items = e.dataTransfer!.items
      if (items.length !== 1) {
        alert('Please drop only one folder.')
        return
      }
      const item = items[0]
      if (item.kind !== 'file') {
        alert('Please drop only a folder here.')
        return
      }
      if (!('getAsFileSystemHandle' in item)) {
        alert('Unsupported browser (sorry).')
        return
      }
      const handleNullable = await item.getAsFileSystemHandle()
      if (!handleNullable || handleNullable.kind !== 'directory') {
        alert('Please drop folder, not a file here.')
        return
      }
      const handle = handleNullable as FileSystemDirectoryHandle
      await handle.requestPermission({ mode: 'read' })
      const chartFiles: { filename: string; label: string }[] = []
      for await (let [name] of handle.entries()) {
        if (/\.(bms|bme|bml|bmson)$/i.test(name)) {
          chartFiles.push({ filename: name, label: name })
        }
      }
      if (chartFiles.length === 0) {
        alert('No BMS/bmson files found in folder.')
        return
      }

      const selectedChartFile = await showQuickPick(chartFiles, {
        title: 'Select a chart file',
      })
      props.onDrop(handle, selectedChartFile.filename)
    }
    window.addEventListener('dragover', onDragOver)
    window.addEventListener('drop', onDrop)
    return () => {
      window.removeEventListener('dragover', onDragOver)
      window.removeEventListener('drop', onDrop)
    }
  }, [props.onDrop])
  return null
}

{'fraction_non_alphanumeric': 0.13254901960784313, 'fraction_numerical': 0.001568627450980392, 'mean_word_length': 2.516544117647059, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '3862743', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1120, 'n_words': 279}