"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = Settings;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const react_1 = require("react");
const SettingsContext_1 = require("../context/SettingsContext");
const Switch_1 = tslib_1.__importDefault(require("../ui/Switch"));
const appSettings_1 = require("./appSettings");
function Settings() {
    const windowLocation = window.location;
    const { setOption, settings: { disableBeforeInput, isAutocomplete, isCharLimit, isCharLimitUtf8, isMaxLength, isRichText, measureTypingPerf, shouldUseLexicalContextMenu, showNestedEditorTreeView, showTableOfContents, showTreeView, }, } = (0, SettingsContext_1.useSettings)();
    const [showSettings, setShowSettings] = (0, react_1.useState)(false);
    const [isSplitScreen, search] = (0, react_1.useMemo)(() => {
        const parentWindow = window.parent;
        const _search = windowLocation.search;
        const _isSplitScreen = parentWindow && parentWindow.location.pathname === '/split/';
        return [_isSplitScreen, _search];
    }, [windowLocation]);
    return (React.createElement(React.Fragment, null,
        React.createElement("button", { className: `editor-dev-button ${showSettings ? 'active' : ''}`, id: 'options-button', onClick: () => setShowSettings(!showSettings), type: 'button' }),
        showSettings ? (React.createElement("div", { className: 'switches' },
            appSettings_1.isDevPlayground && (React.createElement(Switch_1.default, { checked: isSplitScreen, onClick: () => {
                    if (isSplitScreen) {
                        window.parent.location.href = `/${search}`;
                    }
                    else {
                        window.location.href = `/split/${search}`;
                    }
                }, text: 'Split Screen' })),
            React.createElement(Switch_1.default, { checked: measureTypingPerf, onClick: () => setOption('measureTypingPerf', !measureTypingPerf), text: 'Measure Perf' }),
            React.createElement(Switch_1.default, { checked: showTreeView, onClick: () => setOption('showTreeView', !showTreeView), text: 'Debug View' }),
            React.createElement(Switch_1.default, { checked: showNestedEditorTreeView, onClick: () => setOption('showNestedEditorTreeView', !showNestedEditorTreeView), text: 'Nested Editors Debug View' }),
            React.createElement(Switch_1.default, { checked: isRichText, onClick: () => {
                    setOption('isRichText', !isRichText);
                }, text: 'Rich Text' }),
            React.createElement(Switch_1.default, { checked: isCharLimit, onClick: () => setOption('isCharLimit', !isCharLimit), text: 'Char Limit' }),
            React.createElement(Switch_1.default, { checked: isCharLimitUtf8, onClick: () => setOption('isCharLimitUtf8', !isCharLimitUtf8), text: 'Char Limit (UTF-8)' }),
            React.createElement(Switch_1.default, { checked: isMaxLength, onClick: () => setOption('isMaxLength', !isMaxLength), text: 'Max Length' }),
            React.createElement(Switch_1.default, { checked: isAutocomplete, onClick: () => setOption('isAutocomplete', !isAutocomplete), text: 'Autocomplete' }),
            React.createElement(Switch_1.default, { checked: disableBeforeInput, onClick: () => {
                    setOption('disableBeforeInput', !disableBeforeInput);
                    setTimeout(() => window.location.reload(), 500);
                }, text: 'Legacy Events' }),
            React.createElement(Switch_1.default, { checked: showTableOfContents, onClick: () => {
                    setOption('showTableOfContents', !showTableOfContents);
                }, text: 'Table Of Contents' }),
            React.createElement(Switch_1.default, { checked: shouldUseLexicalContextMenu, onClick: () => {
                    setOption('shouldUseLexicalContextMenu', !shouldUseLexicalContextMenu);
                }, text: 'Use Lexical Context Menu' }))) : null));
}
//# sourceMappingURL=Settings.js.map