var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import Editor from '@monaco-editor/react';
import { useRef } from 'react';
import React from 'react';
export function CodeEditor(_a) {
    var { readOnly, lineNumbers = 'off', style } = _a, props = __rest(_a, ["readOnly", "lineNumbers", "style"]);
    const monacoRef = useRef(null);
    function handleEditorWillMount(monaco) {
        // here is the monaco instance
        // do something before editor is mounted
        monaco.languages.typescript.typescriptDefaults.setEagerModelSync(true);
        monaco.languages.typescript.typescriptDefaults.setDiagnosticsOptions({
        // noSemanticValidation: true,
        // noSyntaxValidation: true,
        });
        monaco.languages.typescript.typescriptDefaults.setCompilerOptions({
            jsx: monaco.languages.typescript.JsxEmit.React,
            noEmit: true,
            jsxFactory: 'React.createElement',
            reactNamespace: 'React',
            allowNonTsExtensions: true,
            allowJs: true,
            target: monaco.languages.typescript.ScriptTarget.Latest
        });
    }
    const handleEditorDidMount = function (editor, monaco) {
        // here is another way to get monaco instance
        // you can also store it in `useRef` for further usage
        monacoRef.current = editor;
        editor.updateOptions({
            readOnly,
            lineNumbers,
            minimap: {
                enabled: false
            },
            lineDecorationsWidth: 0,
            glyphMargin: false,
            folding: false,
            automaticLayout: true
        });
    };
    React.useEffect(() => {
        if (monacoRef.current) {
            monacoRef.current.updateOptions({
                readOnly,
                lineNumbers
            });
        }
    }, [readOnly, lineNumbers]);
    return (React.createElement("div", { style: style },
        React.createElement(Editor, Object.assign({ language: "typescript", height: '200px', beforeMount: handleEditorWillMount, onMount: handleEditorDidMount }, props))));
}
//# sourceMappingURL=index.js.map