import React, { useState, useCallback } from 'react'; import { Button, TextInputField, Checkbox, RadioGroup, Paragraph, LinkIcon } from 'evergreen-ui'; import Swal from 'sweetalert2'; import i18n from 'i18next'; import { Trans } from 'react-i18next'; import withReactContent from 'sweetalert2-react-content'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { tomorrow as style } from 'react-syntax-highlighter/dist/esm/styles/hljs'; import JSON5 from 'json5'; import { parseDuration, formatDuration } from './util/duration'; import { parseYouTube } from './edlFormats'; import CopyClipboardButton from './components/CopyClipboardButton'; const { dialog, app } = window.require('@electron/remote'); const electron = window.require('electron'); const ReactSwal = withReactContent(Swal); export async function promptTimeOffset({ initialValue, title, text }) { const { value } = await Swal.fire({ title, text, input: 'text', inputValue: initialValue || '', showCancelButton: true, inputPlaceholder: '00:00:00.000', }); if (value === undefined) { return undefined; } const duration = parseDuration(value); // Invalid, try again if (duration === undefined) return promptTimeOffset({ initialValue: value, title, text }); return duration; } export async function askForHtml5ifySpeed({ allowedOptions, showRemember, initialOption }) { const availOptions = { fastest: i18n.t('Fastest: Low playback speed (no audio)'), 'fastest-audio': i18n.t('Fastest: Low playback speed'), 'fastest-audio-remux': i18n.t('Fastest: Low playback speed (audio remux), likely to fail'), fast: i18n.t('Fast: Full quality remux (no audio), likely to fail'), 'fast-audio-remux': i18n.t('Fast: Full quality remux, likely to fail'), 'fast-audio': i18n.t('Fast: Remux video, encode audio (fails if unsupported video codec)'), slow: i18n.t('Slow: Low quality encode (no audio)'), 'slow-audio': i18n.t('Slow: Low quality encode'), slowest: i18n.t('Slowest: High quality encode'), }; const inputOptions = {}; allowedOptions.forEach((allowedOption) => { inputOptions[allowedOption] = availOptions[allowedOption]; }); let selectedOption = inputOptions[initialOption] ? initialOption : Object.keys(inputOptions)[0]; let rememberChoice = !!initialOption; const Html = () => { const [option, setOption] = useState(selectedOption); const [remember, setRemember] = useState(rememberChoice); const onOptionChange = useCallback((e) => { selectedOption = e.target.value; setOption(selectedOption); }, []); const onRememberChange = useCallback((e) => { rememberChoice = e.target.checked; setRemember(rememberChoice); }, []); return (