monaco-editor
Version:
A browser based code editor
1,626 lines (1,622 loc) • 1.33 MB
JavaScript
/*!-----------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Version: 0.52.2(404545bded1df6ffa41ea0af4e8ddb219018c6c1)
* Released under the MIT license
* https://github.com/microsoft/monaco-editor/blob/main/LICENSE.txt
*-----------------------------------------------------------------------------*/
define("vs/language/css/cssWorker", ["require"],(require)=>{
"use strict";
var moduleExports = (() => {
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/language/css/cssWorker.ts
var cssWorker_exports = {};
__export(cssWorker_exports, {
CSSWorker: () => CSSWorker,
create: () => create
});
// node_modules/vscode-css-languageservice/lib/esm/parser/cssScanner.js
var TokenType;
(function(TokenType2) {
TokenType2[TokenType2["Ident"] = 0] = "Ident";
TokenType2[TokenType2["AtKeyword"] = 1] = "AtKeyword";
TokenType2[TokenType2["String"] = 2] = "String";
TokenType2[TokenType2["BadString"] = 3] = "BadString";
TokenType2[TokenType2["UnquotedString"] = 4] = "UnquotedString";
TokenType2[TokenType2["Hash"] = 5] = "Hash";
TokenType2[TokenType2["Num"] = 6] = "Num";
TokenType2[TokenType2["Percentage"] = 7] = "Percentage";
TokenType2[TokenType2["Dimension"] = 8] = "Dimension";
TokenType2[TokenType2["UnicodeRange"] = 9] = "UnicodeRange";
TokenType2[TokenType2["CDO"] = 10] = "CDO";
TokenType2[TokenType2["CDC"] = 11] = "CDC";
TokenType2[TokenType2["Colon"] = 12] = "Colon";
TokenType2[TokenType2["SemiColon"] = 13] = "SemiColon";
TokenType2[TokenType2["CurlyL"] = 14] = "CurlyL";
TokenType2[TokenType2["CurlyR"] = 15] = "CurlyR";
TokenType2[TokenType2["ParenthesisL"] = 16] = "ParenthesisL";
TokenType2[TokenType2["ParenthesisR"] = 17] = "ParenthesisR";
TokenType2[TokenType2["BracketL"] = 18] = "BracketL";
TokenType2[TokenType2["BracketR"] = 19] = "BracketR";
TokenType2[TokenType2["Whitespace"] = 20] = "Whitespace";
TokenType2[TokenType2["Includes"] = 21] = "Includes";
TokenType2[TokenType2["Dashmatch"] = 22] = "Dashmatch";
TokenType2[TokenType2["SubstringOperator"] = 23] = "SubstringOperator";
TokenType2[TokenType2["PrefixOperator"] = 24] = "PrefixOperator";
TokenType2[TokenType2["SuffixOperator"] = 25] = "SuffixOperator";
TokenType2[TokenType2["Delim"] = 26] = "Delim";
TokenType2[TokenType2["EMS"] = 27] = "EMS";
TokenType2[TokenType2["EXS"] = 28] = "EXS";
TokenType2[TokenType2["Length"] = 29] = "Length";
TokenType2[TokenType2["Angle"] = 30] = "Angle";
TokenType2[TokenType2["Time"] = 31] = "Time";
TokenType2[TokenType2["Freq"] = 32] = "Freq";
TokenType2[TokenType2["Exclamation"] = 33] = "Exclamation";
TokenType2[TokenType2["Resolution"] = 34] = "Resolution";
TokenType2[TokenType2["Comma"] = 35] = "Comma";
TokenType2[TokenType2["Charset"] = 36] = "Charset";
TokenType2[TokenType2["EscapedJavaScript"] = 37] = "EscapedJavaScript";
TokenType2[TokenType2["BadEscapedJavaScript"] = 38] = "BadEscapedJavaScript";
TokenType2[TokenType2["Comment"] = 39] = "Comment";
TokenType2[TokenType2["SingleLineComment"] = 40] = "SingleLineComment";
TokenType2[TokenType2["EOF"] = 41] = "EOF";
TokenType2[TokenType2["ContainerQueryLength"] = 42] = "ContainerQueryLength";
TokenType2[TokenType2["CustomToken"] = 43] = "CustomToken";
})(TokenType || (TokenType = {}));
var MultiLineStream = class {
constructor(source) {
this.source = source;
this.len = source.length;
this.position = 0;
}
substring(from, to = this.position) {
return this.source.substring(from, to);
}
eos() {
return this.len <= this.position;
}
pos() {
return this.position;
}
goBackTo(pos) {
this.position = pos;
}
goBack(n) {
this.position -= n;
}
advance(n) {
this.position += n;
}
nextChar() {
return this.source.charCodeAt(this.position++) || 0;
}
peekChar(n = 0) {
return this.source.charCodeAt(this.position + n) || 0;
}
lookbackChar(n = 0) {
return this.source.charCodeAt(this.position - n) || 0;
}
advanceIfChar(ch) {
if (ch === this.source.charCodeAt(this.position)) {
this.position++;
return true;
}
return false;
}
advanceIfChars(ch) {
if (this.position + ch.length > this.source.length) {
return false;
}
let i = 0;
for (; i < ch.length; i++) {
if (this.source.charCodeAt(this.position + i) !== ch[i]) {
return false;
}
}
this.advance(i);
return true;
}
advanceWhileChar(condition) {
const posNow = this.position;
while (this.position < this.len && condition(this.source.charCodeAt(this.position))) {
this.position++;
}
return this.position - posNow;
}
};
var _a = "a".charCodeAt(0);
var _f = "f".charCodeAt(0);
var _z = "z".charCodeAt(0);
var _u = "u".charCodeAt(0);
var _A = "A".charCodeAt(0);
var _F = "F".charCodeAt(0);
var _Z = "Z".charCodeAt(0);
var _0 = "0".charCodeAt(0);
var _9 = "9".charCodeAt(0);
var _TLD = "~".charCodeAt(0);
var _HAT = "^".charCodeAt(0);
var _EQS = "=".charCodeAt(0);
var _PIP = "|".charCodeAt(0);
var _MIN = "-".charCodeAt(0);
var _USC = "_".charCodeAt(0);
var _PRC = "%".charCodeAt(0);
var _MUL = "*".charCodeAt(0);
var _LPA = "(".charCodeAt(0);
var _RPA = ")".charCodeAt(0);
var _LAN = "<".charCodeAt(0);
var _RAN = ">".charCodeAt(0);
var _ATS = "@".charCodeAt(0);
var _HSH = "#".charCodeAt(0);
var _DLR = "$".charCodeAt(0);
var _BSL = "\\".charCodeAt(0);
var _FSL = "/".charCodeAt(0);
var _NWL = "\n".charCodeAt(0);
var _CAR = "\r".charCodeAt(0);
var _LFD = "\f".charCodeAt(0);
var _DQO = '"'.charCodeAt(0);
var _SQO = "'".charCodeAt(0);
var _WSP = " ".charCodeAt(0);
var _TAB = " ".charCodeAt(0);
var _SEM = ";".charCodeAt(0);
var _COL = ":".charCodeAt(0);
var _CUL = "{".charCodeAt(0);
var _CUR = "}".charCodeAt(0);
var _BRL = "[".charCodeAt(0);
var _BRR = "]".charCodeAt(0);
var _CMA = ",".charCodeAt(0);
var _DOT = ".".charCodeAt(0);
var _BNG = "!".charCodeAt(0);
var _QSM = "?".charCodeAt(0);
var _PLS = "+".charCodeAt(0);
var staticTokenTable = {};
staticTokenTable[_SEM] = TokenType.SemiColon;
staticTokenTable[_COL] = TokenType.Colon;
staticTokenTable[_CUL] = TokenType.CurlyL;
staticTokenTable[_CUR] = TokenType.CurlyR;
staticTokenTable[_BRR] = TokenType.BracketR;
staticTokenTable[_BRL] = TokenType.BracketL;
staticTokenTable[_LPA] = TokenType.ParenthesisL;
staticTokenTable[_RPA] = TokenType.ParenthesisR;
staticTokenTable[_CMA] = TokenType.Comma;
var staticUnitTable = {};
staticUnitTable["em"] = TokenType.EMS;
staticUnitTable["ex"] = TokenType.EXS;
staticUnitTable["px"] = TokenType.Length;
staticUnitTable["cm"] = TokenType.Length;
staticUnitTable["mm"] = TokenType.Length;
staticUnitTable["in"] = TokenType.Length;
staticUnitTable["pt"] = TokenType.Length;
staticUnitTable["pc"] = TokenType.Length;
staticUnitTable["deg"] = TokenType.Angle;
staticUnitTable["rad"] = TokenType.Angle;
staticUnitTable["grad"] = TokenType.Angle;
staticUnitTable["ms"] = TokenType.Time;
staticUnitTable["s"] = TokenType.Time;
staticUnitTable["hz"] = TokenType.Freq;
staticUnitTable["khz"] = TokenType.Freq;
staticUnitTable["%"] = TokenType.Percentage;
staticUnitTable["fr"] = TokenType.Percentage;
staticUnitTable["dpi"] = TokenType.Resolution;
staticUnitTable["dpcm"] = TokenType.Resolution;
staticUnitTable["cqw"] = TokenType.ContainerQueryLength;
staticUnitTable["cqh"] = TokenType.ContainerQueryLength;
staticUnitTable["cqi"] = TokenType.ContainerQueryLength;
staticUnitTable["cqb"] = TokenType.ContainerQueryLength;
staticUnitTable["cqmin"] = TokenType.ContainerQueryLength;
staticUnitTable["cqmax"] = TokenType.ContainerQueryLength;
var Scanner = class {
constructor() {
this.stream = new MultiLineStream("");
this.ignoreComment = true;
this.ignoreWhitespace = true;
this.inURL = false;
}
setSource(input) {
this.stream = new MultiLineStream(input);
}
finishToken(offset, type, text) {
return {
offset,
len: this.stream.pos() - offset,
type,
text: text || this.stream.substring(offset)
};
}
substring(offset, len) {
return this.stream.substring(offset, offset + len);
}
pos() {
return this.stream.pos();
}
goBackTo(pos) {
this.stream.goBackTo(pos);
}
scanUnquotedString() {
const offset = this.stream.pos();
const content = [];
if (this._unquotedString(content)) {
return this.finishToken(offset, TokenType.UnquotedString, content.join(""));
}
return null;
}
scan() {
const triviaToken = this.trivia();
if (triviaToken !== null) {
return triviaToken;
}
const offset = this.stream.pos();
if (this.stream.eos()) {
return this.finishToken(offset, TokenType.EOF);
}
return this.scanNext(offset);
}
/**
* Read the range as described in https://www.w3.org/TR/CSS21/syndata.html#tokenization
* Assume the `u` has aleady been consumed
* @returns if reading the unicode was successful
*/
tryScanUnicode() {
const offset = this.stream.pos();
if (!this.stream.eos() && this._unicodeRange()) {
return this.finishToken(offset, TokenType.UnicodeRange);
}
this.stream.goBackTo(offset);
return void 0;
}
scanNext(offset) {
if (this.stream.advanceIfChars([_LAN, _BNG, _MIN, _MIN])) {
return this.finishToken(offset, TokenType.CDO);
}
if (this.stream.advanceIfChars([_MIN, _MIN, _RAN])) {
return this.finishToken(offset, TokenType.CDC);
}
let content = [];
if (this.ident(content)) {
return this.finishToken(offset, TokenType.Ident, content.join(""));
}
if (this.stream.advanceIfChar(_ATS)) {
content = ["@"];
if (this._name(content)) {
const keywordText = content.join("");
if (keywordText === "@charset") {
return this.finishToken(offset, TokenType.Charset, keywordText);
}
return this.finishToken(offset, TokenType.AtKeyword, keywordText);
} else {
return this.finishToken(offset, TokenType.Delim);
}
}
if (this.stream.advanceIfChar(_HSH)) {
content = ["#"];
if (this._name(content)) {
return this.finishToken(offset, TokenType.Hash, content.join(""));
} else {
return this.finishToken(offset, TokenType.Delim);
}
}
if (this.stream.advanceIfChar(_BNG)) {
return this.finishToken(offset, TokenType.Exclamation);
}
if (this._number()) {
const pos = this.stream.pos();
content = [this.stream.substring(offset, pos)];
if (this.stream.advanceIfChar(_PRC)) {
return this.finishToken(offset, TokenType.Percentage);
} else if (this.ident(content)) {
const dim = this.stream.substring(pos).toLowerCase();
const tokenType2 = staticUnitTable[dim];
if (typeof tokenType2 !== "undefined") {
return this.finishToken(offset, tokenType2, content.join(""));
} else {
return this.finishToken(offset, TokenType.Dimension, content.join(""));
}
}
return this.finishToken(offset, TokenType.Num);
}
content = [];
let tokenType = this._string(content);
if (tokenType !== null) {
return this.finishToken(offset, tokenType, content.join(""));
}
tokenType = staticTokenTable[this.stream.peekChar()];
if (typeof tokenType !== "undefined") {
this.stream.advance(1);
return this.finishToken(offset, tokenType);
}
if (this.stream.peekChar(0) === _TLD && this.stream.peekChar(1) === _EQS) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.Includes);
}
if (this.stream.peekChar(0) === _PIP && this.stream.peekChar(1) === _EQS) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.Dashmatch);
}
if (this.stream.peekChar(0) === _MUL && this.stream.peekChar(1) === _EQS) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.SubstringOperator);
}
if (this.stream.peekChar(0) === _HAT && this.stream.peekChar(1) === _EQS) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.PrefixOperator);
}
if (this.stream.peekChar(0) === _DLR && this.stream.peekChar(1) === _EQS) {
this.stream.advance(2);
return this.finishToken(offset, TokenType.SuffixOperator);
}
this.stream.nextChar();
return this.finishToken(offset, TokenType.Delim);
}
trivia() {
while (true) {
const offset = this.stream.pos();
if (this._whitespace()) {
if (!this.ignoreWhitespace) {
return this.finishToken(offset, TokenType.Whitespace);
}
} else if (this.comment()) {
if (!this.ignoreComment) {
return this.finishToken(offset, TokenType.Comment);
}
} else {
return null;
}
}
}
comment() {
if (this.stream.advanceIfChars([_FSL, _MUL])) {
let success = false, hot = false;
this.stream.advanceWhileChar((ch) => {
if (hot && ch === _FSL) {
success = true;
return false;
}
hot = ch === _MUL;
return true;
});
if (success) {
this.stream.advance(1);
}
return true;
}
return false;
}
_number() {
let npeek = 0, ch;
if (this.stream.peekChar() === _DOT) {
npeek = 1;
}
ch = this.stream.peekChar(npeek);
if (ch >= _0 && ch <= _9) {
this.stream.advance(npeek + 1);
this.stream.advanceWhileChar((ch2) => {
return ch2 >= _0 && ch2 <= _9 || npeek === 0 && ch2 === _DOT;
});
return true;
}
return false;
}
_newline(result) {
const ch = this.stream.peekChar();
switch (ch) {
case _CAR:
case _LFD:
case _NWL:
this.stream.advance(1);
result.push(String.fromCharCode(ch));
if (ch === _CAR && this.stream.advanceIfChar(_NWL)) {
result.push("\n");
}
return true;
}
return false;
}
_escape(result, includeNewLines) {
let ch = this.stream.peekChar();
if (ch === _BSL) {
this.stream.advance(1);
ch = this.stream.peekChar();
let hexNumCount = 0;
while (hexNumCount < 6 && (ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F)) {
this.stream.advance(1);
ch = this.stream.peekChar();
hexNumCount++;
}
if (hexNumCount > 0) {
try {
const hexVal = parseInt(this.stream.substring(this.stream.pos() - hexNumCount), 16);
if (hexVal) {
result.push(String.fromCharCode(hexVal));
}
} catch (e) {
}
if (ch === _WSP || ch === _TAB) {
this.stream.advance(1);
} else {
this._newline([]);
}
return true;
}
if (ch !== _CAR && ch !== _LFD && ch !== _NWL) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
} else if (includeNewLines) {
return this._newline(result);
}
}
return false;
}
_stringChar(closeQuote, result) {
const ch = this.stream.peekChar();
if (ch !== 0 && ch !== closeQuote && ch !== _BSL && ch !== _CAR && ch !== _LFD && ch !== _NWL) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_string(result) {
if (this.stream.peekChar() === _SQO || this.stream.peekChar() === _DQO) {
const closeQuote = this.stream.nextChar();
result.push(String.fromCharCode(closeQuote));
while (this._stringChar(closeQuote, result) || this._escape(result, true)) {
}
if (this.stream.peekChar() === closeQuote) {
this.stream.nextChar();
result.push(String.fromCharCode(closeQuote));
return TokenType.String;
} else {
return TokenType.BadString;
}
}
return null;
}
_unquotedChar(result) {
const ch = this.stream.peekChar();
if (ch !== 0 && ch !== _BSL && ch !== _SQO && ch !== _DQO && ch !== _LPA && ch !== _RPA && ch !== _WSP && ch !== _TAB && ch !== _NWL && ch !== _LFD && ch !== _CAR) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_unquotedString(result) {
let hasContent = false;
while (this._unquotedChar(result) || this._escape(result)) {
hasContent = true;
}
return hasContent;
}
_whitespace() {
const n = this.stream.advanceWhileChar((ch) => {
return ch === _WSP || ch === _TAB || ch === _NWL || ch === _LFD || ch === _CAR;
});
return n > 0;
}
_name(result) {
let matched = false;
while (this._identChar(result) || this._escape(result)) {
matched = true;
}
return matched;
}
ident(result) {
const pos = this.stream.pos();
const hasMinus = this._minus(result);
if (hasMinus) {
if (this._minus(result) || this._identFirstChar(result) || this._escape(result)) {
while (this._identChar(result) || this._escape(result)) {
}
return true;
}
} else if (this._identFirstChar(result) || this._escape(result)) {
while (this._identChar(result) || this._escape(result)) {
}
return true;
}
this.stream.goBackTo(pos);
return false;
}
_identFirstChar(result) {
const ch = this.stream.peekChar();
if (ch === _USC || // _
ch >= _a && ch <= _z || // a-z
ch >= _A && ch <= _Z || // A-Z
ch >= 128 && ch <= 65535) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_minus(result) {
const ch = this.stream.peekChar();
if (ch === _MIN) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_identChar(result) {
const ch = this.stream.peekChar();
if (ch === _USC || // _
ch === _MIN || // -
ch >= _a && ch <= _z || // a-z
ch >= _A && ch <= _Z || // A-Z
ch >= _0 && ch <= _9 || // 0/9
ch >= 128 && ch <= 65535) {
this.stream.advance(1);
result.push(String.fromCharCode(ch));
return true;
}
return false;
}
_unicodeRange() {
if (this.stream.advanceIfChar(_PLS)) {
const isHexDigit = (ch) => ch >= _0 && ch <= _9 || ch >= _a && ch <= _f || ch >= _A && ch <= _F;
const codePoints = this.stream.advanceWhileChar(isHexDigit) + this.stream.advanceWhileChar((ch) => ch === _QSM);
if (codePoints >= 1 && codePoints <= 6) {
if (this.stream.advanceIfChar(_MIN)) {
const digits = this.stream.advanceWhileChar(isHexDigit);
if (digits >= 1 && digits <= 6) {
return true;
}
} else {
return true;
}
}
}
return false;
}
};
// node_modules/vscode-css-languageservice/lib/esm/utils/strings.js
function startsWith(haystack, needle) {
if (haystack.length < needle.length) {
return false;
}
for (let i = 0; i < needle.length; i++) {
if (haystack[i] !== needle[i]) {
return false;
}
}
return true;
}
function endsWith(haystack, needle) {
let diff = haystack.length - needle.length;
if (diff > 0) {
return haystack.lastIndexOf(needle) === diff;
} else if (diff === 0) {
return haystack === needle;
} else {
return false;
}
}
function difference(first, second, maxLenDelta = 4) {
let lengthDifference = Math.abs(first.length - second.length);
if (lengthDifference > maxLenDelta) {
return 0;
}
let LCS = [];
let zeroArray = [];
let i, j;
for (i = 0; i < second.length + 1; ++i) {
zeroArray.push(0);
}
for (i = 0; i < first.length + 1; ++i) {
LCS.push(zeroArray);
}
for (i = 1; i < first.length + 1; ++i) {
for (j = 1; j < second.length + 1; ++j) {
if (first[i - 1] === second[j - 1]) {
LCS[i][j] = LCS[i - 1][j - 1] + 1;
} else {
LCS[i][j] = Math.max(LCS[i - 1][j], LCS[i][j - 1]);
}
}
}
return LCS[first.length][second.length] - Math.sqrt(lengthDifference);
}
function getLimitedString(str, ellipsis = true) {
if (!str) {
return "";
}
if (str.length < 140) {
return str;
}
return str.slice(0, 140) + (ellipsis ? "\u2026" : "");
}
function trim(str, regexp) {
const m = regexp.exec(str);
if (m && m[0].length) {
return str.substr(0, str.length - m[0].length);
}
return str;
}
function repeat(value, count) {
let s = "";
while (count > 0) {
if ((count & 1) === 1) {
s += value;
}
value += value;
count = count >>> 1;
}
return s;
}
// node_modules/vscode-css-languageservice/lib/esm/parser/cssNodes.js
var NodeType;
(function(NodeType2) {
NodeType2[NodeType2["Undefined"] = 0] = "Undefined";
NodeType2[NodeType2["Identifier"] = 1] = "Identifier";
NodeType2[NodeType2["Stylesheet"] = 2] = "Stylesheet";
NodeType2[NodeType2["Ruleset"] = 3] = "Ruleset";
NodeType2[NodeType2["Selector"] = 4] = "Selector";
NodeType2[NodeType2["SimpleSelector"] = 5] = "SimpleSelector";
NodeType2[NodeType2["SelectorInterpolation"] = 6] = "SelectorInterpolation";
NodeType2[NodeType2["SelectorCombinator"] = 7] = "SelectorCombinator";
NodeType2[NodeType2["SelectorCombinatorParent"] = 8] = "SelectorCombinatorParent";
NodeType2[NodeType2["SelectorCombinatorSibling"] = 9] = "SelectorCombinatorSibling";
NodeType2[NodeType2["SelectorCombinatorAllSiblings"] = 10] = "SelectorCombinatorAllSiblings";
NodeType2[NodeType2["SelectorCombinatorShadowPiercingDescendant"] = 11] = "SelectorCombinatorShadowPiercingDescendant";
NodeType2[NodeType2["Page"] = 12] = "Page";
NodeType2[NodeType2["PageBoxMarginBox"] = 13] = "PageBoxMarginBox";
NodeType2[NodeType2["ClassSelector"] = 14] = "ClassSelector";
NodeType2[NodeType2["IdentifierSelector"] = 15] = "IdentifierSelector";
NodeType2[NodeType2["ElementNameSelector"] = 16] = "ElementNameSelector";
NodeType2[NodeType2["PseudoSelector"] = 17] = "PseudoSelector";
NodeType2[NodeType2["AttributeSelector"] = 18] = "AttributeSelector";
NodeType2[NodeType2["Declaration"] = 19] = "Declaration";
NodeType2[NodeType2["Declarations"] = 20] = "Declarations";
NodeType2[NodeType2["Property"] = 21] = "Property";
NodeType2[NodeType2["Expression"] = 22] = "Expression";
NodeType2[NodeType2["BinaryExpression"] = 23] = "BinaryExpression";
NodeType2[NodeType2["Term"] = 24] = "Term";
NodeType2[NodeType2["Operator"] = 25] = "Operator";
NodeType2[NodeType2["Value"] = 26] = "Value";
NodeType2[NodeType2["StringLiteral"] = 27] = "StringLiteral";
NodeType2[NodeType2["URILiteral"] = 28] = "URILiteral";
NodeType2[NodeType2["EscapedValue"] = 29] = "EscapedValue";
NodeType2[NodeType2["Function"] = 30] = "Function";
NodeType2[NodeType2["NumericValue"] = 31] = "NumericValue";
NodeType2[NodeType2["HexColorValue"] = 32] = "HexColorValue";
NodeType2[NodeType2["RatioValue"] = 33] = "RatioValue";
NodeType2[NodeType2["MixinDeclaration"] = 34] = "MixinDeclaration";
NodeType2[NodeType2["MixinReference"] = 35] = "MixinReference";
NodeType2[NodeType2["VariableName"] = 36] = "VariableName";
NodeType2[NodeType2["VariableDeclaration"] = 37] = "VariableDeclaration";
NodeType2[NodeType2["Prio"] = 38] = "Prio";
NodeType2[NodeType2["Interpolation"] = 39] = "Interpolation";
NodeType2[NodeType2["NestedProperties"] = 40] = "NestedProperties";
NodeType2[NodeType2["ExtendsReference"] = 41] = "ExtendsReference";
NodeType2[NodeType2["SelectorPlaceholder"] = 42] = "SelectorPlaceholder";
NodeType2[NodeType2["Debug"] = 43] = "Debug";
NodeType2[NodeType2["If"] = 44] = "If";
NodeType2[NodeType2["Else"] = 45] = "Else";
NodeType2[NodeType2["For"] = 46] = "For";
NodeType2[NodeType2["Each"] = 47] = "Each";
NodeType2[NodeType2["While"] = 48] = "While";
NodeType2[NodeType2["MixinContentReference"] = 49] = "MixinContentReference";
NodeType2[NodeType2["MixinContentDeclaration"] = 50] = "MixinContentDeclaration";
NodeType2[NodeType2["Media"] = 51] = "Media";
NodeType2[NodeType2["Keyframe"] = 52] = "Keyframe";
NodeType2[NodeType2["FontFace"] = 53] = "FontFace";
NodeType2[NodeType2["Import"] = 54] = "Import";
NodeType2[NodeType2["Namespace"] = 55] = "Namespace";
NodeType2[NodeType2["Invocation"] = 56] = "Invocation";
NodeType2[NodeType2["FunctionDeclaration"] = 57] = "FunctionDeclaration";
NodeType2[NodeType2["ReturnStatement"] = 58] = "ReturnStatement";
NodeType2[NodeType2["MediaQuery"] = 59] = "MediaQuery";
NodeType2[NodeType2["MediaCondition"] = 60] = "MediaCondition";
NodeType2[NodeType2["MediaFeature"] = 61] = "MediaFeature";
NodeType2[NodeType2["FunctionParameter"] = 62] = "FunctionParameter";
NodeType2[NodeType2["FunctionArgument"] = 63] = "FunctionArgument";
NodeType2[NodeType2["KeyframeSelector"] = 64] = "KeyframeSelector";
NodeType2[NodeType2["ViewPort"] = 65] = "ViewPort";
NodeType2[NodeType2["Document"] = 66] = "Document";
NodeType2[NodeType2["AtApplyRule"] = 67] = "AtApplyRule";
NodeType2[NodeType2["CustomPropertyDeclaration"] = 68] = "CustomPropertyDeclaration";
NodeType2[NodeType2["CustomPropertySet"] = 69] = "CustomPropertySet";
NodeType2[NodeType2["ListEntry"] = 70] = "ListEntry";
NodeType2[NodeType2["Supports"] = 71] = "Supports";
NodeType2[NodeType2["SupportsCondition"] = 72] = "SupportsCondition";
NodeType2[NodeType2["NamespacePrefix"] = 73] = "NamespacePrefix";
NodeType2[NodeType2["GridLine"] = 74] = "GridLine";
NodeType2[NodeType2["Plugin"] = 75] = "Plugin";
NodeType2[NodeType2["UnknownAtRule"] = 76] = "UnknownAtRule";
NodeType2[NodeType2["Use"] = 77] = "Use";
NodeType2[NodeType2["ModuleConfiguration"] = 78] = "ModuleConfiguration";
NodeType2[NodeType2["Forward"] = 79] = "Forward";
NodeType2[NodeType2["ForwardVisibility"] = 80] = "ForwardVisibility";
NodeType2[NodeType2["Module"] = 81] = "Module";
NodeType2[NodeType2["UnicodeRange"] = 82] = "UnicodeRange";
NodeType2[NodeType2["Layer"] = 83] = "Layer";
NodeType2[NodeType2["LayerNameList"] = 84] = "LayerNameList";
NodeType2[NodeType2["LayerName"] = 85] = "LayerName";
NodeType2[NodeType2["PropertyAtRule"] = 86] = "PropertyAtRule";
NodeType2[NodeType2["Container"] = 87] = "Container";
})(NodeType || (NodeType = {}));
var ReferenceType;
(function(ReferenceType2) {
ReferenceType2[ReferenceType2["Mixin"] = 0] = "Mixin";
ReferenceType2[ReferenceType2["Rule"] = 1] = "Rule";
ReferenceType2[ReferenceType2["Variable"] = 2] = "Variable";
ReferenceType2[ReferenceType2["Function"] = 3] = "Function";
ReferenceType2[ReferenceType2["Keyframe"] = 4] = "Keyframe";
ReferenceType2[ReferenceType2["Unknown"] = 5] = "Unknown";
ReferenceType2[ReferenceType2["Module"] = 6] = "Module";
ReferenceType2[ReferenceType2["Forward"] = 7] = "Forward";
ReferenceType2[ReferenceType2["ForwardVisibility"] = 8] = "ForwardVisibility";
ReferenceType2[ReferenceType2["Property"] = 9] = "Property";
})(ReferenceType || (ReferenceType = {}));
function getNodeAtOffset(node, offset) {
let candidate = null;
if (!node || offset < node.offset || offset > node.end) {
return null;
}
node.accept((node2) => {
if (node2.offset === -1 && node2.length === -1) {
return true;
}
if (node2.offset <= offset && node2.end >= offset) {
if (!candidate) {
candidate = node2;
} else if (node2.length <= candidate.length) {
candidate = node2;
}
return true;
}
return false;
});
return candidate;
}
function getNodePath(node, offset) {
let candidate = getNodeAtOffset(node, offset);
const path = [];
while (candidate) {
path.unshift(candidate);
candidate = candidate.parent;
}
return path;
}
function getParentDeclaration(node) {
const decl = node.findParent(NodeType.Declaration);
const value = decl && decl.getValue();
if (value && value.encloses(node)) {
return decl;
}
return null;
}
var Node = class {
get end() {
return this.offset + this.length;
}
constructor(offset = -1, len = -1, nodeType) {
this.parent = null;
this.offset = offset;
this.length = len;
if (nodeType) {
this.nodeType = nodeType;
}
}
set type(type) {
this.nodeType = type;
}
get type() {
return this.nodeType || NodeType.Undefined;
}
getTextProvider() {
let node = this;
while (node && !node.textProvider) {
node = node.parent;
}
if (node) {
return node.textProvider;
}
return () => {
return "unknown";
};
}
getText() {
return this.getTextProvider()(this.offset, this.length);
}
matches(str) {
return this.length === str.length && this.getTextProvider()(this.offset, this.length) === str;
}
startsWith(str) {
return this.length >= str.length && this.getTextProvider()(this.offset, str.length) === str;
}
endsWith(str) {
return this.length >= str.length && this.getTextProvider()(this.end - str.length, str.length) === str;
}
accept(visitor) {
if (visitor(this) && this.children) {
for (const child of this.children) {
child.accept(visitor);
}
}
}
acceptVisitor(visitor) {
this.accept(visitor.visitNode.bind(visitor));
}
adoptChild(node, index = -1) {
if (node.parent && node.parent.children) {
const idx = node.parent.children.indexOf(node);
if (idx >= 0) {
node.parent.children.splice(idx, 1);
}
}
node.parent = this;
let children = this.children;
if (!children) {
children = this.children = [];
}
if (index !== -1) {
children.splice(index, 0, node);
} else {
children.push(node);
}
return node;
}
attachTo(parent, index = -1) {
if (parent) {
parent.adoptChild(this, index);
}
return this;
}
collectIssues(results) {
if (this.issues) {
results.push.apply(results, this.issues);
}
}
addIssue(issue) {
if (!this.issues) {
this.issues = [];
}
this.issues.push(issue);
}
hasIssue(rule) {
return Array.isArray(this.issues) && this.issues.some((i) => i.getRule() === rule);
}
isErroneous(recursive = false) {
if (this.issues && this.issues.length > 0) {
return true;
}
return recursive && Array.isArray(this.children) && this.children.some((c) => c.isErroneous(true));
}
setNode(field, node, index = -1) {
if (node) {
node.attachTo(this, index);
this[field] = node;
return true;
}
return false;
}
addChild(node) {
if (node) {
if (!this.children) {
this.children = [];
}
node.attachTo(this);
this.updateOffsetAndLength(node);
return true;
}
return false;
}
updateOffsetAndLength(node) {
if (node.offset < this.offset || this.offset === -1) {
this.offset = node.offset;
}
const nodeEnd = node.end;
if (nodeEnd > this.end || this.length === -1) {
this.length = nodeEnd - this.offset;
}
}
hasChildren() {
return !!this.children && this.children.length > 0;
}
getChildren() {
return this.children ? this.children.slice(0) : [];
}
getChild(index) {
if (this.children && index < this.children.length) {
return this.children[index];
}
return null;
}
addChildren(nodes) {
for (const node of nodes) {
this.addChild(node);
}
}
findFirstChildBeforeOffset(offset) {
if (this.children) {
let current = null;
for (let i = this.children.length - 1; i >= 0; i--) {
current = this.children[i];
if (current.offset <= offset) {
return current;
}
}
}
return null;
}
findChildAtOffset(offset, goDeep) {
const current = this.findFirstChildBeforeOffset(offset);
if (current && current.end >= offset) {
if (goDeep) {
return current.findChildAtOffset(offset, true) || current;
}
return current;
}
return null;
}
encloses(candidate) {
return this.offset <= candidate.offset && this.offset + this.length >= candidate.offset + candidate.length;
}
getParent() {
let result = this.parent;
while (result instanceof Nodelist) {
result = result.parent;
}
return result;
}
findParent(type) {
let result = this;
while (result && result.type !== type) {
result = result.parent;
}
return result;
}
findAParent(...types) {
let result = this;
while (result && !types.some((t2) => result.type === t2)) {
result = result.parent;
}
return result;
}
setData(key, value) {
if (!this.options) {
this.options = {};
}
this.options[key] = value;
}
getData(key) {
if (!this.options || !this.options.hasOwnProperty(key)) {
return null;
}
return this.options[key];
}
};
var Nodelist = class extends Node {
constructor(parent, index = -1) {
super(-1, -1);
this.attachTo(parent, index);
this.offset = -1;
this.length = -1;
}
};
var UnicodeRange = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.UnicodeRange;
}
setRangeStart(rangeStart) {
return this.setNode("rangeStart", rangeStart);
}
getRangeStart() {
return this.rangeStart;
}
setRangeEnd(rangeEnd) {
return this.setNode("rangeEnd", rangeEnd);
}
getRangeEnd() {
return this.rangeEnd;
}
};
var Identifier = class extends Node {
constructor(offset, length) {
super(offset, length);
this.isCustomProperty = false;
}
get type() {
return NodeType.Identifier;
}
containsInterpolation() {
return this.hasChildren();
}
};
var Stylesheet = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Stylesheet;
}
};
var Declarations = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Declarations;
}
};
var BodyDeclaration = class extends Node {
constructor(offset, length) {
super(offset, length);
}
getDeclarations() {
return this.declarations;
}
setDeclarations(decls) {
return this.setNode("declarations", decls);
}
};
var RuleSet = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Ruleset;
}
getSelectors() {
if (!this.selectors) {
this.selectors = new Nodelist(this);
}
return this.selectors;
}
isNested() {
return !!this.parent && this.parent.findParent(NodeType.Declarations) !== null;
}
};
var Selector = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Selector;
}
};
var SimpleSelector = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.SimpleSelector;
}
};
var AbstractDeclaration = class extends Node {
constructor(offset, length) {
super(offset, length);
}
};
var CustomPropertySet = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.CustomPropertySet;
}
};
var Declaration = class _Declaration extends AbstractDeclaration {
constructor(offset, length) {
super(offset, length);
this.property = null;
}
get type() {
return NodeType.Declaration;
}
setProperty(node) {
return this.setNode("property", node);
}
getProperty() {
return this.property;
}
getFullPropertyName() {
const propertyName = this.property ? this.property.getName() : "unknown";
if (this.parent instanceof Declarations && this.parent.getParent() instanceof NestedProperties) {
const parentDecl = this.parent.getParent().getParent();
if (parentDecl instanceof _Declaration) {
return parentDecl.getFullPropertyName() + propertyName;
}
}
return propertyName;
}
getNonPrefixedPropertyName() {
const propertyName = this.getFullPropertyName();
if (propertyName && propertyName.charAt(0) === "-") {
const vendorPrefixEnd = propertyName.indexOf("-", 1);
if (vendorPrefixEnd !== -1) {
return propertyName.substring(vendorPrefixEnd + 1);
}
}
return propertyName;
}
setValue(value) {
return this.setNode("value", value);
}
getValue() {
return this.value;
}
setNestedProperties(value) {
return this.setNode("nestedProperties", value);
}
getNestedProperties() {
return this.nestedProperties;
}
};
var CustomPropertyDeclaration = class extends Declaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.CustomPropertyDeclaration;
}
setPropertySet(value) {
return this.setNode("propertySet", value);
}
getPropertySet() {
return this.propertySet;
}
};
var Property = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Property;
}
setIdentifier(value) {
return this.setNode("identifier", value);
}
getIdentifier() {
return this.identifier;
}
getName() {
return trim(this.getText(), /[_\+]+$/);
}
isCustomProperty() {
return !!this.identifier && this.identifier.isCustomProperty;
}
};
var Invocation = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Invocation;
}
getArguments() {
if (!this.arguments) {
this.arguments = new Nodelist(this);
}
return this.arguments;
}
};
var Function = class extends Invocation {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Function;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
};
var FunctionParameter = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionParameter;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setDefaultValue(node) {
return this.setNode("defaultValue", node, 0);
}
getDefaultValue() {
return this.defaultValue;
}
};
var FunctionArgument = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionArgument;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setValue(node) {
return this.setNode("value", node, 0);
}
getValue() {
return this.value;
}
};
var IfStatement = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.If;
}
setExpression(node) {
return this.setNode("expression", node, 0);
}
setElseClause(elseClause) {
return this.setNode("elseClause", elseClause);
}
};
var ForStatement = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.For;
}
setVariable(node) {
return this.setNode("variable", node, 0);
}
};
var EachStatement = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Each;
}
getVariables() {
if (!this.variables) {
this.variables = new Nodelist(this);
}
return this.variables;
}
};
var WhileStatement = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.While;
}
};
var ElseStatement = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Else;
}
};
var FunctionDeclaration = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FunctionDeclaration;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
};
var ViewPort = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.ViewPort;
}
};
var FontFace = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.FontFace;
}
};
var NestedProperties = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.NestedProperties;
}
};
var Keyframe = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Keyframe;
}
setKeyword(keyword) {
return this.setNode("keyword", keyword, 0);
}
getKeyword() {
return this.keyword;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
};
var KeyframeSelector = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.KeyframeSelector;
}
};
var Import = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Import;
}
setMedialist(node) {
if (node) {
node.attachTo(this);
return true;
}
return false;
}
};
var Use = class extends Node {
get type() {
return NodeType.Use;
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
};
var ModuleConfiguration = class extends Node {
get type() {
return NodeType.ModuleConfiguration;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getName() {
return this.identifier ? this.identifier.getText() : "";
}
setValue(node) {
return this.setNode("value", node, 0);
}
getValue() {
return this.value;
}
};
var Forward = class extends Node {
get type() {
return NodeType.Forward;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
getMembers() {
if (!this.members) {
this.members = new Nodelist(this);
}
return this.members;
}
getParameters() {
if (!this.parameters) {
this.parameters = new Nodelist(this);
}
return this.parameters;
}
};
var ForwardVisibility = class extends Node {
get type() {
return NodeType.ForwardVisibility;
}
setIdentifier(node) {
return this.setNode("identifier", node, 0);
}
getIdentifier() {
return this.identifier;
}
};
var Namespace = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Namespace;
}
};
var Media = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Media;
}
};
var Supports = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Supports;
}
};
var Layer = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Layer;
}
setNames(names) {
return this.setNode("names", names);
}
getNames() {
return this.names;
}
};
var PropertyAtRule = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.PropertyAtRule;
}
setName(node) {
if (node) {
node.attachTo(this);
this.name = node;
return true;
}
return false;
}
getName() {
return this.name;
}
};
var Document = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Document;
}
};
var Container = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Container;
}
};
var Medialist = class extends Node {
constructor(offset, length) {
super(offset, length);
}
};
var MediaQuery = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaQuery;
}
};
var MediaCondition = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaCondition;
}
};
var MediaFeature = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.MediaFeature;
}
};
var SupportsCondition = class extends Node {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.SupportsCondition;
}
};
var Page = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.Page;
}
};
var PageBoxMarginBox = class extends BodyDeclaration {
constructor(offset, length) {
super(offset, length);
}
get type() {
return NodeType.PageBoxMarginBox;
}
};
var Expression = class exten