
import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
import { localize } from '../../../../nls.js';
import { parse, getNodeType } from '../../../../base/common/json.js';
import { isObject } from '../../../../base/common/types.js';
import { IndentAction } from '../../../../editor/common/languages/languageConfiguration.js';
import { ILanguageConfigurationService } from '../../../../editor/common/languages/languageConfigurationRegistry.service.js';
import { ILanguageService } from '../../../../editor/common/languages/language.service.js';
import { Extensions } from '../../../../platform/jsonschemas/common/jsonContributionRegistry.js';
import { Registry } from '../../../../platform/registry/common/platform.js';
import { IExtensionService } from '../../../services/extensions/common/extensions.service.js';
import { getParseErrorMessage } from '../../../../base/common/jsonErrorMessages.js';
import { IExtensionResourceLoaderService } from '../../../../platform/extensionResourceLoader/common/extensionResourceLoader.service.js';
import { hash } from '../../../../base/common/hash.js';
import { Disposable } from '../../../../base/common/lifecycle.js';
import { registerWorkbenchContribution2, WorkbenchPhase } from '../../../common/contributions.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';

var LanguageConfigurationFileHandler_1;
function isStringArr(something) {
    if (!Array.isArray(something)) {
        return false;
    }
    for (let i = 0, len = something.length; i < len; i++) {
        if (typeof something[i] !== "string") {
            return false;
        }
    }
    return true;
}
function isCharacterPair(something) {
    return (isStringArr(something) && something.length === 2);
}
let LanguageConfigurationFileHandler = LanguageConfigurationFileHandler_1 = class LanguageConfigurationFileHandler extends Disposable {
    constructor(
        _languageService,
        _extensionResourceLoaderService,
        _extensionService,
        _languageConfigurationService
    ) {
        super();
        this._languageService = _languageService;
        this._extensionResourceLoaderService = _extensionResourceLoaderService;
        this._extensionService = _extensionService;
        this._languageConfigurationService = _languageConfigurationService;
        this._done = ( new Map());
        this._register(
            this._languageService.onDidRequestBasicLanguageFeatures(async languageIdentifier => {
                this._extensionService.whenInstalledExtensionsRegistered().then(() => {
                    this._loadConfigurationsForMode(languageIdentifier);
                });
            })
        );
        this._register(this._languageService.onDidChange(() => {
            for (const [languageId] of this._done) {
                this._loadConfigurationsForMode(languageId);
            }
        }));
    }
    async _loadConfigurationsForMode(languageId) {
        const configurationFiles = this._languageService.getConfigurationFiles(languageId);
        const configurationHash = hash(( configurationFiles.map(uri => ( uri.toString()))));
        if (this._done.get(languageId) === configurationHash) {
            return;
        }
        this._done.set(languageId, configurationHash);
        const configs = await Promise.all(( configurationFiles.map(configFile => this._readConfigFile(configFile))));
        for (const config of configs) {
            this._handleConfig(languageId, config);
        }
    }
    async _readConfigFile(configFileLocation) {
        try {
            const contents = await this._extensionResourceLoaderService.readExtensionResource(configFileLocation);
            const errors = [];
            let configuration = parse(contents, errors);
            if (errors.length) {
                console.error(( localize(
                    8509,
                    "Errors parsing {0}: {1}",
                    (configFileLocation.toString()),
                    ( errors.map(e => (`[${e.offset}, ${e.length}] ${getParseErrorMessage(e.error)}`))).join("\n")
                )));
            }
            if (getNodeType(configuration) !== "object") {
                console.error(( localize(
                    8510,
                    "{0}: Invalid format, JSON object expected.",
                    (configFileLocation.toString())
                )));
                configuration = {};
            }
            return configuration;
        } catch (err) {
            console.error(err);
            return {};
        }
    }
    static _extractValidCommentRule(languageId, configuration) {
        const source = configuration.comments;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!isObject(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`comments\` to be an object.`
            );
            return undefined;
        }
        let result = undefined;
        if (typeof source.lineComment !== "undefined") {
            if (typeof source.lineComment === "string") {
                result = result || {};
                result.lineComment = source.lineComment;
            } else if (isObject(source.lineComment)) {
                const lineCommentObj = source.lineComment;
                if (typeof lineCommentObj.comment === "string") {
                    result = result || {};
                    result.lineComment = {
                        comment: lineCommentObj.comment,
                        noIndent: lineCommentObj.noIndent
                    };
                } else {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`comments.lineComment.comment\` to be a string.`
                    );
                }
            } else {
                console.warn(
                    `[${languageId}]: language configuration: expected \`comments.lineComment\` to be a string or an object with comment property.`
                );
            }
        }
        if (typeof source.blockComment !== "undefined") {
            if (!isCharacterPair(source.blockComment)) {
                console.warn(
                    `[${languageId}]: language configuration: expected \`comments.blockComment\` to be an array of two strings.`
                );
            } else {
                result = result || {};
                result.blockComment = source.blockComment;
            }
        }
        return result;
    }
    static _extractValidBrackets(languageId, configuration) {
        const source = configuration.brackets;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!Array.isArray(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`brackets\` to be an array.`
            );
            return undefined;
        }
        let result = undefined;
        for (let i = 0, len = source.length; i < len; i++) {
            const pair = source[i];
            if (!isCharacterPair(pair)) {
                console.warn(
                    `[${languageId}]: language configuration: expected \`brackets[${i}]\` to be an array of two strings.`
                );
                continue;
            }
            result = result || [];
            result.push(pair);
        }
        return result;
    }
    static _extractValidAutoClosingPairs(languageId, configuration) {
        const source = configuration.autoClosingPairs;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!Array.isArray(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`autoClosingPairs\` to be an array.`
            );
            return undefined;
        }
        let result = undefined;
        for (let i = 0, len = source.length; i < len; i++) {
            const pair = source[i];
            if (Array.isArray(pair)) {
                if (!isCharacterPair(pair)) {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`autoClosingPairs[${i}]\` to be an array of two strings or an object.`
                    );
                    continue;
                }
                result = result || [];
                result.push({
                    open: pair[0],
                    close: pair[1]
                });
            } else {
                if (!isObject(pair)) {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`autoClosingPairs[${i}]\` to be an array of two strings or an object.`
                    );
                    continue;
                }
                if (typeof pair.open !== "string") {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`autoClosingPairs[${i}].open\` to be a string.`
                    );
                    continue;
                }
                if (typeof pair.close !== "string") {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`autoClosingPairs[${i}].close\` to be a string.`
                    );
                    continue;
                }
                if (typeof pair.notIn !== "undefined") {
                    if (!isStringArr(pair.notIn)) {
                        console.warn(
                            `[${languageId}]: language configuration: expected \`autoClosingPairs[${i}].notIn\` to be a string array.`
                        );
                        continue;
                    }
                }
                result = result || [];
                result.push({
                    open: pair.open,
                    close: pair.close,
                    notIn: pair.notIn
                });
            }
        }
        return result;
    }
    static _extractValidSurroundingPairs(languageId, configuration) {
        const source = configuration.surroundingPairs;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!Array.isArray(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`surroundingPairs\` to be an array.`
            );
            return undefined;
        }
        let result = undefined;
        for (let i = 0, len = source.length; i < len; i++) {
            const pair = source[i];
            if (Array.isArray(pair)) {
                if (!isCharacterPair(pair)) {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`surroundingPairs[${i}]\` to be an array of two strings or an object.`
                    );
                    continue;
                }
                result = result || [];
                result.push({
                    open: pair[0],
                    close: pair[1]
                });
            } else {
                if (!isObject(pair)) {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`surroundingPairs[${i}]\` to be an array of two strings or an object.`
                    );
                    continue;
                }
                if (typeof pair.open !== "string") {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`surroundingPairs[${i}].open\` to be a string.`
                    );
                    continue;
                }
                if (typeof pair.close !== "string") {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`surroundingPairs[${i}].close\` to be a string.`
                    );
                    continue;
                }
                result = result || [];
                result.push({
                    open: pair.open,
                    close: pair.close
                });
            }
        }
        return result;
    }
    static _extractValidColorizedBracketPairs(languageId, configuration) {
        const source = configuration.colorizedBracketPairs;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!Array.isArray(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`colorizedBracketPairs\` to be an array.`
            );
            return undefined;
        }
        const result = [];
        for (let i = 0, len = source.length; i < len; i++) {
            const pair = source[i];
            if (!isCharacterPair(pair)) {
                console.warn(
                    `[${languageId}]: language configuration: expected \`colorizedBracketPairs[${i}]\` to be an array of two strings.`
                );
                continue;
            }
            result.push([pair[0], pair[1]]);
        }
        return result;
    }
    static _extractValidOnEnterRules(languageId, configuration) {
        const source = configuration.onEnterRules;
        if (typeof source === "undefined") {
            return undefined;
        }
        if (!Array.isArray(source)) {
            console.warn(
                `[${languageId}]: language configuration: expected \`onEnterRules\` to be an array.`
            );
            return undefined;
        }
        let result = undefined;
        for (let i = 0, len = source.length; i < len; i++) {
            const onEnterRule = source[i];
            if (!isObject(onEnterRule)) {
                console.warn(
                    `[${languageId}]: language configuration: expected \`onEnterRules[${i}]\` to be an object.`
                );
                continue;
            }
            if (!isObject(onEnterRule.action)) {
                console.warn(
                    `[${languageId}]: language configuration: expected \`onEnterRules[${i}].action\` to be an object.`
                );
                continue;
            }
            let indentAction;
            if (onEnterRule.action.indent === "none") {
                indentAction = IndentAction.None;
            } else if (onEnterRule.action.indent === "indent") {
                indentAction = IndentAction.Indent;
            } else if (onEnterRule.action.indent === "indentOutdent") {
                indentAction = IndentAction.IndentOutdent;
            } else if (onEnterRule.action.indent === "outdent") {
                indentAction = IndentAction.Outdent;
            } else {
                console.warn(
                    `[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.indent\` to be 'none', 'indent', 'indentOutdent' or 'outdent'.`
                );
                continue;
            }
            const action = {
                indentAction
            };
            if (onEnterRule.action.appendText) {
                if (typeof onEnterRule.action.appendText === "string") {
                    action.appendText = onEnterRule.action.appendText;
                } else {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.appendText\` to be undefined or a string.`
                    );
                }
            }
            if (onEnterRule.action.removeText) {
                if (typeof onEnterRule.action.removeText === "number") {
                    action.removeText = onEnterRule.action.removeText;
                } else {
                    console.warn(
                        `[${languageId}]: language configuration: expected \`onEnterRules[${i}].action.removeText\` to be undefined or a number.`
                    );
                }
            }
            const beforeText = this._parseRegex(languageId, `onEnterRules[${i}].beforeText`, onEnterRule.beforeText);
            if (!beforeText) {
                continue;
            }
            const resultingOnEnterRule = {
                beforeText,
                action
            };
            if (onEnterRule.afterText) {
                const afterText = this._parseRegex(languageId, `onEnterRules[${i}].afterText`, onEnterRule.afterText);
                if (afterText) {
                    resultingOnEnterRule.afterText = afterText;
                }
            }
            if (onEnterRule.previousLineText) {
                const previousLineText = this._parseRegex(
                    languageId,
                    `onEnterRules[${i}].previousLineText`,
                    onEnterRule.previousLineText
                );
                if (previousLineText) {
                    resultingOnEnterRule.previousLineText = previousLineText;
                }
            }
            result = result || [];
            result.push(resultingOnEnterRule);
        }
        return result;
    }
    static extractValidConfig(languageId, configuration) {
        const comments = this._extractValidCommentRule(languageId, configuration);
        const brackets = this._extractValidBrackets(languageId, configuration);
        const autoClosingPairs = this._extractValidAutoClosingPairs(languageId, configuration);
        const surroundingPairs = this._extractValidSurroundingPairs(languageId, configuration);
        const colorizedBracketPairs = this._extractValidColorizedBracketPairs(languageId, configuration);
        const autoCloseBefore = (typeof configuration.autoCloseBefore === "string" ? configuration.autoCloseBefore : undefined);
        const wordPattern = (configuration.wordPattern ? this._parseRegex(languageId, `wordPattern`, configuration.wordPattern) : undefined);
        const indentationRules = (configuration.indentationRules ? this._mapIndentationRules(languageId, configuration.indentationRules) : undefined);
        let folding = undefined;
        if (configuration.folding) {
            const rawMarkers = configuration.folding.markers;
            const startMarker = (rawMarkers && rawMarkers.start ? this._parseRegex(languageId, `folding.markers.start`, rawMarkers.start) : undefined);
            const endMarker = (rawMarkers && rawMarkers.end ? this._parseRegex(languageId, `folding.markers.end`, rawMarkers.end) : undefined);
            const markers = (startMarker && endMarker ? {
                start: startMarker,
                end: endMarker
            } : undefined);
            folding = {
                offSide: configuration.folding.offSide,
                markers
            };
        }
        const onEnterRules = this._extractValidOnEnterRules(languageId, configuration);
        const richEditConfig = {
            comments,
            brackets,
            wordPattern,
            indentationRules,
            onEnterRules,
            autoClosingPairs,
            surroundingPairs,
            colorizedBracketPairs,
            autoCloseBefore,
            folding,
            __electricCharacterSupport: undefined
        };
        return richEditConfig;
    }
    _handleConfig(languageId, configuration) {
        const richEditConfig = LanguageConfigurationFileHandler_1.extractValidConfig(languageId, configuration);
        this._languageConfigurationService.register(languageId, richEditConfig, 50);
    }
    static _parseRegex(languageId, confPath, value) {
        if (typeof value === "string") {
            try {
                return ( new RegExp(value, ""));
            } catch (err) {
                console.warn(`[${languageId}]: Invalid regular expression in \`${confPath}\`: `, err);
                return undefined;
            }
        }
        if (isObject(value)) {
            if (typeof value.pattern !== "string") {
                console.warn(
                    `[${languageId}]: language configuration: expected \`${confPath}.pattern\` to be a string.`
                );
                return undefined;
            }
            if (typeof value.flags !== "undefined" && typeof value.flags !== "string") {
                console.warn(
                    `[${languageId}]: language configuration: expected \`${confPath}.flags\` to be a string.`
                );
                return undefined;
            }
            try {
                return ( new RegExp(value.pattern, value.flags));
            } catch (err) {
                console.warn(`[${languageId}]: Invalid regular expression in \`${confPath}\`: `, err);
                return undefined;
            }
        }
        console.warn(
            `[${languageId}]: language configuration: expected \`${confPath}\` to be a string or an object.`
        );
        return undefined;
    }
    static _mapIndentationRules(languageId, indentationRules) {
        const increaseIndentPattern = this._parseRegex(
            languageId,
            `indentationRules.increaseIndentPattern`,
            indentationRules.increaseIndentPattern
        );
        if (!increaseIndentPattern) {
            return undefined;
        }
        const decreaseIndentPattern = this._parseRegex(
            languageId,
            `indentationRules.decreaseIndentPattern`,
            indentationRules.decreaseIndentPattern
        );
        if (!decreaseIndentPattern) {
            return undefined;
        }
        const result = {
            increaseIndentPattern: increaseIndentPattern,
            decreaseIndentPattern: decreaseIndentPattern
        };
        if (indentationRules.indentNextLinePattern) {
            result.indentNextLinePattern = this._parseRegex(
                languageId,
                `indentationRules.indentNextLinePattern`,
                indentationRules.indentNextLinePattern
            );
        }
        if (indentationRules.unIndentedLinePattern) {
            result.unIndentedLinePattern = this._parseRegex(
                languageId,
                `indentationRules.unIndentedLinePattern`,
                indentationRules.unIndentedLinePattern
            );
        }
        return result;
    }
};
LanguageConfigurationFileHandler = LanguageConfigurationFileHandler_1 = ( __decorate([( __param(0, ILanguageService)), ( __param(1, IExtensionResourceLoaderService)), ( __param(2, IExtensionService)), ( __param(3, ILanguageConfigurationService))], LanguageConfigurationFileHandler));
const schemaId = "vscode://schemas/language-configuration";
const schema = {
    allowComments: true,
    allowTrailingCommas: true,
    default: {
        comments: {
            blockComment: ["/*", "*/"],
            lineComment: "//"
        },
        brackets: [["(", ")"], ["[", "]"], ["{", "}"]],
        autoClosingPairs: [["(", ")"], ["[", "]"], ["{", "}"]],
        surroundingPairs: [["(", ")"], ["[", "]"], ["{", "}"]]
    },
    definitions: {
        openBracket: {
            type: "string",
            description: ( localize(8511, "The opening bracket character or string sequence."))
        },
        closeBracket: {
            type: "string",
            description: ( localize(8512, "The closing bracket character or string sequence."))
        },
        bracketPair: {
            type: "array",
            items: [{
                $ref: "#/definitions/openBracket"
            }, {
                $ref: "#/definitions/closeBracket"
            }]
        }
    },
    properties: {
        comments: {
            default: {
                blockComment: ["/*", "*/"],
                lineComment: {
                    comment: "//",
                    noIndent: false
                }
            },
            description: ( localize(8513, "Defines the comment symbols")),
            type: "object",
            properties: {
                blockComment: {
                    type: "array",
                    description: ( localize(8514, "Defines how block comments are marked.")),
                    items: [{
                        type: "string",
                        description: ( localize(8515, "The character sequence that starts a block comment."))
                    }, {
                        type: "string",
                        description: ( localize(8516, "The character sequence that ends a block comment."))
                    }]
                },
                lineComment: {
                    type: "object",
                    description: ( localize(8517, "Configuration for line comments.")),
                    properties: {
                        comment: {
                            type: "string",
                            description: ( localize(8518, "The character sequence that starts a line comment."))
                        },
                        noIndent: {
                            type: "boolean",
                            description: ( localize(
                                8519,
                                "Whether the comment token should not be indented and placed at the first column. Defaults to false."
                            )),
                            default: false
                        }
                    },
                    required: ["comment"],
                    additionalProperties: false
                }
            }
        },
        brackets: {
            default: [["(", ")"], ["[", "]"], ["{", "}"]],
            markdownDescription: ( localize(
                8520,
                "Defines the bracket symbols that increase or decrease the indentation. When bracket pair colorization is enabled and {0} is not defined, this also defines the bracket pairs that are colorized by their nesting level.",
                "`colorizedBracketPairs`"
            )),
            type: "array",
            items: {
                $ref: "#/definitions/bracketPair"
            }
        },
        colorizedBracketPairs: {
            default: [["(", ")"], ["[", "]"], ["{", "}"]],
            markdownDescription: ( localize(
                8521,
                "Defines the bracket pairs that are colorized by their nesting level if bracket pair colorization is enabled. Any brackets included here that are not included in {0} will be automatically included in {0}.",
                "`brackets`"
            )),
            type: "array",
            items: {
                $ref: "#/definitions/bracketPair"
            }
        },
        autoClosingPairs: {
            default: [["(", ")"], ["[", "]"], ["{", "}"]],
            description: ( localize(
                8522,
                "Defines the bracket pairs. When a opening bracket is entered, the closing bracket is inserted automatically."
            )),
            type: "array",
            items: {
                oneOf: [{
                    $ref: "#/definitions/bracketPair"
                }, {
                    type: "object",
                    properties: {
                        open: {
                            $ref: "#/definitions/openBracket"
                        },
                        close: {
                            $ref: "#/definitions/closeBracket"
                        },
                        notIn: {
                            type: "array",
                            description: ( localize(8523, "Defines a list of scopes where the auto pairs are disabled.")),
                            items: {
                                enum: ["string", "comment"]
                            }
                        }
                    }
                }]
            }
        },
        autoCloseBefore: {
            default: ";:.,=}])> \n\t",
            description: ( localize(
                8524,
                "Defines what characters must be after the cursor in order for bracket or quote autoclosing to occur when using the 'languageDefined' autoclosing setting. This is typically the set of characters which can not start an expression."
            )),
            type: "string"
        },
        surroundingPairs: {
            default: [["(", ")"], ["[", "]"], ["{", "}"]],
            description: ( localize(
                8525,
                "Defines the bracket pairs that can be used to surround a selected string."
            )),
            type: "array",
            items: {
                oneOf: [{
                    $ref: "#/definitions/bracketPair"
                }, {
                    type: "object",
                    properties: {
                        open: {
                            $ref: "#/definitions/openBracket"
                        },
                        close: {
                            $ref: "#/definitions/closeBracket"
                        }
                    }
                }]
            }
        },
        wordPattern: {
            default: "",
            description: ( localize(
                8526,
                "Defines what is considered to be a word in the programming language."
            )),
            type: ["string", "object"],
            properties: {
                pattern: {
                    type: "string",
                    description: ( localize(8527, "The RegExp pattern used to match words.")),
                    default: ""
                },
                flags: {
                    type: "string",
                    description: ( localize(8528, "The RegExp flags used to match words.")),
                    default: "g",
                    pattern: "^([gimuy]+)$",
                    patternErrorMessage: ( localize(8529, "Must match the pattern `/^([gimuy]+)$/`."))
                }
            }
        },
        indentationRules: {
            default: {
                increaseIndentPattern: "",
                decreaseIndentPattern: ""
            },
            description: ( localize(8530, "The language's indentation settings.")),
            type: "object",
            properties: {
                increaseIndentPattern: {
                    type: ["string", "object"],
                    description: ( localize(
                        8531,
                        "If a line matches this pattern, then all the lines after it should be indented once (until another rule matches)."
                    )),
                    properties: {
                        pattern: {
                            type: "string",
                            description: ( localize(8532, "The RegExp pattern for increaseIndentPattern.")),
                            default: ""
                        },
                        flags: {
                            type: "string",
                            description: ( localize(8533, "The RegExp flags for increaseIndentPattern.")),
                            default: "",
                            pattern: "^([gimuy]+)$",
                            patternErrorMessage: ( localize(8534, "Must match the pattern `/^([gimuy]+)$/`."))
                        }
                    }
                },
                decreaseIndentPattern: {
                    type: ["string", "object"],
                    description: ( localize(
                        8535,
                        "If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches)."
                    )),
                    properties: {
                        pattern: {
                            type: "string",
                            description: ( localize(8536, "The RegExp pattern for decreaseIndentPattern.")),
                            default: ""
                        },
                        flags: {
                            type: "string",
                            description: ( localize(8537, "The RegExp flags for decreaseIndentPattern.")),
                            default: "",
                            pattern: "^([gimuy]+)$",
                            patternErrorMessage: ( localize(8538, "Must match the pattern `/^([gimuy]+)$/`."))
                        }
                    }
                },
                indentNextLinePattern: {
                    type: ["string", "object"],
                    description: ( localize(
                        8539,
                        "If a line matches this pattern, then **only the next line** after it should be indented once."
                    )),
                    properties: {
                        pattern: {
                            type: "string",
                            description: ( localize(8540, "The RegExp pattern for indentNextLinePattern.")),
                            default: ""
                        },
                        flags: {
                            type: "string",
                            description: ( localize(8541, "The RegExp flags for indentNextLinePattern.")),
                            default: "",
                            pattern: "^([gimuy]+)$",
                            patternErrorMessage: ( localize(8542, "Must match the pattern `/^([gimuy]+)$/`."))
                        }
                    }
                },
                unIndentedLinePattern: {
                    type: ["string", "object"],
                    description: ( localize(
                        8543,
                        "If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules."
                    )),
                    properties: {
                        pattern: {
                            type: "string",
                            description: ( localize(8544, "The RegExp pattern for unIndentedLinePattern.")),
                            default: ""
                        },
                        flags: {
                            type: "string",
                            description: ( localize(8545, "The RegExp flags for unIndentedLinePattern.")),
                            default: "",
                            pattern: "^([gimuy]+)$",
                            patternErrorMessage: ( localize(8546, "Must match the pattern `/^([gimuy]+)$/`."))
                        }
                    }
                }
            }
        },
        folding: {
            type: "object",
            description: ( localize(8547, "The language's folding settings.")),
            properties: {
                offSide: {
                    type: "boolean",
                    description: ( localize(
                        8548,
                        "A language adheres to the off-side rule if blocks in that language are expressed by their indentation. If set, empty lines belong to the subsequent block."
                    ))
                },
                markers: {
                    type: "object",
                    description: ( localize(
                        8549,
                        "Language specific folding markers such as '#region' and '#endregion'. The start and end regexes will be tested against the contents of all lines and must be designed efficiently"
                    )),
                    properties: {
                        start: {
                            type: ["string", "object"],
                            description: ( localize(
                                8550,
                                "The RegExp pattern for the start marker. The regexp must start with '^'."
                            )),
                            properties: {
                                pattern: {
                                    type: "string",
                                    description: ( localize(8551, "The RegExp pattern for the start marker.")),
                                    default: ""
                                },
                                flags: {
                                    type: "string",
                                    description: ( localize(8552, "The RegExp flags for the start marker.")),
                                    default: "",
                                    pattern: "^([gimuy]+)$",
                                    patternErrorMessage: ( localize(8553, "Must match the pattern `/^([gimuy]+)$/`."))
                                }
                            }
                        },
                        end: {
                            type: ["string", "object"],
                            description: ( localize(
                                8554,
                                "The RegExp pattern for the end marker. The regexp must start with '^'."
                            )),
                            properties: {
                                pattern: {
                                    type: "string",
                                    description: ( localize(8555, "The RegExp pattern for the end marker.")),
                                    default: ""
                                },
                                flags: {
                                    type: "string",
                                    description: ( localize(8556, "The RegExp flags for the end marker.")),
                                    default: "",
                                    pattern: "^([gimuy]+)$",
                                    patternErrorMessage: ( localize(8557, "Must match the pattern `/^([gimuy]+)$/`."))
                                }
                            }
                        }
                    }
                }
            }
        },
        onEnterRules: {
            type: "array",
            description: ( localize(8558, "The language's rules to be evaluated when pressing Enter.")),
            items: {
                type: "object",
                description: ( localize(8558, "The language's rules to be evaluated when pressing Enter.")),
                required: ["beforeText", "action"],
                properties: {
                    beforeText: {
                        type: ["string", "object"],
                        description: ( localize(
                            8559,
                            "This rule will only execute if the text before the cursor matches this regular expression."
                        )),
                        properties: {
                            pattern: {
                                type: "string",
                                description: ( localize(8560, "The RegExp pattern for beforeText.")),
                                default: ""
                            },
                            flags: {
                                type: "string",
                                description: ( localize(8561, "The RegExp flags for beforeText.")),
                                default: "",
                                pattern: "^([gimuy]+)$",
                                patternErrorMessage: ( localize(8562, "Must match the pattern `/^([gimuy]+)$/`."))
                            }
                        }
                    },
                    afterText: {
                        type: ["string", "object"],
                        description: ( localize(
                            8563,
                            "This rule will only execute if the text after the cursor matches this regular expression."
                        )),
                        properties: {
                            pattern: {
                                type: "string",
                                description: ( localize(8564, "The RegExp pattern for afterText.")),
                                default: ""
                            },
                            flags: {
                                type: "string",
                                description: ( localize(8565, "The RegExp flags for afterText.")),
                                default: "",
                                pattern: "^([gimuy]+)$",
                                patternErrorMessage: ( localize(8566, "Must match the pattern `/^([gimuy]+)$/`."))
                            }
                        }
                    },
                    previousLineText: {
                        type: ["string", "object"],
                        description: ( localize(
                            8567,
                            "This rule will only execute if the text above the line matches this regular expression."
                        )),
                        properties: {
                            pattern: {
                                type: "string",
                                description: ( localize(8568, "The RegExp pattern for previousLineText.")),
                                default: ""
                            },
                            flags: {
                                type: "string",
                                description: ( localize(8569, "The RegExp flags for previousLineText.")),
                                default: "",
                                pattern: "^([gimuy]+)$",
                                patternErrorMessage: ( localize(8570, "Must match the pattern `/^([gimuy]+)$/`."))
                            }
                        }
                    },
                    action: {
                        type: ["string", "object"],
                        description: ( localize(8571, "The action to execute.")),
                        required: ["indent"],
                        default: {
                            "indent": "indent"
                        },
                        properties: {
                            indent: {
                                type: "string",
                                description: ( localize(8572, "Describe what to do with the indentation")),
                                default: "indent",
                                enum: ["none", "indent", "indentOutdent", "outdent"],
                                markdownEnumDescriptions: [( localize(8573, "Insert new line and copy the previous line's indentation.")), ( localize(
                                    8574,
                                    "Insert new line and indent once (relative to the previous line's indentation)."
                                )), ( localize(
                                    8575,
                                    "Insert two new lines:\n - the first one indented which will hold the cursor\n - the second one at the same indentation level"
                                )), ( localize(
                                    8576,
                                    "Insert new line and outdent once (relative to the previous line's indentation)."
                                ))]
                            },
                            appendText: {
                                type: "string",
                                description: ( localize(
                                    8577,
                                    "Describes text to be appended after the new line and after the indentation."
                                )),
                                default: ""
                            },
                            removeText: {
                                type: "number",
                                description: ( localize(
                                    8578,
                                    "Describes the number of characters to remove from the new line's indentation."
                                )),
                                default: 0
                            }
                        }
                    }
                }
            }
        }
    }
};
const schemaRegistry = ( Registry.as(Extensions.JSONContribution));
schemaRegistry.registerSchema(schemaId, schema);
let LanguageConfigurationWorkbenchContribution = class LanguageConfigurationWorkbenchContribution {
    static {
        this.ID = "workbench.contrib.languageConfigurationExtensionPoint";
    }
    constructor(instantiationService) {
        this.instantiationService = instantiationService;
        this.instantiationService.createInstance(LanguageConfigurationFileHandler);
    }
};
LanguageConfigurationWorkbenchContribution = ( __decorate([( __param(0, IInstantiationService))], LanguageConfigurationWorkbenchContribution));
registerWorkbenchContribution2(
    LanguageConfigurationWorkbenchContribution.ID,
    LanguageConfigurationWorkbenchContribution,
    WorkbenchPhase.BlockStartup
);

export { LanguageConfigurationFileHandler };
