"use strict";
// Copyright [c] Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.PredefinedTokens = void 0;
const PredefinedTokenEnum_1 = require("./PredefinedTokenEnum");
const PredefinedType_1 = require("./PredefinedType");
/**
 * Predefined tokens
 * @internal
 */
class PredefinedTokens {
    /**
     * Create a hash to find a string to type
     * @internal
     */
    static initializeTextToTypeHash() {
        const textToTypeHash = new Map();
        for (const token of PredefinedTokens.supportedPredefinedTokensList) {
            textToTypeHash.set(token[1], token[2]);
        }
        return textToTypeHash;
    }
    /**
     * Create a hash to find a string to token enum
     * @internal
     */
    static initializeTextToTokenHash() {
        const textToTokenHash = new Map();
        for (const token of PredefinedTokens.supportedPredefinedTokensList) {
            textToTokenHash.set(token[1], token[0]);
        }
        return textToTokenHash;
    }
    /**
     * FOR UNIT TESTS ONLY
     * Function to retrieve and cache the list of predefined tokens that are recognized as keywords and are supported directly
     * @internal
     */
    static getPredefinedTokens() {
        const tokens = [];
        const foundTokens = PredefinedTokens.supportedPredefinedTokensList
            .filter((token) => token[2] === PredefinedType_1.PredefinedType.token);
        for (const token of foundTokens) {
            tokens.push(token[1]);
        }
        // Expected: { "always", "depth", "maxDepth", "cardinality.minimum", "cardinality.maximum", "referenceOnly", "normalized", "structured",  }
        return tokens;
    }
    /**
     * FOR UNIT TESTS ONLY
     * Function to retrieve and cache the list of supported operators
     * @internal
     */
    static getSupportedOperators() {
        const operators = [];
        const foundOperators = PredefinedTokens.supportedPredefinedTokensList
            .filter((token) => token[2] === PredefinedType_1.PredefinedType.operator);
        for (const op of foundOperators) {
            operators.push(op[1]);
        }
        // Expected: { "&&", "||", ">", "<", "==", "!=", ">=", "<=",  }
        // "!" is captured as PredefinedType.NotOperator and not included here
        return operators;
    }
    /**
     * FOR UNIT TESTS ONLY
     * Function to retrieve and cache the supported open and close parenthesis
     * @internal
     */
    static getSupportedParenthesis() {
        const parenthesis = [];
        const foundParenthesis = PredefinedTokens.supportedPredefinedTokensList
            .filter((token) => token[2] === PredefinedType_1.PredefinedType.openParenthesis || token[2] === PredefinedType_1.PredefinedType.closeParenthesis);
        for (const paren of foundParenthesis) {
            parenthesis.push(paren[1]);
        }
        // Expected: { "(", ")",  }
        return parenthesis;
    }
    /**
     * FOR UNIT TESTS ONLY
     * Function to retrieve and cache the predefined constants
     * @internal
     */
    static getPredefinedConstants() {
        const constants = [];
        const foundConstants = PredefinedTokens.supportedPredefinedTokensList
            .filter((token) => token[2] === PredefinedType_1.PredefinedType.constant);
        for (const constant of foundConstants) {
            constants.push(constant[1]);
        }
        // Expected: { "true", "false",  }
        return constants;
    }
}
exports.PredefinedTokens = PredefinedTokens;
/**
 * @internal
 */
PredefinedTokens.supportedPredefinedTokensList = [
    [PredefinedTokenEnum_1.PredefinedTokenEnum.ALWAYS, 'always', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.AND, '&&', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.OR, '||', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.NOT, '!', PredefinedType_1.PredefinedType.notOperator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.TRUE, 'true', PredefinedType_1.PredefinedType.constant],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.FALSE, 'false', PredefinedType_1.PredefinedType.constant],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.GT, '>', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.LT, '<', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.EQ, '==', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.NE, '!=', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.GE, '>=', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.LE, '<=', PredefinedType_1.PredefinedType.operator],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.DEPTH, 'depth', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.MAXDEPTH, 'maxDepth', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.NOMAXDEPTH, 'noMaxDepth', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.ISARRAY, 'isArray', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.MINCARDINALITY, 'cardinality.minimum', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.MAXCARDINALITY, 'cardinality.maximum', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.REFERENCEONLY, 'referenceOnly', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.NORMALIZED, 'normalized', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.STRUCTURED, 'structured', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.VIRTUAL, 'virtual', PredefinedType_1.PredefinedType.token],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.OPENPAREN, '(', PredefinedType_1.PredefinedType.openParenthesis],
    [PredefinedTokenEnum_1.PredefinedTokenEnum.CLOSEPAREN, ')', PredefinedType_1.PredefinedType.closeParenthesis],
];
//# sourceMappingURL=PredefinedTokens.js.map