@kusto/monaco-kusto 4.1.0 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/release/dev/kustoWorker.js +16 -16
- package/release/esm/languageService/kustoLanguageService.js +16 -16
- package/release/esm/monaco.d.ts +21 -4
- package/release/min/kustoMode.js +1 -1
- package/release/min/kustoWorker.js +2 -2
- package/release/min/monaco.contribution.js +1 -1
- package/release/min/monaco.d.ts +21 -4
package/package.json
CHANGED
|
@@ -6535,6 +6535,8 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
6535
6535
|
*/
|
|
6536
6536
|
set: function (globalState) {
|
|
6537
6537
|
this.__kustoJsSchemaV2 = globalState;
|
|
6538
|
+
this._clustersSetInGlobalState.clear();
|
|
6539
|
+
this._nonEmptyDatabaseSetInGlobalState.clear();
|
|
6538
6540
|
// create 2 Sets with cluster names and database names based on the updated Global State.
|
|
6539
6541
|
for (var i = 0; i < globalState.Clusters.Count; i++) {
|
|
6540
6542
|
var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
|
|
@@ -6775,14 +6777,14 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
6775
6777
|
// Keep only unique clusters that aren't already exist in the Global State
|
|
6776
6778
|
for (var i = 0; i < clusterReferences.Count; i++) {
|
|
6777
6779
|
var clusterReference = clusterReferences.getItem(i);
|
|
6778
|
-
var clusterHostName = clusterReference.Cluster;
|
|
6780
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
|
|
6779
6781
|
// ignore duplicates
|
|
6780
6782
|
if (newClustersReferencesSet.has(clusterHostName)) {
|
|
6781
6783
|
continue;
|
|
6782
6784
|
}
|
|
6783
6785
|
newClustersReferencesSet.add(clusterHostName);
|
|
6784
6786
|
// ignore references that are already in the GlobalState.
|
|
6785
|
-
if (!this._clustersSetInGlobalState.has(clusterHostName
|
|
6787
|
+
if (!this._clustersSetInGlobalState.has(clusterHostName)) {
|
|
6786
6788
|
newClustersReferences.push({ clusterName: clusterHostName });
|
|
6787
6789
|
}
|
|
6788
6790
|
}
|
|
@@ -6800,8 +6802,9 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
6800
6802
|
var newDatabasesReferencesSet = new Set();
|
|
6801
6803
|
for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
|
|
6802
6804
|
var databaseReference = databasesReferences.getItem(i1);
|
|
6805
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
|
|
6803
6806
|
// ignore duplicates
|
|
6804
|
-
var databaseReferenceUniqueId = this.createDatabaseUniqueName(
|
|
6807
|
+
var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
|
|
6805
6808
|
if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
|
|
6806
6809
|
continue;
|
|
6807
6810
|
}
|
|
@@ -6983,19 +6986,16 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
|
|
|
6983
6986
|
return Promise.resolve();
|
|
6984
6987
|
};
|
|
6985
6988
|
KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
|
|
6986
|
-
var
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
|
|
6996
|
-
_this._script = k2.CodeScript.From$1(document.getText(), _this._kustoJsSchemaV2);
|
|
6997
|
-
resolve();
|
|
6998
|
-
});
|
|
6989
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
|
|
6990
|
+
var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
|
|
6991
|
+
if (!cluster) {
|
|
6992
|
+
cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
|
|
6993
|
+
}
|
|
6994
|
+
var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
|
|
6995
|
+
cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
|
|
6996
|
+
this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
|
|
6997
|
+
this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
|
|
6998
|
+
return Promise.resolve();
|
|
6999
6999
|
};
|
|
7000
7000
|
KustoLanguageService.prototype.setSchema = function (schema) {
|
|
7001
7001
|
var _this = this;
|
|
@@ -273,6 +273,8 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
273
273
|
*/
|
|
274
274
|
set: function (globalState) {
|
|
275
275
|
this.__kustoJsSchemaV2 = globalState;
|
|
276
|
+
this._clustersSetInGlobalState.clear();
|
|
277
|
+
this._nonEmptyDatabaseSetInGlobalState.clear();
|
|
276
278
|
// create 2 Sets with cluster names and database names based on the updated Global State.
|
|
277
279
|
for (var i = 0; i < globalState.Clusters.Count; i++) {
|
|
278
280
|
var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
|
|
@@ -513,14 +515,14 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
513
515
|
// Keep only unique clusters that aren't already exist in the Global State
|
|
514
516
|
for (var i = 0; i < clusterReferences.Count; i++) {
|
|
515
517
|
var clusterReference = clusterReferences.getItem(i);
|
|
516
|
-
var clusterHostName = clusterReference.Cluster;
|
|
518
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
|
|
517
519
|
// ignore duplicates
|
|
518
520
|
if (newClustersReferencesSet.has(clusterHostName)) {
|
|
519
521
|
continue;
|
|
520
522
|
}
|
|
521
523
|
newClustersReferencesSet.add(clusterHostName);
|
|
522
524
|
// ignore references that are already in the GlobalState.
|
|
523
|
-
if (!this._clustersSetInGlobalState.has(clusterHostName
|
|
525
|
+
if (!this._clustersSetInGlobalState.has(clusterHostName)) {
|
|
524
526
|
newClustersReferences.push({ clusterName: clusterHostName });
|
|
525
527
|
}
|
|
526
528
|
}
|
|
@@ -538,8 +540,9 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
538
540
|
var newDatabasesReferencesSet = new Set();
|
|
539
541
|
for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
|
|
540
542
|
var databaseReference = databasesReferences.getItem(i1);
|
|
543
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
|
|
541
544
|
// ignore duplicates
|
|
542
|
-
var databaseReferenceUniqueId = this.createDatabaseUniqueName(
|
|
545
|
+
var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
|
|
543
546
|
if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
|
|
544
547
|
continue;
|
|
545
548
|
}
|
|
@@ -721,19 +724,16 @@ var KustoLanguageService = /** @class */ (function () {
|
|
|
721
724
|
return Promise.resolve();
|
|
722
725
|
};
|
|
723
726
|
KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
|
|
724
|
-
var
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
_this._script = k2.CodeScript.From$1(document.getText(), _this._kustoJsSchemaV2);
|
|
735
|
-
resolve();
|
|
736
|
-
});
|
|
727
|
+
var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterName);
|
|
728
|
+
var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterHostName);
|
|
729
|
+
if (!cluster) {
|
|
730
|
+
cluster = new sym.ClusterSymbol.$ctor1(clusterHostName, null, false);
|
|
731
|
+
}
|
|
732
|
+
var databaseSymbol = KustoLanguageService.convertToDatabaseSymbol(databaseSchema);
|
|
733
|
+
cluster = cluster.AddOrUpdateDatabase(databaseSymbol);
|
|
734
|
+
this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
|
|
735
|
+
this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
|
|
736
|
+
return Promise.resolve();
|
|
737
737
|
};
|
|
738
738
|
KustoLanguageService.prototype.setSchema = function (schema) {
|
|
739
739
|
var _this = this;
|
package/release/esm/monaco.d.ts
CHANGED
|
@@ -121,29 +121,46 @@ declare module monaco.languages.kusto {
|
|
|
121
121
|
setParameters(parameters: ScalarParameter[]): void;
|
|
122
122
|
/**
|
|
123
123
|
* Get all the database references from the current command.
|
|
124
|
-
* If database's schema is already cached it will not be returned.
|
|
124
|
+
* If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
|
|
125
125
|
* This method should be used to get all the cross-databases in a command, then schema for the database should be fetched and added with addDatabaseToSchema.
|
|
126
126
|
* @example
|
|
127
127
|
* If the current command includes: cluster('help').database('Samples')
|
|
128
|
-
*
|
|
128
|
+
* getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
|
|
129
129
|
*/
|
|
130
130
|
getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
|
|
131
131
|
/**
|
|
132
132
|
* Get all the cluster references from the current command.
|
|
133
133
|
* If cluster's schema is already cached it will not be returned.
|
|
134
134
|
* This method should be used to get all the cross-clusters in a command, then schema for the cluster should be fetched and added with addClusterToSchema.
|
|
135
|
+
* cluster name is returned exactly as written in the KQL `cluster(<cluster name>)` function.
|
|
135
136
|
* @example
|
|
136
137
|
* If the current command includes: cluster('help')
|
|
137
138
|
* it returns [{ clusterName: 'help' }]
|
|
139
|
+
* @example
|
|
140
|
+
* If the current command includes: cluster('https://demo11.westus.kusto.windows.net')
|
|
141
|
+
* getClusterReferences will return [{ clusterName: 'https://demo11.westus.kusto.windows.net' }]
|
|
138
142
|
*/
|
|
139
143
|
getClusterReferences(uri: string, cursorOffset: number): Promise<ClusterReference[]>;
|
|
140
144
|
/**
|
|
141
145
|
* Adds a database's scheme. Useful with getDatabaseReferences to load schema for cross-cluster commands.
|
|
146
|
+
* @param clusterName the name of the cluster as returned from getDatabaseReferences/getClusterReferences.
|
|
147
|
+
* @example
|
|
148
|
+
* - User enters cluster('help').database('Samples')
|
|
149
|
+
* - hosting app calls getDatabaseReferences which returns [{ clusterName: 'help', databaseName: 'Samples' }].
|
|
150
|
+
* - hosting app fetches the database Schema from https://help.kusto.windows.net
|
|
151
|
+
* - hosting app calls 'addDatabaseToSchema' with the database's schema.
|
|
152
|
+
* - now, when user types cluster('help').database('Samples') then the auto complete list will show all the tables.
|
|
142
153
|
*/
|
|
143
154
|
addDatabaseToSchema(uri: string, clusterName: string, databaseSchema: Database): Promise<void>;
|
|
144
155
|
/**
|
|
145
|
-
* Adds a cluster's
|
|
146
|
-
*
|
|
156
|
+
* Adds a cluster's databases to the schema. Useful when used with getClusterReferences in cross-cluster commands.
|
|
157
|
+
* @param clusterName the name of the cluster as returned in getClusterReferences.
|
|
158
|
+
* @example
|
|
159
|
+
* - User enters cluster('help')
|
|
160
|
+
* - hosting app calls getClusterReferences which returns [{ clusterName: 'help' }].
|
|
161
|
+
* - hosting app fetches the list of databases from https://help.kusto.windows.net
|
|
162
|
+
* - hosting app calls addClusterToSchema with the list of databases.
|
|
163
|
+
* - now, when user type `cluster('help').database(` then the auto complete list will show all the databases.
|
|
147
164
|
*/
|
|
148
165
|
addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
|
|
149
166
|
}
|
package/release/min/kustoMode.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 4.1.
|
|
3
|
+
* monaco-kusto version: 4.1.1(undefined)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 4.1.
|
|
3
|
+
* monaco-kusto version: 4.1.1(undefined)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|
|
@@ -57,4 +57,4 @@ d.exports=function(e){"use strict";if(!e.addUnicodeData)throw new ReferenceError
|
|
|
57
57
|
* <xregexp.com>
|
|
58
58
|
* Steven Levithan (c) 2007-2017 MIT License
|
|
59
59
|
*/
|
|
60
|
-
var n={astral:!1,natives:!1},t={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},a={},r={},i={},o=[],c={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/},f=/\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g,s=void 0===t.exec.call(/()??/,"")[1],l=void 0!==/x/.flags,m={}.toString;function p(e){var d=!0;try{new RegExp("",e)}catch(e){d=!1}return d}var b=p("u"),g=p("y"),h={g:!0,i:!0,m:!0,u:b,y:g};function v(e,d,u,n,t){var a;if(e.xregexp={captureNames:d},t)return e;if(e.__proto__)e.__proto__=O.prototype;else for(a in O.prototype)e[a]=O.prototype[a];return e.xregexp.source=u,e.xregexp.flags=n?n.split("").sort().join(""):n,e}function y(e){return t.replace.call(e,/([\s\S])(?=[\s\S]*\1)/g,"")}function C(e,d){if(!O.isRegExp(e))throw new TypeError("Type RegExp expected");var u=e.xregexp||{},n=function(e){return l?e.flags:t.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(e))[1]}(e),a="",r="",i=null,o=null;return(d=d||{}).removeG&&(r+="g"),d.removeY&&(r+="y"),r&&(n=t.replace.call(n,new RegExp("["+r+"]+","g"),"")),d.addG&&(a+="g"),d.addY&&(a+="y"),a&&(n=y(n+a)),d.isInternalOnly||(void 0!==u.source&&(i=u.source),null!=u.flags&&(o=a?y(u.flags+a):u.flags)),e=v(new RegExp(d.source||e.source,n),function(e){return!(!e.xregexp||!e.xregexp.captureNames)}(e)?u.captureNames.slice(0):null,i,o,d.isInternalOnly)}function _(e){return parseInt(e,16)}function S(e,d,u){return"("===e.input.charAt(e.index-1)||")"===e.input.charAt(e.index+e[0].length)||function(e,d,u,n){var a=u.indexOf("x")>-1?["\\s","#[^#\\n]*","\\(\\?#[^)]*\\)"]:["\\(\\?#[^)]*\\)"];return t.test.call(new RegExp("^(?:"+a.join("|")+")*(?:"+n+")"),e.slice(d))}(e.input,e.index+e[0].length,u,"[?*+]|{\\d+(?:,\\d*)?}")?"":"(?:)"}function I(e){return parseInt(e,10).toString(16)}function x(e,d){var u,n=e.length;for(u=0;u<n;++u)if(e[u]===d)return u;return-1}function T(e,d){return m.call(e)==="[object "+d+"]"}function K(e){for(;e.length<4;)e="0"+e;return e}function P(e){var d={};return T(e,"String")?(O.forEach(e,/[^\s,]+/,(function(e){d[e]=!0})),d):e}function k(e){if(!/^[\w$]$/.test(e))throw new Error("Flag must be a single character A-Za-z0-9_$");h[e]=!0}function E(e,d,u,n,t){for(var a,r,i=o.length,c=e.charAt(u),f=null;i--;)if(!((r=o[i]).leadChar&&r.leadChar!==c||r.scope!==n&&"all"!==r.scope||r.flag&&-1===d.indexOf(r.flag))&&(a=O.exec(e,r.regex,u,"sticky"))){f={matchLength:a[0].length,output:r.handler.call(t,a,n,d),reparse:r.reparse};break}return f}function w(e){n.astral=e}function A(e){RegExp.prototype.exec=(e?a:t).exec,RegExp.prototype.test=(e?a:t).test,String.prototype.match=(e?a:t).match,String.prototype.replace=(e?a:t).replace,String.prototype.split=(e?a:t).split,n.natives=e}function D(e){if(null==e)throw new TypeError("Cannot convert null or undefined to object");return e}function O(e,d){if(O.isRegExp(e)){if(void 0!==d)throw new TypeError("Cannot supply flags when copying a RegExp");return C(e)}if(e=void 0===e?"":String(e),d=void 0===d?"":String(d),O.isInstalled("astral")&&-1===d.indexOf("A")&&(d+="A"),i[e]||(i[e]={}),!i[e][d]){for(var u,n={hasNamedCapture:!1,captureNames:[]},a="default",r="",o=0,f=function(e,d){var u;if(y(d)!==d)throw new SyntaxError("Invalid duplicate regex flag "+d);for(e=t.replace.call(e,/^\(\?([\w$]+)\)/,(function(e,u){if(t.test.call(/[gy]/,u))throw new SyntaxError("Cannot use flag g or y in mode modifier "+e);return d=y(d+u),""})),u=0;u<d.length;++u)if(!h[d.charAt(u)])throw new SyntaxError("Unknown regex flag "+d.charAt(u));return{pattern:e,flags:d}}(e,d),s=f.pattern,l=f.flags;o<s.length;){do{(u=E(s,l,o,a,n))&&u.reparse&&(s=s.slice(0,o)+u.output+s.slice(o+u.matchLength))}while(u&&u.reparse);if(u)r+=u.output,o+=u.matchLength||1;else{var m=O.exec(s,c[a],o,"sticky")[0];r+=m,o+=m.length,"["===m&&"default"===a?a="class":"]"===m&&"class"===a&&(a="default")}}i[e][d]={pattern:t.replace.call(r,/(?:\(\?:\))+/g,"(?:)"),flags:t.replace.call(l,/[^gimuy]+/g,""),captures:n.hasNamedCapture?n.captureNames:null}}var p=i[e][d];return v(new RegExp(p.pattern,p.flags),p.captures,e,d)}O.prototype=new RegExp,O.version="3.2.0",O._clipDuplicates=y,O._hasNativeFlag=p,O._dec=_,O._hex=I,O._pad4=K,O.addToken=function(e,d,u){var n,a=(u=u||{}).optionalFlags;if(u.flag&&k(u.flag),a)for(a=t.split.call(a,""),n=0;n<a.length;++n)k(a[n]);o.push({regex:C(e,{addG:!0,addY:g,isInternalOnly:!0}),handler:d,scope:u.scope||"default",flag:u.flag,reparse:u.reparse,leadChar:u.leadChar}),O.cache.flush("patterns")},O.cache=function(e,d){return r[e]||(r[e]={}),r[e][d]||(r[e][d]=O(e,d))},O.cache.flush=function(e){"patterns"===e?i={}:r={}},O.escape=function(e){return t.replace.call(D(e),/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},O.exec=function(e,d,u,n){var t,r,i,o="g",c=!1;return(t=g&&!!(n||d.sticky&&!1!==n))?o+="y":n&&(c=!0,o+="FakeY"),d.xregexp=d.xregexp||{},u=u||0,(i=d.xregexp[o]||(d.xregexp[o]=C(d,{addG:!0,addY:t,source:c?d.source+"|()":void 0,removeY:!1===n,isInternalOnly:!0}))).lastIndex=u,r=a.exec.call(i,e),c&&r&&""===r.pop()&&(r=null),d.global&&(d.lastIndex=r?i.lastIndex:0),r},O.forEach=function(e,d,u){for(var n,t=0,a=-1;n=O.exec(e,d,t);)u(n,++a,e,d),t=n.index+(n[0].length||1)},O.globalize=function(e){return C(e,{addG:!0})},O.install=function(e){e=P(e),!n.astral&&e.astral&&w(!0),!n.natives&&e.natives&&A(!0)},O.isInstalled=function(e){return!!n[e]},O.isRegExp=function(e){return"[object RegExp]"===m.call(e)},O.match=function(e,d,u){var n,a,r=d.global&&"one"!==u||"all"===u,i=(r?"g":"")+(d.sticky?"y":"")||"noGY";return d.xregexp=d.xregexp||{},a=d.xregexp[i]||(d.xregexp[i]=C(d,{addG:!!r,removeG:"one"===u,isInternalOnly:!0})),n=t.match.call(D(e),a),d.global&&(d.lastIndex="one"===u&&n?n.index+n[0].length:0),r?n||[]:n&&n[0]},O.matchChain=function(e,d){return function e(u,n){var t=d[n].regex?d[n]:{regex:d[n]},a=[];function r(e){if(t.backref){if(!(e.hasOwnProperty(t.backref)||+t.backref<e.length))throw new ReferenceError("Backreference to undefined group: "+t.backref);a.push(e[t.backref]||"")}else a.push(e[0])}for(var i=0;i<u.length;++i)O.forEach(u[i],t.regex,r);return n!==d.length-1&&a.length?e(a,n+1):a}([e],0)},O.replace=function(e,d,u,n){var t,r=O.isRegExp(d),i=d.global&&"one"!==n||"all"===n,o=(i?"g":"")+(d.sticky?"y":"")||"noGY",c=d;return r?(d.xregexp=d.xregexp||{},c=d.xregexp[o]||(d.xregexp[o]=C(d,{addG:!!i,removeG:"one"===n,isInternalOnly:!0}))):i&&(c=new RegExp(O.escape(String(d)),"g")),t=a.replace.call(D(e),c,u),r&&d.global&&(d.lastIndex=0),t},O.replaceEach=function(e,d){var u,n;for(u=0;u<d.length;++u)n=d[u],e=O.replace(e,n[0],n[1],n[2]);return e},O.split=function(e,d,u){return a.split.call(D(e),d,u)},O.test=function(e,d,u,n){return!!O.exec(e,d,u,n)},O.uninstall=function(e){e=P(e),n.astral&&e.astral&&w(!1),n.natives&&e.natives&&A(!1)},O.union=function(e,d,u){var n,a,r=(u=u||{}).conjunction||"or",i=0;function o(e,d,u){var t=a[i-n];if(d){if(++i,t)return"(?<"+t+">"}else if(u)return"\\"+(+u+n);return e}if(!T(e,"Array")||!e.length)throw new TypeError("Must provide a nonempty array of patterns to merge");for(var c,f=/(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g,s=[],l=0;l<e.length;++l)c=e[l],O.isRegExp(c)?(n=i,a=c.xregexp&&c.xregexp.captureNames||[],s.push(t.replace.call(O(c.source).source,f,o))):s.push(O.escape(c));var m="none"===r?"":"|";return O(s.join(m),d)},a.exec=function(e){var d,u,n,a=this.lastIndex,r=t.exec.apply(this,arguments);if(r){if(!s&&r.length>1&&x(r,"")>-1&&(u=C(this,{removeG:!0,isInternalOnly:!0}),t.replace.call(String(e).slice(r.index),u,(function(){var e,d=arguments.length;for(e=1;e<d-2;++e)void 0===arguments[e]&&(r[e]=void 0)}))),this.xregexp&&this.xregexp.captureNames)for(n=1;n<r.length;++n)(d=this.xregexp.captureNames[n-1])&&(r[d]=r[n]);this.global&&!r[0].length&&this.lastIndex>r.index&&(this.lastIndex=r.index)}return this.global||(this.lastIndex=a),r},a.test=function(e){return!!a.exec.call(this,e)},a.match=function(e){var d;if(O.isRegExp(e)){if(e.global)return d=t.match.apply(this,arguments),e.lastIndex=0,d}else e=new RegExp(e);return a.exec.call(e,D(this))},a.replace=function(e,d){var u,n,a,r=O.isRegExp(e);return r?(e.xregexp&&(n=e.xregexp.captureNames),u=e.lastIndex):e+="",a=T(d,"Function")?t.replace.call(String(this),e,(function(){var u,t=arguments;if(n)for(t[0]=new String(t[0]),u=0;u<n.length;++u)n[u]&&(t[0][n[u]]=t[u+1]);return r&&e.global&&(e.lastIndex=t[t.length-2]+t[0].length),d.apply(void 0,t)})):t.replace.call(null==this?this:String(this),e,(function(){var e=arguments;return t.replace.call(String(d),f,(function(d,u,t){var a;if(u){if((a=+u)<=e.length-3)return e[a]||"";if((a=n?x(n,u):-1)<0)throw new SyntaxError("Backreference to undefined group "+d);return e[a+1]||""}if("$"===t)return"$";if("&"===t||0==+t)return e[0];if("`"===t)return e[e.length-1].slice(0,e[e.length-2]);if("'"===t)return e[e.length-1].slice(e[e.length-2]+e[0].length);if(t=+t,!isNaN(t)){if(t>e.length-3)throw new SyntaxError("Backreference to undefined group "+d);return e[t]||""}throw new SyntaxError("Invalid token "+d)}))})),r&&(e.global?e.lastIndex=0:e.lastIndex=u),a},a.split=function(e,d){if(!O.isRegExp(e))return t.split.apply(this,arguments);var u,n=String(this),a=[],r=e.lastIndex,i=0;return d=(void 0===d?-1:d)>>>0,O.forEach(n,e,(function(e){e.index+e[0].length>i&&(a.push(n.slice(i,e.index)),e.length>1&&e.index<n.length&&Array.prototype.push.apply(a,e.slice(1)),u=e[0].length,i=e.index+u)})),i===n.length?t.test.call(e,"")&&!u||a.push(""):a.push(n.slice(i)),e.lastIndex=r,a.length>d?a.slice(0,d):a},O.addToken(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/,(function(e,d){if("B"===e[1]&&"default"===d)return e[0];throw new SyntaxError("Invalid escape "+e[0])}),{scope:"all",leadChar:"\\"}),O.addToken(/\\u{([\dA-Fa-f]+)}/,(function(e,d,u){var n=_(e[1]);if(n>1114111)throw new SyntaxError("Invalid Unicode code point "+e[0]);if(n<=65535)return"\\u"+K(I(n));if(b&&u.indexOf("u")>-1)return e[0];throw new SyntaxError("Cannot use Unicode code point above \\u{FFFF} without flag u")}),{scope:"all",leadChar:"\\"}),O.addToken(/\[(\^?)\]/,(function(e){return e[1]?"[\\s\\S]":"\\b\\B"}),{leadChar:"["}),O.addToken(/\(\?#[^)]*\)/,S,{leadChar:"("}),O.addToken(/\s+|#[^\n]*\n?/,S,{flag:"x"}),O.addToken(/\./,(function(){return"[\\s\\S]"}),{flag:"s",leadChar:"."}),O.addToken(/\\k<([\w$]+)>/,(function(e){var d=isNaN(e[1])?x(this.captureNames,e[1])+1:+e[1],u=e.index+e[0].length;if(!d||d>this.captureNames.length)throw new SyntaxError("Backreference to undefined group "+e[0]);return"\\"+d+(u===e.input.length||isNaN(e.input.charAt(u))?"":"(?:)")}),{leadChar:"\\"}),O.addToken(/\\(\d+)/,(function(e,d){if(!("default"===d&&/^[1-9]/.test(e[1])&&+e[1]<=this.captureNames.length)&&"0"!==e[1])throw new SyntaxError("Cannot use octal escape or backreference to undefined group "+e[0]);return e[0]}),{scope:"all",leadChar:"\\"}),O.addToken(/\(\?P?<([\w$]+)>/,(function(e){if(!isNaN(e[1]))throw new SyntaxError("Cannot use integer as capture name "+e[0]);if("length"===e[1]||"__proto__"===e[1])throw new SyntaxError("Cannot use reserved word as capture name "+e[0]);if(x(this.captureNames,e[1])>-1)throw new SyntaxError("Cannot use same name for multiple groups "+e[0]);return this.captureNames.push(e[1]),this.hasNamedCapture=!0,"("}),{leadChar:"("}),O.addToken(/\((?!\?)/,(function(e,d,u){return u.indexOf("n")>-1?"(?:":(this.captureNames.push(null),"(")}),{optionalFlags:"n",leadChar:"("}),d.exports=O},{}]},{},[8])(8)})),define("xregexp",["xregexp/xregexp-all"],(function(e){return e}));var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var d,u=1,n=arguments.length;u<n;u++)for(var t in d=arguments[u])Object.prototype.hasOwnProperty.call(d,t)&&(e[t]=d[t]);return e}).apply(this,arguments)};define("vs/language/kusto/languageService/kustoLanguageService",["require","exports","./schema","vscode-languageserver-types","xregexp","./schema"],(function(e,d,u,n,t,a){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.getKustoLanguageService=d.TokenKind=void 0,String.prototype.endsWith||(String.prototype.endsWith=function(e,d){return(void 0===d||d>this.length)&&(d=this.length),this.substring(d-e.length,d)===e}),"undefined"==typeof document&&(importScripts("../../language/kusto/bridge.min.js"),importScripts("../../language/kusto/kusto.javascript.client.min.js"),importScripts("../../language/kusto/Kusto.Language.Bridge.min.js"));var r=Kusto.Data.IntelliSense,i=Kusto.Language.Parsing,o=Kusto.Language.Editor,c=Kusto.Language.Symbols,f=Kusto.Language.GlobalState,s=System.Collections.Generic.List$1;function l(e){throw new Error("Unexpected object: "+e)}var m,p=function(){function e(e,d,u,n){this.version=e,this.uri=d,this.rulesProvider=u,this.parseMode=n}return e.prototype.isParseNeeded=function(e,d,u){return!(e.uri===this.uri&&(!d||d===this.rulesProvider)&&e.version<=this.version&&u&&u<=this.parseMode)},e}();function b(e){return e.map((function(e){return{start:e.Start,end:e.End,length:e.Length,kind:e.Kind}}))}!function(e){e[e.TableToken=2]="TableToken",e[e.TableColumnToken=4]="TableColumnToken",e[e.OperatorToken=8]="OperatorToken",e[e.SubOperatorToken=16]="SubOperatorToken",e[e.CalculatedColumnToken=32]="CalculatedColumnToken",e[e.StringLiteralToken=64]="StringLiteralToken",e[e.FunctionNameToken=128]="FunctionNameToken",e[e.UnknownToken=256]="UnknownToken",e[e.CommentToken=512]="CommentToken",e[e.PlainTextToken=1024]="PlainTextToken",e[e.DataTypeToken=2048]="DataTypeToken",e[e.ControlCommandToken=4096]="ControlCommandToken",e[e.CommandPartToken=8192]="CommandPartToken",e[e.QueryParametersToken=16384]="QueryParametersToken",e[e.CslCommandToken=32768]="CslCommandToken",e[e.LetVariablesToken=65536]="LetVariablesToken",e[e.PluginToken=131072]="PluginToken",e[e.BracketRangeToken=262144]="BracketRangeToken",e[e.ClientDirectiveToken=524288]="ClientDirectiveToken"}(m=d.TokenKind||(d.TokenKind={}));var g=function(){function e(d,u){var t,a,i,c,f=this;this._toOptionKind=((t={})[o.CompletionKind.AggregateFunction]=r.OptionKind.FunctionAggregation,t[o.CompletionKind.BuiltInFunction]=r.OptionKind.FunctionServerSide,t[o.CompletionKind.Cluster]=r.OptionKind.Database,t[o.CompletionKind.Column]=r.OptionKind.Column,t[o.CompletionKind.CommandPrefix]=r.OptionKind.None,t[o.CompletionKind.Database]=r.OptionKind.Database,t[o.CompletionKind.DatabaseFunction]=r.OptionKind.FunctionServerSide,t[o.CompletionKind.Example]=r.OptionKind.None,t[o.CompletionKind.Identifier]=r.OptionKind.None,t[o.CompletionKind.Keyword]=r.OptionKind.None,t[o.CompletionKind.LocalFunction]=r.OptionKind.FunctionLocal,t[o.CompletionKind.MaterialiedView]=r.OptionKind.MaterializedView,t[o.CompletionKind.Parameter]=r.OptionKind.Parameter,t[o.CompletionKind.Punctuation]=r.OptionKind.None,t[o.CompletionKind.QueryPrefix]=r.OptionKind.Operator,t[o.CompletionKind.RenderChart]=r.OptionKind.Operator,t[o.CompletionKind.ScalarInfix]=r.OptionKind.None,t[o.CompletionKind.ScalarPrefix]=r.OptionKind.None,t[o.CompletionKind.ScalarType]=r.OptionKind.DataType,t[o.CompletionKind.Syntax]=r.OptionKind.None,t[o.CompletionKind.Table]=r.OptionKind.Table,t[o.CompletionKind.TabularPrefix]=r.OptionKind.None,t[o.CompletionKind.TabularSuffix]=r.OptionKind.None,t[o.CompletionKind.Unknown]=r.OptionKind.None,t[o.CompletionKind.Variable]=r.OptionKind.Parameter,t[o.CompletionKind.Option]=r.OptionKind.Option,t),this.disabledCompletionItemsV2={ladderchart:o.CompletionKind.RenderChart,pivotchart:o.CompletionKind.RenderChart,timeline:o.CompletionKind.RenderChart,timepivot:o.CompletionKind.RenderChart,"3Dchart":o.CompletionKind.RenderChart,list:o.CompletionKind.RenderChart},this.isIntellisenseV2=function(){return f._languageSettings.useIntellisenseV2&&f._schema&&"Engine"===f._schema.clusterType},this.disabledCompletionItemsV1={capacity:r.OptionKind.Policy,callout:r.OptionKind.Policy,encoding:r.OptionKind.Policy,batching:r.OptionKind.Policy,querythrottling:r.OptionKind.Policy,merge:r.OptionKind.Policy,querylimit:r.OptionKind.Policy,rowstore:r.OptionKind.Policy,streamingingestion:r.OptionKind.Policy,restricted_view_access:r.OptionKind.Policy,sharding:r.OptionKind.Policy,"restricted-viewers":r.OptionKind.Policy,attach:r.OptionKind.Command,purge:r.OptionKind.Command},this._kustoKindtolsKind=((a={})[r.OptionKind.None]=n.CompletionItemKind.Interface,a[r.OptionKind.Operator]=n.CompletionItemKind.Method,a[r.OptionKind.Command]=n.CompletionItemKind.Method,a[r.OptionKind.Service]=n.CompletionItemKind.Class,a[r.OptionKind.Policy]=n.CompletionItemKind.Reference,a[r.OptionKind.Database]=n.CompletionItemKind.Class,a[r.OptionKind.Table]=n.CompletionItemKind.Class,a[r.OptionKind.DataType]=n.CompletionItemKind.Class,a[r.OptionKind.Literal]=n.CompletionItemKind.Property,a[r.OptionKind.Parameter]=n.CompletionItemKind.Variable,a[r.OptionKind.IngestionMapping]=n.CompletionItemKind.Variable,a[r.OptionKind.ExpressionFunction]=n.CompletionItemKind.Variable,a[r.OptionKind.Option]=n.CompletionItemKind.Interface,a[r.OptionKind.OptionKind]=n.CompletionItemKind.Interface,a[r.OptionKind.OptionRender]=n.CompletionItemKind.Interface,a[r.OptionKind.Column]=n.CompletionItemKind.Function,a[r.OptionKind.ColumnString]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnNumeric]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnDateTime]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnTimespan]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionServerSide]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionAggregation]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionFilter]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionScalar]=n.CompletionItemKind.Field,a[r.OptionKind.ClientDirective]=n.CompletionItemKind.Enum,a),this._kustoKindToLsKindV2=((i={})[o.CompletionKind.AggregateFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.BuiltInFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.Cluster]=n.CompletionItemKind.Class,i[o.CompletionKind.Column]=n.CompletionItemKind.Function,i[o.CompletionKind.CommandPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.Database]=n.CompletionItemKind.Class,i[o.CompletionKind.DatabaseFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.Example]=n.CompletionItemKind.Text,i[o.CompletionKind.Identifier]=n.CompletionItemKind.Method,i[o.CompletionKind.Keyword]=n.CompletionItemKind.Method,i[o.CompletionKind.LocalFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.MaterialiedView]=n.CompletionItemKind.Class,i[o.CompletionKind.Parameter]=n.CompletionItemKind.Variable,i[o.CompletionKind.Punctuation]=n.CompletionItemKind.Interface,i[o.CompletionKind.QueryPrefix]=n.CompletionItemKind.Function,i[o.CompletionKind.RenderChart]=n.CompletionItemKind.Method,i[o.CompletionKind.ScalarInfix]=n.CompletionItemKind.Field,i[o.CompletionKind.ScalarPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.ScalarType]=n.CompletionItemKind.TypeParameter,i[o.CompletionKind.Syntax]=n.CompletionItemKind.Method,i[o.CompletionKind.Table]=n.CompletionItemKind.Class,i[o.CompletionKind.TabularPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.TabularSuffix]=n.CompletionItemKind.Field,i[o.CompletionKind.Unknown]=n.CompletionItemKind.Interface,i[o.CompletionKind.Variable]=n.CompletionItemKind.Variable,i[o.CompletionKind.Option]=n.CompletionItemKind.Text,i),this._tokenKindToClassificationKind=((c={})[m.TableToken]=o.ClassificationKind.Table,c[m.TableColumnToken]=o.ClassificationKind.Column,c[m.OperatorToken]=o.ClassificationKind.QueryOperator,c[m.SubOperatorToken]=o.ClassificationKind.Function,c[m.CalculatedColumnToken]=o.ClassificationKind.Column,c[m.StringLiteralToken]=o.ClassificationKind.Literal,c[m.FunctionNameToken]=o.ClassificationKind.Function,c[m.UnknownToken]=o.ClassificationKind.PlainText,c[m.CommentToken]=o.ClassificationKind.Comment,c[m.PlainTextToken]=o.ClassificationKind.PlainText,c[m.DataTypeToken]=o.ClassificationKind.Type,c[m.ControlCommandToken]=o.ClassificationKind.PlainText,c[m.CommandPartToken]=o.ClassificationKind.PlainText,c[m.QueryParametersToken]=o.ClassificationKind.QueryParameter,c[m.CslCommandToken]=o.ClassificationKind.Keyword,c[m.LetVariablesToken]=o.ClassificationKind.Identifier,c[m.PluginToken]=o.ClassificationKind.Function,c[m.BracketRangeToken]=o.ClassificationKind.Keyword,c[m.ClientDirectiveToken]=o.ClassificationKind.Keyword,c),this._schemaCache={},this._kustoJsSchema=e.convertToKustoJsSchema(d),this.__kustoJsSchemaV2=this.convertToKustoJsSchemaV2(d),this._schema=d,this._clustersSetInGlobalState=new Set,this._nonEmptyDatabaseSetInGlobalState=new Set,this.configure(u),this._newlineAppendPipePolicy=new Kusto.Data.IntelliSense.ApplyPolicy,this._newlineAppendPipePolicy.Text="\n| "}return e.prototype.createDatabaseUniqueName=function(e,d){return e+"_"+d},Object.defineProperty(e.prototype,"_kustoJsSchemaV2",{get:function(){return this.__kustoJsSchemaV2},set:function(e){this.__kustoJsSchemaV2=e;for(var d=0;d<e.Clusters.Count;d++){var u=this._kustoJsSchemaV2.Clusters.getItem(d);this._clustersSetInGlobalState.add(u.Name);for(var n=0;n<u.Databases.Count;n++){var t=u.Databases.getItem(n);t.Tables.Count>0&&this._nonEmptyDatabaseSetInGlobalState.add(this.createDatabaseUniqueName(u.Name,t.Name))}}},enumerable:!1,configurable:!0}),e.prototype.configure=function(e){this._languageSettings=e,this.createRulesProvider(this._kustoJsSchema,this._schema.clusterType)},e.prototype.doComplete=function(e,d){return this.isIntellisenseV2()?this.doCompleteV2(e,d):this.doCompleteV1(e,d)},e.prototype.debugGlobalState=function(e){console.log("globals.Clusters.Count: "+e.Clusters.Count);for(var d=0;d<e.Clusters.Count;d++){var u=e.Clusters.getItem(d);console.log("cluster: "+u.Name),console.log("cluster.Databases.Count: "+u.Databases.Count);for(var n=0;n<u.Databases.Count;n++){var t=u.Databases.getItem(n);console.log("cluster.database: ["+u.Name+"].["+t.Name+"]"),console.log("cluster.Databases.Tables.Count: "+t.Tables.Count);for(var a=0;a<t.Tables.Count;a++){var r=t.Tables.getItem(a);console.log("cluster.database.table: ["+u.Name+"].["+t.Name+"].["+r.Name+"]")}}}},e.prototype.doCompleteV2=function(e,d){var u=this;if(!e)return Promise.resolve(n.CompletionList.create([]));var t=this.parseDocumentV2(e),a=e.offsetAt(d),i=t.GetBlockAtPosition(a).Service.GetCompletionItems(a),c=this.disabledCompletionItemsV2;this._languageSettings.disabledCompletionItems&&this._languageSettings.disabledCompletionItems.map((function(e){c[e]=o.CompletionKind.Unknown}));var f=this.toArray(i.Items).filter((function(e){return!(e&&e.MatchText&&void 0!==c[e.MatchText]&&(c[e.MatchText]===o.CompletionKind.Unknown||c[e.MatchText]===e.Kind))})).map((function(d,t){var a=new r.CompletionOption(u._toOptionKind[d.Kind]||r.OptionKind.None,d.DisplayText),o=u.getTopic(a),c=d.AfterText&&d.AfterText.length>0?{textToInsert:d.EditText+"$0"+d.AfterText,format:n.InsertTextFormat.Snippet}:{textToInsert:d.EditText,format:n.InsertTextFormat.PlainText},f=c.textToInsert,s=c.format,l=n.CompletionItem.create(d.DisplayText),m=e.positionAt(i.EditStart),p=e.positionAt(i.EditStart+i.EditLength);return l.textEdit=n.TextEdit.replace(n.Range.create(m,p),f),l.sortText=u.getSortText(t+1),l.kind=u.kustoKindToLsKindV2(d.Kind),l.insertTextFormat=s,l.detail=o?o.ShortDescription:void 0,l.documentation=o?{value:o.LongDescription,kind:n.MarkupKind.Markdown}:void 0,l}));return Promise.resolve(n.CompletionList.create(f))},e.prototype.getTopic=function(e){if(e.Kind==r.OptionKind.FunctionScalar||e.Kind==r.OptionKind.FunctionAggregation){var d=e.Value.indexOf("(");d>=0&&(e=new r.CompletionOption(e.Kind,e.Value.substring(0,d)))}return r.CslDocumentation.Instance.GetTopic(e)},e.prototype.doCompleteV1=function(e,d){var u=this,t=e.offsetAt(d);this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var a=this.getCurrentCommand(e,t),i="";if(a){a.AbsoluteStart;this.parseTextV1(a.Text,r.ParseMode.TokenizeAllText);var o=t-a.AbsoluteStart;i=a.Text.substring(a.CslExpressionStartPosition,o)}var c=this.getCommandWithoutLastWord(i),f=this._rulesProvider.AnalyzeCommand$1(i,a).Context,s={v:null};this._rulesProvider.TryMatchAnyRule(c,s);var l=s.v;if(l){var m=this.toArray(l.GetCompletionOptions(f));this._languageSettings.newlineAfterPipe&&l.DefaultAfterApplyPolicy===Kusto.Data.IntelliSense.ApplyPolicy.AppendPipePolicy&&(l.DefaultAfterApplyPolicy=this._newlineAppendPipePolicy);var p=m.filter((function(e){return!(e&&e.Value&&u.disabledCompletionItemsV1[e.Value]===e.Kind)})).map((function(e,d){var t=u.getTextToInsert(l,e),a=t.insertText,i=t.insertTextFormat,o=r.CslDocumentation.Instance.GetTopic(e),c=n.CompletionItem.create(e.Value);return c.kind=u.kustoKindToLsKind(e.Kind),c.insertText=a,c.insertTextFormat=i,c.sortText=u.getSortText(d+1),c.detail=o?o.ShortDescription:void 0,c.documentation=o?{value:o.LongDescription,kind:n.MarkupKind.Markdown}:void 0,c}));return Promise.resolve(n.CompletionList.create(p))}return Promise.resolve(n.CompletionList.create([]))},e.prototype.doRangeFormat=function(e,d){if(!e)return Promise.resolve([]);var u=e.offsetAt(d.start),t=e.offsetAt(d.end),a=this.getFormattedCommandsInDocumentV2(e,u,t);return a.originalRange&&0!==a.formattedCommands.length?Promise.resolve([n.TextEdit.replace(a.originalRange,a.formattedCommands.join(""))]):Promise.resolve([])},e.prototype.doDocumentFormat=function(e){if(!e)return Promise.resolve([]);var d=e.positionAt(0),u=e.positionAt(e.getText().length),t=n.Range.create(d,u),a=this.getFormattedCommandsInDocumentV2(e).formattedCommands.join("");return Promise.resolve([n.TextEdit.replace(t,a)])},e.prototype.doCurrentCommandFormat=function(e,d){var u=e.offsetAt(d),n=this.createRange(e,u-1,u+1);return this.doRangeFormat(e,n)},e.prototype.doFolding=function(e){return e?this.getCommandsInDocument(e).then((function(d){return d.map((function(d){d.text.endsWith("\r\n")?d.absoluteEnd-=2:(d.text.endsWith("\r")||d.text.endsWith("\n"))&&--d.absoluteEnd;var u=e.positionAt(d.absoluteStart),n=e.positionAt(d.absoluteEnd);return{startLine:u.line,startCharacter:u.character,endLine:n.line,endCharacter:n.character}}))})):Promise.resolve([])},e.prototype.getClusterReferences=function(e,d){var u,n=this.parseDocumentV2(e),t=this.getCurrentCommandV2(n,d),a=null===(u=null==t?void 0:t.Service)||void 0===u?void 0:u.GetClusterReferences();if(!a)return Promise.resolve([]);for(var r=[],i=new Set,o=0;o<a.Count;o++){var c=a.getItem(o).Cluster;i.has(c)||(i.add(c),this._clustersSetInGlobalState.has(c.toLowerCase())||r.push({clusterName:c}))}return Promise.resolve(r)},e.prototype.getDatabaseReferences=function(e,d){var u,n=this.parseDocumentV2(e),t=this.getCurrentCommandV2(n,d),a=null===(u=null==t?void 0:t.Service)||void 0===u?void 0:u.GetDatabaseReferences();if(!a)return Promise.resolve([]);for(var r=[],i=new Set,o=0;o<a.Count;o++){var c=a.getItem(o),f=this.createDatabaseUniqueName(c.Cluster,c.Database);if(!i.has(f))i.add(f),this._nonEmptyDatabaseSetInGlobalState.has(f)||r.push({databaseName:c.Database,clusterName:c.Cluster})}return Promise.resolve(r)},e.prototype.doValidation=function(e,d){var u=this;if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var n=this.parseDocumentV2(e),t=this.toArray(n.Blocks);d.length>0&&(t=this.getAffectedBlocks(t,d));var a=t.map((function(e){var d=u.toArray(e.Service.GetDiagnostics());return d||[]})).reduce((function(e,d){return e.concat(d)}),[]),r=this.toLsDiagnostics(a,e);return Promise.resolve(r)},e.prototype.toLsDiagnostics=function(e,d){return e.filter((function(e){return e.HasLocation})).map((function(e){var u=d.positionAt(e.Start),t=d.positionAt(e.Start+e.Length),a=n.Range.create(u,t);return n.Diagnostic.create(a,e.Message,n.DiagnosticSeverity.Error)}))},e.prototype.doColorization=function(e,d){var u=this;if(!e||!this._languageSettings.useSemanticColorization)return Promise.resolve([]);if(!this.isIntellisenseV2()){if(d.length>0){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var n=this.toArray(this._parser.Results).filter((function(e){return!!e&&d.some((function(d){var u=d.start,n=d.end;return e.AbsoluteStart>=u&&e.AbsoluteStart<=n||u>=e.AbsoluteStart&&u<=e.AbsoluteEnd+1}))}));if(!n||0===n.length)return Promise.resolve([{classifications:[],absoluteStart:d[0].start,absoluteEnd:d[0].end}]);var t=n.map((function(e){return u.parseTextV1(e.Text,r.ParseMode.TokenizeAllText),{classifications:b(u.getClassificationsFromParseResult(e.AbsoluteStart)),absoluteStart:e.AbsoluteStart,absoluteEnd:e.AbsoluteEnd}}));return Promise.resolve(t)}this.parseDocumentV1(e,r.ParseMode.TokenizeAllText);var a=this.getClassificationsFromParseResult();return Promise.resolve([{classifications:b(a),absoluteStart:0,absoluteEnd:e.getText().length}])}var i=this.parseDocumentV2(e);if(d.length>0){var o=this.toArray(i.Blocks),c=this.getAffectedBlocks(o,d).map((function(e){return{classifications:b(u.toArray(e.Service.GetClassifications(e.Start,e.End).Classifications)),absoluteStart:e.Start,absoluteEnd:e.End}}));return Promise.resolve(c)}var f=this.toArray(i.Blocks).map((function(e){return u.toArray(e.Service.GetClassifications(e.Start,e.Length).Classifications)})).reduce((function(e,d){return e.concat(d)}),[]);return Promise.resolve([{classifications:b(f),absoluteStart:0,absoluteEnd:e.getText().length}])},e.prototype.getAffectedBlocks=function(e,d){return e.filter((function(e){return!!e&&d.some((function(d){var u=d.start,n=d.end;return e.Start>=u&&e.Start<=n||u>=e.Start&&u<=e.End+1}))}))},e.prototype.addClusterToSchema=function(d,u,n){var t=Kusto.Language.KustoFacts.GetHostName(u),a=this._kustoJsSchemaV2.GetCluster$1(t);if(a&&n.filter((function(e){return!a.GetDatabase(e)})).map((function(e){var d=new c.DatabaseSymbol.$ctor1(e,void 0,!1);a=a.AddDatabase(d)})),!a){var r=n.map((function(e){return new c.DatabaseSymbol.$ctor1(e,void 0,!1)})),i=e.toBridgeList(r);a=new c.ClusterSymbol.$ctor1(t,i,!1)}return this._kustoJsSchemaV2=this._kustoJsSchemaV2.AddOrReplaceCluster(a),this._script=o.CodeScript.From$1(d.getText(),this._kustoJsSchemaV2),Promise.resolve()},e.prototype.addDatabaseToSchema=function(d,u,n){var t=this;return new Promise((function(a){var r=Kusto.Language.KustoFacts.GetHostName(u),i=t._kustoJsSchemaV2.GetCluster$1(r);i||(i=new c.ClusterSymbol.$ctor1(r,null,!1));var f=e.convertToDatabaseSymbol(n);i=i.AddOrUpdateDatabase(f),t._kustoJsSchemaV2=t._kustoJsSchemaV2.AddOrReplaceCluster(i),t._script=o.CodeScript.From$1(d.getText(),t._kustoJsSchemaV2),a()}))},e.prototype.setSchema=function(d){var u=this;if(this._schema=d,this._languageSettings.useIntellisenseV2){var n=d&&"Engine"===d.clusterType?this.convertToKustoJsSchemaV2(d):null;this._kustoJsSchemaV2=n,this._script=void 0,this._parsePropertiesV2=void 0}return new Promise((function(n,t){var a=d?e.convertToKustoJsSchema(d):void 0;u._kustoJsSchema=a,u.createRulesProvider(a,d.clusterType),n(void 0)}))},e.prototype.setParameters=function(d){if(!this._languageSettings.useIntellisenseV2||"Engine"!==this._schema.clusterType)throw new Error("setParameters requires intellisense V2 and Engine cluster");this._schema.globalParameters=d;var u=d.map((function(d){return e.createParameterSymbol(d)}));return this._kustoJsSchemaV2=this._kustoJsSchemaV2.WithParameters(e.toBridgeList(u)),Promise.resolve(void 0)},e.prototype.setSchemaFromShowSchema=function(e,d,u,n){var t=this;return this.normalizeSchema(e,d,u).then((function(e){return t.setSchema(__assign(__assign({},e),{globalParameters:n}))}))},e.prototype.normalizeSchema=function(e,d,u){var n=Object.keys(e.Databases).map((function(d){return e.Databases[d]})).map((function(e){var d=e.Name,u=e.Tables,n=e.ExternalTables,t=e.MaterializedViews,a=e.Functions;return{name:d,minorVersion:e.MinorVersion,majorVersion:e.MajorVersion,tables:[].concat.apply([],[[u,"Table"],[t,"MaterializedView"],[n,"ExternalTable"]].filter((function(e){return e[0]})).map((function(e){var d=e[0],u=e[1];return Object.values(d).map((function(e){var d=e.Name,n=e.OrderedColumns;return{name:d,docstring:e.DocString,entityType:u,columns:n.map((function(e){var d=e.Name,u=(e.Type,e.DocString);return{name:d,type:e.CslType,docstring:u}}))}}))}))),functions:Object.keys(a).map((function(e){return a[e]})).map((function(e){return{name:e.Name,body:e.Body,docstring:e.DocString,inputParameters:e.InputParameters.map((function(e){return{name:e.Name,type:e.Type,cslType:e.CslType,cslDefaultValue:e.CslDefaultValue,columns:e.Columns?e.Columns.map((function(e){return{name:e.Name,type:e.Type,cslType:e.CslType}})):e.Columns}}))}}))}})),t={clusterType:"Engine",cluster:{connectionString:d,databases:n},database:n.filter((function(e){return e.name===u}))[0]};return Promise.resolve(t)},e.prototype.getSchema=function(){return Promise.resolve(this._schema)},e.prototype.getCommandInContext=function(e,d){return this.isIntellisenseV2()?this.getCommandInContextV2(e,d):this.getCommandInContextV1(e,d)},e.prototype.getCommandAndLocationInContext=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve(null);var u=this.parseDocumentV2(e),t=this.getCurrentCommandV2(u,d);if(!t)return Promise.resolve(null);var a=e.positionAt(t.Start),r=e.positionAt(t.End),i=n.Location.create(e.uri,n.Range.create(a,r)),o=t.Text;return Promise.resolve({text:o,location:i})},e.prototype.getCommandInContextV1=function(e,d){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var u=this.getCurrentCommand(e,d);return u?Promise.resolve(u.Text):Promise.resolve(null)},e.prototype.getCommandInContextV2=function(e,d){if(!e)return Promise.resolve(null);var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);return n?Promise.resolve(n.Text):Promise.resolve(null)},e.prototype.getCommandsInDocument=function(e){return e?this.isIntellisenseV2()?this.getCommandsInDocumentV2(e):this.getCommandsInDocumentV1(e):Promise.resolve([])},e.prototype.getCommandsInDocumentV1=function(e){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var d=this.toArray(this._parser.Results);return Promise.resolve(d.map((function(e){return{absoluteStart:e.AbsoluteStart,absoluteEnd:e.AbsoluteEnd,text:e.Text}})))},e.prototype.toPlacementStyle=function(e){if(e)switch(e){case"None":return o.PlacementStyle.None;case"NewLine":return o.PlacementStyle.NewLine;case"Smart":return o.PlacementStyle.Smart;default:throw new Error("Unknown PlacementStyle")}},e.prototype.getFormattedCommandsInDocumentV2=function(e,d,u){var n=this,t=this.parseDocumentV2(e),a=this.toArray(t.Blocks).filter((function(e){if(!e.Text||""==e.Text.trim())return!1;if(null==d||null==u)return!0;for(var n=e.End,t=e.Text,a=t.length-1;a>=0&&("\r"==t[a]||"\n"==t[a]);a--)n--;return e.Start>d&&e.Start<u||(n>d&&n<u||(e.Start<=d&&n>=u||void 0))}));return 0===a.length?{formattedCommands:[]}:{formattedCommands:a.map((function(e){var t,a,r=n._languageSettings.formatter,i=Kusto.Language.Editor.FormattingOptions.Default.WithIndentationSize(null!==(t=null==r?void 0:r.indentationSize)&&void 0!==t?t:4).WithInsertMissingTokens(!1).WithPipeOperatorStyle(null!==(a=n.toPlacementStyle(null==r?void 0:r.pipeOperatorStyle))&&void 0!==a?a:o.PlacementStyle.Smart).WithSemicolonStyle(Kusto.Language.Editor.PlacementStyle.None).WithBrackettingStyle(o.BrackettingStyle.Diagonal);return null==d||null==u||d===e.Start&&e.End,e.Service.GetFormattedText(i).Text})),originalRange:this.createRange(e,a[0].Start,a[a.length-1].End)}},e.prototype.getCommandsInDocumentV2=function(e){var d=this.parseDocumentV2(e),u=this.toArray(d.Blocks).filter((function(e){return""!=e.Text.trim()}));return Promise.resolve(u.map((function(e){return{absoluteStart:e.Start,absoluteEnd:e.End,text:e.Text}})))},e.prototype.getClientDirective=function(e){var d={v:null},u=r.CslCommandParser.IsClientDirective(e,d);return Promise.resolve({isClientDirective:u,directiveWithoutLeadingComments:d.v})},e.prototype.getAdminCommand=function(e){var d={v:null},u=r.CslCommandParser.IsAdminCommand$1(e,d);return Promise.resolve({isAdminCommand:u,adminCommandWithoutLeadingComments:d.v})},e.prototype.findDefinition=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),t=e.offsetAt(d),a=this.getCurrentCommandV2(u,t);if(!a)return Promise.resolve([]);var r=a.Service.GetRelatedElements(e.offsetAt(d)),i=this.toArray(r.Elements)[0];if(!i)return Promise.resolve([]);var o=e.positionAt(i.Start),c=e.positionAt(i.End),f=n.Range.create(o,c),s=n.Location.create(e.uri,f);return Promise.resolve([s])},e.prototype.findReferences=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),t=e.offsetAt(d),a=this.getCurrentCommandV2(u,t);if(!a)return Promise.resolve([]);var r=a.Service.GetRelatedElements(e.offsetAt(d)),i=this.toArray(r.Elements);if(!i||0==i.length)return Promise.resolve([]);var o=i.map((function(d){var u=e.positionAt(d.Start),t=e.positionAt(d.End),a=n.Range.create(u,t);return n.Location.create(e.uri,a)}));return Promise.resolve(o)},e.prototype.getQueryParams=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);this.parseDocumentV2(e);var u=this.parseAndAnalyze(e,d),n=this.toArray(u.Syntax.GetDescendants(Kusto.Language.Syntax.QueryParametersStatement));if(!n||0==n.length)return Promise.resolve([]);var t=[];return n.forEach((function(e){e.WalkElements((function(e){return e.ReferencedSymbol&&e.ReferencedSymbol.Type?t.push({name:e.ReferencedSymbol.Name,type:e.ReferencedSymbol.Type.Name}):void 0}))})),Promise.resolve(t)},e.prototype.getRenderInfo=function(e,d){var u=this,n=this.parseAndAnalyze(e,d);if(!n)return Promise.resolve(void 0);var t=this.toArray(n.Syntax.GetDescendants(Kusto.Language.Syntax.RenderOperator));if(!t||0===t.length)return Promise.resolve(void 0);var a=t[0],r=a.TextStart,i=a.End,o=a.ChartType.ValueText,c=a.WithClause;if(!c){var f={options:{visualization:o},location:{startOffset:r,endOffset:i}};return Promise.resolve(f)}var s=this.toArray(c.Properties).reduce((function(e,d){var n=d.Element$1.Name.SimpleName;switch(n){case"xcolumn":var t=d.Element$1.Expression.ReferencedSymbol.Name;e[n]=t;break;case"ycolumns":case"anomalycolumns":var a=u.toArray(d.Element$1.Expression.Names).map((function(e){return e.Element$1.SimpleName}));e[n]=a;break;case"ymin":case"ymax":var r=parseFloat(d.Element$1.Expression.ConstantValue);e[n]=r;break;case"title":case"xtitle":case"ytitle":case"visualization":case"series":var i=d.Element$1.Expression.ConstantValue;e[n]=i;break;case"xaxis":case"yaxis":var o=d.Element$1.Expression.ConstantValue;e[n]=o;break;case"legend":var c=d.Element$1.Expression.ConstantValue;e[n]=c;break;case"ySplit":var f=d.Element$1.Expression.ConstantValue;e[n]=f;break;case"accumulate":var s=d.Element$1.Expression.ConstantValue;e[n]=s;break;case"kind":var m=d.Element$1.Expression.ConstantValue;e[n]=m;break;default:l(n)}return e}),{}),m={options:__assign({visualization:o},s),location:{startOffset:r,endOffset:i}};return Promise.resolve(m)},e.prototype.getReferencedGlobalParams=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);if(!n)return Promise.resolve([]);var t=n.Text,a=Kusto.Language.KustoCode.ParseAndAnalyze(t,this._kustoJsSchemaV2),r=this.toArray(this._kustoJsSchemaV2.Parameters),i=this.toArray(a.Syntax.GetDescendants(Kusto.Language.Syntax.Expression)).filter((function(e){return null!==e.ReferencedSymbol})).map((function(e){return e.ReferencedSymbol})).filter((function(e){return r.filter((function(d){return d===e})).length>0})).map((function(e){return{name:e.Name,type:e.Type.Name}}));return Promise.resolve(i)},e.prototype.getGlobalParams=function(e){if(!this.isIntellisenseV2())return Promise.resolve([]);var d=this.toArray(this._kustoJsSchemaV2.Parameters).map((function(e){return{name:e.Name,type:e.Type.Name}}));return Promise.resolve(d)},e.prototype.doRename=function(e,d,u){var t;if(!e||!this.isIntellisenseV2())return Promise.resolve(void 0);var a=this.parseDocumentV2(e),r=e.offsetAt(d),i=this.getCurrentCommandV2(a,r);if(!i)return Promise.resolve(void 0);var c=i.Service.GetRelatedElements(e.offsetAt(d)),f=this.toArray(c.Elements),s=f.filter((function(e){return e.Kind==o.RelatedElementKind.Declaration}));if(!s||0==s.length)return Promise.resolve(void 0);var l=f.map((function(d){var t=e.positionAt(d.Start),a=e.positionAt(d.End),r=n.Range.create(t,a);return n.TextEdit.replace(r,u)})),m={changes:(t={},t[e.uri]=l,t)};return Promise.resolve(m)},e.prototype.doHover=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve(void 0);var u=this.parseDocumentV2(e),n=e.offsetAt(d),t=this.getCurrentCommandV2(u,n);if(!t)return Promise.resolve(void 0);if(!t.Service.IsFeatureSupported(o.CodeServiceFeatures.QuickInfo,n))return Promise.resolve(void 0);var a=t.Service.GetQuickInfo(n);if(!a||!a.Items)return Promise.resolve(void 0);var r=this.toArray(a.Items);if(!r)return Promise.resolve(void 0);var i=(r=r.filter((function(e){return e.Kind!==o.QuickInfoKind.Error}))).map((function(e){return e.Text.replace("\n\n","\n* * *\n")})).join("\n* * *\n");return Promise.resolve({contents:i})},Object.defineProperty(e,"dummySchema",{get:function(){var e={majorVersion:0,minorVersion:0,name:"Kuskus",tables:[{name:"KustoLogs",columns:[{name:"Source",type:"string"},{name:"Timestamp",type:"datetime"},{name:"Directory",type:"string"}],docstring:"A dummy description to test that docstring shows as expected when hovering over a table"}],functions:[{name:"HowBig",inputParameters:[{name:"T",columns:[{name:"Timestamp",type:"System.DateTime",cslType:"datetime"}]}],docstring:"A dummy description to test that docstring shows as expected when hovering over a function",body:"{\r\n union \r\n (T | count | project V='Volume', Metric = strcat(Count/1e9, ' Billion records')),\r\n (T | summarize FirstRecord=min(Timestamp)| project V='Volume', Metric = strcat(toint((now()-FirstRecord)/1d), ' Days of data (from: ', format_datetime(FirstRecord, 'yyyy-MM-dd'),')')),\r\n (T | where Timestamp > ago(1h) | count | project V='Velocity', Metric = strcat(Count/1e6, ' Million records / hour')),\r\n (T | summarize Latency=now()-max(Timestamp) | project V='Velocity', Metric = strcat(Latency / 1sec, ' seconds latency')),\r\n (T | take 1 | project V='Variety', Metric=tostring(pack_all()))\r\n | order by V \r\n}"},{name:"FindCIDPast24h",inputParameters:[{name:"clientActivityId",type:"System.String",cslType:"string"}],body:"{ KustoLogs | where Timestamp > now(-1d) | where ClientActivityId == clientActivityId} "}]};return{clusterType:"Engine",cluster:{connectionString:"https://kuskus.kusto.windows.net;fed=true",databases:[e]},database:e}},enumerable:!1,configurable:!0}),e.convertToEntityDataType=function(e){},e.convertToKustoJsSchema=function(e){switch(e.clusterType){case"Engine":var d=e.database?e.database.name:void 0,n=new r.KustoIntelliSenseClusterEntity,t=void 0;n.ConnectionString=e.cluster.connectionString;var i=[];return e.cluster.databases.forEach((function(e){var n=new r.KustoIntelliSenseDatabaseEntity;n.Name=e.name;var o=[];e.tables.forEach((function(e){var d=new r.KustoIntelliSenseTableEntity;d.Name=e.name;var u=[];e.columns.forEach((function(e){var d=new r.KustoIntelliSenseColumnEntity;d.Name=e.name,d.TypeCode=r.EntityDataType[a.getEntityDataTypeFromCslType(e.type)],u.push(d)})),d.Columns=new Bridge.ArrayEnumerable(u),o.push(d)}));var c=[];e.functions.forEach((function(e){var d=new r.KustoIntelliSenseFunctionEntity;d.Name=e.name,d.CallName=u.getCallName(e),d.Expression=u.getExpression(e),c.push(d)})),n.Tables=new Bridge.ArrayEnumerable(o),n.Functions=new Bridge.ArrayEnumerable(c),i.push(n),e.name==d&&(t=n)})),n.Databases=new Bridge.ArrayEnumerable(i),new r.KustoIntelliSenseQuerySchema(n,t);case"ClusterManager":return{accounts:e.accounts.map((function(e){var d=new r.KustoIntelliSenseAccountEntity;return d.Name=e,d})),services:e.services.map((function(e){var d=new r.KustoIntelliSenseServiceEntity;return d.Name=e,d})),connectionString:e.connectionString};case"DataManagement":return;default:return l(e)}},e.scalarParametersToSignature=function(e){return"("+e.map((function(e){return e.name+": "+e.cslType})).join(", ")+")"},e.inputParameterToSignature=function(e){var d=this;return"("+e.map((function(e){if(e.columns){var u=d.scalarParametersToSignature(e.columns);return e.name+": "+u}return e.name+": "+e.cslType})).join(", ")+")"},e.toLetStatement=function(e){var d=this.inputParameterToSignature(e.inputParameters);return"let "+e.name+" = "+d+" "+e.body},e.createColumnSymbol=function(e){return new c.ColumnSymbol(e.name,c.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(e.type)),e.docstring)},e.createParameterSymbol=function(e){var d=Kusto.Language.Symbols.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(e.type));return new c.ParameterSymbol(e.name,d,null)},e.createParameter=function(d){if(!d.columns){var u=Kusto.Language.Symbols.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(d.type)),n=d.cslDefaultValue&&"string"==typeof d.cslDefaultValue?i.QueryParser.ParseLiteral$1(d.cslDefaultValue):void 0;return new c.Parameter.$ctor3(d.name,u,null,null,null,!1,null,1,1,n,null)}if(0==d.columns.length)return new c.Parameter.ctor(d.name,c.ParameterTypeKind.Tabular,c.ArgumentKind.Expression,null,null,!1,null,1,1,null,null);var t=new c.TableSymbol.ctor(d.columns.map((function(d){return e.createColumnSymbol(d)})));return new c.Parameter.$ctor2(d.name,t)},e.convertToDatabaseSymbol=function(d){return function(d){var u=d.tables?d.tables.map((function(d){return function(d){var u=d.columns.map((function(d){return e.createColumnSymbol(d)})),n=new c.TableSymbol.$ctor3(d.name,u);switch(n.Description=d.docstring,d.entityType){case"MaterializedViewTable":n=n.WithIsMaterializedView(!0);break;case"ExternalTable":n=n.WithIsExternal(!0)}return n}(d)})):[],n=d.functions?d.functions.map((function(d){return n=(u=d).inputParameters.map((function(d){return e.createParameter(d)})),new c.FunctionSymbol.$ctor16(u.name,u.body,e.toBridgeList(n),u.docstring);var u,n})):[];return new c.DatabaseSymbol.ctor(d.name,u.concat(n))}(d)},e.prototype.convertToKustoJsSchemaV2=function(d){var u=this._schemaCache[d.cluster.connectionString];u||(this._schemaCache[d.cluster.connectionString]={},u=this._schemaCache[d.cluster.connectionString]);var n=d.cluster.databases.reduce((function(e,d){return e[d.name]=d}),{});Object.keys(u).map((function(e){n[e]||delete u.dbName}));var t=f.Default,a=d.database?d.database.name:void 0,r=void 0,i=d.cluster.databases.map((function(d){var n=d.name===a,t=u[d.name];if(!t||t.database.majorVersion<d.majorVersion||n&&!t.includesFunctions){var i=e.convertToDatabaseSymbol(d);u[d.name]={database:d,symbol:i,includesFunctions:n}}var o=u[d.name].symbol;return d.name===a&&(r=o),o})),o=d.cluster.connectionString.match(/(.*\/\/)?([^\/;]*)/)[2].split(".")[0],s=new c.ClusterSymbol.ctor(o,i);if(t=t.WithCluster(s),r&&(t=t.WithDatabase(r)),d.globalParameters){var l=d.globalParameters.map((function(d){return e.createParameterSymbol(d)}));t=t.WithParameters(e.toBridgeList(l))}return t},e.prototype.getClassificationsFromParseResult=function(e){var d=this;return void 0===e&&(e=0),this.toArray(this._parser.Results).map((function(e){return d.toArray(e.Tokens)})).reduce((function(e,d){return e.concat(d)}),[]).map((function(u){return new o.ClassifiedRange(d.tokenKindToClassificationKind(u.TokenKind),u.AbsoluteStart+e,u.Length)}))},e.trimTrailingNewlineFromRange=function(e,d,u,t){for(var a=e.length-1;"\r"===e[a]||"\n"===e[a];)--a;var r=d+a+1,i=u.positionAt(r);return n.Range.create(t.start,i)},e.prototype.getSortText=function(e){if(e<=0)throw new RangeError("order should be a number >= 1. instead got "+e);for(var d="",u=Math.floor(e/26),n=0;n<u;++n)d+="z";var t=e%26;return t>0&&(d+=String.fromCharCode(96+t)),d},e.prototype.parseTextV1=function(e,d){this._parser.Parse("Engine"===this._schema.clusterType?this._rulesProvider:null,e,d)},e.prototype.parseDocumentV1=function(e,d){this._parsePropertiesV1&&!this._parsePropertiesV1.isParseNeeded(e,this._rulesProvider,d)||(this.parseTextV1(e.getText(),d),this._parsePropertiesV1=new p(e.version,e.uri,this._rulesProvider,d))},e.prototype.parseDocumentV2=function(e){return this._parsePropertiesV2&&!this._parsePropertiesV2.isParseNeeded(e,this._rulesProvider)||(this._script?this._script=this._script.WithText(e.getText()):this._script=o.CodeScript.From$1(e.getText(),this._kustoJsSchemaV2),this._parsePropertiesV2=new p(e.version,e.uri)),this._script},e.prototype.getCurrentCommand=function(e,d){var u=this.toArray(this._parser.Results),n=u.filter((function(e){return e.AbsoluteStart<=d&&e.AbsoluteEnd>=d}))[0];return n||(n=u.filter((function(e){return e.AbsoluteStart<=d&&e.AbsoluteEnd+1>=d}))[0])&&!n.Text.endsWith("\r\n\r\n")?n:null},e.prototype.getCurrentCommandV2=function(e,d){return e.GetBlockAtPosition(d)},e.prototype.getTextToInsert=function(e,d){var u=e.GetBeforeApplyInfo(d.Value),t=e.GetAfterApplyInfo(d.Value),a=u.Text||""+d.Value+t.Text||"",r=n.InsertTextFormat.PlainText;if(t.OffsetToken&&t.OffsetPosition){var i=a.indexOf(t.OffsetToken);i>=0&&(a=this.insertToString(a,"$0",i-a.length+t.OffsetPosition),r=n.InsertTextFormat.Snippet)}else t.OffsetPosition&&(a=this.insertToString(a,"$0",t.OffsetPosition),r=n.InsertTextFormat.Snippet);return{insertText:a,insertTextFormat:r}},e.prototype.insertToString=function(e,d,u){var n=e.length+u;return u>=0||n<0?e:e.substring(0,n)+d+e.substring(n)},e.prototype.getCommandWithoutLastWord=function(e){var d=t("[\\w_]*$","s");return e.replace(d,"")},e.prototype.createRulesProvider=function(e,d){var u=new(s(String)),n=new(s(String));if(this._parser=new r.CslCommandParser,"Engine"!=d)if("DataManagement"!==d){var t=e,a=t.accounts,i=t.services,o=t.connectionString;new r.KustoIntelliSenseAccountEntity,new r.KustoIntelliSenseServiceEntity,this._rulesProvider=new r.ClusterManagerIntelliSenseRulesProvider.$ctor1(new Bridge.ArrayEnumerable(a),new Bridge.ArrayEnumerable(i),o)}else this._rulesProvider=new r.DataManagerIntelliSenseRulesProvider(null);else{var c=e;this._rulesProvider=this._languageSettings&&this._languageSettings.includeControlCommands?new r.CslIntelliSenseRulesProvider.$ctor1(c.Cluster,c,u,n,null,!0,!0):new r.CslQueryIntelliSenseRulesProvider.$ctor1(c.Cluster,c,u,n,null,null,null)}},e.prototype.kustoKindToLsKind=function(e){var d=this._kustoKindtolsKind[e];return d||n.CompletionItemKind.Variable},e.prototype.kustoKindToLsKindV2=function(e){var d=this._kustoKindToLsKindV2[e];return d||n.CompletionItemKind.Variable},e.prototype.createRange=function(e,d,u){return n.Range.create(e.positionAt(d),e.positionAt(u))},e.prototype.toArray=function(e){return Bridge.toArray(e)},e.toBridgeList=function(e){return new(System.Collections.Generic.List$1(System.Object).$ctor1)(e)},e.prototype.tokenKindToClassificationKind=function(e){return this._tokenKindToClassificationKind[e]||o.ClassificationKind.PlainText},e.prototype.parseAndAnalyze=function(e,d){if(e&&this.isIntellisenseV2()){var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);if(n){var t=n.Text;return Kusto.Language.KustoCode.ParseAndAnalyze(t,this._kustoJsSchemaV2)}}},e}(),h=new g(g.dummySchema,{includeControlCommands:!0,useIntellisenseV2:!0,useSemanticColorization:!0});d.getKustoLanguageService=function(){return h}})),define("vs/language/kusto/kustoWorker",["require","exports","./languageService/kustoLanguageService","vscode-languageserver-types"],(function(e,d,u,n){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.create=d.KustoWorker=void 0;var t=function(){function e(e,d){this._ctx=e,this._languageSettings=d.languageSettings,this._languageService=u.getKustoLanguageService(),this._languageService.configure(this._languageSettings)}return e.prototype.setSchema=function(e){return this._languageService.setSchema(e)},e.prototype.addClusterToSchema=function(e,d,u){var n=this._getTextDocument(e);return n?this._languageService.addClusterToSchema(n,d,u):(console.error("addClusterToSchema: document is "+n+". uri is "+e),null)},e.prototype.addDatabaseToSchema=function(e,d,u){var n=this._getTextDocument(e);return n?this._languageService.addDatabaseToSchema(n,d,u):(console.error("addDatabaseToSchema: document is "+n+". uri is "+e),null)},e.prototype.setSchemaFromShowSchema=function(e,d,u){return this._languageService.setSchemaFromShowSchema(e,d,u)},e.prototype.normalizeSchema=function(e,d,u){return this._languageService.normalizeSchema(e,d,u)},e.prototype.getSchema=function(){return this._languageService.getSchema()},e.prototype.getCommandInContext=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getCommandInContext: document is "+u+". uri is "+e),null;var n=this._languageService.getCommandInContext(u,d);return void 0===n?null:n},e.prototype.getQueryParams=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getQueryParams: document is "+u+". uri is "+e),null;var n=this._languageService.getQueryParams(u,d);return void 0===n?null:n},e.prototype.getGlobalParams=function(e){var d=this._getTextDocument(e);if(!d)return console.error("getGLobalParams: document is "+d+". uri is "+e),null;var u=this._languageService.getGlobalParams(d);return void 0===u?null:u},e.prototype.getReferencedGlobalParams=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getReferencedGlobalParams: document is "+u+". uri is "+e),null;var n=this._languageService.getReferencedGlobalParams(u,d);return void 0===n?null:n},e.prototype.getRenderInfo=function(e,d){var u=this._getTextDocument(e);return u||console.error("getRenderInfo: document is "+u+". uri is "+e),this._languageService.getRenderInfo(u,d).then((function(e){return e||null}))},e.prototype.getCommandAndLocationInContext=function(e,d){var u=this._getTextDocument(e);return u?this._languageService.getCommandAndLocationInContext(u,d).then((function(e){if(!e)return null;var d=e.text,u=e.location.range,n=u.start,t=u.end;return{range:new monaco.Range(n.line+1,n.character+1,t.line+1,t.character+1),text:d}})):(console.error("getCommandAndLocationInContext: document is "+u+". uri is "+e),Promise.resolve(null))},e.prototype.getCommandsInDocument=function(e){var d=this._getTextDocument(e);return d?this._languageService.getCommandsInDocument(d):(console.error("getCommandInDocument: document is "+d+". uri is "+e),null)},e.prototype.doComplete=function(e,d){var u=this._getTextDocument(e);return u?this._languageService.doComplete(u,d):null},e.prototype.doValidation=function(e,d){var u=this._getTextDocument(e);return this._languageService.doValidation(u,d)},e.prototype.doRangeFormat=function(e,d){var u=this._getTextDocument(e);return this._languageService.doRangeFormat(u,d)},e.prototype.doFolding=function(e){var d=this._getTextDocument(e);return this._languageService.doFolding(d)},e.prototype.doDocumentFormat=function(e){var d=this._getTextDocument(e);return this._languageService.doDocumentFormat(d)},e.prototype.doCurrentCommandFormat=function(e,d){var u=this._getTextDocument(e);return this._languageService.doCurrentCommandFormat(u,d)},e.prototype.doColorization=function(e,d){var u=this._getTextDocument(e);return this._languageService.doColorization(u,d)},e.prototype.getClientDirective=function(e){return this._languageService.getClientDirective(e)},e.prototype.getAdminCommand=function(e){return this._languageService.getAdminCommand(e)},e.prototype.findDefinition=function(e,d){var u=this._getTextDocument(e);return this._languageService.findDefinition(u,d)},e.prototype.findReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.findReferences(u,d)},e.prototype.doRename=function(e,d,u){var n=this._getTextDocument(e);return this._languageService.doRename(n,d,u)},e.prototype.doHover=function(e,d){var u=this._getTextDocument(e);return this._languageService.doHover(u,d)},e.prototype.setParameters=function(e){return this._languageService.setParameters(e)},e.prototype.getClusterReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.getClusterReferences(u,d)},e.prototype.getDatabaseReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.getDatabaseReferences(u,d)},e.prototype._getTextDocument=function(e){for(var d=0,u=this._ctx.getMirrorModels();d<u.length;d++){var t=u[d];if(t.uri.toString()===e)return n.TextDocument.create(e,this._languageId,t.version,t.getValue())}return null},e}();d.KustoWorker=t,d.create=function(e,d){return new t(e,d)}}));
|
|
60
|
+
var n={astral:!1,natives:!1},t={exec:RegExp.prototype.exec,test:RegExp.prototype.test,match:String.prototype.match,replace:String.prototype.replace,split:String.prototype.split},a={},r={},i={},o=[],c={default:/\\(?:0(?:[0-3][0-7]{0,2}|[4-7][0-7]?)?|[1-9]\d*|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|\(\?(?:[:=!]|<[=!])|[?*+]\?|{\d+(?:,\d*)?}\??|[\s\S]/,class:/\\(?:[0-3][0-7]{0,2}|[4-7][0-7]?|x[\dA-Fa-f]{2}|u(?:[\dA-Fa-f]{4}|{[\dA-Fa-f]+})|c[A-Za-z]|[\s\S])|[\s\S]/},f=/\$(?:{([\w$]+)}|(\d\d?|[\s\S]))/g,s=void 0===t.exec.call(/()??/,"")[1],l=void 0!==/x/.flags,m={}.toString;function p(e){var d=!0;try{new RegExp("",e)}catch(e){d=!1}return d}var b=p("u"),g=p("y"),h={g:!0,i:!0,m:!0,u:b,y:g};function v(e,d,u,n,t){var a;if(e.xregexp={captureNames:d},t)return e;if(e.__proto__)e.__proto__=O.prototype;else for(a in O.prototype)e[a]=O.prototype[a];return e.xregexp.source=u,e.xregexp.flags=n?n.split("").sort().join(""):n,e}function y(e){return t.replace.call(e,/([\s\S])(?=[\s\S]*\1)/g,"")}function C(e,d){if(!O.isRegExp(e))throw new TypeError("Type RegExp expected");var u=e.xregexp||{},n=function(e){return l?e.flags:t.exec.call(/\/([a-z]*)$/i,RegExp.prototype.toString.call(e))[1]}(e),a="",r="",i=null,o=null;return(d=d||{}).removeG&&(r+="g"),d.removeY&&(r+="y"),r&&(n=t.replace.call(n,new RegExp("["+r+"]+","g"),"")),d.addG&&(a+="g"),d.addY&&(a+="y"),a&&(n=y(n+a)),d.isInternalOnly||(void 0!==u.source&&(i=u.source),null!=u.flags&&(o=a?y(u.flags+a):u.flags)),e=v(new RegExp(d.source||e.source,n),function(e){return!(!e.xregexp||!e.xregexp.captureNames)}(e)?u.captureNames.slice(0):null,i,o,d.isInternalOnly)}function _(e){return parseInt(e,16)}function S(e,d,u){return"("===e.input.charAt(e.index-1)||")"===e.input.charAt(e.index+e[0].length)||function(e,d,u,n){var a=u.indexOf("x")>-1?["\\s","#[^#\\n]*","\\(\\?#[^)]*\\)"]:["\\(\\?#[^)]*\\)"];return t.test.call(new RegExp("^(?:"+a.join("|")+")*(?:"+n+")"),e.slice(d))}(e.input,e.index+e[0].length,u,"[?*+]|{\\d+(?:,\\d*)?}")?"":"(?:)"}function I(e){return parseInt(e,10).toString(16)}function x(e,d){var u,n=e.length;for(u=0;u<n;++u)if(e[u]===d)return u;return-1}function T(e,d){return m.call(e)==="[object "+d+"]"}function K(e){for(;e.length<4;)e="0"+e;return e}function P(e){var d={};return T(e,"String")?(O.forEach(e,/[^\s,]+/,(function(e){d[e]=!0})),d):e}function k(e){if(!/^[\w$]$/.test(e))throw new Error("Flag must be a single character A-Za-z0-9_$");h[e]=!0}function E(e,d,u,n,t){for(var a,r,i=o.length,c=e.charAt(u),f=null;i--;)if(!((r=o[i]).leadChar&&r.leadChar!==c||r.scope!==n&&"all"!==r.scope||r.flag&&-1===d.indexOf(r.flag))&&(a=O.exec(e,r.regex,u,"sticky"))){f={matchLength:a[0].length,output:r.handler.call(t,a,n,d),reparse:r.reparse};break}return f}function w(e){n.astral=e}function A(e){RegExp.prototype.exec=(e?a:t).exec,RegExp.prototype.test=(e?a:t).test,String.prototype.match=(e?a:t).match,String.prototype.replace=(e?a:t).replace,String.prototype.split=(e?a:t).split,n.natives=e}function D(e){if(null==e)throw new TypeError("Cannot convert null or undefined to object");return e}function O(e,d){if(O.isRegExp(e)){if(void 0!==d)throw new TypeError("Cannot supply flags when copying a RegExp");return C(e)}if(e=void 0===e?"":String(e),d=void 0===d?"":String(d),O.isInstalled("astral")&&-1===d.indexOf("A")&&(d+="A"),i[e]||(i[e]={}),!i[e][d]){for(var u,n={hasNamedCapture:!1,captureNames:[]},a="default",r="",o=0,f=function(e,d){var u;if(y(d)!==d)throw new SyntaxError("Invalid duplicate regex flag "+d);for(e=t.replace.call(e,/^\(\?([\w$]+)\)/,(function(e,u){if(t.test.call(/[gy]/,u))throw new SyntaxError("Cannot use flag g or y in mode modifier "+e);return d=y(d+u),""})),u=0;u<d.length;++u)if(!h[d.charAt(u)])throw new SyntaxError("Unknown regex flag "+d.charAt(u));return{pattern:e,flags:d}}(e,d),s=f.pattern,l=f.flags;o<s.length;){do{(u=E(s,l,o,a,n))&&u.reparse&&(s=s.slice(0,o)+u.output+s.slice(o+u.matchLength))}while(u&&u.reparse);if(u)r+=u.output,o+=u.matchLength||1;else{var m=O.exec(s,c[a],o,"sticky")[0];r+=m,o+=m.length,"["===m&&"default"===a?a="class":"]"===m&&"class"===a&&(a="default")}}i[e][d]={pattern:t.replace.call(r,/(?:\(\?:\))+/g,"(?:)"),flags:t.replace.call(l,/[^gimuy]+/g,""),captures:n.hasNamedCapture?n.captureNames:null}}var p=i[e][d];return v(new RegExp(p.pattern,p.flags),p.captures,e,d)}O.prototype=new RegExp,O.version="3.2.0",O._clipDuplicates=y,O._hasNativeFlag=p,O._dec=_,O._hex=I,O._pad4=K,O.addToken=function(e,d,u){var n,a=(u=u||{}).optionalFlags;if(u.flag&&k(u.flag),a)for(a=t.split.call(a,""),n=0;n<a.length;++n)k(a[n]);o.push({regex:C(e,{addG:!0,addY:g,isInternalOnly:!0}),handler:d,scope:u.scope||"default",flag:u.flag,reparse:u.reparse,leadChar:u.leadChar}),O.cache.flush("patterns")},O.cache=function(e,d){return r[e]||(r[e]={}),r[e][d]||(r[e][d]=O(e,d))},O.cache.flush=function(e){"patterns"===e?i={}:r={}},O.escape=function(e){return t.replace.call(D(e),/[-\[\]{}()*+?.,\\^$|#\s]/g,"\\$&")},O.exec=function(e,d,u,n){var t,r,i,o="g",c=!1;return(t=g&&!!(n||d.sticky&&!1!==n))?o+="y":n&&(c=!0,o+="FakeY"),d.xregexp=d.xregexp||{},u=u||0,(i=d.xregexp[o]||(d.xregexp[o]=C(d,{addG:!0,addY:t,source:c?d.source+"|()":void 0,removeY:!1===n,isInternalOnly:!0}))).lastIndex=u,r=a.exec.call(i,e),c&&r&&""===r.pop()&&(r=null),d.global&&(d.lastIndex=r?i.lastIndex:0),r},O.forEach=function(e,d,u){for(var n,t=0,a=-1;n=O.exec(e,d,t);)u(n,++a,e,d),t=n.index+(n[0].length||1)},O.globalize=function(e){return C(e,{addG:!0})},O.install=function(e){e=P(e),!n.astral&&e.astral&&w(!0),!n.natives&&e.natives&&A(!0)},O.isInstalled=function(e){return!!n[e]},O.isRegExp=function(e){return"[object RegExp]"===m.call(e)},O.match=function(e,d,u){var n,a,r=d.global&&"one"!==u||"all"===u,i=(r?"g":"")+(d.sticky?"y":"")||"noGY";return d.xregexp=d.xregexp||{},a=d.xregexp[i]||(d.xregexp[i]=C(d,{addG:!!r,removeG:"one"===u,isInternalOnly:!0})),n=t.match.call(D(e),a),d.global&&(d.lastIndex="one"===u&&n?n.index+n[0].length:0),r?n||[]:n&&n[0]},O.matchChain=function(e,d){return function e(u,n){var t=d[n].regex?d[n]:{regex:d[n]},a=[];function r(e){if(t.backref){if(!(e.hasOwnProperty(t.backref)||+t.backref<e.length))throw new ReferenceError("Backreference to undefined group: "+t.backref);a.push(e[t.backref]||"")}else a.push(e[0])}for(var i=0;i<u.length;++i)O.forEach(u[i],t.regex,r);return n!==d.length-1&&a.length?e(a,n+1):a}([e],0)},O.replace=function(e,d,u,n){var t,r=O.isRegExp(d),i=d.global&&"one"!==n||"all"===n,o=(i?"g":"")+(d.sticky?"y":"")||"noGY",c=d;return r?(d.xregexp=d.xregexp||{},c=d.xregexp[o]||(d.xregexp[o]=C(d,{addG:!!i,removeG:"one"===n,isInternalOnly:!0}))):i&&(c=new RegExp(O.escape(String(d)),"g")),t=a.replace.call(D(e),c,u),r&&d.global&&(d.lastIndex=0),t},O.replaceEach=function(e,d){var u,n;for(u=0;u<d.length;++u)n=d[u],e=O.replace(e,n[0],n[1],n[2]);return e},O.split=function(e,d,u){return a.split.call(D(e),d,u)},O.test=function(e,d,u,n){return!!O.exec(e,d,u,n)},O.uninstall=function(e){e=P(e),n.astral&&e.astral&&w(!1),n.natives&&e.natives&&A(!1)},O.union=function(e,d,u){var n,a,r=(u=u||{}).conjunction||"or",i=0;function o(e,d,u){var t=a[i-n];if(d){if(++i,t)return"(?<"+t+">"}else if(u)return"\\"+(+u+n);return e}if(!T(e,"Array")||!e.length)throw new TypeError("Must provide a nonempty array of patterns to merge");for(var c,f=/(\()(?!\?)|\\([1-9]\d*)|\\[\s\S]|\[(?:[^\\\]]|\\[\s\S])*\]/g,s=[],l=0;l<e.length;++l)c=e[l],O.isRegExp(c)?(n=i,a=c.xregexp&&c.xregexp.captureNames||[],s.push(t.replace.call(O(c.source).source,f,o))):s.push(O.escape(c));var m="none"===r?"":"|";return O(s.join(m),d)},a.exec=function(e){var d,u,n,a=this.lastIndex,r=t.exec.apply(this,arguments);if(r){if(!s&&r.length>1&&x(r,"")>-1&&(u=C(this,{removeG:!0,isInternalOnly:!0}),t.replace.call(String(e).slice(r.index),u,(function(){var e,d=arguments.length;for(e=1;e<d-2;++e)void 0===arguments[e]&&(r[e]=void 0)}))),this.xregexp&&this.xregexp.captureNames)for(n=1;n<r.length;++n)(d=this.xregexp.captureNames[n-1])&&(r[d]=r[n]);this.global&&!r[0].length&&this.lastIndex>r.index&&(this.lastIndex=r.index)}return this.global||(this.lastIndex=a),r},a.test=function(e){return!!a.exec.call(this,e)},a.match=function(e){var d;if(O.isRegExp(e)){if(e.global)return d=t.match.apply(this,arguments),e.lastIndex=0,d}else e=new RegExp(e);return a.exec.call(e,D(this))},a.replace=function(e,d){var u,n,a,r=O.isRegExp(e);return r?(e.xregexp&&(n=e.xregexp.captureNames),u=e.lastIndex):e+="",a=T(d,"Function")?t.replace.call(String(this),e,(function(){var u,t=arguments;if(n)for(t[0]=new String(t[0]),u=0;u<n.length;++u)n[u]&&(t[0][n[u]]=t[u+1]);return r&&e.global&&(e.lastIndex=t[t.length-2]+t[0].length),d.apply(void 0,t)})):t.replace.call(null==this?this:String(this),e,(function(){var e=arguments;return t.replace.call(String(d),f,(function(d,u,t){var a;if(u){if((a=+u)<=e.length-3)return e[a]||"";if((a=n?x(n,u):-1)<0)throw new SyntaxError("Backreference to undefined group "+d);return e[a+1]||""}if("$"===t)return"$";if("&"===t||0==+t)return e[0];if("`"===t)return e[e.length-1].slice(0,e[e.length-2]);if("'"===t)return e[e.length-1].slice(e[e.length-2]+e[0].length);if(t=+t,!isNaN(t)){if(t>e.length-3)throw new SyntaxError("Backreference to undefined group "+d);return e[t]||""}throw new SyntaxError("Invalid token "+d)}))})),r&&(e.global?e.lastIndex=0:e.lastIndex=u),a},a.split=function(e,d){if(!O.isRegExp(e))return t.split.apply(this,arguments);var u,n=String(this),a=[],r=e.lastIndex,i=0;return d=(void 0===d?-1:d)>>>0,O.forEach(n,e,(function(e){e.index+e[0].length>i&&(a.push(n.slice(i,e.index)),e.length>1&&e.index<n.length&&Array.prototype.push.apply(a,e.slice(1)),u=e[0].length,i=e.index+u)})),i===n.length?t.test.call(e,"")&&!u||a.push(""):a.push(n.slice(i)),e.lastIndex=r,a.length>d?a.slice(0,d):a},O.addToken(/\\([ABCE-RTUVXYZaeg-mopqyz]|c(?![A-Za-z])|u(?![\dA-Fa-f]{4}|{[\dA-Fa-f]+})|x(?![\dA-Fa-f]{2}))/,(function(e,d){if("B"===e[1]&&"default"===d)return e[0];throw new SyntaxError("Invalid escape "+e[0])}),{scope:"all",leadChar:"\\"}),O.addToken(/\\u{([\dA-Fa-f]+)}/,(function(e,d,u){var n=_(e[1]);if(n>1114111)throw new SyntaxError("Invalid Unicode code point "+e[0]);if(n<=65535)return"\\u"+K(I(n));if(b&&u.indexOf("u")>-1)return e[0];throw new SyntaxError("Cannot use Unicode code point above \\u{FFFF} without flag u")}),{scope:"all",leadChar:"\\"}),O.addToken(/\[(\^?)\]/,(function(e){return e[1]?"[\\s\\S]":"\\b\\B"}),{leadChar:"["}),O.addToken(/\(\?#[^)]*\)/,S,{leadChar:"("}),O.addToken(/\s+|#[^\n]*\n?/,S,{flag:"x"}),O.addToken(/\./,(function(){return"[\\s\\S]"}),{flag:"s",leadChar:"."}),O.addToken(/\\k<([\w$]+)>/,(function(e){var d=isNaN(e[1])?x(this.captureNames,e[1])+1:+e[1],u=e.index+e[0].length;if(!d||d>this.captureNames.length)throw new SyntaxError("Backreference to undefined group "+e[0]);return"\\"+d+(u===e.input.length||isNaN(e.input.charAt(u))?"":"(?:)")}),{leadChar:"\\"}),O.addToken(/\\(\d+)/,(function(e,d){if(!("default"===d&&/^[1-9]/.test(e[1])&&+e[1]<=this.captureNames.length)&&"0"!==e[1])throw new SyntaxError("Cannot use octal escape or backreference to undefined group "+e[0]);return e[0]}),{scope:"all",leadChar:"\\"}),O.addToken(/\(\?P?<([\w$]+)>/,(function(e){if(!isNaN(e[1]))throw new SyntaxError("Cannot use integer as capture name "+e[0]);if("length"===e[1]||"__proto__"===e[1])throw new SyntaxError("Cannot use reserved word as capture name "+e[0]);if(x(this.captureNames,e[1])>-1)throw new SyntaxError("Cannot use same name for multiple groups "+e[0]);return this.captureNames.push(e[1]),this.hasNamedCapture=!0,"("}),{leadChar:"("}),O.addToken(/\((?!\?)/,(function(e,d,u){return u.indexOf("n")>-1?"(?:":(this.captureNames.push(null),"(")}),{optionalFlags:"n",leadChar:"("}),d.exports=O},{}]},{},[8])(8)})),define("xregexp",["xregexp/xregexp-all"],(function(e){return e}));var __assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var d,u=1,n=arguments.length;u<n;u++)for(var t in d=arguments[u])Object.prototype.hasOwnProperty.call(d,t)&&(e[t]=d[t]);return e}).apply(this,arguments)};define("vs/language/kusto/languageService/kustoLanguageService",["require","exports","./schema","vscode-languageserver-types","xregexp","./schema"],(function(e,d,u,n,t,a){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.getKustoLanguageService=d.TokenKind=void 0,String.prototype.endsWith||(String.prototype.endsWith=function(e,d){return(void 0===d||d>this.length)&&(d=this.length),this.substring(d-e.length,d)===e}),"undefined"==typeof document&&(importScripts("../../language/kusto/bridge.min.js"),importScripts("../../language/kusto/kusto.javascript.client.min.js"),importScripts("../../language/kusto/Kusto.Language.Bridge.min.js"));var r=Kusto.Data.IntelliSense,i=Kusto.Language.Parsing,o=Kusto.Language.Editor,c=Kusto.Language.Symbols,f=Kusto.Language.GlobalState,s=System.Collections.Generic.List$1;function l(e){throw new Error("Unexpected object: "+e)}var m,p=function(){function e(e,d,u,n){this.version=e,this.uri=d,this.rulesProvider=u,this.parseMode=n}return e.prototype.isParseNeeded=function(e,d,u){return!(e.uri===this.uri&&(!d||d===this.rulesProvider)&&e.version<=this.version&&u&&u<=this.parseMode)},e}();function b(e){return e.map((function(e){return{start:e.Start,end:e.End,length:e.Length,kind:e.Kind}}))}!function(e){e[e.TableToken=2]="TableToken",e[e.TableColumnToken=4]="TableColumnToken",e[e.OperatorToken=8]="OperatorToken",e[e.SubOperatorToken=16]="SubOperatorToken",e[e.CalculatedColumnToken=32]="CalculatedColumnToken",e[e.StringLiteralToken=64]="StringLiteralToken",e[e.FunctionNameToken=128]="FunctionNameToken",e[e.UnknownToken=256]="UnknownToken",e[e.CommentToken=512]="CommentToken",e[e.PlainTextToken=1024]="PlainTextToken",e[e.DataTypeToken=2048]="DataTypeToken",e[e.ControlCommandToken=4096]="ControlCommandToken",e[e.CommandPartToken=8192]="CommandPartToken",e[e.QueryParametersToken=16384]="QueryParametersToken",e[e.CslCommandToken=32768]="CslCommandToken",e[e.LetVariablesToken=65536]="LetVariablesToken",e[e.PluginToken=131072]="PluginToken",e[e.BracketRangeToken=262144]="BracketRangeToken",e[e.ClientDirectiveToken=524288]="ClientDirectiveToken"}(m=d.TokenKind||(d.TokenKind={}));var g=function(){function e(d,u){var t,a,i,c,f=this;this._toOptionKind=((t={})[o.CompletionKind.AggregateFunction]=r.OptionKind.FunctionAggregation,t[o.CompletionKind.BuiltInFunction]=r.OptionKind.FunctionServerSide,t[o.CompletionKind.Cluster]=r.OptionKind.Database,t[o.CompletionKind.Column]=r.OptionKind.Column,t[o.CompletionKind.CommandPrefix]=r.OptionKind.None,t[o.CompletionKind.Database]=r.OptionKind.Database,t[o.CompletionKind.DatabaseFunction]=r.OptionKind.FunctionServerSide,t[o.CompletionKind.Example]=r.OptionKind.None,t[o.CompletionKind.Identifier]=r.OptionKind.None,t[o.CompletionKind.Keyword]=r.OptionKind.None,t[o.CompletionKind.LocalFunction]=r.OptionKind.FunctionLocal,t[o.CompletionKind.MaterialiedView]=r.OptionKind.MaterializedView,t[o.CompletionKind.Parameter]=r.OptionKind.Parameter,t[o.CompletionKind.Punctuation]=r.OptionKind.None,t[o.CompletionKind.QueryPrefix]=r.OptionKind.Operator,t[o.CompletionKind.RenderChart]=r.OptionKind.Operator,t[o.CompletionKind.ScalarInfix]=r.OptionKind.None,t[o.CompletionKind.ScalarPrefix]=r.OptionKind.None,t[o.CompletionKind.ScalarType]=r.OptionKind.DataType,t[o.CompletionKind.Syntax]=r.OptionKind.None,t[o.CompletionKind.Table]=r.OptionKind.Table,t[o.CompletionKind.TabularPrefix]=r.OptionKind.None,t[o.CompletionKind.TabularSuffix]=r.OptionKind.None,t[o.CompletionKind.Unknown]=r.OptionKind.None,t[o.CompletionKind.Variable]=r.OptionKind.Parameter,t[o.CompletionKind.Option]=r.OptionKind.Option,t),this.disabledCompletionItemsV2={ladderchart:o.CompletionKind.RenderChart,pivotchart:o.CompletionKind.RenderChart,timeline:o.CompletionKind.RenderChart,timepivot:o.CompletionKind.RenderChart,"3Dchart":o.CompletionKind.RenderChart,list:o.CompletionKind.RenderChart},this.isIntellisenseV2=function(){return f._languageSettings.useIntellisenseV2&&f._schema&&"Engine"===f._schema.clusterType},this.disabledCompletionItemsV1={capacity:r.OptionKind.Policy,callout:r.OptionKind.Policy,encoding:r.OptionKind.Policy,batching:r.OptionKind.Policy,querythrottling:r.OptionKind.Policy,merge:r.OptionKind.Policy,querylimit:r.OptionKind.Policy,rowstore:r.OptionKind.Policy,streamingingestion:r.OptionKind.Policy,restricted_view_access:r.OptionKind.Policy,sharding:r.OptionKind.Policy,"restricted-viewers":r.OptionKind.Policy,attach:r.OptionKind.Command,purge:r.OptionKind.Command},this._kustoKindtolsKind=((a={})[r.OptionKind.None]=n.CompletionItemKind.Interface,a[r.OptionKind.Operator]=n.CompletionItemKind.Method,a[r.OptionKind.Command]=n.CompletionItemKind.Method,a[r.OptionKind.Service]=n.CompletionItemKind.Class,a[r.OptionKind.Policy]=n.CompletionItemKind.Reference,a[r.OptionKind.Database]=n.CompletionItemKind.Class,a[r.OptionKind.Table]=n.CompletionItemKind.Class,a[r.OptionKind.DataType]=n.CompletionItemKind.Class,a[r.OptionKind.Literal]=n.CompletionItemKind.Property,a[r.OptionKind.Parameter]=n.CompletionItemKind.Variable,a[r.OptionKind.IngestionMapping]=n.CompletionItemKind.Variable,a[r.OptionKind.ExpressionFunction]=n.CompletionItemKind.Variable,a[r.OptionKind.Option]=n.CompletionItemKind.Interface,a[r.OptionKind.OptionKind]=n.CompletionItemKind.Interface,a[r.OptionKind.OptionRender]=n.CompletionItemKind.Interface,a[r.OptionKind.Column]=n.CompletionItemKind.Function,a[r.OptionKind.ColumnString]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnNumeric]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnDateTime]=n.CompletionItemKind.Field,a[r.OptionKind.ColumnTimespan]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionServerSide]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionAggregation]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionFilter]=n.CompletionItemKind.Field,a[r.OptionKind.FunctionScalar]=n.CompletionItemKind.Field,a[r.OptionKind.ClientDirective]=n.CompletionItemKind.Enum,a),this._kustoKindToLsKindV2=((i={})[o.CompletionKind.AggregateFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.BuiltInFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.Cluster]=n.CompletionItemKind.Class,i[o.CompletionKind.Column]=n.CompletionItemKind.Function,i[o.CompletionKind.CommandPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.Database]=n.CompletionItemKind.Class,i[o.CompletionKind.DatabaseFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.Example]=n.CompletionItemKind.Text,i[o.CompletionKind.Identifier]=n.CompletionItemKind.Method,i[o.CompletionKind.Keyword]=n.CompletionItemKind.Method,i[o.CompletionKind.LocalFunction]=n.CompletionItemKind.Field,i[o.CompletionKind.MaterialiedView]=n.CompletionItemKind.Class,i[o.CompletionKind.Parameter]=n.CompletionItemKind.Variable,i[o.CompletionKind.Punctuation]=n.CompletionItemKind.Interface,i[o.CompletionKind.QueryPrefix]=n.CompletionItemKind.Function,i[o.CompletionKind.RenderChart]=n.CompletionItemKind.Method,i[o.CompletionKind.ScalarInfix]=n.CompletionItemKind.Field,i[o.CompletionKind.ScalarPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.ScalarType]=n.CompletionItemKind.TypeParameter,i[o.CompletionKind.Syntax]=n.CompletionItemKind.Method,i[o.CompletionKind.Table]=n.CompletionItemKind.Class,i[o.CompletionKind.TabularPrefix]=n.CompletionItemKind.Field,i[o.CompletionKind.TabularSuffix]=n.CompletionItemKind.Field,i[o.CompletionKind.Unknown]=n.CompletionItemKind.Interface,i[o.CompletionKind.Variable]=n.CompletionItemKind.Variable,i[o.CompletionKind.Option]=n.CompletionItemKind.Text,i),this._tokenKindToClassificationKind=((c={})[m.TableToken]=o.ClassificationKind.Table,c[m.TableColumnToken]=o.ClassificationKind.Column,c[m.OperatorToken]=o.ClassificationKind.QueryOperator,c[m.SubOperatorToken]=o.ClassificationKind.Function,c[m.CalculatedColumnToken]=o.ClassificationKind.Column,c[m.StringLiteralToken]=o.ClassificationKind.Literal,c[m.FunctionNameToken]=o.ClassificationKind.Function,c[m.UnknownToken]=o.ClassificationKind.PlainText,c[m.CommentToken]=o.ClassificationKind.Comment,c[m.PlainTextToken]=o.ClassificationKind.PlainText,c[m.DataTypeToken]=o.ClassificationKind.Type,c[m.ControlCommandToken]=o.ClassificationKind.PlainText,c[m.CommandPartToken]=o.ClassificationKind.PlainText,c[m.QueryParametersToken]=o.ClassificationKind.QueryParameter,c[m.CslCommandToken]=o.ClassificationKind.Keyword,c[m.LetVariablesToken]=o.ClassificationKind.Identifier,c[m.PluginToken]=o.ClassificationKind.Function,c[m.BracketRangeToken]=o.ClassificationKind.Keyword,c[m.ClientDirectiveToken]=o.ClassificationKind.Keyword,c),this._schemaCache={},this._kustoJsSchema=e.convertToKustoJsSchema(d),this.__kustoJsSchemaV2=this.convertToKustoJsSchemaV2(d),this._schema=d,this._clustersSetInGlobalState=new Set,this._nonEmptyDatabaseSetInGlobalState=new Set,this.configure(u),this._newlineAppendPipePolicy=new Kusto.Data.IntelliSense.ApplyPolicy,this._newlineAppendPipePolicy.Text="\n| "}return e.prototype.createDatabaseUniqueName=function(e,d){return e+"_"+d},Object.defineProperty(e.prototype,"_kustoJsSchemaV2",{get:function(){return this.__kustoJsSchemaV2},set:function(e){this.__kustoJsSchemaV2=e,this._clustersSetInGlobalState.clear(),this._nonEmptyDatabaseSetInGlobalState.clear();for(var d=0;d<e.Clusters.Count;d++){var u=this._kustoJsSchemaV2.Clusters.getItem(d);this._clustersSetInGlobalState.add(u.Name);for(var n=0;n<u.Databases.Count;n++){var t=u.Databases.getItem(n);t.Tables.Count>0&&this._nonEmptyDatabaseSetInGlobalState.add(this.createDatabaseUniqueName(u.Name,t.Name))}}},enumerable:!1,configurable:!0}),e.prototype.configure=function(e){this._languageSettings=e,this.createRulesProvider(this._kustoJsSchema,this._schema.clusterType)},e.prototype.doComplete=function(e,d){return this.isIntellisenseV2()?this.doCompleteV2(e,d):this.doCompleteV1(e,d)},e.prototype.debugGlobalState=function(e){console.log("globals.Clusters.Count: "+e.Clusters.Count);for(var d=0;d<e.Clusters.Count;d++){var u=e.Clusters.getItem(d);console.log("cluster: "+u.Name),console.log("cluster.Databases.Count: "+u.Databases.Count);for(var n=0;n<u.Databases.Count;n++){var t=u.Databases.getItem(n);console.log("cluster.database: ["+u.Name+"].["+t.Name+"]"),console.log("cluster.Databases.Tables.Count: "+t.Tables.Count);for(var a=0;a<t.Tables.Count;a++){var r=t.Tables.getItem(a);console.log("cluster.database.table: ["+u.Name+"].["+t.Name+"].["+r.Name+"]")}}}},e.prototype.doCompleteV2=function(e,d){var u=this;if(!e)return Promise.resolve(n.CompletionList.create([]));var t=this.parseDocumentV2(e),a=e.offsetAt(d),i=t.GetBlockAtPosition(a).Service.GetCompletionItems(a),c=this.disabledCompletionItemsV2;this._languageSettings.disabledCompletionItems&&this._languageSettings.disabledCompletionItems.map((function(e){c[e]=o.CompletionKind.Unknown}));var f=this.toArray(i.Items).filter((function(e){return!(e&&e.MatchText&&void 0!==c[e.MatchText]&&(c[e.MatchText]===o.CompletionKind.Unknown||c[e.MatchText]===e.Kind))})).map((function(d,t){var a=new r.CompletionOption(u._toOptionKind[d.Kind]||r.OptionKind.None,d.DisplayText),o=u.getTopic(a),c=d.AfterText&&d.AfterText.length>0?{textToInsert:d.EditText+"$0"+d.AfterText,format:n.InsertTextFormat.Snippet}:{textToInsert:d.EditText,format:n.InsertTextFormat.PlainText},f=c.textToInsert,s=c.format,l=n.CompletionItem.create(d.DisplayText),m=e.positionAt(i.EditStart),p=e.positionAt(i.EditStart+i.EditLength);return l.textEdit=n.TextEdit.replace(n.Range.create(m,p),f),l.sortText=u.getSortText(t+1),l.kind=u.kustoKindToLsKindV2(d.Kind),l.insertTextFormat=s,l.detail=o?o.ShortDescription:void 0,l.documentation=o?{value:o.LongDescription,kind:n.MarkupKind.Markdown}:void 0,l}));return Promise.resolve(n.CompletionList.create(f))},e.prototype.getTopic=function(e){if(e.Kind==r.OptionKind.FunctionScalar||e.Kind==r.OptionKind.FunctionAggregation){var d=e.Value.indexOf("(");d>=0&&(e=new r.CompletionOption(e.Kind,e.Value.substring(0,d)))}return r.CslDocumentation.Instance.GetTopic(e)},e.prototype.doCompleteV1=function(e,d){var u=this,t=e.offsetAt(d);this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var a=this.getCurrentCommand(e,t),i="";if(a){a.AbsoluteStart;this.parseTextV1(a.Text,r.ParseMode.TokenizeAllText);var o=t-a.AbsoluteStart;i=a.Text.substring(a.CslExpressionStartPosition,o)}var c=this.getCommandWithoutLastWord(i),f=this._rulesProvider.AnalyzeCommand$1(i,a).Context,s={v:null};this._rulesProvider.TryMatchAnyRule(c,s);var l=s.v;if(l){var m=this.toArray(l.GetCompletionOptions(f));this._languageSettings.newlineAfterPipe&&l.DefaultAfterApplyPolicy===Kusto.Data.IntelliSense.ApplyPolicy.AppendPipePolicy&&(l.DefaultAfterApplyPolicy=this._newlineAppendPipePolicy);var p=m.filter((function(e){return!(e&&e.Value&&u.disabledCompletionItemsV1[e.Value]===e.Kind)})).map((function(e,d){var t=u.getTextToInsert(l,e),a=t.insertText,i=t.insertTextFormat,o=r.CslDocumentation.Instance.GetTopic(e),c=n.CompletionItem.create(e.Value);return c.kind=u.kustoKindToLsKind(e.Kind),c.insertText=a,c.insertTextFormat=i,c.sortText=u.getSortText(d+1),c.detail=o?o.ShortDescription:void 0,c.documentation=o?{value:o.LongDescription,kind:n.MarkupKind.Markdown}:void 0,c}));return Promise.resolve(n.CompletionList.create(p))}return Promise.resolve(n.CompletionList.create([]))},e.prototype.doRangeFormat=function(e,d){if(!e)return Promise.resolve([]);var u=e.offsetAt(d.start),t=e.offsetAt(d.end),a=this.getFormattedCommandsInDocumentV2(e,u,t);return a.originalRange&&0!==a.formattedCommands.length?Promise.resolve([n.TextEdit.replace(a.originalRange,a.formattedCommands.join(""))]):Promise.resolve([])},e.prototype.doDocumentFormat=function(e){if(!e)return Promise.resolve([]);var d=e.positionAt(0),u=e.positionAt(e.getText().length),t=n.Range.create(d,u),a=this.getFormattedCommandsInDocumentV2(e).formattedCommands.join("");return Promise.resolve([n.TextEdit.replace(t,a)])},e.prototype.doCurrentCommandFormat=function(e,d){var u=e.offsetAt(d),n=this.createRange(e,u-1,u+1);return this.doRangeFormat(e,n)},e.prototype.doFolding=function(e){return e?this.getCommandsInDocument(e).then((function(d){return d.map((function(d){d.text.endsWith("\r\n")?d.absoluteEnd-=2:(d.text.endsWith("\r")||d.text.endsWith("\n"))&&--d.absoluteEnd;var u=e.positionAt(d.absoluteStart),n=e.positionAt(d.absoluteEnd);return{startLine:u.line,startCharacter:u.character,endLine:n.line,endCharacter:n.character}}))})):Promise.resolve([])},e.prototype.getClusterReferences=function(e,d){var u,n=this.parseDocumentV2(e),t=this.getCurrentCommandV2(n,d),a=null===(u=null==t?void 0:t.Service)||void 0===u?void 0:u.GetClusterReferences();if(!a)return Promise.resolve([]);for(var r=[],i=new Set,o=0;o<a.Count;o++){var c=a.getItem(o),f=Kusto.Language.KustoFacts.GetHostName(c.Cluster);i.has(f)||(i.add(f),this._clustersSetInGlobalState.has(f)||r.push({clusterName:f}))}return Promise.resolve(r)},e.prototype.getDatabaseReferences=function(e,d){var u,n=this.parseDocumentV2(e),t=this.getCurrentCommandV2(n,d),a=null===(u=null==t?void 0:t.Service)||void 0===u?void 0:u.GetDatabaseReferences();if(!a)return Promise.resolve([]);for(var r=[],i=new Set,o=0;o<a.Count;o++){var c=a.getItem(o),f=Kusto.Language.KustoFacts.GetHostName(c.Cluster),s=this.createDatabaseUniqueName(f,c.Database);if(!i.has(s))i.add(s),this._nonEmptyDatabaseSetInGlobalState.has(s)||r.push({databaseName:c.Database,clusterName:c.Cluster})}return Promise.resolve(r)},e.prototype.doValidation=function(e,d){var u=this;if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var n=this.parseDocumentV2(e),t=this.toArray(n.Blocks);d.length>0&&(t=this.getAffectedBlocks(t,d));var a=t.map((function(e){var d=u.toArray(e.Service.GetDiagnostics());return d||[]})).reduce((function(e,d){return e.concat(d)}),[]),r=this.toLsDiagnostics(a,e);return Promise.resolve(r)},e.prototype.toLsDiagnostics=function(e,d){return e.filter((function(e){return e.HasLocation})).map((function(e){var u=d.positionAt(e.Start),t=d.positionAt(e.Start+e.Length),a=n.Range.create(u,t);return n.Diagnostic.create(a,e.Message,n.DiagnosticSeverity.Error)}))},e.prototype.doColorization=function(e,d){var u=this;if(!e||!this._languageSettings.useSemanticColorization)return Promise.resolve([]);if(!this.isIntellisenseV2()){if(d.length>0){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var n=this.toArray(this._parser.Results).filter((function(e){return!!e&&d.some((function(d){var u=d.start,n=d.end;return e.AbsoluteStart>=u&&e.AbsoluteStart<=n||u>=e.AbsoluteStart&&u<=e.AbsoluteEnd+1}))}));if(!n||0===n.length)return Promise.resolve([{classifications:[],absoluteStart:d[0].start,absoluteEnd:d[0].end}]);var t=n.map((function(e){return u.parseTextV1(e.Text,r.ParseMode.TokenizeAllText),{classifications:b(u.getClassificationsFromParseResult(e.AbsoluteStart)),absoluteStart:e.AbsoluteStart,absoluteEnd:e.AbsoluteEnd}}));return Promise.resolve(t)}this.parseDocumentV1(e,r.ParseMode.TokenizeAllText);var a=this.getClassificationsFromParseResult();return Promise.resolve([{classifications:b(a),absoluteStart:0,absoluteEnd:e.getText().length}])}var i=this.parseDocumentV2(e);if(d.length>0){var o=this.toArray(i.Blocks),c=this.getAffectedBlocks(o,d).map((function(e){return{classifications:b(u.toArray(e.Service.GetClassifications(e.Start,e.End).Classifications)),absoluteStart:e.Start,absoluteEnd:e.End}}));return Promise.resolve(c)}var f=this.toArray(i.Blocks).map((function(e){return u.toArray(e.Service.GetClassifications(e.Start,e.Length).Classifications)})).reduce((function(e,d){return e.concat(d)}),[]);return Promise.resolve([{classifications:b(f),absoluteStart:0,absoluteEnd:e.getText().length}])},e.prototype.getAffectedBlocks=function(e,d){return e.filter((function(e){return!!e&&d.some((function(d){var u=d.start,n=d.end;return e.Start>=u&&e.Start<=n||u>=e.Start&&u<=e.End+1}))}))},e.prototype.addClusterToSchema=function(d,u,n){var t=Kusto.Language.KustoFacts.GetHostName(u),a=this._kustoJsSchemaV2.GetCluster$1(t);if(a&&n.filter((function(e){return!a.GetDatabase(e)})).map((function(e){var d=new c.DatabaseSymbol.$ctor1(e,void 0,!1);a=a.AddDatabase(d)})),!a){var r=n.map((function(e){return new c.DatabaseSymbol.$ctor1(e,void 0,!1)})),i=e.toBridgeList(r);a=new c.ClusterSymbol.$ctor1(t,i,!1)}return this._kustoJsSchemaV2=this._kustoJsSchemaV2.AddOrReplaceCluster(a),this._script=o.CodeScript.From$1(d.getText(),this._kustoJsSchemaV2),Promise.resolve()},e.prototype.addDatabaseToSchema=function(d,u,n){var t=Kusto.Language.KustoFacts.GetHostName(u),a=this._kustoJsSchemaV2.GetCluster$1(t);a||(a=new c.ClusterSymbol.$ctor1(t,null,!1));var r=e.convertToDatabaseSymbol(n);return a=a.AddOrUpdateDatabase(r),this._kustoJsSchemaV2=this._kustoJsSchemaV2.AddOrReplaceCluster(a),this._script=o.CodeScript.From$1(d.getText(),this._kustoJsSchemaV2),Promise.resolve()},e.prototype.setSchema=function(d){var u=this;if(this._schema=d,this._languageSettings.useIntellisenseV2){var n=d&&"Engine"===d.clusterType?this.convertToKustoJsSchemaV2(d):null;this._kustoJsSchemaV2=n,this._script=void 0,this._parsePropertiesV2=void 0}return new Promise((function(n,t){var a=d?e.convertToKustoJsSchema(d):void 0;u._kustoJsSchema=a,u.createRulesProvider(a,d.clusterType),n(void 0)}))},e.prototype.setParameters=function(d){if(!this._languageSettings.useIntellisenseV2||"Engine"!==this._schema.clusterType)throw new Error("setParameters requires intellisense V2 and Engine cluster");this._schema.globalParameters=d;var u=d.map((function(d){return e.createParameterSymbol(d)}));return this._kustoJsSchemaV2=this._kustoJsSchemaV2.WithParameters(e.toBridgeList(u)),Promise.resolve(void 0)},e.prototype.setSchemaFromShowSchema=function(e,d,u,n){var t=this;return this.normalizeSchema(e,d,u).then((function(e){return t.setSchema(__assign(__assign({},e),{globalParameters:n}))}))},e.prototype.normalizeSchema=function(e,d,u){var n=Object.keys(e.Databases).map((function(d){return e.Databases[d]})).map((function(e){var d=e.Name,u=e.Tables,n=e.ExternalTables,t=e.MaterializedViews,a=e.Functions;return{name:d,minorVersion:e.MinorVersion,majorVersion:e.MajorVersion,tables:[].concat.apply([],[[u,"Table"],[t,"MaterializedView"],[n,"ExternalTable"]].filter((function(e){return e[0]})).map((function(e){var d=e[0],u=e[1];return Object.values(d).map((function(e){var d=e.Name,n=e.OrderedColumns;return{name:d,docstring:e.DocString,entityType:u,columns:n.map((function(e){var d=e.Name,u=(e.Type,e.DocString);return{name:d,type:e.CslType,docstring:u}}))}}))}))),functions:Object.keys(a).map((function(e){return a[e]})).map((function(e){return{name:e.Name,body:e.Body,docstring:e.DocString,inputParameters:e.InputParameters.map((function(e){return{name:e.Name,type:e.Type,cslType:e.CslType,cslDefaultValue:e.CslDefaultValue,columns:e.Columns?e.Columns.map((function(e){return{name:e.Name,type:e.Type,cslType:e.CslType}})):e.Columns}}))}}))}})),t={clusterType:"Engine",cluster:{connectionString:d,databases:n},database:n.filter((function(e){return e.name===u}))[0]};return Promise.resolve(t)},e.prototype.getSchema=function(){return Promise.resolve(this._schema)},e.prototype.getCommandInContext=function(e,d){return this.isIntellisenseV2()?this.getCommandInContextV2(e,d):this.getCommandInContextV1(e,d)},e.prototype.getCommandAndLocationInContext=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve(null);var u=this.parseDocumentV2(e),t=this.getCurrentCommandV2(u,d);if(!t)return Promise.resolve(null);var a=e.positionAt(t.Start),r=e.positionAt(t.End),i=n.Location.create(e.uri,n.Range.create(a,r)),o=t.Text;return Promise.resolve({text:o,location:i})},e.prototype.getCommandInContextV1=function(e,d){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var u=this.getCurrentCommand(e,d);return u?Promise.resolve(u.Text):Promise.resolve(null)},e.prototype.getCommandInContextV2=function(e,d){if(!e)return Promise.resolve(null);var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);return n?Promise.resolve(n.Text):Promise.resolve(null)},e.prototype.getCommandsInDocument=function(e){return e?this.isIntellisenseV2()?this.getCommandsInDocumentV2(e):this.getCommandsInDocumentV1(e):Promise.resolve([])},e.prototype.getCommandsInDocumentV1=function(e){this.parseDocumentV1(e,r.ParseMode.CommandTokensOnly);var d=this.toArray(this._parser.Results);return Promise.resolve(d.map((function(e){return{absoluteStart:e.AbsoluteStart,absoluteEnd:e.AbsoluteEnd,text:e.Text}})))},e.prototype.toPlacementStyle=function(e){if(e)switch(e){case"None":return o.PlacementStyle.None;case"NewLine":return o.PlacementStyle.NewLine;case"Smart":return o.PlacementStyle.Smart;default:throw new Error("Unknown PlacementStyle")}},e.prototype.getFormattedCommandsInDocumentV2=function(e,d,u){var n=this,t=this.parseDocumentV2(e),a=this.toArray(t.Blocks).filter((function(e){if(!e.Text||""==e.Text.trim())return!1;if(null==d||null==u)return!0;for(var n=e.End,t=e.Text,a=t.length-1;a>=0&&("\r"==t[a]||"\n"==t[a]);a--)n--;return e.Start>d&&e.Start<u||(n>d&&n<u||(e.Start<=d&&n>=u||void 0))}));return 0===a.length?{formattedCommands:[]}:{formattedCommands:a.map((function(e){var t,a,r=n._languageSettings.formatter,i=Kusto.Language.Editor.FormattingOptions.Default.WithIndentationSize(null!==(t=null==r?void 0:r.indentationSize)&&void 0!==t?t:4).WithInsertMissingTokens(!1).WithPipeOperatorStyle(null!==(a=n.toPlacementStyle(null==r?void 0:r.pipeOperatorStyle))&&void 0!==a?a:o.PlacementStyle.Smart).WithSemicolonStyle(Kusto.Language.Editor.PlacementStyle.None).WithBrackettingStyle(o.BrackettingStyle.Diagonal);return null==d||null==u||d===e.Start&&e.End,e.Service.GetFormattedText(i).Text})),originalRange:this.createRange(e,a[0].Start,a[a.length-1].End)}},e.prototype.getCommandsInDocumentV2=function(e){var d=this.parseDocumentV2(e),u=this.toArray(d.Blocks).filter((function(e){return""!=e.Text.trim()}));return Promise.resolve(u.map((function(e){return{absoluteStart:e.Start,absoluteEnd:e.End,text:e.Text}})))},e.prototype.getClientDirective=function(e){var d={v:null},u=r.CslCommandParser.IsClientDirective(e,d);return Promise.resolve({isClientDirective:u,directiveWithoutLeadingComments:d.v})},e.prototype.getAdminCommand=function(e){var d={v:null},u=r.CslCommandParser.IsAdminCommand$1(e,d);return Promise.resolve({isAdminCommand:u,adminCommandWithoutLeadingComments:d.v})},e.prototype.findDefinition=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),t=e.offsetAt(d),a=this.getCurrentCommandV2(u,t);if(!a)return Promise.resolve([]);var r=a.Service.GetRelatedElements(e.offsetAt(d)),i=this.toArray(r.Elements)[0];if(!i)return Promise.resolve([]);var o=e.positionAt(i.Start),c=e.positionAt(i.End),f=n.Range.create(o,c),s=n.Location.create(e.uri,f);return Promise.resolve([s])},e.prototype.findReferences=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),t=e.offsetAt(d),a=this.getCurrentCommandV2(u,t);if(!a)return Promise.resolve([]);var r=a.Service.GetRelatedElements(e.offsetAt(d)),i=this.toArray(r.Elements);if(!i||0==i.length)return Promise.resolve([]);var o=i.map((function(d){var u=e.positionAt(d.Start),t=e.positionAt(d.End),a=n.Range.create(u,t);return n.Location.create(e.uri,a)}));return Promise.resolve(o)},e.prototype.getQueryParams=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);this.parseDocumentV2(e);var u=this.parseAndAnalyze(e,d),n=this.toArray(u.Syntax.GetDescendants(Kusto.Language.Syntax.QueryParametersStatement));if(!n||0==n.length)return Promise.resolve([]);var t=[];return n.forEach((function(e){e.WalkElements((function(e){return e.ReferencedSymbol&&e.ReferencedSymbol.Type?t.push({name:e.ReferencedSymbol.Name,type:e.ReferencedSymbol.Type.Name}):void 0}))})),Promise.resolve(t)},e.prototype.getRenderInfo=function(e,d){var u=this,n=this.parseAndAnalyze(e,d);if(!n)return Promise.resolve(void 0);var t=this.toArray(n.Syntax.GetDescendants(Kusto.Language.Syntax.RenderOperator));if(!t||0===t.length)return Promise.resolve(void 0);var a=t[0],r=a.TextStart,i=a.End,o=a.ChartType.ValueText,c=a.WithClause;if(!c){var f={options:{visualization:o},location:{startOffset:r,endOffset:i}};return Promise.resolve(f)}var s=this.toArray(c.Properties).reduce((function(e,d){var n=d.Element$1.Name.SimpleName;switch(n){case"xcolumn":var t=d.Element$1.Expression.ReferencedSymbol.Name;e[n]=t;break;case"ycolumns":case"anomalycolumns":var a=u.toArray(d.Element$1.Expression.Names).map((function(e){return e.Element$1.SimpleName}));e[n]=a;break;case"ymin":case"ymax":var r=parseFloat(d.Element$1.Expression.ConstantValue);e[n]=r;break;case"title":case"xtitle":case"ytitle":case"visualization":case"series":var i=d.Element$1.Expression.ConstantValue;e[n]=i;break;case"xaxis":case"yaxis":var o=d.Element$1.Expression.ConstantValue;e[n]=o;break;case"legend":var c=d.Element$1.Expression.ConstantValue;e[n]=c;break;case"ySplit":var f=d.Element$1.Expression.ConstantValue;e[n]=f;break;case"accumulate":var s=d.Element$1.Expression.ConstantValue;e[n]=s;break;case"kind":var m=d.Element$1.Expression.ConstantValue;e[n]=m;break;default:l(n)}return e}),{}),m={options:__assign({visualization:o},s),location:{startOffset:r,endOffset:i}};return Promise.resolve(m)},e.prototype.getReferencedGlobalParams=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve([]);var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);if(!n)return Promise.resolve([]);var t=n.Text,a=Kusto.Language.KustoCode.ParseAndAnalyze(t,this._kustoJsSchemaV2),r=this.toArray(this._kustoJsSchemaV2.Parameters),i=this.toArray(a.Syntax.GetDescendants(Kusto.Language.Syntax.Expression)).filter((function(e){return null!==e.ReferencedSymbol})).map((function(e){return e.ReferencedSymbol})).filter((function(e){return r.filter((function(d){return d===e})).length>0})).map((function(e){return{name:e.Name,type:e.Type.Name}}));return Promise.resolve(i)},e.prototype.getGlobalParams=function(e){if(!this.isIntellisenseV2())return Promise.resolve([]);var d=this.toArray(this._kustoJsSchemaV2.Parameters).map((function(e){return{name:e.Name,type:e.Type.Name}}));return Promise.resolve(d)},e.prototype.doRename=function(e,d,u){var t;if(!e||!this.isIntellisenseV2())return Promise.resolve(void 0);var a=this.parseDocumentV2(e),r=e.offsetAt(d),i=this.getCurrentCommandV2(a,r);if(!i)return Promise.resolve(void 0);var c=i.Service.GetRelatedElements(e.offsetAt(d)),f=this.toArray(c.Elements),s=f.filter((function(e){return e.Kind==o.RelatedElementKind.Declaration}));if(!s||0==s.length)return Promise.resolve(void 0);var l=f.map((function(d){var t=e.positionAt(d.Start),a=e.positionAt(d.End),r=n.Range.create(t,a);return n.TextEdit.replace(r,u)})),m={changes:(t={},t[e.uri]=l,t)};return Promise.resolve(m)},e.prototype.doHover=function(e,d){if(!e||!this.isIntellisenseV2())return Promise.resolve(void 0);var u=this.parseDocumentV2(e),n=e.offsetAt(d),t=this.getCurrentCommandV2(u,n);if(!t)return Promise.resolve(void 0);if(!t.Service.IsFeatureSupported(o.CodeServiceFeatures.QuickInfo,n))return Promise.resolve(void 0);var a=t.Service.GetQuickInfo(n);if(!a||!a.Items)return Promise.resolve(void 0);var r=this.toArray(a.Items);if(!r)return Promise.resolve(void 0);var i=(r=r.filter((function(e){return e.Kind!==o.QuickInfoKind.Error}))).map((function(e){return e.Text.replace("\n\n","\n* * *\n")})).join("\n* * *\n");return Promise.resolve({contents:i})},Object.defineProperty(e,"dummySchema",{get:function(){var e={majorVersion:0,minorVersion:0,name:"Kuskus",tables:[{name:"KustoLogs",columns:[{name:"Source",type:"string"},{name:"Timestamp",type:"datetime"},{name:"Directory",type:"string"}],docstring:"A dummy description to test that docstring shows as expected when hovering over a table"}],functions:[{name:"HowBig",inputParameters:[{name:"T",columns:[{name:"Timestamp",type:"System.DateTime",cslType:"datetime"}]}],docstring:"A dummy description to test that docstring shows as expected when hovering over a function",body:"{\r\n union \r\n (T | count | project V='Volume', Metric = strcat(Count/1e9, ' Billion records')),\r\n (T | summarize FirstRecord=min(Timestamp)| project V='Volume', Metric = strcat(toint((now()-FirstRecord)/1d), ' Days of data (from: ', format_datetime(FirstRecord, 'yyyy-MM-dd'),')')),\r\n (T | where Timestamp > ago(1h) | count | project V='Velocity', Metric = strcat(Count/1e6, ' Million records / hour')),\r\n (T | summarize Latency=now()-max(Timestamp) | project V='Velocity', Metric = strcat(Latency / 1sec, ' seconds latency')),\r\n (T | take 1 | project V='Variety', Metric=tostring(pack_all()))\r\n | order by V \r\n}"},{name:"FindCIDPast24h",inputParameters:[{name:"clientActivityId",type:"System.String",cslType:"string"}],body:"{ KustoLogs | where Timestamp > now(-1d) | where ClientActivityId == clientActivityId} "}]};return{clusterType:"Engine",cluster:{connectionString:"https://kuskus.kusto.windows.net;fed=true",databases:[e]},database:e}},enumerable:!1,configurable:!0}),e.convertToEntityDataType=function(e){},e.convertToKustoJsSchema=function(e){switch(e.clusterType){case"Engine":var d=e.database?e.database.name:void 0,n=new r.KustoIntelliSenseClusterEntity,t=void 0;n.ConnectionString=e.cluster.connectionString;var i=[];return e.cluster.databases.forEach((function(e){var n=new r.KustoIntelliSenseDatabaseEntity;n.Name=e.name;var o=[];e.tables.forEach((function(e){var d=new r.KustoIntelliSenseTableEntity;d.Name=e.name;var u=[];e.columns.forEach((function(e){var d=new r.KustoIntelliSenseColumnEntity;d.Name=e.name,d.TypeCode=r.EntityDataType[a.getEntityDataTypeFromCslType(e.type)],u.push(d)})),d.Columns=new Bridge.ArrayEnumerable(u),o.push(d)}));var c=[];e.functions.forEach((function(e){var d=new r.KustoIntelliSenseFunctionEntity;d.Name=e.name,d.CallName=u.getCallName(e),d.Expression=u.getExpression(e),c.push(d)})),n.Tables=new Bridge.ArrayEnumerable(o),n.Functions=new Bridge.ArrayEnumerable(c),i.push(n),e.name==d&&(t=n)})),n.Databases=new Bridge.ArrayEnumerable(i),new r.KustoIntelliSenseQuerySchema(n,t);case"ClusterManager":return{accounts:e.accounts.map((function(e){var d=new r.KustoIntelliSenseAccountEntity;return d.Name=e,d})),services:e.services.map((function(e){var d=new r.KustoIntelliSenseServiceEntity;return d.Name=e,d})),connectionString:e.connectionString};case"DataManagement":return;default:return l(e)}},e.scalarParametersToSignature=function(e){return"("+e.map((function(e){return e.name+": "+e.cslType})).join(", ")+")"},e.inputParameterToSignature=function(e){var d=this;return"("+e.map((function(e){if(e.columns){var u=d.scalarParametersToSignature(e.columns);return e.name+": "+u}return e.name+": "+e.cslType})).join(", ")+")"},e.toLetStatement=function(e){var d=this.inputParameterToSignature(e.inputParameters);return"let "+e.name+" = "+d+" "+e.body},e.createColumnSymbol=function(e){return new c.ColumnSymbol(e.name,c.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(e.type)),e.docstring)},e.createParameterSymbol=function(e){var d=Kusto.Language.Symbols.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(e.type));return new c.ParameterSymbol(e.name,d,null)},e.createParameter=function(d){if(!d.columns){var u=Kusto.Language.Symbols.ScalarTypes.GetSymbol(a.getCslTypeNameFromClrType(d.type)),n=d.cslDefaultValue&&"string"==typeof d.cslDefaultValue?i.QueryParser.ParseLiteral$1(d.cslDefaultValue):void 0;return new c.Parameter.$ctor3(d.name,u,null,null,null,!1,null,1,1,n,null)}if(0==d.columns.length)return new c.Parameter.ctor(d.name,c.ParameterTypeKind.Tabular,c.ArgumentKind.Expression,null,null,!1,null,1,1,null,null);var t=new c.TableSymbol.ctor(d.columns.map((function(d){return e.createColumnSymbol(d)})));return new c.Parameter.$ctor2(d.name,t)},e.convertToDatabaseSymbol=function(d){return function(d){var u=d.tables?d.tables.map((function(d){return function(d){var u=d.columns.map((function(d){return e.createColumnSymbol(d)})),n=new c.TableSymbol.$ctor3(d.name,u);switch(n.Description=d.docstring,d.entityType){case"MaterializedViewTable":n=n.WithIsMaterializedView(!0);break;case"ExternalTable":n=n.WithIsExternal(!0)}return n}(d)})):[],n=d.functions?d.functions.map((function(d){return n=(u=d).inputParameters.map((function(d){return e.createParameter(d)})),new c.FunctionSymbol.$ctor16(u.name,u.body,e.toBridgeList(n),u.docstring);var u,n})):[];return new c.DatabaseSymbol.ctor(d.name,u.concat(n))}(d)},e.prototype.convertToKustoJsSchemaV2=function(d){var u=this._schemaCache[d.cluster.connectionString];u||(this._schemaCache[d.cluster.connectionString]={},u=this._schemaCache[d.cluster.connectionString]);var n=d.cluster.databases.reduce((function(e,d){return e[d.name]=d}),{});Object.keys(u).map((function(e){n[e]||delete u.dbName}));var t=f.Default,a=d.database?d.database.name:void 0,r=void 0,i=d.cluster.databases.map((function(d){var n=d.name===a,t=u[d.name];if(!t||t.database.majorVersion<d.majorVersion||n&&!t.includesFunctions){var i=e.convertToDatabaseSymbol(d);u[d.name]={database:d,symbol:i,includesFunctions:n}}var o=u[d.name].symbol;return d.name===a&&(r=o),o})),o=d.cluster.connectionString.match(/(.*\/\/)?([^\/;]*)/)[2].split(".")[0],s=new c.ClusterSymbol.ctor(o,i);if(t=t.WithCluster(s),r&&(t=t.WithDatabase(r)),d.globalParameters){var l=d.globalParameters.map((function(d){return e.createParameterSymbol(d)}));t=t.WithParameters(e.toBridgeList(l))}return t},e.prototype.getClassificationsFromParseResult=function(e){var d=this;return void 0===e&&(e=0),this.toArray(this._parser.Results).map((function(e){return d.toArray(e.Tokens)})).reduce((function(e,d){return e.concat(d)}),[]).map((function(u){return new o.ClassifiedRange(d.tokenKindToClassificationKind(u.TokenKind),u.AbsoluteStart+e,u.Length)}))},e.trimTrailingNewlineFromRange=function(e,d,u,t){for(var a=e.length-1;"\r"===e[a]||"\n"===e[a];)--a;var r=d+a+1,i=u.positionAt(r);return n.Range.create(t.start,i)},e.prototype.getSortText=function(e){if(e<=0)throw new RangeError("order should be a number >= 1. instead got "+e);for(var d="",u=Math.floor(e/26),n=0;n<u;++n)d+="z";var t=e%26;return t>0&&(d+=String.fromCharCode(96+t)),d},e.prototype.parseTextV1=function(e,d){this._parser.Parse("Engine"===this._schema.clusterType?this._rulesProvider:null,e,d)},e.prototype.parseDocumentV1=function(e,d){this._parsePropertiesV1&&!this._parsePropertiesV1.isParseNeeded(e,this._rulesProvider,d)||(this.parseTextV1(e.getText(),d),this._parsePropertiesV1=new p(e.version,e.uri,this._rulesProvider,d))},e.prototype.parseDocumentV2=function(e){return this._parsePropertiesV2&&!this._parsePropertiesV2.isParseNeeded(e,this._rulesProvider)||(this._script?this._script=this._script.WithText(e.getText()):this._script=o.CodeScript.From$1(e.getText(),this._kustoJsSchemaV2),this._parsePropertiesV2=new p(e.version,e.uri)),this._script},e.prototype.getCurrentCommand=function(e,d){var u=this.toArray(this._parser.Results),n=u.filter((function(e){return e.AbsoluteStart<=d&&e.AbsoluteEnd>=d}))[0];return n||(n=u.filter((function(e){return e.AbsoluteStart<=d&&e.AbsoluteEnd+1>=d}))[0])&&!n.Text.endsWith("\r\n\r\n")?n:null},e.prototype.getCurrentCommandV2=function(e,d){return e.GetBlockAtPosition(d)},e.prototype.getTextToInsert=function(e,d){var u=e.GetBeforeApplyInfo(d.Value),t=e.GetAfterApplyInfo(d.Value),a=u.Text||""+d.Value+t.Text||"",r=n.InsertTextFormat.PlainText;if(t.OffsetToken&&t.OffsetPosition){var i=a.indexOf(t.OffsetToken);i>=0&&(a=this.insertToString(a,"$0",i-a.length+t.OffsetPosition),r=n.InsertTextFormat.Snippet)}else t.OffsetPosition&&(a=this.insertToString(a,"$0",t.OffsetPosition),r=n.InsertTextFormat.Snippet);return{insertText:a,insertTextFormat:r}},e.prototype.insertToString=function(e,d,u){var n=e.length+u;return u>=0||n<0?e:e.substring(0,n)+d+e.substring(n)},e.prototype.getCommandWithoutLastWord=function(e){var d=t("[\\w_]*$","s");return e.replace(d,"")},e.prototype.createRulesProvider=function(e,d){var u=new(s(String)),n=new(s(String));if(this._parser=new r.CslCommandParser,"Engine"!=d)if("DataManagement"!==d){var t=e,a=t.accounts,i=t.services,o=t.connectionString;new r.KustoIntelliSenseAccountEntity,new r.KustoIntelliSenseServiceEntity,this._rulesProvider=new r.ClusterManagerIntelliSenseRulesProvider.$ctor1(new Bridge.ArrayEnumerable(a),new Bridge.ArrayEnumerable(i),o)}else this._rulesProvider=new r.DataManagerIntelliSenseRulesProvider(null);else{var c=e;this._rulesProvider=this._languageSettings&&this._languageSettings.includeControlCommands?new r.CslIntelliSenseRulesProvider.$ctor1(c.Cluster,c,u,n,null,!0,!0):new r.CslQueryIntelliSenseRulesProvider.$ctor1(c.Cluster,c,u,n,null,null,null)}},e.prototype.kustoKindToLsKind=function(e){var d=this._kustoKindtolsKind[e];return d||n.CompletionItemKind.Variable},e.prototype.kustoKindToLsKindV2=function(e){var d=this._kustoKindToLsKindV2[e];return d||n.CompletionItemKind.Variable},e.prototype.createRange=function(e,d,u){return n.Range.create(e.positionAt(d),e.positionAt(u))},e.prototype.toArray=function(e){return Bridge.toArray(e)},e.toBridgeList=function(e){return new(System.Collections.Generic.List$1(System.Object).$ctor1)(e)},e.prototype.tokenKindToClassificationKind=function(e){return this._tokenKindToClassificationKind[e]||o.ClassificationKind.PlainText},e.prototype.parseAndAnalyze=function(e,d){if(e&&this.isIntellisenseV2()){var u=this.parseDocumentV2(e),n=this.getCurrentCommandV2(u,d);if(n){var t=n.Text;return Kusto.Language.KustoCode.ParseAndAnalyze(t,this._kustoJsSchemaV2)}}},e}(),h=new g(g.dummySchema,{includeControlCommands:!0,useIntellisenseV2:!0,useSemanticColorization:!0});d.getKustoLanguageService=function(){return h}})),define("vs/language/kusto/kustoWorker",["require","exports","./languageService/kustoLanguageService","vscode-languageserver-types"],(function(e,d,u,n){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.create=d.KustoWorker=void 0;var t=function(){function e(e,d){this._ctx=e,this._languageSettings=d.languageSettings,this._languageService=u.getKustoLanguageService(),this._languageService.configure(this._languageSettings)}return e.prototype.setSchema=function(e){return this._languageService.setSchema(e)},e.prototype.addClusterToSchema=function(e,d,u){var n=this._getTextDocument(e);return n?this._languageService.addClusterToSchema(n,d,u):(console.error("addClusterToSchema: document is "+n+". uri is "+e),null)},e.prototype.addDatabaseToSchema=function(e,d,u){var n=this._getTextDocument(e);return n?this._languageService.addDatabaseToSchema(n,d,u):(console.error("addDatabaseToSchema: document is "+n+". uri is "+e),null)},e.prototype.setSchemaFromShowSchema=function(e,d,u){return this._languageService.setSchemaFromShowSchema(e,d,u)},e.prototype.normalizeSchema=function(e,d,u){return this._languageService.normalizeSchema(e,d,u)},e.prototype.getSchema=function(){return this._languageService.getSchema()},e.prototype.getCommandInContext=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getCommandInContext: document is "+u+". uri is "+e),null;var n=this._languageService.getCommandInContext(u,d);return void 0===n?null:n},e.prototype.getQueryParams=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getQueryParams: document is "+u+". uri is "+e),null;var n=this._languageService.getQueryParams(u,d);return void 0===n?null:n},e.prototype.getGlobalParams=function(e){var d=this._getTextDocument(e);if(!d)return console.error("getGLobalParams: document is "+d+". uri is "+e),null;var u=this._languageService.getGlobalParams(d);return void 0===u?null:u},e.prototype.getReferencedGlobalParams=function(e,d){var u=this._getTextDocument(e);if(!u)return console.error("getReferencedGlobalParams: document is "+u+". uri is "+e),null;var n=this._languageService.getReferencedGlobalParams(u,d);return void 0===n?null:n},e.prototype.getRenderInfo=function(e,d){var u=this._getTextDocument(e);return u||console.error("getRenderInfo: document is "+u+". uri is "+e),this._languageService.getRenderInfo(u,d).then((function(e){return e||null}))},e.prototype.getCommandAndLocationInContext=function(e,d){var u=this._getTextDocument(e);return u?this._languageService.getCommandAndLocationInContext(u,d).then((function(e){if(!e)return null;var d=e.text,u=e.location.range,n=u.start,t=u.end;return{range:new monaco.Range(n.line+1,n.character+1,t.line+1,t.character+1),text:d}})):(console.error("getCommandAndLocationInContext: document is "+u+". uri is "+e),Promise.resolve(null))},e.prototype.getCommandsInDocument=function(e){var d=this._getTextDocument(e);return d?this._languageService.getCommandsInDocument(d):(console.error("getCommandInDocument: document is "+d+". uri is "+e),null)},e.prototype.doComplete=function(e,d){var u=this._getTextDocument(e);return u?this._languageService.doComplete(u,d):null},e.prototype.doValidation=function(e,d){var u=this._getTextDocument(e);return this._languageService.doValidation(u,d)},e.prototype.doRangeFormat=function(e,d){var u=this._getTextDocument(e);return this._languageService.doRangeFormat(u,d)},e.prototype.doFolding=function(e){var d=this._getTextDocument(e);return this._languageService.doFolding(d)},e.prototype.doDocumentFormat=function(e){var d=this._getTextDocument(e);return this._languageService.doDocumentFormat(d)},e.prototype.doCurrentCommandFormat=function(e,d){var u=this._getTextDocument(e);return this._languageService.doCurrentCommandFormat(u,d)},e.prototype.doColorization=function(e,d){var u=this._getTextDocument(e);return this._languageService.doColorization(u,d)},e.prototype.getClientDirective=function(e){return this._languageService.getClientDirective(e)},e.prototype.getAdminCommand=function(e){return this._languageService.getAdminCommand(e)},e.prototype.findDefinition=function(e,d){var u=this._getTextDocument(e);return this._languageService.findDefinition(u,d)},e.prototype.findReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.findReferences(u,d)},e.prototype.doRename=function(e,d,u){var n=this._getTextDocument(e);return this._languageService.doRename(n,d,u)},e.prototype.doHover=function(e,d){var u=this._getTextDocument(e);return this._languageService.doHover(u,d)},e.prototype.setParameters=function(e){return this._languageService.setParameters(e)},e.prototype.getClusterReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.getClusterReferences(u,d)},e.prototype.getDatabaseReferences=function(e,d){var u=this._getTextDocument(e);return this._languageService.getDatabaseReferences(u,d)},e.prototype._getTextDocument=function(e){for(var d=0,u=this._ctx.getMirrorModels();d<u.length;d++){var t=u[d];if(t.uri.toString()===e)return n.TextDocument.create(e,this._languageId,t.version,t.getValue())}return null},e}();d.KustoWorker=t,d.create=function(e,d){return new t(e,d)}}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!-----------------------------------------------------------------------------
|
|
2
2
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
3
|
-
* monaco-kusto version: 4.1.
|
|
3
|
+
* monaco-kusto version: 4.1.1(undefined)
|
|
4
4
|
* Released under the MIT license
|
|
5
5
|
* https://https://github.com/Azure/monaco-kusto/blob/master/README.md
|
|
6
6
|
*-----------------------------------------------------------------------------*/
|
package/release/min/monaco.d.ts
CHANGED
|
@@ -121,29 +121,46 @@ declare module monaco.languages.kusto {
|
|
|
121
121
|
setParameters(parameters: ScalarParameter[]): void;
|
|
122
122
|
/**
|
|
123
123
|
* Get all the database references from the current command.
|
|
124
|
-
* If database's schema is already cached it will not be returned.
|
|
124
|
+
* If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
|
|
125
125
|
* This method should be used to get all the cross-databases in a command, then schema for the database should be fetched and added with addDatabaseToSchema.
|
|
126
126
|
* @example
|
|
127
127
|
* If the current command includes: cluster('help').database('Samples')
|
|
128
|
-
*
|
|
128
|
+
* getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
|
|
129
129
|
*/
|
|
130
130
|
getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
|
|
131
131
|
/**
|
|
132
132
|
* Get all the cluster references from the current command.
|
|
133
133
|
* If cluster's schema is already cached it will not be returned.
|
|
134
134
|
* This method should be used to get all the cross-clusters in a command, then schema for the cluster should be fetched and added with addClusterToSchema.
|
|
135
|
+
* cluster name is returned exactly as written in the KQL `cluster(<cluster name>)` function.
|
|
135
136
|
* @example
|
|
136
137
|
* If the current command includes: cluster('help')
|
|
137
138
|
* it returns [{ clusterName: 'help' }]
|
|
139
|
+
* @example
|
|
140
|
+
* If the current command includes: cluster('https://demo11.westus.kusto.windows.net')
|
|
141
|
+
* getClusterReferences will return [{ clusterName: 'https://demo11.westus.kusto.windows.net' }]
|
|
138
142
|
*/
|
|
139
143
|
getClusterReferences(uri: string, cursorOffset: number): Promise<ClusterReference[]>;
|
|
140
144
|
/**
|
|
141
145
|
* Adds a database's scheme. Useful with getDatabaseReferences to load schema for cross-cluster commands.
|
|
146
|
+
* @param clusterName the name of the cluster as returned from getDatabaseReferences/getClusterReferences.
|
|
147
|
+
* @example
|
|
148
|
+
* - User enters cluster('help').database('Samples')
|
|
149
|
+
* - hosting app calls getDatabaseReferences which returns [{ clusterName: 'help', databaseName: 'Samples' }].
|
|
150
|
+
* - hosting app fetches the database Schema from https://help.kusto.windows.net
|
|
151
|
+
* - hosting app calls 'addDatabaseToSchema' with the database's schema.
|
|
152
|
+
* - now, when user types cluster('help').database('Samples') then the auto complete list will show all the tables.
|
|
142
153
|
*/
|
|
143
154
|
addDatabaseToSchema(uri: string, clusterName: string, databaseSchema: Database): Promise<void>;
|
|
144
155
|
/**
|
|
145
|
-
* Adds a cluster's
|
|
146
|
-
*
|
|
156
|
+
* Adds a cluster's databases to the schema. Useful when used with getClusterReferences in cross-cluster commands.
|
|
157
|
+
* @param clusterName the name of the cluster as returned in getClusterReferences.
|
|
158
|
+
* @example
|
|
159
|
+
* - User enters cluster('help')
|
|
160
|
+
* - hosting app calls getClusterReferences which returns [{ clusterName: 'help' }].
|
|
161
|
+
* - hosting app fetches the list of databases from https://help.kusto.windows.net
|
|
162
|
+
* - hosting app calls addClusterToSchema with the list of databases.
|
|
163
|
+
* - now, when user type `cluster('help').database(` then the auto complete list will show all the databases.
|
|
147
164
|
*/
|
|
148
165
|
addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
|
|
149
166
|
}
|