import * as i1 from '@angular/common';
import { CommonModule } from '@angular/common';
import * as i0 from '@angular/core';
import { forwardRef, Component, Input } from '@angular/core';
import * as i2 from '@angular/forms';
import { NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms';
import { AggregationRole, C_MEASURES, getEntityDimensionAndHierarchies, isMeasureControlProperty, nonNullable } from '@metad/ocap-core';
import { BehaviorSubject, combineLatest } from 'rxjs';
import { filter, tap } from 'rxjs/operators';
import * as i3 from 'ngx-monaco-editor';
import { MonacoEditorModule } from 'ngx-monaco-editor';
import { NgmBaseEditorDirective } from '@metad/ocap-angular/formula';
import { isNil, lowerCase, isEmpty } from 'lodash-es';

// MDX Functions
const FUNCTIONS = [
    {
        label: 'Aggregate',
        expression: `Aggregate(Set_Expression [ ,Numeric_Expression ])`,
        insertText: 'Aggregate()',
        documentation: `Returns a number that is calculated by aggregating over the cells returned by the set expression. If a numeric expression is not provided, this function aggregates each measure within the current query context by using the default aggregation operator that is specified for each measure. If a numeric expression is provided, this function first evaluates, and then sums, the numeric expression for each cell in the specified set.`
    },
    {
        label: 'Filter',
        expression: `Filter(**Set_Expression**, **Logical_Expression**)`,
        insertText: 'Filter()',
        documentation: `Returns the set that results from filtering a specified set based on a search condition.

The Filter function evaluates the specified logical expression against each tuple in the specified set. The function returns a set that consists of each tuple in the specified set where the logical expression evaluates to true. If no tuples evaluate to true, an empty set is returned.

The Filter function works in a fashion similar to that of the IIf function. The IIf function returns only one of two options based on the evaluation of an MDX logical expression, while the Filter function returns a set of tuples that meet the specified search condition. In effect, the Filter function executes \`IIf(Logical_Expression, Set_Expression.Current, NULL)\` on each tuple in the set, and returns the resulting set.

## Examples

The following example returns the sum of the \`Measures.[Order Quantity]\` member, aggregated over the first eight months of calendar year 2003 that are contained in the Date dimension, from the Adventure Works cube.

\`\`\`sql
WITH MEMBER [Date].[Calendar].[First8Months2003] AS  
    Aggregate(  
        PeriodsToDate(  
            [Date].[Calendar].[Calendar Year],   
            [Date].[Calendar].[Month].[August 2003]  
        )  
    )  
SELECT   
    [Date].[Calendar].[First8Months2003] ON COLUMNS,  
    [Product].[Category].Children ON ROWS  
FROM  
    [Adventure Works]  
WHERE  
    [Measures].[Order Quantity]
\`\`\`
`
    },
    {
        label: 'Avg',
        expression: 'Avg(Set_Expression [, Numeric_Expression])',
        insertText: 'Avg()',
        documentation: 'Returns the average (arithmetic mean) of a numeric expression that is evaluated over the specified set.'
    },
    {
        label: 'Count',
        expression: 'Count(Set_Expression [, ExcludeEmpty | IncludeEmpty])',
        insertText: 'Count()',
        documentation: 'Returns the number of tuples in a specified set, with an optional flag to include or exclude empty tuples.'
    },
    {
        label: 'Max',
        expression: 'Max(Set_Expression, Numeric_Expression)',
        insertText: 'Max()',
        documentation: 'Returns the maximum value of a numeric expression evaluated over a specified set.'
    },
    {
        label: 'Min',
        expression: 'Min(Set_Expression, Numeric_Expression)',
        insertText: 'Min()',
        documentation: 'Returns the minimum value of a numeric expression evaluated over a specified set.'
    },
    {
        label: 'Sum',
        expression: 'Sum(Set_Expression [, Numeric_Expression])',
        insertText: 'Sum()',
        documentation: 'Returns the sum of a numeric expression evaluated over a specified set.'
    },
    {
        label: 'Exists',
        expression: 'Exists(Set_Expression1, Set_Expression2 [, String_Expression])',
        insertText: 'Exists()',
        documentation: 'Returns the set of tuples of the first set specified that exist with one or more tuples of the second specified set.'
    },
    {
        label: 'Generate',
        expression: 'Generate(Set_Expression, Expression [, ALL])',
        insertText: 'Generate()',
        documentation: 'Returns a set generated by evaluating a specified expression for each tuple in a specified set.'
    },
    {
        label: 'IIf',
        expression: 'IIf(Logical_Expression, Expression1, Expression2)',
        insertText: 'IIf()',
        documentation: 'Returns one of two expressions based on the evaluation of a logical expression.'
    },
    {
        label: 'CoalesceEmpty',
        expression: 'CoalesceEmpty(Expression1, Expression2)',
        insertText: 'CoalesceEmpty()',
        documentation: 'Returns the first expression if it is not empty; otherwise, returns the second expression.'
    },
    {
        label: 'CrossJoin',
        expression: 'CrossJoin(Set_Expression1, Set_Expression2)',
        insertText: 'CrossJoin()',
        documentation: 'Returns the cross product of two sets.'
    },
    {
        label: 'ClosingPeriod',
        expression: 'ClosingPeriod([<Level>][, <Member>])',
        insertText: 'ClosingPeriod()',
        documentation: 'Returns the last descendant of a member at a level.'
    },
    {
        label: 'Children',
        expression: '<Member>.Children',
        insertText: '.Children',
        documentation: 'Returns the children of a member.'
    },
    {
        label: 'Except',
        expression: 'Except(Set_Expression1, Set_Expression2 [, ALL])',
        insertText: 'Except()',
        documentation: 'Returns the set that results from removing the tuples of the second set specified from the first set specified.'
    },
    {
        label: 'Intersect',
        expression: 'Intersect(Set_Expression1, Set_Expression2 [, ALL])',
        insertText: 'Intersect()',
        documentation: 'Returns the intersection of two sets, optionally retaining duplicates.'
    },
    {
        label: 'Union',
        expression: 'Union(Set_Expression1, Set_Expression2 [, ALL])',
        insertText: 'Union()',
        documentation: 'Returns the union of two sets, optionally retaining duplicates.'
    },
    {
        label: 'FirstChild',
        expression: 'Member_Expression.FirstChild',
        insertText: '.FirstChild',
        documentation: 'Returns the first child of a specified member.'
    },
    {
        label: 'LastChild',
        expression: 'Member_Expression.LastChild',
        insertText: '.LastChild',
        documentation: 'Returns the last child of a specified member.'
    },
    {
        label: 'FirstSibling',
        expression: 'Member_Expression.FirstSibling',
        insertText: '.FirstSibling',
        documentation: 'Returns the first sibling of a specified member.'
    },
    {
        label: 'LastSibling',
        expression: 'Member_Expression.LastSibling',
        insertText: '.LastSibling',
        documentation: 'Returns the last sibling of a specified member.'
    },
    {
        label: 'NextMember',
        expression: 'Member_Expression.NextMember',
        insertText: '.NextMember',
        documentation: 'Returns the next member in the level that contains a specified member.'
    },
    {
        label: 'PrevMember',
        expression: 'Member_Expression.PrevMember',
        insertText: '.PrevMember',
        documentation: 'Returns the previous member in the level that contains a specified member.'
    },
    {
        label: 'Ancestor',
        expression: 'Ancestor(Member_Expression, Level_Expression)',
        insertText: 'Ancestor()',
        documentation: 'Returns the ancestor of a member at a specified level.'
    },
    {
        label: 'Cousin',
        expression: 'Cousin(Member_Expression, Ancestor_Member_Expression)',
        insertText: 'Cousin()',
        documentation: 'Returns the cousin of a member based on a second member.'
    },
    {
        label: 'Parent',
        expression: 'Member_Expression.Parent',
        insertText: '.Parent',
        documentation: 'Returns the parent of a specified member.'
    },
    {
        label: 'StrToMember',
        expression: 'StrToMember(String_Expression [, CONSTRAINED])',
        insertText: 'StrToMember()',
        documentation: 'Converts a string to a member. If the optional CONSTRAINED flag is used, the function will raise an error if the member does not exist.'
    },
    {
        label: 'StrToSet',
        expression: 'StrToSet(String_Expression [, CONSTRAINED])',
        insertText: 'StrToSet()',
        documentation: 'Converts a string to a set. If the optional CONSTRAINED flag is used, the function will raise an error if the set does not exist.'
    },
    {
        label: 'StrToValue',
        expression: 'StrToValue(String_Expression)',
        insertText: 'StrToValue()',
        documentation: 'Converts a string to a value.'
    },
    {
        label: 'CurrentMember',
        expression: 'Hierarchy_Expression.CurrentMember',
        insertText: '.CurrentMember',
        documentation: 'Returns the current member along a specified hierarchy during iteration.'
    },
    {
        label: 'DefaultMember',
        expression: 'Hierarchy_Expression.DefaultMember',
        insertText: '.DefaultMember',
        documentation: 'Returns the default member of a specified hierarchy.'
    },
    {
        label: 'Members',
        expression: 'Level_Expression.Members',
        insertText: '.Members',
        documentation: 'Returns the set of members in a specified level.'
    },
    {
        label: 'AllMembers',
        expression: 'Hierarchy_Expression.AllMembers',
        insertText: '.AllMembers',
        documentation: 'Returns the set of all members, including calculated members, in a specified hierarchy.'
    },
    {
        label: 'Ascendants',
        expression: '<Set> Ascendants(<Member>)',
        insertText: '.Ascendants',
        documentation: 'Returns the set of the ascendants of a specified member.'
    },
    {
        label: 'Descendants',
        expression: 'Descendants(Member_Expression, Level_Expression [, Desc_Flag])',
        insertText: 'Descendants()',
        documentation: 'Returns the set of descendants of a specified member at a specified level, optionally filtered by a specified type of descendant.'
    },
    {
        label: 'DrilldownLevel',
        expression: 'DrilldownLevel(Set_Expression [, Level_Expression [, RECURSIVE]])',
        insertText: 'DrilldownLevel()',
        documentation: 'Returns a set generated by drilling down a specified number of levels from a specified level, optionally drilling down recursively.'
    },
    {
        label: 'DrilldownMember',
        expression: 'DrilldownMember(Set_Expression, Set_Expression2 [, RECURSIVE])',
        insertText: 'DrilldownMember()',
        documentation: 'Returns a set generated by drilling down from a specified member, optionally drilling down recursively.'
    },
    {
        label: 'DrillupLevel',
        expression: 'DrillupLevel(Set_Expression [, Level_Expression])',
        insertText: 'DrillupLevel()',
        documentation: 'Returns a set generated by drilling up from a specified level to its parent level.'
    },
    {
        label: 'DrillupMember',
        expression: 'DrillupMember(Set_Expression, Set_Expression2)',
        insertText: 'DrillupMember()',
        documentation: 'Returns a set generated by drilling up from a specified member to its parent member.'
    },
    {
        label: 'BottomCount',
        expression: 'BottomCount(Set_Expression, Count [, Numeric_Expression])',
        insertText: 'BottomCount()',
        documentation: 'Returns the bottom N tuples of a specified set, optionally ordered by a numeric expression.'
    },
    {
        label: 'BottomPercent',
        expression: 'BottomPercent(Set_Expression, Percent [, Numeric_Expression])',
        insertText: 'BottomPercent()',
        documentation: 'Returns the bottom N percent of tuples in a specified set, optionally ordered by a numeric expression.'
    },
    {
        label: 'BottomSum',
        expression: '<Set> BottomSum(<Set>, <Numeric Expression>, <Numeric Expression>)',
        insertText: 'BottomSum()',
        documentation: 'Sorts a set and returns the bottom N elements whose cumulative total is at least a specified value.'
    },
    {
        label: 'TopCount',
        expression: 'TopCount(Set_Expression, Count [, Numeric_Expression])',
        insertText: 'TopCount()',
        documentation: 'Returns the top N tuples of a specified set, optionally ordered by a numeric expression.'
    },
    {
        label: 'TopPercent',
        expression: 'TopPercent(Set_Expression, Percent [, Numeric_Expression])',
        insertText: 'TopPercent()',
        documentation: `Returns the top N percent of tuples in a specified set, optionally ordered by a numeric expression.
  
The TopPercent function calculates the sum of the specified numeric expression evaluated over the specified set, sorting the set in descending order.
The function then returns the elements with the highest values whose cumulative percentage of the total summed value is at least the specified percentage.
This function returns the smallest subset of a set whose cumulative total is at least the specified percentage. The returned elements are ordered largest to smallest.`
    },
    {
        label: 'TopSum',
        expression: '<Set> TopSum(<Set>, <Numeric Expression>, <Numeric Expression>)',
        insertText: 'TopSum()',
        documentation: 'Sorts a set and returns the top N elements whose cumulative total is at least a specified value.'
    },
    {
        label: 'Head',
        expression: 'Head(Set_Expression, Count)',
        insertText: 'Head()',
        documentation: 'Returns the first N elements of a specified set.'
    },
    {
        label: 'Tail',
        expression: 'Tail(Set_Expression, Count)',
        insertText: 'Tail()',
        documentation: 'Returns the last N elements of a specified set.'
    },
    {
        label: 'Item',
        expression: 'Set_Expression.Item(Index)',
        insertText: '.Item()',
        documentation: 'Returns the tuple at a specified index within a set.'
    },
    {
        label: 'Left',
        expression: 'Left(Member_Expression | String, Count)',
        insertText: 'Left()',
        documentation: 'Returns a specified number of characters from the left side of a string.'
    },
    {
        label: 'Len',
        expression: 'Len(Member_Expression | String)',
        insertText: 'Len()',
        documentation: 'Returns the number of characters in a string.'
    },
    {
        label: 'Order',
        expression: 'Order(Set_Expression, Numeric_Expression [, ASC | DESC | BASC | BDESC])',
        insertText: 'Order()',
        documentation: 'Returns a set sorted by a specified numeric expression, optionally specifying the sort order.'
    },
    {
        label: 'Rank',
        expression: 'Rank(Tuple_Expression, Set_Expression [, Numeric_Expression])',
        insertText: 'Rank()',
        documentation: 'Returns the one-based rank of a specified tuple within a specified set, optionally ordered by a numeric expression.'
    },
    {
        label: 'ParallelPeriod',
        expression: 'ParallelPeriod(<Level>[, <Numeric Expression>[, <Member>]])',
        insertText: 'ParallelPeriod()',
        documentation: 'Returns a member from a prior period in the same relative position as a specified member.'
    },
    {
        label: 'PeriodsToDate',
        expression: 'PeriodsToDate(<Level>, <Member>)',
        insertText: 'PeriodsToDate()',
        documentation: 'Returns a set of periods (members) from a specified level starting with the first period and ending with a specified member.'
    },
    {
        label: 'Properties',
        expression: 'Member_Expression.Properties(Property_Name [, TYPED])',
        insertText: '.Properties()',
        documentation: 'Returns the value of a specified property for a specified member, optionally returning the value in the data type of the property.'
    },
    {
        label: 'IsEmpty',
        expression: 'IsEmpty(Expression)',
        insertText: 'IsEmpty()',
        documentation: 'Returns true if a specified expression is empty; otherwise, returns false.'
    },
    {
        label: 'IsLeaf',
        expression: 'IsLeaf(Expression)',
        insertText: 'IsLeaf()',
        documentation: 'Returns true if a specified member is a leaf member (has no children); otherwise, returns false.'
    },
    {
        label: 'IsSibling',
        expression: 'IsSibling(Member_Expression1, Member_Expression2)',
        insertText: 'IsSibling()',
        documentation: 'Returns true if the specified members are siblings (share the same parent); otherwise, returns false.'
    }
];

const SUFFIX_FUNCTIONS = [
    {
        label: 'AllMembers',
        expression: `Hierarchy_Expression.AllMembers | Level_Expression.AllMembers`,
        insertText: 'AllMembers',
        documentation: `The AllMembers function returns a set that contains all members, which includes calculated members, in the specified hierarchy or level. The AllMembers function returns the calculated members even if the specified hierarchy or level contains no visible members.
> When a dimension contains only a single visible hierarchy, the hierarchy can be either referred to by the dimension name or by the hierarchy name, because the dimension name in this case is resolved to its only visible hierarchy. For example, Measures.AllMembers is a valid MDX expression because it resolves to the only hierarchy in the Measures dimension.

## Examples

The following example returns all members in the [Date].[Calendar Year] attribute hierarchy on the column axis, this includes calculated members, and the set of all children of the [Product].[Model Name] attribute hierarchy on the row axis from the Adventure Works cube.

\`\`\`sql
SELECT  
   [Date].[Calendar Year].AllMembers ON COLUMNS,  
   [Product].[Model Name].Children ON ROWS  
FROM  
   [Adventure Works]
\`\`\`
`,
    },
    {
        label: 'Members',
        expression: `Hierarchy_Expression.Members | Level_Expression.Members`,
        insertText: 'Members',
        documentation: ``
    }
];

var index = /*#__PURE__*/Object.freeze({
  __proto__: null,
  FUNCTIONS: FUNCTIONS,
  SUFFIX_FUNCTIONS: SUFFIX_FUNCTIONS
});

// dimension or hierarchy field name regex
const C_MDX_FIELD_NAME_REGEX = `[a-zA-Z0-9\u4E00-\u9FCC\\/\\s_\\-]*`;
/**
 * NodeType 即 PropertyType 代表字段节点的类型, 联合上 Readonly 属性可以表示一个字段是来源于 CUbe 配置还是来源目标系统 API.
 * 来源于本系统的 XMLA Model 的 Cube 配置可以被修改, 而来源于目标系统 API 的字段是只读 Readonly, 只能配置一些增强属性.
 */
var MDXNodeType;
(function (MDXNodeType) {
    MDXNodeType["Property"] = "property";
    MDXNodeType["Dimension"] = "dimension";
    MDXNodeType["Hierarchy"] = "hierarchy";
    MDXNodeType["Level"] = "level";
    MDXNodeType["Measure"] = "measure";
    MDXNodeType["CalculatedMember"] = "calculatedMember";
    MDXNodeType["NamedSet"] = "namedSet";
})(MDXNodeType || (MDXNodeType = {}));
/**
 * Node for Property item
 */
class PropertyItemNode {
}
/** Flat Property item node with expandable and level information */
class PropertyItemFlatNode {
}

const functionProposals = {
    provideCompletionItems: (model, position) => {
        const word = model.getWordUntilPosition(position);
        const range = {
            startLineNumber: position.lineNumber,
            endLineNumber: position.lineNumber,
            startColumn: word.startColumn,
            endColumn: word.endColumn
        };
        return {
            suggestions: FUNCTIONS.map((item) => {
                return {
                    ...item,
                    kind: monaco.languages.CompletionItemKind.Function,
                    insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
                    detail: item.expression,
                    documentation: `${item.expression}\n${item.documentation}`,
                    range: range
                };
            })
        };
    }
};
function createCubeSuggestions(model, position, entityType) {
    const word = model.getWordUntilPosition(position);
    let from = null;
    let startColumn = word.startColumn - 1;
    while (!from?.word && startColumn > 0) {
        from = model.getWordUntilPosition(new monaco.Position(position.lineNumber, --startColumn));
    }
    if (!isNil(from?.word) && lowerCase(from.word) === 'from') {
        const range = {
            startLineNumber: position.lineNumber,
            endLineNumber: position.lineNumber,
            // startColumn: word.startColumn,
            // endColumn: word.endColumn,
            startColumn: word.startColumn - 1,
            endColumn: word.endColumn + 1
        };
        return [
            {
                label: `[${entityType.name}]`,
                kind: monaco.languages.CompletionItemKind.Method,
                detail: ``,
                insertText: `[${entityType.name}]`,
                range: range
            }
        ];
    }
    return null;
}
const createHierarchyProvider = (entityType) => {
    return {
        triggerCharacters: ['['],
        provideCompletionItems: (model, position) => {
            const suggestions = createCubeSuggestions(model, position, entityType);
            if (!isEmpty(suggestions)) {
                return {
                    suggestions
                };
            }
            const word = model.getWordUntilPosition(position);
            const range = {
                startLineNumber: position.lineNumber,
                endLineNumber: position.lineNumber,
                // startColumn: word.startColumn,
                // endColumn: word.endColumn,
                startColumn: word.startColumn - 1,
                endColumn: word.endColumn + 1
            };
            return {
                suggestions: createFieldProposals(range, entityType)
            };
        }
    };
};
function createFieldProposals(range, entityType) {
    const proposals = [];
    Object.values(entityType.properties)
        .filter((property) => property.role === AggregationRole.dimension || property.role === AggregationRole.measure)
        .forEach((property) => {
        const text = property.role === AggregationRole.measure ? `[${C_MEASURES}].[${property.name}]` : property.name;
        proposals.push({
            label: text,
            kind: property.role === AggregationRole.dimension
                ? monaco.languages.CompletionItemKind.Method
                : property.role === AggregationRole.measure
                    ? monaco.languages.CompletionItemKind.Unit
                    : monaco.languages.CompletionItemKind.Field,
            detail: property.caption,
            insertText: text,
            range: range
        });
        property.hierarchies?.forEach((hierarchy) => {
            const dimension = proposals.find((item) => item.insertText === hierarchy.name);
            // 不存在相同名称的 Dimension 时再加入
            if (!dimension) {
                proposals.push({
                    label: hierarchy.name,
                    kind: monaco.languages.CompletionItemKind.Class,
                    detail: property.caption + ' ' + hierarchy.caption,
                    insertText: hierarchy.name,
                    range: range
                });
            }
        });
    });
    proposals.push({
        label: `[${C_MEASURES}]`,
        kind: monaco.languages.CompletionItemKind.Method,
        detail: ``,
        insertText: `[${C_MEASURES}]`,
        range: range
    });
    return proposals;
}
const createSuffixProvider = (entityType) => {
    return {
        triggerCharacters: ['.'],
        provideCompletionItems: (model, position) => {
            const textUntilPosition = model.getValueInRange({
                startLineNumber: position.lineNumber,
                startColumn: 1,
                endLineNumber: position.lineNumber,
                endColumn: position.column - 1
            });
            const MDX_NAME_REGEX = `\\[(${C_MDX_FIELD_NAME_REGEX})\\]`;
            const regExp = new RegExp(MDX_NAME_REGEX, 'g');
            let match;
            let word;
            do {
                match = regExp.exec(textUntilPosition);
                if (match?.length) {
                    word = match[0];
                }
            } while (match);
            if (word) {
                const range = {
                    startLineNumber: position.lineNumber,
                    endLineNumber: position.lineNumber,
                    startColumn: position.column,
                    endColumn: position.column
                };
                return {
                    suggestions: createSuffixProposals(range, word, entityType)
                };
            }
            return null;
        }
    };
};
function createSuffixProposals(range, parent, entityType) {
    const proposals = [];
    SUFFIX_FUNCTIONS.map((item) => proposals.push({
        ...item,
        kind: monaco.languages.CompletionItemKind.Function,
        insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
        detail: item.expression,
        range: range
    }));
    if (parent === `[${C_MEASURES}]`) {
        Object.values(entityType.properties)
            .filter((property) => property.role === AggregationRole.measure)
            .forEach((property) => proposals.push({
            label: property.name,
            kind: monaco.languages.CompletionItemKind.Unit,
            detail: property.caption,
            insertText: `[${property.name}]`,
            range: range
        }));
        return proposals;
    }
    let property = Object.values(entityType.properties).find((property) => property.name === parent);
    if (property) {
        if (property.role === AggregationRole.dimension) {
            property = property.hierarchies?.find((item) => item.name === parent);
        }
        property?.levels?.forEach((level) => {
            const text = level.name.replace(`${parent}.`, '');
            proposals.push({
                label: text,
                kind: monaco.languages.CompletionItemKind.Constant,
                detail: level.caption,
                insertText: text,
                range: range
            });
        });
    }
    return proposals;
}
const createHoverProvider = (entityType) => {
    return {
        provideHover: (model, position, token) => {
            const line = model.getLineContent(position.lineNumber);
            const MDX_MEASURE_NAME_REGEX = `\\[(${C_MDX_FIELD_NAME_REGEX})\\]`;
            const regExp = new RegExp(MDX_MEASURE_NAME_REGEX, 'g');
            let match;
            let word;
            do {
                match = regExp.exec(line);
                if (match?.length && match.index <= position.column && match.index + match[0].length >= position.column) {
                    word = match[0];
                    break;
                }
            } while (match);
            // dimension or hierarchy
            if (word) {
                return {
                    range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
                    contents: getFieldHoverDocument(word, entityType)
                };
            }
            else {
                // mdx function
                word = model.getWordAtPosition(position)?.word;
                if (word) {
                    return {
                        range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
                        contents: getFunctionHoverDocument(word)
                    };
                }
            }
            return {
                range: new monaco.Range(1, 1, model.getLineCount(), model.getLineMaxColumn(model.getLineCount())),
                contents: [
                    { value: 'Filter(**Set_Expression**, **Logical_Expression**)' },
                    {
                        value: 'Returns the set that results from filtering a specified set based on a search condition.\n\n`Filter(Set_Expression, Logical_Expression)`'
                    }
                ]
            };
        }
    };
};
function getFieldHoverDocument(name, entityType) {
    const property = getEntityDimensionAndHierarchies(entityType).find((property) => property.name === name);
    return property ? [{ value: `\`${property.name}\`` }, { value: property.caption }] : [];
}
function getFunctionHoverDocument(name) {
    const item = FUNCTIONS.find((item) => item.label.toLocaleLowerCase() === name.toLocaleLowerCase());
    return item ? [{ value: `\`${item.expression}\`
${item.documentation}` }] : [];
}
const createSignatureHelpProvider = () => {
    return {
        signatureHelpTriggerCharacters: ['('],
        signatureHelpRetriggerCharacters: ['('],
        /**
         * Provide help for the signature at the given position and document.
         */
        provideSignatureHelp: (model, position, token, context) => {
            var textUntilPosition = model.getValueInRange({
                startLineNumber: 1,
                startColumn: 1,
                endLineNumber: position.lineNumber,
                endColumn: position.column
            });
            var match = textUntilPosition.match('\\(');
            // if (match) {
            return {
                value: {
                    signatures: [
                        {
                            label: 'parameter1',
                            documentation: ' this method does blah',
                            parameters: [
                                {
                                    label: 'ParamInfo1',
                                    documentation: 'this param does blah'
                                }
                            ]
                        }
                    ],
                    activeSignature: 1,
                    activeParameter: 1
                },
                dispose() { }
            };
            // }
            // return null
        }
    };
};
/** @type {languages.SemanticTokensLegend} */
const legend = {
    tokenTypes: [
        'comment',
        'string',
        'keyword',
        'number',
        'regexp',
        'operator',
        'namespace',
        'type',
        'struct',
        'class',
        'interface',
        'enum',
        'typeParameter',
        'function',
        'member',
        'macro',
        'variable',
        'parameter',
        'property',
        'label'
    ],
    tokenModifiers: [
        'declaration',
        'documentation',
        'readonly',
        'static',
        'abstract',
        'deprecated',
        'modification',
        'async'
    ]
};
/** @type {(type: string)=>number} */
function getType(type) {
    return legend.tokenTypes.indexOf(type);
}
// /** @type {(modifier: string[]|string|null)=>number} */
// function getModifier(modifiers) {
//   if (typeof modifiers === 'string') {
//       modifiers = [modifiers];
//   }
//   if (Array.isArray(modifiers)) {
//       let nModifiers = 0;
//       for (let modifier of modifiers) {
//           nModifier = legend.tokenModifiers.indexOf(modifier);
//           if (nModifier > -1) {
//               nModifiers |= (1 << nModifier) >>> 0;
//           }
//       }
//       return nModifiers;
//   } else {
//       return 0;
//   }
// }
// const tokenPattern = new RegExp('(?<=\\[)([a-zA-Z]+)((?:\\.[a-zA-Z]+)*)(?=\\])', 'g');
// export const createDocumentSemanticTokensProvider = (entityType: EntityType) => {
//   return {
//     getLegend: () => {
//         return legend;
//     },
//     provideDocumentSemanticTokens: (model, lastResultId, token) => {
//       const lines = model.getLinesContent()
//       /** @type {number[]} */
//       const data = [];
//       let prevLine = 0;
//       let prevChar = 0;
//       for (let i = 0; i < lines.length; i++) {
//           const line = lines[i];
//           for (let match = null; match = tokenPattern.exec(line);) {
//               // translate token and modifiers to number representations
//               let type = getType(match[1]);
//               if (type === -1) {
//                   continue;
//               }
//               let modifier = match[2].length ? 0 : 0;
//               data.push(
//                   // translate line to deltaLine
//                   i - prevLine,
//                   // for the same line, translate start to deltaStart
//                   prevLine === i ? match.index - prevChar : match.index,
//                   match[0].length,
//                   type,
//                   modifier
//               )
//               prevLine = i;
//               prevChar = match.index;
//           }
//       }
//       console.warn(data)
//       return {
//           data: new Uint32Array(data),
//           resultId: null
//       }
//     },
//     releaseDocumentSemanticTokens: (resultId) => { }
//   }
// }
const createParameterProvider = (entityType) => {
    return {
        triggerCharacters: ['@', '[@'],
        provideCompletionItems: (model, position) => {
            const word = model.getWordUntilPosition(position);
            const triggerCharacter = model.getValueInRange({
                startLineNumber: position.lineNumber,
                endLineNumber: position.lineNumber,
                startColumn: word.startColumn - 2,
                endColumn: word.startColumn
            });
            const range = triggerCharacter === '[@'
                ? {
                    startLineNumber: position.lineNumber,
                    endLineNumber: position.lineNumber,
                    startColumn: word.startColumn - 2,
                    endColumn: word.endColumn + 1
                }
                : {
                    startLineNumber: position.lineNumber,
                    endLineNumber: position.lineNumber,
                    startColumn: word.startColumn - 1,
                    endColumn: word.endColumn
                };
            const parameters = Object.keys(entityType.properties)
                .map((key) => entityType.properties[key])
                .filter((property) => isMeasureControlProperty(property));
            parameters.push(...Object.values(entityType.parameters || {}));
            return {
                suggestions: parameters.map((property) => ({
                    label: `[@${property.name}]`,
                    kind: monaco.languages.CompletionItemKind.Variable,
                    detail: ``,
                    insertText: `[@${property.name}]`,
                    range: range
                }))
            };
        }
    };
};

const conf = {
    comments: {
        lineComment: '--',
        blockComment: ['/*', '*/']
    },
    brackets: [
        ['{', '}'],
        ['[', ']'],
        ['(', ')']
    ],
    autoClosingPairs: [
        { open: '{', close: '}' },
        { open: '[', close: ']' },
        { open: '(', close: ')' },
        { open: '"', close: '"' },
        { open: "'", close: "'" }
    ],
    surroundingPairs: [
        { open: '{', close: '}' },
        { open: '[', close: ']' },
        { open: '(', close: ')' },
        { open: '"', close: '"' },
        { open: "'", close: "'" }
    ]
};
const language = {
    defaultToken: '',
    tokenPostfix: '.mdx',
    ignoreCase: true,
    brackets: [
        { open: '[', close: ']', token: 'delimiter.square' },
        { open: '(', close: ')', token: 'delimiter.parenthesis' }
    ],
    keywords: [
        'AllMembers',
        'Measures',
        // '\[Measures\]',
        'Members',
        'Children',
        'CurrentMember',
        ...FUNCTIONS.map(({ label }) => label),
        'ABORT_AFTER_WAIT',
        'ABSENT',
        'ABSOLUTE',
        'ACCENT_SENSITIVITY',
        'ACTION',
        'ACTIVATION',
        'ACTIVE',
        'ADD',
        'ADDRESS',
        'ADMIN',
        'AES',
        'AES_128',
        'AES_192',
        'AES_256',
        'AFFINITY',
        'AFTER',
        'AGGREGATE',
        'ALGORITHM',
        'ALL_CONSTRAINTS',
        'ALL_ERRORMSGS',
        'ALL_INDEXES',
        'ALL_LEVELS',
        'ALL_SPARSE_COLUMNS',
        'ALLOW_CONNECTIONS',
        'ALLOW_MULTIPLE_EVENT_LOSS',
        'ALLOW_PAGE_LOCKS',
        'ALLOW_ROW_LOCKS',
        'ALLOW_SINGLE_EVENT_LOSS',
        'ALLOW_SNAPSHOT_ISOLATION',
        'ALLOWED',
        'ALTER',
        'ANONYMOUS',
        'ANSI_DEFAULTS',
        'ANSI_NULL_DEFAULT',
        'ANSI_NULL_DFLT_OFF',
        'ANSI_NULL_DFLT_ON',
        'ANSI_NULLS',
        'ANSI_PADDING',
        'ANSI_WARNINGS',
        'APPEND',
        'APPLICATION',
        'APPLICATION_LOG',
        'ARITHABORT',
        'ARITHIGNORE',
        'AS',
        'ASC',
        'ASSEMBLY',
        'ASYMMETRIC',
        'ASYNCHRONOUS_COMMIT',
        'AT',
        'ATOMIC',
        'ATTACH',
        'ATTACH_REBUILD_LOG',
        'AUDIT',
        'AUDIT_GUID',
        'AUTHENTICATION',
        'AUTHORIZATION',
        'AUTO',
        'AUTO_CLEANUP',
        'AUTO_CLOSE',
        'AUTO_CREATE_STATISTICS',
        'AUTO_SHRINK',
        'AUTO_UPDATE_STATISTICS',
        'AUTO_UPDATE_STATISTICS_ASYNC',
        'AUTOMATED_BACKUP_PREFERENCE',
        'AUTOMATIC',
        'AVAILABILITY',
        'AVAILABILITY_MODE',
        'BACKUP',
        'BACKUP_PRIORITY',
        'BASE64',
        'BATCHSIZE',
        'BEGIN',
        'BEGIN_DIALOG',
        'BIGINT',
        'BINARY',
        'BINDING',
        'BIT',
        'BLOCKERS',
        'BLOCKSIZE',
        'BOUNDING_BOX',
        'BREAK',
        'BROKER',
        'BROKER_INSTANCE',
        'BROWSE',
        'BUCKET_COUNT',
        'BUFFER',
        'BUFFERCOUNT',
        'BULK',
        'BULK_LOGGED',
        'BY',
        'CACHE',
        'CALL',
        'CALLED',
        'CALLER',
        'CAP_CPU_PERCENT',
        'CASCADE',
        'CASE',
        'CATALOG',
        'CATCH',
        'CELLS_PER_OBJECT',
        'CERTIFICATE',
        'CHANGE_RETENTION',
        'CHANGE_TRACKING',
        'CHANGES',
        'CHAR',
        'CHARACTER',
        'CHECK',
        'CHECK_CONSTRAINTS',
        'CHECK_EXPIRATION',
        'CHECK_POLICY',
        'CHECKALLOC',
        'CHECKCATALOG',
        'CHECKCONSTRAINTS',
        'CHECKDB',
        'CHECKFILEGROUP',
        'CHECKIDENT',
        'CHECKPOINT',
        'CHECKTABLE',
        'CLASSIFIER_FUNCTION',
        'CLEANTABLE',
        'CLEANUP',
        'CLEAR',
        'CLOSE',
        'CLUSTER',
        'CLUSTERED',
        'CODEPAGE',
        'COLLATE',
        'COLLECTION',
        'COLUMN',
        'COLUMN_SET',
        'COLUMNS',
        'COLUMNSTORE',
        'COLUMNSTORE_ARCHIVE',
        'COMMIT',
        'COMMITTED',
        'COMPATIBILITY_LEVEL',
        'COMPRESSION',
        'COMPUTE',
        'CONCAT',
        'CONCAT_NULL_YIELDS_NULL',
        'CONFIGURATION',
        'CONNECT',
        'CONSTRAINT',
        'CONTAINMENT',
        'CONTENT',
        'CONTEXT',
        'CONTINUE',
        'CONTINUE_AFTER_ERROR',
        'CONTRACT',
        'CONTRACT_NAME',
        'CONTROL',
        'CONVERSATION',
        'COOKIE',
        'COPY_ONLY',
        'COUNTER',
        'CPU',
        'CREATE',
        'CREATE_NEW',
        'CREATION_DISPOSITION',
        'CREDENTIAL',
        'CRYPTOGRAPHIC',
        'CUBE',
        'CURRENT',
        'CURRENT_DATE',
        'CURSOR',
        'CURSOR_CLOSE_ON_COMMIT',
        'CURSOR_DEFAULT',
        'CYCLE',
        'DATA',
        'DATA_COMPRESSION',
        'DATA_PURITY',
        'DATABASE',
        'DATABASE_DEFAULT',
        'DATABASE_MIRRORING',
        'DATABASE_SNAPSHOT',
        'DATAFILETYPE',
        'DATE',
        'DATE_CORRELATION_OPTIMIZATION',
        'DATEFIRST',
        'DATEFORMAT',
        'DATETIME',
        'DATETIME2',
        'DATETIMEOFFSET',
        'DAY',
        'DAYOFYEAR',
        'DAYS',
        'DB_CHAINING',
        'DBCC',
        'DBREINDEX',
        'DDL_DATABASE_LEVEL_EVENTS',
        'DEADLOCK_PRIORITY',
        'DEALLOCATE',
        'DEC',
        'DECIMAL',
        'DECLARE',
        'DECRYPTION',
        'DEFAULT',
        'DEFAULT_DATABASE',
        'DEFAULT_FULLTEXT_LANGUAGE',
        'DEFAULT_LANGUAGE',
        'DEFAULT_SCHEMA',
        'DEFINITION',
        'DELAY',
        'DELAYED_DURABILITY',
        'DELETE',
        'DELETED',
        'DENSITY_VECTOR',
        'DENY',
        'DEPENDENTS',
        'DES',
        'DESC',
        'DESCRIPTION',
        'DESX',
        'DHCP',
        'DIAGNOSTICS',
        'DIALOG',
        'DIFFERENTIAL',
        'DIRECTORY_NAME',
        'DISABLE',
        'DISABLE_BROKER',
        'DISABLED',
        'DISK',
        'DISTINCT',
        'DISTRIBUTED',
        'DOCUMENT',
        'DOUBLE',
        'DROP',
        'DROP_EXISTING',
        'DROPCLEANBUFFERS',
        'DUMP',
        'DURABILITY',
        'DYNAMIC',
        'EDITION',
        'ELEMENTS',
        'ELSE',
        'EMERGENCY',
        'EMPTY',
        'EMPTYFILE',
        'ENABLE',
        'ENABLE_BROKER',
        'ENABLED',
        'ENCRYPTION',
        'END',
        'ENDPOINT',
        'ENDPOINT_URL',
        'ERRLVL',
        'ERROR',
        'ERROR_BROKER_CONVERSATIONS',
        'ERRORFILE',
        'ESCAPE',
        'ESTIMATEONLY',
        'EVENT',
        'EVENT_RETENTION_MODE',
        'EXEC',
        'EXECUTABLE',
        'EXECUTE',
        'EXIT',
        'EXPAND',
        'EXPIREDATE',
        'EXPIRY_DATE',
        'EXPLICIT',
        'EXTENDED_LOGICAL_CHECKS',
        'EXTENSION',
        'EXTERNAL',
        'EXTERNAL_ACCESS',
        'FAIL_OPERATION',
        'FAILOVER',
        'FAILOVER_MODE',
        'FAILURE_CONDITION_LEVEL',
        'FALSE',
        'FAN_IN',
        'FAST',
        'FAST_FORWARD',
        'FETCH',
        'FIELDTERMINATOR',
        'FILE',
        'FILEGROUP',
        'FILEGROWTH',
        'FILELISTONLY',
        'FILENAME',
        'FILEPATH',
        'FILESTREAM',
        'FILESTREAM_ON',
        'FILETABLE_COLLATE_FILENAME',
        'FILETABLE_DIRECTORY',
        'FILETABLE_FULLPATH_UNIQUE_CONSTRAINT_NAME',
        'FILETABLE_NAMESPACE',
        'FILETABLE_PRIMARY_KEY_CONSTRAINT_NAME',
        'FILETABLE_STREAMID_UNIQUE_CONSTRAINT_NAME',
        'FILLFACTOR',
        'FILTERING',
        'FIRE_TRIGGERS',
        'FIRST',
        'FIRSTROW',
        'FLOAT',
        'FMTONLY',
        'FOLLOWING',
        'FOR',
        'FORCE',
        'FORCE_FAILOVER_ALLOW_DATA_LOSS',
        'FORCE_SERVICE_ALLOW_DATA_LOSS',
        'FORCED',
        'FORCEPLAN',
        'FORCESCAN',
        'FORCESEEK',
        'FOREIGN',
        'FORMATFILE',
        'FORMSOF',
        'FORWARD_ONLY',
        'FREE',
        'FREEPROCCACHE',
        'FREESESSIONCACHE',
        'FREESYSTEMCACHE',
        'FROM',
        'FULL',
        'FULLSCAN',
        'FULLTEXT',
        'FUNCTION',
        'GB',
        'GEOGRAPHY_AUTO_GRID',
        'GEOGRAPHY_GRID',
        'GEOMETRY_AUTO_GRID',
        'GEOMETRY_GRID',
        'GET',
        'GLOBAL',
        'GO',
        'GOTO',
        'GOVERNOR',
        'GRANT',
        'GRIDS',
        'GROUP',
        'GROUP_MAX_REQUESTS',
        'HADR',
        'HASH',
        'HASHED',
        'HAVING',
        'HEADERONLY',
        'HEALTH_CHECK_TIMEOUT',
        'HELP',
        'HIERARCHYID',
        'HIGH',
        'HINT',
        'HISTOGRAM',
        'HOLDLOCK',
        'HONOR_BROKER_PRIORITY',
        'HOUR',
        'HOURS',
        'IDENTITY',
        'IDENTITY_INSERT',
        'IDENTITY_VALUE',
        'IDENTITYCOL',
        'IF',
        'IGNORE_CONSTRAINTS',
        'IGNORE_DUP_KEY',
        'IGNORE_NONCLUSTERED_COLUMNSTORE_INDEX',
        'IGNORE_TRIGGERS',
        'IMAGE',
        'IMMEDIATE',
        'IMPERSONATE',
        'IMPLICIT_TRANSACTIONS',
        'IMPORTANCE',
        'INCLUDE',
        'INCREMENT',
        'INCREMENTAL',
        'INDEX',
        'INDEXDEFRAG',
        'INFINITE',
        'INFLECTIONAL',
        'INIT',
        'INITIATOR',
        'INPUT',
        'INPUTBUFFER',
        'INSENSITIVE',
        'INSERT',
        'INSERTED',
        'INSTEAD',
        'INT',
        'INTEGER',
        'INTO',
        'IO',
        'IP',
        'ISABOUT',
        'ISOLATION',
        'JOB',
        'KB',
        'KEEP',
        'KEEP_CDC',
        'KEEP_NULLS',
        'KEEP_REPLICATION',
        'KEEPDEFAULTS',
        'KEEPFIXED',
        'KEEPIDENTITY',
        'KEEPNULLS',
        'KERBEROS',
        'KEY',
        'KEY_SOURCE',
        'KEYS',
        'KEYSET',
        'KILL',
        'KILOBYTES_PER_BATCH',
        'LABELONLY',
        'LANGUAGE',
        'LAST',
        'LASTROW',
        'LEVEL',
        'LEVEL_1',
        'LEVEL_2',
        'LEVEL_3',
        'LEVEL_4',
        'LIFETIME',
        'LIMIT',
        'LINENO',
        'LIST',
        'LISTENER',
        'LISTENER_IP',
        'LISTENER_PORT',
        'LOAD',
        'LOADHISTORY',
        'LOB_COMPACTION',
        'LOCAL',
        'LOCAL_SERVICE_NAME',
        'LOCK_ESCALATION',
        'LOCK_TIMEOUT',
        'LOGIN',
        'LOGSPACE',
        'LOOP',
        'LOW',
        'MANUAL',
        'MARK',
        'MARK_IN_USE_FOR_REMOVAL',
        'MASTER',
        'MAX_CPU_PERCENT',
        'MAX_DISPATCH_LATENCY',
        'MAX_DOP',
        'MAX_DURATION',
        'MAX_EVENT_SIZE',
        'MAX_FILES',
        'MAX_IOPS_PER_VOLUME',
        'MAX_MEMORY',
        'MAX_MEMORY_PERCENT',
        'MAX_QUEUE_READERS',
        'MAX_ROLLOVER_FILES',
        'MAX_SIZE',
        'MAXDOP',
        'MAXERRORS',
        'MAXLENGTH',
        'MAXRECURSION',
        'MAXSIZE',
        'MAXTRANSFERSIZE',
        'MAXVALUE',
        'MB',
        'MEDIADESCRIPTION',
        'MEDIANAME',
        'MEDIAPASSWORD',
        'MEDIUM',
        'MEMBER',
        'MEMORY_OPTIMIZED',
        'MEMORY_OPTIMIZED_DATA',
        'MEMORY_OPTIMIZED_ELEVATE_TO_SNAPSHOT',
        'MEMORY_PARTITION_MODE',
        'MERGE',
        'MESSAGE',
        'MESSAGE_FORWARD_SIZE',
        'MESSAGE_FORWARDING',
        'MICROSECOND',
        'MILLISECOND',
        'MIN_CPU_PERCENT',
        'MIN_IOPS_PER_VOLUME',
        'MIN_MEMORY_PERCENT',
        'MINUTE',
        'MINUTES',
        'MINVALUE',
        'MIRROR',
        'MIRROR_ADDRESS',
        'MODIFY',
        'MONEY',
        'MONTH',
        'MOVE',
        'MULTI_USER',
        'MUST_CHANGE',
        'NAME',
        'NANOSECOND',
        'NATIONAL',
        'NATIVE_COMPILATION',
        'NCHAR',
        'NEGOTIATE',
        'NESTED_TRIGGERS',
        'NEW_ACCOUNT',
        'NEW_BROKER',
        'NEW_PASSWORD',
        'NEWNAME',
        'NEXT',
        'NO',
        'NO_BROWSETABLE',
        'NO_CHECKSUM',
        'NO_COMPRESSION',
        'NO_EVENT_LOSS',
        'NO_INFOMSGS',
        'NO_TRUNCATE',
        'NO_WAIT',
        'NOCHECK',
        'NOCOUNT',
        'NOEXEC',
        'NOEXPAND',
        'NOFORMAT',
        'NOINDEX',
        'NOINIT',
        'NOLOCK',
        'NON',
        'NON_TRANSACTED_ACCESS',
        'NONCLUSTERED',
        'NONE',
        'NORECOMPUTE',
        'NORECOVERY',
        'NORESEED',
        'NORESET',
        'NOREWIND',
        'NORMAL',
        'NOSKIP',
        'NOTIFICATION',
        'NOTRUNCATE',
        'NOUNLOAD',
        'NOWAIT',
        'NTEXT',
        'NTLM',
        'NUMANODE',
        'NUMERIC',
        'NUMERIC_ROUNDABORT',
        'NVARCHAR',
        'OBJECT',
        'OF',
        'OFF',
        'OFFLINE',
        'OFFSET',
        'OFFSETS',
        'OLD_ACCOUNT',
        'OLD_PASSWORD',
        'ON',
        'ON_FAILURE',
        'ONLINE',
        'ONLY',
        'OPEN',
        'OPEN_EXISTING',
        'OPENTRAN',
        'OPTIMISTIC',
        'OPTIMIZE',
        'OPTION',
        'ORDER',
        'OUT',
        'OUTPUT',
        'OUTPUTBUFFER',
        'OVER',
        'OVERRIDE',
        'OWNER',
        'OWNERSHIP',
        'PAD_INDEX',
        'PAGE',
        'PAGE_VERIFY',
        'PAGECOUNT',
        'PAGLOCK',
        'PARAMETERIZATION',
        'PARSEONLY',
        'PARTIAL',
        'PARTITION',
        'PARTITIONS',
        'PARTNER',
        'PASSWORD',
        'PATH',
        'PER_CPU',
        'PER_NODE',
        'PERCENT',
        'PERMISSION_SET',
        'PERSISTED',
        'PHYSICAL_ONLY',
        'PLAN',
        'POISON_MESSAGE_HANDLING',
        'POOL',
        'POPULATION',
        'PORT',
        'PRECEDING',
        'PRECISION',
        'PRIMARY',
        'PRIMARY_ROLE',
        'PRINT',
        'PRIOR',
        'PRIORITY',
        'PRIORITY_LEVEL',
        'PRIVATE',
        'PRIVILEGES',
        'PROC',
        'PROCCACHE',
        'PROCEDURE',
        'PROCEDURE_NAME',
        'PROCESS',
        'PROFILE',
        'PROPERTY',
        'PROPERTY_DESCRIPTION',
        'PROPERTY_INT_ID',
        'PROPERTY_SET_GUID',
        'PROVIDER',
        'PROVIDER_KEY_NAME',
        'PUBLIC',
        'PUT',
        'QUARTER',
        'QUERY',
        'QUERY_GOVERNOR_COST_LIMIT',
        'QUEUE',
        'QUEUE_DELAY',
        'QUOTED_IDENTIFIER',
        'RAISERROR',
        'RANGE',
        'RAW',
        'RC2',
        'RC4',
        'RC4_128',
        'READ',
        'READ_COMMITTED_SNAPSHOT',
        'READ_ONLY',
        'READ_ONLY_ROUTING_LIST',
        'READ_ONLY_ROUTING_URL',
        'READ_WRITE',
        'READ_WRITE_FILEGROUPS',
        'READCOMMITTED',
        'READCOMMITTEDLOCK',
        'READONLY',
        'READPAST',
        'READTEXT',
        'READUNCOMMITTED',
        'READWRITE',
        'REAL',
        'REBUILD',
        'RECEIVE',
        'RECOMPILE',
        'RECONFIGURE',
        'RECOVERY',
        'RECURSIVE',
        'RECURSIVE_TRIGGERS',
        'REFERENCES',
        'REGENERATE',
        'RELATED_CONVERSATION',
        'RELATED_CONVERSATION_GROUP',
        'RELATIVE',
        'REMOTE',
        'REMOTE_PROC_TRANSACTIONS',
        'REMOTE_SERVICE_NAME',
        'REMOVE',
        'REORGANIZE',
        'REPAIR_ALLOW_DATA_LOSS',
        'REPAIR_FAST',
        'REPAIR_REBUILD',
        'REPEATABLE',
        'REPEATABLEREAD',
        'REPLICA',
        'REPLICATION',
        'REQUEST_MAX_CPU_TIME_SEC',
        'REQUEST_MAX_MEMORY_GRANT_PERCENT',
        'REQUEST_MEMORY_GRANT_TIMEOUT_SEC',
        'REQUIRED',
        'RESAMPLE',
        'RESEED',
        'RESERVE_DISK_SPACE',
        'RESET',
        'RESOURCE',
        'RESTART',
        'RESTORE',
        'RESTRICT',
        'RESTRICTED_USER',
        'RESULT',
        'RESUME',
        'RETAINDAYS',
        'RETENTION',
        'RETURN',
        'RETURNS',
        'REVERT',
        'REVOKE',
        'REWIND',
        'REWINDONLY',
        'ROBUST',
        'ROLE',
        'ROLLBACK',
        'ROLLUP',
        'ROOT',
        'ROUTE',
        'ROW',
        'ROWCOUNT',
        'ROWGUIDCOL',
        'ROWLOCK',
        'ROWS',
        'ROWS_PER_BATCH',
        'ROWTERMINATOR',
        'ROWVERSION',
        'RSA_1024',
        'RSA_2048',
        'RSA_512',
        'RULE',
        'SAFE',
        'SAFETY',
        'SAMPLE',
        'SAVE',
        'SCHEDULER',
        'SCHEMA',
        'SCHEMA_AND_DATA',
        'SCHEMA_ONLY',
        'SCHEMABINDING',
        'SCHEME',
        'SCROLL',
        'SCROLL_LOCKS',
        'SEARCH',
        'SECOND',
        'SECONDARY',
        'SECONDARY_ONLY',
        'SECONDARY_ROLE',
        'SECONDS',
        'SECRET',
        'SECURITY_LOG',
        'SECURITYAUDIT',
        'SELECT',
        'SELECTIVE',
        'SELF',
        'SEND',
        'SENT',
        'SEQUENCE',
        'SERIALIZABLE',
        'SERVER',
        'SERVICE',
        'SERVICE_BROKER',
        'SERVICE_NAME',
        'SESSION',
        'SESSION_TIMEOUT',
        'SET',
        'SETS',
        'SETUSER',
        'SHOW_STATISTICS',
        'SHOWCONTIG',
        'SHOWPLAN',
        'SHOWPLAN_ALL',
        'SHOWPLAN_TEXT',
        'SHOWPLAN_XML',
        'SHRINKDATABASE',
        'SHRINKFILE',
        'SHUTDOWN',
        'SID',
        'SIGNATURE',
        'SIMPLE',
        'SINGLE_BLOB',
        'SINGLE_CLOB',
        'SINGLE_NCLOB',
        'SINGLE_USER',
        'SINGLETON',
        'SIZE',
        'SKIP',
        'SMALLDATETIME',
        'SMALLINT',
        'SMALLMONEY',
        'SNAPSHOT',
        'SORT_IN_TEMPDB',
        'SOURCE',
        'SPARSE',
        'SPATIAL',
        'SPATIAL_WINDOW_MAX_CELLS',
        'SPECIFICATION',
        'SPLIT',
        'SQL',
        'SQL_VARIANT',
        'SQLPERF',
        'STANDBY',
        'START',
        'START_DATE',
        'STARTED',
        'STARTUP_STATE',
        'STAT_HEADER',
        'STATE',
        'STATEMENT',
        'STATIC',
        'STATISTICAL_SEMANTICS',
        'STATISTICS',
        'STATISTICS_INCREMENTAL',
        'STATISTICS_NORECOMPUTE',
        'STATS',
        'STATS_STREAM',
        'STATUS',
        'STATUSONLY',
        'STOP',
        'STOP_ON_ERROR',
        'STOPAT',
        'STOPATMARK',
        'STOPBEFOREMARK',
        'STOPLIST',
        'STOPPED',
        'SUBJECT',
        'SUBSCRIPTION',
        'SUPPORTED',
        'SUSPEND',
        'SWITCH',
        'SYMMETRIC',
        'SYNCHRONOUS_COMMIT',
        'SYNONYM',
        'SYSNAME',
        'SYSTEM',
        'TABLE',
        'TABLERESULTS',
        'TABLESAMPLE',
        'TABLOCK',
        'TABLOCKX',
        'TAKE',
        'TAPE',
        'TARGET',
        'TARGET_RECOVERY_TIME',
        'TB',
        'TCP',
        'TEXT',
        'TEXTIMAGE_ON',
        'TEXTSIZE',
        'THEN',
        'THESAURUS',
        'THROW',
        'TIES',
        'TIME',
        'TIMEOUT',
        'TIMER',
        'TIMESTAMP',
        'TINYINT',
        'TO',
        'TOP',
        'TORN_PAGE_DETECTION',
        'TRACEOFF',
        'TRACEON',
        'TRACESTATUS',
        'TRACK_CAUSALITY',
        'TRACK_COLUMNS_UPDATED',
        'TRAN',
        'TRANSACTION',
        'TRANSFER',
        'TRANSFORM_NOISE_WORDS',
        'TRIGGER',
        'TRIPLE_DES',
        'TRIPLE_DES_3KEY',
        'TRUE',
        'TRUNCATE',
        'TRUNCATEONLY',
        'TRUSTWORTHY',
        'TRY',
        'TSQL',
        'TWO_DIGIT_YEAR_CUTOFF',
        'TYPE',
        'TYPE_WARNING',
        'UNBOUNDED',
        'UNCHECKED',
        'UNCOMMITTED',
        'UNDEFINED',
        'UNIQUE',
        'UNIQUEIDENTIFIER',
        'UNKNOWN',
        'UNLIMITED',
        'UNLOAD',
        'UNSAFE',
        'UPDATE',
        'UPDATETEXT',
        'UPDATEUSAGE',
        'UPDLOCK',
        'URL',
        'USE',
        'USED',
        'USER',
        'USEROPTIONS',
        'USING',
        'VALID_XML',
        'VALIDATION',
        'VALUE',
        'VALUES',
        'VARBINARY',
        'VARCHAR',
        'VARYING',
        'VERIFYONLY',
        'VERSION',
        'VIEW',
        'VIEW_METADATA',
        'VIEWS',
        'VISIBILITY',
        'WAIT_AT_LOW_PRIORITY',
        'WAITFOR',
        'WEEK',
        'WEIGHT',
        'WELL_FORMED_XML',
        'WHEN',
        'WHERE',
        'WHILE',
        'WINDOWS',
        'WITH',
        'WITHIN',
        'WITHOUT',
        'WITNESS',
        'WORK',
        'WORKLOAD',
        'WRITETEXT',
        'XACT_ABORT',
        'XLOCK',
        'XMAX',
        'XMIN',
        'XML',
        'XMLDATA',
        'XMLNAMESPACES',
        'XMLSCHEMA',
        'XQUERY',
        'XSINIL',
        'YEAR',
        'YMAX',
        'YMIN'
    ],
    operators: [
        // Logical
        'ALL',
        'AND',
        'ANY',
        'BETWEEN',
        'EXISTS',
        'IN',
        'LIKE',
        'NOT',
        'OR',
        'SOME',
        // Set
        'EXCEPT',
        'INTERSECT',
        'UNION',
        // Join
        'APPLY',
        'CROSS',
        'FULL',
        'INNER',
        'JOIN',
        'LEFT',
        'OUTER',
        'RIGHT',
        // Predicates
        'CONTAINS',
        'FREETEXT',
        'IS',
        'NULL',
        // Pivoting
        'PIVOT',
        'UNPIVOT',
        // Merging
        'MATCHED'
    ],
    builtinFunctions: [
        // mdx functions
        'AVG',
        'CoalesceEmpty',
        'Filter',
        'Aggregate',
        'LastPeriods',
        'ParallelPeriod',
        ...FUNCTIONS.map(({ label }) => label),
        'CHECKSUM_AGG',
        'COUNT',
        'COUNT_BIG',
        'GROUPING',
        'GROUPING_ID',
        'MAX',
        'MIN',
        'SUM',
        'STDEV',
        'STDEVP',
        'VAR',
        'VARP',
        // Analytic
        'CUME_DIST',
        'FIRST_VALUE',
        'LAG',
        'LAST_VALUE',
        'LEAD',
        'PERCENTILE_CONT',
        'PERCENTILE_DISC',
        'PERCENT_RANK',
        // Collation
        'COLLATE',
        'COLLATIONPROPERTY',
        'TERTIARY_WEIGHTS',
        // Azure
        'FEDERATION_FILTERING_VALUE',
        // Conversion
        'CAST',
        'CONVERT',
        'PARSE',
        'TRY_CAST',
        'TRY_CONVERT',
        'TRY_PARSE',
        // Cryptographic
        'ASYMKEY_ID',
        'ASYMKEYPROPERTY',
        'CERTPROPERTY',
        'CERT_ID',
        'CRYPT_GEN_RANDOM',
        'DECRYPTBYASYMKEY',
        'DECRYPTBYCERT',
        'DECRYPTBYKEY',
        'DECRYPTBYKEYAUTOASYMKEY',
        'DECRYPTBYKEYAUTOCERT',
        'DECRYPTBYPASSPHRASE',
        'ENCRYPTBYASYMKEY',
        'ENCRYPTBYCERT',
        'ENCRYPTBYKEY',
        'ENCRYPTBYPASSPHRASE',
        'HASHBYTES',
        'IS_OBJECTSIGNED',
        'KEY_GUID',
        'KEY_ID',
        'KEY_NAME',
        'SIGNBYASYMKEY',
        'SIGNBYCERT',
        'SYMKEYPROPERTY',
        'VERIFYSIGNEDBYCERT',
        'VERIFYSIGNEDBYASYMKEY',
        // Cursor
        'CURSOR_STATUS',
        // Datatype
        'DATALENGTH',
        'IDENT_CURRENT',
        'IDENT_INCR',
        'IDENT_SEED',
        'IDENTITY',
        'SQL_VARIANT_PROPERTY',
        // Datetime
        'CURRENT_TIMESTAMP',
        'DATEADD',
        'DATEDIFF',
        'DATEFROMPARTS',
        'DATENAME',
        'DATEPART',
        'DATETIME2FROMPARTS',
        'DATETIMEFROMPARTS',
        'DATETIMEOFFSETFROMPARTS',
        'DAY',
        'EOMONTH',
        'GETDATE',
        'GETUTCDATE',
        'ISDATE',
        'MONTH',
        'SMALLDATETIMEFROMPARTS',
        'SWITCHOFFSET',
        'SYSDATETIME',
        'SYSDATETIMEOFFSET',
        'SYSUTCDATETIME',
        'TIMEFROMPARTS',
        'TODATETIMEOFFSET',
        'YEAR',
        // Logical
        'CHOOSE',
        'COALESCE',
        'IIF',
        'NULLIF',
        // Mathematical
        'ABS',
        'ACOS',
        'ASIN',
        'ATAN',
        'ATN2',
        'CEILING',
        'COS',
        'COT',
        'DEGREES',
        'EXP',
        'FLOOR',
        'LOG',
        'LOG10',
        'PI',
        'POWER',
        'RADIANS',
        'RAND',
        'ROUND',
        'SIGN',
        'SIN',
        'SQRT',
        'SQUARE',
        'TAN',
        // Metadata
        'APP_NAME',
        'APPLOCK_MODE',
        'APPLOCK_TEST',
        'ASSEMBLYPROPERTY',
        'COL_LENGTH',
        'COL_NAME',
        'COLUMNPROPERTY',
        'DATABASE_PRINCIPAL_ID',
        'DATABASEPROPERTYEX',
        'DB_ID',
        'DB_NAME',
        'FILE_ID',
        'FILE_IDEX',
        'FILE_NAME',
        'FILEGROUP_ID',
        'FILEGROUP_NAME',
        'FILEGROUPPROPERTY',
        'FILEPROPERTY',
        'FULLTEXTCATALOGPROPERTY',
        'FULLTEXTSERVICEPROPERTY',
        'INDEX_COL',
        'INDEXKEY_PROPERTY',
        'INDEXPROPERTY',
        'OBJECT_DEFINITION',
        'OBJECT_ID',
        'OBJECT_NAME',
        'OBJECT_SCHEMA_NAME',
        'OBJECTPROPERTY',
        'OBJECTPROPERTYEX',
        'ORIGINAL_DB_NAME',
        'PARSENAME',
        'SCHEMA_ID',
        'SCHEMA_NAME',
        'SCOPE_IDENTITY',
        'SERVERPROPERTY',
        'STATS_DATE',
        'TYPE_ID',
        'TYPE_NAME',
        'TYPEPROPERTY',
        // Ranking
        'DENSE_RANK',
        'NTILE',
        'RANK',
        'ROW_NUMBER',
        // Replication
        'PUBLISHINGSERVERNAME',
        // Rowset
        'OPENDATASOURCE',
        'OPENQUERY',
        'OPENROWSET',
        'OPENXML',
        // Security
        'CERTENCODED',
        'CERTPRIVATEKEY',
        'CURRENT_USER',
        'HAS_DBACCESS',
        'HAS_PERMS_BY_NAME',
        'IS_MEMBER',
        'IS_ROLEMEMBER',
        'IS_SRVROLEMEMBER',
        'LOGINPROPERTY',
        'ORIGINAL_LOGIN',
        'PERMISSIONS',
        'PWDENCRYPT',
        'PWDCOMPARE',
        'SESSION_USER',
        'SESSIONPROPERTY',
        'SUSER_ID',
        'SUSER_NAME',
        'SUSER_SID',
        'SUSER_SNAME',
        'SYSTEM_USER',
        'USER',
        'USER_ID',
        'USER_NAME',
        // String
        'ASCII',
        'CHAR',
        'CHARINDEX',
        'CONCAT',
        'DIFFERENCE',
        'FORMAT',
        'LEFT',
        'LEN',
        'LOWER',
        'LTRIM',
        'NCHAR',
        'PATINDEX',
        'QUOTENAME',
        'REPLACE',
        'REPLICATE',
        'REVERSE',
        'RIGHT',
        'RTRIM',
        'SOUNDEX',
        'SPACE',
        'STR',
        'STUFF',
        'SUBSTRING',
        'UNICODE',
        'UPPER',
        // System
        'BINARY_CHECKSUM',
        'CHECKSUM',
        'CONNECTIONPROPERTY',
        'CONTEXT_INFO',
        'CURRENT_REQUEST_ID',
        'ERROR_LINE',
        'ERROR_NUMBER',
        'ERROR_MESSAGE',
        'ERROR_PROCEDURE',
        'ERROR_SEVERITY',
        'ERROR_STATE',
        'FORMATMESSAGE',
        'GETANSINULL',
        'GET_FILESTREAM_TRANSACTION_CONTEXT',
        'HOST_ID',
        'HOST_NAME',
        'ISNULL',
        'ISNUMERIC',
        'MIN_ACTIVE_ROWVERSION',
        'NEWID',
        'NEWSEQUENTIALID',
        'ROWCOUNT_BIG',
        'XACT_STATE',
        // TextImage
        'TEXTPTR',
        'TEXTVALID',
        // Trigger
        'COLUMNS_UPDATED',
        'EVENTDATA',
        'TRIGGER_NESTLEVEL',
        'UPDATE',
        // ChangeTracking
        'CHANGETABLE',
        'CHANGE_TRACKING_CONTEXT',
        'CHANGE_TRACKING_CURRENT_VERSION',
        'CHANGE_TRACKING_IS_COLUMN_IN_MASK',
        'CHANGE_TRACKING_MIN_VALID_VERSION',
        // FullTextSearch
        'CONTAINSTABLE',
        'FREETEXTTABLE',
        // SemanticTextSearch
        'SEMANTICKEYPHRASETABLE',
        'SEMANTICSIMILARITYDETAILSTABLE',
        'SEMANTICSIMILARITYTABLE',
        // FileStream
        'FILETABLEROOTPATH',
        'GETFILENAMESPACEPATH',
        'GETPATHLOCATOR',
        'PATHNAME',
        // ServiceBroker
        'GET_TRANSMISSION_STATUS'
    ],
    builtinVariables: [
        // Configuration
        '@@DATEFIRST',
        '@@DBTS',
        '@@LANGID',
        '@@LANGUAGE',
        '@@LOCK_TIMEOUT',
        '@@MAX_CONNECTIONS',
        '@@MAX_PRECISION',
        '@@NESTLEVEL',
        '@@OPTIONS',
        '@@REMSERVER',
        '@@SERVERNAME',
        '@@SERVICENAME',
        '@@SPID',
        '@@TEXTSIZE',
        '@@VERSION',
        // Cursor
        '@@CURSOR_ROWS',
        '@@FETCH_STATUS',
        // Datetime
        '@@DATEFIRST',
        // Metadata
        '@@PROCID',
        // System
        '@@ERROR',
        '@@IDENTITY',
        '@@ROWCOUNT',
        '@@TRANCOUNT',
        // Stats
        '@@CONNECTIONS',
        '@@CPU_BUSY',
        '@@IDLE',
        '@@IO_BUSY',
        '@@PACKET_ERRORS',
        '@@PACK_RECEIVED',
        '@@PACK_SENT',
        '@@TIMETICKS',
        '@@TOTAL_ERRORS',
        '@@TOTAL_READ',
        '@@TOTAL_WRITE'
    ],
    pseudoColumns: ['$ACTION', '$IDENTITY', '$ROWGUID', '$PARTITION'],
    tokenizer: {
        root: [
            { include: '@comments' },
            { include: '@whitespace' },
            { include: '@pseudoColumns' },
            { include: '@numbers' },
            { include: '@strings' },
            { include: '@complexIdentifiers' },
            { include: '@scopes' },
            [/[;,.]/, 'delimiter'],
            [/[()]/, '@brackets'],
            [
                /[\w@#$]+/,
                {
                    cases: {
                        '@keywords': 'keyword',
                        '@operators': 'operator',
                        '@builtinVariables': 'keyword',
                        '@builtinFunctions': 'keyword',
                        '@default': 'identifier'
                    }
                }
            ],
            [/[<>=!%&+\-*/|~^]/, 'operator']
        ],
        whitespace: [[/\s+/, 'white']],
        comments: [
            [/--+.*/, 'comment'],
            [/\/\*/, { token: 'comment.quote', next: '@comment' }]
        ],
        comment: [
            [/[^*/]+/, 'comment'],
            // Not supporting nested comments, as nested comments seem to not be standard?
            // i.e. http://stackoverflow.com/questions/728172/are-there-multiline-comment-delimiters-in-sql-that-are-vendor-agnostic
            // [/\/\*/, { token: 'comment.quote', next: '@push' }],    // nested comment not allowed :-(
            [/\*\//, { token: 'comment.quote', next: '@pop' }],
            [/./, 'comment']
        ],
        pseudoColumns: [
            [
                /[$][A-Za-z_][\w@#$]*/,
                {
                    cases: {
                        '@pseudoColumns': 'predefined',
                        '@default': 'identifier'
                    }
                }
            ]
        ],
        numbers: [
            [/0[xX][0-9a-fA-F]*/, 'number'],
            [/[$][+-]*\d*(\.\d*)?/, 'number'],
            [/((\d+(\.\d*)?)|(\.\d+))([eE][\-+]?\d+)?/, 'number']
        ],
        strings: [
            [/N'/, { token: 'string', next: '@string' }],
            [/'/, { token: 'string', next: '@string' }]
        ],
        string: [
            [/[^']+/, 'string'],
            [/''/, 'string'],
            [/'/, { token: 'string', next: '@pop' }]
        ],
        complexIdentifiers: [
            [/\[/, { token: 'identifier.quote', next: '@bracketedIdentifier' }],
            [/"/, { token: 'identifier.quote', next: '@quotedIdentifier' }]
        ],
        bracketedIdentifier: [
            [/[^\]]+/, 'identifier'],
            [/]]/, 'identifier'],
            [/]/, { token: 'identifier.quote', next: '@pop' }]
        ],
        quotedIdentifier: [
            [/[^"]+/, 'identifier'],
            [/""/, 'identifier'],
            [/"/, { token: 'identifier.quote', next: '@pop' }]
        ],
        scopes: [
            [/BEGIN\s+(DISTRIBUTED\s+)?TRAN(SACTION)?\b/i, 'keyword'],
            [/BEGIN\s+TRY\b/i, { token: 'keyword.try' }],
            [/END\s+TRY\b/i, { token: 'keyword.try' }],
            [/BEGIN\s+CATCH\b/i, { token: 'keyword.catch' }],
            [/END\s+CATCH\b/i, { token: 'keyword.catch' }],
            [/(BEGIN|CASE)\b/i, { token: 'keyword.block' }],
            [/END\b/i, { token: 'keyword.block' }],
            [/WHEN\b/i, { token: 'keyword.choice' }],
            [/THEN\b/i, { token: 'keyword.choice' }]
        ]
    }
};

// @ts-nocheck
class NgmMDXEditorComponent extends NgmBaseEditorDirective {
    constructor() {
        super(...arguments);
        this._entityType$ = new BehaviorSubject(null);
        this.languageId = 'mdx';
    }
    // EntityType
    get entityType() {
        return this._entityType$.value;
    }
    set entityType(value) {
        this._entityType$.next(value);
    }
    ngOnInit() {
        // 要使用 `monaco.languages.` 进行调用, 不能使用 `languages.`
        combineLatest([
            this.editor$.pipe(filter(nonNullable), tap((editor) => {
                monaco.languages.register({
                    id: this.languageId,
                    extensions: ['.mdx'],
                    aliases: ['MDX']
                });
                monaco.languages.setMonarchTokensProvider(this.languageId, language);
                monaco.languages.setLanguageConfiguration(this.languageId, conf);
            })),
            this._entityType$.pipe(filter(nonNullable))
        ]).subscribe(([editor, entityType]) => {
            this.dispose();
            // // SQL formatter 对 MDX 格式化效果不理想
            // this._providers.push(
            //   monaco.languages.registerDocumentFormattingEditProvider(this.languageId, {
            //     provideDocumentFormattingEdits(model, options) {
            //       const formatted = format(model.getValue(), {
            //         indent: ' '.repeat(options.tabSize)
            //       })
            //       return [
            //         {
            //           range: model.getFullModelRange(),
            //           text: formatted
            //         }
            //       ]
            //     }
            //   })
            // )
            this._providers.push(monaco.languages.registerCompletionItemProvider(this.languageId, functionProposals));
            this._providers.push(monaco.languages.registerCompletionItemProvider(this.languageId, createParameterProvider(entityType)));
            this._providers.push(monaco.languages.registerCompletionItemProvider(this.languageId, createHierarchyProvider(entityType)));
            this._providers.push(monaco.languages.registerCompletionItemProvider(this.languageId, createSuffixProvider(entityType)));
            this._providers.push(monaco.languages.registerSignatureHelpProvider(this.languageId, createSignatureHelpProvider()));
            this._providers.push(monaco.languages.registerHoverProvider(this.languageId, createHoverProvider(entityType)));
            // this._providers.push(
            //   monaco.languages.registerDocumentSemanticTokensProvider('plaintext', createDocumentSemanticTokensProvider(entityType))
            // )
        });
    }
    static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmMDXEditorComponent, deps: null, target: i0.ɵɵFactoryTarget.Component }); }
    static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.3.10", type: NgmMDXEditorComponent, isStandalone: true, selector: "ngm-mdx-editor", inputs: { entityType: "entityType" }, host: { classAttribute: "ngm-mdx-editor" }, providers: [
            {
                provide: NG_VALUE_ACCESSOR,
                multi: true,
                useExisting: forwardRef(() => NgmMDXEditorComponent)
            }
        ], usesInheritance: true, ngImport: i0, template: "<ngx-monaco-editor [ngStyle]=\"{'height': 'calc(100% - 1rem)'}\"\n    [options]=\"editorOptions()\"\n    [(ngModel)]=\"code\"\n    (ngModelChange)=\"onModelChange($event)\"\n    (resized)=\"onResized($event)\"\n    (onInit)=\"onInit($event)\"\n></ngx-monaco-editor>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "ngmodule", type: MonacoEditorModule }, { kind: "component", type: i3.EditorComponent, selector: "ngx-monaco-editor", inputs: ["options", "model"] }] }); }
}
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.10", ngImport: i0, type: NgmMDXEditorComponent, decorators: [{
            type: Component,
            args: [{ standalone: true, imports: [CommonModule, FormsModule, MonacoEditorModule], selector: 'ngm-mdx-editor', host: {
                        class: 'ngm-mdx-editor'
                    }, providers: [
                        {
                            provide: NG_VALUE_ACCESSOR,
                            multi: true,
                            useExisting: forwardRef(() => NgmMDXEditorComponent)
                        }
                    ], template: "<ngx-monaco-editor [ngStyle]=\"{'height': 'calc(100% - 1rem)'}\"\n    [options]=\"editorOptions()\"\n    [(ngModel)]=\"code\"\n    (ngModelChange)=\"onModelChange($event)\"\n    (resized)=\"onResized($event)\"\n    (onInit)=\"onInit($event)\"\n></ngx-monaco-editor>\n" }]
        }], propDecorators: { entityType: [{
                type: Input
            }] } });

/**
 * Generated bundle index. Do not edit.
 */

export { C_MDX_FIELD_NAME_REGEX, MDXNodeType, index as MDXReference, NgmMDXEditorComponent, PropertyItemFlatNode, PropertyItemNode };
//# sourceMappingURL=metad-ocap-angular-mdx.mjs.map
