@kusto/monaco-kusto 4.0.5 → 4.1.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kusto/monaco-kusto",
3
- "version": "4.0.5",
3
+ "version": "4.1.2",
4
4
  "description": "CSL, KQL plugin for the Monaco Editor",
5
5
  "author": {
6
6
  "name": "Microsoft"
@@ -6358,6 +6358,7 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6358
6358
  kind: classification.Kind,
6359
6359
  }); });
6360
6360
  }
6361
+ ;
6361
6362
  /**
6362
6363
  * Kusto Language service translates the kusto object model (transpiled from C# by Bridge.Net)
6363
6364
  * to the vscode language server types, which are used by vscode language extensions.
@@ -6511,12 +6512,46 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6511
6512
  _d);
6512
6513
  this._schemaCache = {};
6513
6514
  this._kustoJsSchema = KustoLanguageService.convertToKustoJsSchema(schema);
6514
- this._kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
6515
+ this.__kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
6515
6516
  this._schema = schema;
6517
+ this._clustersSetInGlobalState = new Set();
6518
+ this._nonEmptyDatabaseSetInGlobalState = new Set(); // used to remove clusters that are already in the global state
6516
6519
  this.configure(languageSettings);
6517
6520
  this._newlineAppendPipePolicy = new Kusto.Data.IntelliSense.ApplyPolicy();
6518
6521
  this._newlineAppendPipePolicy.Text = '\n| ';
6519
6522
  }
6523
+ KustoLanguageService.prototype.createDatabaseUniqueName = function (clusterName, databaseName) {
6524
+ return clusterName + "_" + databaseName;
6525
+ };
6526
+ Object.defineProperty(KustoLanguageService.prototype, "_kustoJsSchemaV2", {
6527
+ /**
6528
+ * A getter for __kustoJsSchemaV2
6529
+ */
6530
+ get: function () {
6531
+ return this.__kustoJsSchemaV2;
6532
+ },
6533
+ /**
6534
+ * A setter for _kustoJsSchemaV2. After a schema (global state) is set, create 2 sets of cluster and database names.
6535
+ */
6536
+ set: function (globalState) {
6537
+ this.__kustoJsSchemaV2 = globalState;
6538
+ this._clustersSetInGlobalState.clear();
6539
+ this._nonEmptyDatabaseSetInGlobalState.clear();
6540
+ // create 2 Sets with cluster names and database names based on the updated Global State.
6541
+ for (var i = 0; i < globalState.Clusters.Count; i++) {
6542
+ var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
6543
+ this._clustersSetInGlobalState.add(clusterSymbol.Name);
6544
+ for (var i2 = 0; i2 < clusterSymbol.Databases.Count; i2++) {
6545
+ var databaseSymbol = clusterSymbol.Databases.getItem(i2);
6546
+ if (databaseSymbol.Tables.Count > 0) { // only include database with tables
6547
+ this._nonEmptyDatabaseSetInGlobalState.add(this.createDatabaseUniqueName(clusterSymbol.Name, databaseSymbol.Name));
6548
+ }
6549
+ }
6550
+ }
6551
+ },
6552
+ enumerable: false,
6553
+ configurable: true
6554
+ });
6520
6555
  KustoLanguageService.prototype.configure = function (languageSettings) {
6521
6556
  this._languageSettings = languageSettings;
6522
6557
  // Since we're still reverting to V1 intellisense for control commands, we need to update the rules provider
@@ -6526,15 +6561,43 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6526
6561
  KustoLanguageService.prototype.doComplete = function (document, position) {
6527
6562
  return this.isIntellisenseV2() ? this.doCompleteV2(document, position) : this.doCompleteV1(document, position);
6528
6563
  };
6564
+ /**
6565
+ * important: Only use during development to test Global State.
6566
+ * Prints clusters, databases and tables that are currently in the GlobalState.
6567
+ */
6568
+ KustoLanguageService.prototype.debugGlobalState = function (globals) {
6569
+ // iterate over clusters
6570
+ console.log("globals.Clusters.Count: " + globals.Clusters.Count);
6571
+ for (var i = 0; i < globals.Clusters.Count; i++) {
6572
+ var cluster = globals.Clusters.getItem(i);
6573
+ console.log("cluster: " + cluster.Name);
6574
+ // iterate over databases
6575
+ console.log("cluster.Databases.Count: " + cluster.Databases.Count);
6576
+ for (var i2 = 0; i2 < cluster.Databases.Count; i2++) {
6577
+ var database = cluster.Databases.getItem(i2);
6578
+ console.log("cluster.database: [" + cluster.Name + "].[" + database.Name + "]");
6579
+ // iterate over tables
6580
+ console.log("cluster.Databases.Tables.Count: " + database.Tables.Count);
6581
+ for (var i3 = 0; i3 < database.Tables.Count; i3++) {
6582
+ var table = database.Tables.getItem(i3);
6583
+ console.log("cluster.database.table: [" + cluster.Name + "].[" + database.Name + "].[" + table.Name + "]");
6584
+ }
6585
+ }
6586
+ }
6587
+ };
6529
6588
  KustoLanguageService.prototype.doCompleteV2 = function (document, position) {
6530
6589
  var _this = this;
6531
6590
  if (!document) {
6532
6591
  return Promise.resolve(ls.CompletionList.create([]));
6533
6592
  }
6534
6593
  var script = this.parseDocumentV2(document);
6594
+ // print cluster/database/tables from CodeScript.Globals
6595
+ // this.debugGlobalState(script.Globals);
6596
+ // get current command
6535
6597
  var cursorOffset = document.offsetAt(position);
6536
- var currentcommand = this.getCurrentCommandV2(script, cursorOffset);
6537
- var completionItems = currentcommand.Service.GetCompletionItems(cursorOffset);
6598
+ var currentCommand = script.GetBlockAtPosition(cursorOffset);
6599
+ // get completion items
6600
+ var completionItems = currentCommand.Service.GetCompletionItems(cursorOffset);
6538
6601
  var disabledItems = this.disabledCompletionItemsV2;
6539
6602
  if (this._languageSettings.disabledCompletionItems) {
6540
6603
  this._languageSettings.disabledCompletionItems.map(function (item) {
@@ -6701,6 +6764,62 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6701
6764
  });
6702
6765
  });
6703
6766
  };
6767
+ KustoLanguageService.prototype.getClusterReferences = function (document, cursorOffset) {
6768
+ var _a;
6769
+ var script = this.parseDocumentV2(document);
6770
+ var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
6771
+ var clusterReferences = (_a = currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.Service) === null || _a === void 0 ? void 0 : _a.GetClusterReferences();
6772
+ if (!clusterReferences) {
6773
+ return Promise.resolve([]);
6774
+ }
6775
+ var newClustersReferences = [];
6776
+ var newClustersReferencesSet = new Set(); // used to remove duplicates
6777
+ // Keep only unique clusters that aren't already exist in the Global State
6778
+ for (var i = 0; i < clusterReferences.Count; i++) {
6779
+ var clusterReference = clusterReferences.getItem(i);
6780
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
6781
+ // ignore duplicates
6782
+ if (newClustersReferencesSet.has(clusterHostName)) {
6783
+ continue;
6784
+ }
6785
+ newClustersReferencesSet.add(clusterHostName);
6786
+ // ignore references that are already in the GlobalState.
6787
+ if (!this._clustersSetInGlobalState.has(clusterHostName)) {
6788
+ newClustersReferences.push({ clusterName: clusterHostName });
6789
+ }
6790
+ }
6791
+ return Promise.resolve(newClustersReferences);
6792
+ };
6793
+ KustoLanguageService.prototype.getDatabaseReferences = function (document, cursorOffset) {
6794
+ var _a;
6795
+ var script = this.parseDocumentV2(document);
6796
+ var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
6797
+ var databasesReferences = (_a = currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.Service) === null || _a === void 0 ? void 0 : _a.GetDatabaseReferences();
6798
+ if (!databasesReferences) {
6799
+ return Promise.resolve([]);
6800
+ }
6801
+ var newDatabasesReferences = [];
6802
+ var newDatabasesReferencesSet = new Set();
6803
+ for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
6804
+ var databaseReference = databasesReferences.getItem(i1);
6805
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
6806
+ // ignore duplicates
6807
+ var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
6808
+ if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
6809
+ continue;
6810
+ }
6811
+ newDatabasesReferencesSet.add(databaseReferenceUniqueId);
6812
+ // ignore references that are already in the GlobalState.
6813
+ var foundInGlobalState = this._nonEmptyDatabaseSetInGlobalState.has(databaseReferenceUniqueId);
6814
+ if (!foundInGlobalState) {
6815
+ newDatabasesReferences.push({
6816
+ databaseName: databaseReference.Database,
6817
+ clusterName: databaseReference.Cluster
6818
+ });
6819
+ }
6820
+ }
6821
+ return Promise.resolve(newDatabasesReferences);
6822
+ };
6704
6823
  KustoLanguageService.prototype.doValidation = function (document, changeIntervals) {
6705
6824
  var _this = this;
6706
6825
  // didn't implement validation for v1.
@@ -6841,6 +6960,43 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6841
6960
  : false;
6842
6961
  });
6843
6962
  };
6963
+ KustoLanguageService.prototype.addClusterToSchema = function (document, clusterName, databaseNames) {
6964
+ var clusterNameOnly = Kusto.Language.KustoFacts.GetHostName(clusterName);
6965
+ var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterNameOnly);
6966
+ if (cluster) {
6967
+ // add databases that are not already in the cluster.
6968
+ databaseNames
6969
+ .filter(function (databaseName) { return !cluster.GetDatabase(databaseName); })
6970
+ .map(function (databaseName) {
6971
+ var symbol = new sym.DatabaseSymbol.$ctor1(databaseName, undefined, false);
6972
+ cluster = cluster.AddDatabase(symbol);
6973
+ });
6974
+ }
6975
+ if (!cluster) {
6976
+ var databaseSymbols = databaseNames
6977
+ .map(function (databaseName) {
6978
+ var symbol = new sym.DatabaseSymbol.$ctor1(databaseName, undefined, false);
6979
+ return symbol;
6980
+ });
6981
+ var databaseSymbolsList = KustoLanguageService.toBridgeList(databaseSymbols);
6982
+ cluster = new sym.ClusterSymbol.$ctor1(clusterNameOnly, databaseSymbolsList, false);
6983
+ }
6984
+ this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
6985
+ this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
6986
+ return Promise.resolve();
6987
+ };
6988
+ KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
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
+ };
6844
7000
  KustoLanguageService.prototype.setSchema = function (schema) {
6845
7001
  var _this = this;
6846
7002
  this._schema = schema;
@@ -6889,29 +7045,37 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
6889
7045
  var databases = Object.keys(schema.Databases)
6890
7046
  .map(function (key) { return schema.Databases[key]; })
6891
7047
  .map(function (_a) {
6892
- var Name = _a.Name, Tables = _a.Tables, Functions = _a.Functions, MinorVersion = _a.MinorVersion, MajorVersion = _a.MajorVersion;
7048
+ var Name = _a.Name, Tables = _a.Tables, ExternalTables = _a.ExternalTables, MaterializedViews = _a.MaterializedViews, Functions = _a.Functions, MinorVersion = _a.MinorVersion, MajorVersion = _a.MajorVersion;
6893
7049
  return ({
6894
7050
  name: Name,
6895
7051
  minorVersion: MinorVersion,
6896
7052
  majorVersion: MajorVersion,
6897
- tables: Object.keys(Tables)
6898
- .map(function (key) { return Tables[key]; })
7053
+ tables: [].concat.apply([], [[Tables, 'Table'], [MaterializedViews, 'MaterializedView'], [ExternalTables, 'ExternalTable']]
7054
+ .filter(function (_a) {
7055
+ var tableContainer = _a[0];
7056
+ return tableContainer;
7057
+ })
6899
7058
  .map(function (_a) {
6900
- var Name = _a.Name, OrderedColumns = _a.OrderedColumns, DocString = _a.DocString, EntityType = _a.EntityType;
6901
- return ({
6902
- name: Name,
6903
- docstring: DocString,
6904
- entityType: EntityType,
6905
- columns: OrderedColumns.map(function (_a) {
6906
- var Name = _a.Name, Type = _a.Type, DocString = _a.DocString, CslType = _a.CslType;
6907
- return ({
6908
- name: Name,
6909
- type: CslType,
6910
- docstring: DocString,
6911
- });
6912
- }),
7059
+ var tableContainer = _a[0], tableEntity = _a[1];
7060
+ return Object
7061
+ .values(tableContainer)
7062
+ .map(function (_a) {
7063
+ var Name = _a.Name, OrderedColumns = _a.OrderedColumns, DocString = _a.DocString;
7064
+ return ({
7065
+ name: Name,
7066
+ docstring: DocString,
7067
+ entityType: tableEntity,
7068
+ columns: OrderedColumns.map(function (_a) {
7069
+ var Name = _a.Name, Type = _a.Type, DocString = _a.DocString, CslType = _a.CslType;
7070
+ return ({
7071
+ name: Name,
7072
+ type: CslType,
7073
+ docstring: DocString,
7074
+ });
7075
+ }),
7076
+ });
6913
7077
  });
6914
- }),
7078
+ })),
6915
7079
  functions: Object.keys(Functions)
6916
7080
  .map(function (key) { return Functions[key]; })
6917
7081
  .map(function (_a) {
@@ -7547,7 +7711,7 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
7547
7711
  var argumentType = new sym.TableSymbol.ctor(param.columns.map(function (col) { return KustoLanguageService.createColumnSymbol(col); }));
7548
7712
  return new sym.Parameter.$ctor2(param.name, argumentType);
7549
7713
  };
7550
- KustoLanguageService.convertToDatabaseSymbol = function (db, globalState, addFunctions) {
7714
+ KustoLanguageService.convertToDatabaseSymbol = function (db) {
7551
7715
  var createFunctionSymbol = function (fn) {
7552
7716
  var parameters = fn.inputParameters.map(function (param) {
7553
7717
  return KustoLanguageService.createParameter(param);
@@ -7604,7 +7768,7 @@ define('vs/language/kusto/languageService/kustoLanguageService',["require", "exp
7604
7768
  cachedDb.database.majorVersion < db.majorVersion ||
7605
7769
  (shouldIncludeFunctions && !cachedDb.includesFunctions)) {
7606
7770
  // only add functions for the database in context (it's very time consuming)
7607
- var databaseSymbol_1 = KustoLanguageService.convertToDatabaseSymbol(db, globalState, shouldIncludeFunctions);
7771
+ var databaseSymbol_1 = KustoLanguageService.convertToDatabaseSymbol(db);
7608
7772
  cached[db.name] = { database: db, symbol: databaseSymbol_1, includesFunctions: shouldIncludeFunctions };
7609
7773
  }
7610
7774
  var databaseSymbol = cached[db.name].symbol;
@@ -7866,6 +8030,22 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
7866
8030
  KustoWorker.prototype.setSchema = function (schema) {
7867
8031
  return this._languageService.setSchema(schema);
7868
8032
  };
8033
+ KustoWorker.prototype.addClusterToSchema = function (uri, clusterName, databasesNames) {
8034
+ var document = this._getTextDocument(uri);
8035
+ if (!document) {
8036
+ console.error("addClusterToSchema: document is " + document + ". uri is " + uri);
8037
+ return Promise.resolve();
8038
+ }
8039
+ return this._languageService.addClusterToSchema(document, clusterName, databasesNames);
8040
+ };
8041
+ KustoWorker.prototype.addDatabaseToSchema = function (uri, clusterName, databaseSchema) {
8042
+ var document = this._getTextDocument(uri);
8043
+ if (!document) {
8044
+ console.error("addDatabaseToSchema: document is " + document + ". uri is " + uri);
8045
+ return Promise.resolve();
8046
+ }
8047
+ return this._languageService.addDatabaseToSchema(document, clusterName, databaseSchema);
8048
+ };
7869
8049
  KustoWorker.prototype.setSchemaFromShowSchema = function (schema, clusterConnectionString, databaseInContextName) {
7870
8050
  return this._languageService.setSchemaFromShowSchema(schema, clusterConnectionString, databaseInContextName);
7871
8051
  };
@@ -8036,6 +8216,20 @@ define('vs/language/kusto/kustoWorker',["require", "exports", "./languageService
8036
8216
  KustoWorker.prototype.setParameters = function (parameters) {
8037
8217
  return this._languageService.setParameters(parameters);
8038
8218
  };
8219
+ KustoWorker.prototype.getClusterReferences = function (uri, cursorOffset) {
8220
+ var document = this._getTextDocument(uri);
8221
+ if (!document) {
8222
+ return Promise.resolve(null);
8223
+ }
8224
+ return this._languageService.getClusterReferences(document, cursorOffset);
8225
+ };
8226
+ KustoWorker.prototype.getDatabaseReferences = function (uri, cursorOffset) {
8227
+ var document = this._getTextDocument(uri);
8228
+ if (!document) {
8229
+ return Promise.resolve(null);
8230
+ }
8231
+ return this._languageService.getDatabaseReferences(document, cursorOffset);
8232
+ };
8039
8233
  KustoWorker.prototype._getTextDocument = function (uri) {
8040
8234
  var models = this._ctx.getMirrorModels();
8041
8235
  for (var _i = 0, models_1 = models; _i < models_1.length; _i++) {
@@ -11,6 +11,22 @@ var KustoWorker = /** @class */ (function () {
11
11
  KustoWorker.prototype.setSchema = function (schema) {
12
12
  return this._languageService.setSchema(schema);
13
13
  };
14
+ KustoWorker.prototype.addClusterToSchema = function (uri, clusterName, databasesNames) {
15
+ var document = this._getTextDocument(uri);
16
+ if (!document) {
17
+ console.error("addClusterToSchema: document is " + document + ". uri is " + uri);
18
+ return Promise.resolve();
19
+ }
20
+ return this._languageService.addClusterToSchema(document, clusterName, databasesNames);
21
+ };
22
+ KustoWorker.prototype.addDatabaseToSchema = function (uri, clusterName, databaseSchema) {
23
+ var document = this._getTextDocument(uri);
24
+ if (!document) {
25
+ console.error("addDatabaseToSchema: document is " + document + ". uri is " + uri);
26
+ return Promise.resolve();
27
+ }
28
+ return this._languageService.addDatabaseToSchema(document, clusterName, databaseSchema);
29
+ };
14
30
  KustoWorker.prototype.setSchemaFromShowSchema = function (schema, clusterConnectionString, databaseInContextName) {
15
31
  return this._languageService.setSchemaFromShowSchema(schema, clusterConnectionString, databaseInContextName);
16
32
  };
@@ -181,6 +197,20 @@ var KustoWorker = /** @class */ (function () {
181
197
  KustoWorker.prototype.setParameters = function (parameters) {
182
198
  return this._languageService.setParameters(parameters);
183
199
  };
200
+ KustoWorker.prototype.getClusterReferences = function (uri, cursorOffset) {
201
+ var document = this._getTextDocument(uri);
202
+ if (!document) {
203
+ return Promise.resolve(null);
204
+ }
205
+ return this._languageService.getClusterReferences(document, cursorOffset);
206
+ };
207
+ KustoWorker.prototype.getDatabaseReferences = function (uri, cursorOffset) {
208
+ var document = this._getTextDocument(uri);
209
+ if (!document) {
210
+ return Promise.resolve(null);
211
+ }
212
+ return this._languageService.getDatabaseReferences(document, cursorOffset);
213
+ };
184
214
  KustoWorker.prototype._getTextDocument = function (uri) {
185
215
  var models = this._ctx.getMirrorModels();
186
216
  for (var _i = 0, models_1 = models; _i < models_1.length; _i++) {
@@ -96,6 +96,7 @@ function toClassifiedRange(k2Classifications) {
96
96
  kind: classification.Kind,
97
97
  }); });
98
98
  }
99
+ ;
99
100
  /**
100
101
  * Kusto Language service translates the kusto object model (transpiled from C# by Bridge.Net)
101
102
  * to the vscode language server types, which are used by vscode language extensions.
@@ -249,12 +250,46 @@ var KustoLanguageService = /** @class */ (function () {
249
250
  _d);
250
251
  this._schemaCache = {};
251
252
  this._kustoJsSchema = KustoLanguageService.convertToKustoJsSchema(schema);
252
- this._kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
253
+ this.__kustoJsSchemaV2 = this.convertToKustoJsSchemaV2(schema);
253
254
  this._schema = schema;
255
+ this._clustersSetInGlobalState = new Set();
256
+ this._nonEmptyDatabaseSetInGlobalState = new Set(); // used to remove clusters that are already in the global state
254
257
  this.configure(languageSettings);
255
258
  this._newlineAppendPipePolicy = new Kusto.Data.IntelliSense.ApplyPolicy();
256
259
  this._newlineAppendPipePolicy.Text = '\n| ';
257
260
  }
261
+ KustoLanguageService.prototype.createDatabaseUniqueName = function (clusterName, databaseName) {
262
+ return clusterName + "_" + databaseName;
263
+ };
264
+ Object.defineProperty(KustoLanguageService.prototype, "_kustoJsSchemaV2", {
265
+ /**
266
+ * A getter for __kustoJsSchemaV2
267
+ */
268
+ get: function () {
269
+ return this.__kustoJsSchemaV2;
270
+ },
271
+ /**
272
+ * A setter for _kustoJsSchemaV2. After a schema (global state) is set, create 2 sets of cluster and database names.
273
+ */
274
+ set: function (globalState) {
275
+ this.__kustoJsSchemaV2 = globalState;
276
+ this._clustersSetInGlobalState.clear();
277
+ this._nonEmptyDatabaseSetInGlobalState.clear();
278
+ // create 2 Sets with cluster names and database names based on the updated Global State.
279
+ for (var i = 0; i < globalState.Clusters.Count; i++) {
280
+ var clusterSymbol = this._kustoJsSchemaV2.Clusters.getItem(i);
281
+ this._clustersSetInGlobalState.add(clusterSymbol.Name);
282
+ for (var i2 = 0; i2 < clusterSymbol.Databases.Count; i2++) {
283
+ var databaseSymbol = clusterSymbol.Databases.getItem(i2);
284
+ if (databaseSymbol.Tables.Count > 0) { // only include database with tables
285
+ this._nonEmptyDatabaseSetInGlobalState.add(this.createDatabaseUniqueName(clusterSymbol.Name, databaseSymbol.Name));
286
+ }
287
+ }
288
+ }
289
+ },
290
+ enumerable: false,
291
+ configurable: true
292
+ });
258
293
  KustoLanguageService.prototype.configure = function (languageSettings) {
259
294
  this._languageSettings = languageSettings;
260
295
  // Since we're still reverting to V1 intellisense for control commands, we need to update the rules provider
@@ -264,15 +299,43 @@ var KustoLanguageService = /** @class */ (function () {
264
299
  KustoLanguageService.prototype.doComplete = function (document, position) {
265
300
  return this.isIntellisenseV2() ? this.doCompleteV2(document, position) : this.doCompleteV1(document, position);
266
301
  };
302
+ /**
303
+ * important: Only use during development to test Global State.
304
+ * Prints clusters, databases and tables that are currently in the GlobalState.
305
+ */
306
+ KustoLanguageService.prototype.debugGlobalState = function (globals) {
307
+ // iterate over clusters
308
+ console.log("globals.Clusters.Count: " + globals.Clusters.Count);
309
+ for (var i = 0; i < globals.Clusters.Count; i++) {
310
+ var cluster = globals.Clusters.getItem(i);
311
+ console.log("cluster: " + cluster.Name);
312
+ // iterate over databases
313
+ console.log("cluster.Databases.Count: " + cluster.Databases.Count);
314
+ for (var i2 = 0; i2 < cluster.Databases.Count; i2++) {
315
+ var database = cluster.Databases.getItem(i2);
316
+ console.log("cluster.database: [" + cluster.Name + "].[" + database.Name + "]");
317
+ // iterate over tables
318
+ console.log("cluster.Databases.Tables.Count: " + database.Tables.Count);
319
+ for (var i3 = 0; i3 < database.Tables.Count; i3++) {
320
+ var table = database.Tables.getItem(i3);
321
+ console.log("cluster.database.table: [" + cluster.Name + "].[" + database.Name + "].[" + table.Name + "]");
322
+ }
323
+ }
324
+ }
325
+ };
267
326
  KustoLanguageService.prototype.doCompleteV2 = function (document, position) {
268
327
  var _this = this;
269
328
  if (!document) {
270
329
  return Promise.resolve(ls.CompletionList.create([]));
271
330
  }
272
331
  var script = this.parseDocumentV2(document);
332
+ // print cluster/database/tables from CodeScript.Globals
333
+ // this.debugGlobalState(script.Globals);
334
+ // get current command
273
335
  var cursorOffset = document.offsetAt(position);
274
- var currentcommand = this.getCurrentCommandV2(script, cursorOffset);
275
- var completionItems = currentcommand.Service.GetCompletionItems(cursorOffset);
336
+ var currentCommand = script.GetBlockAtPosition(cursorOffset);
337
+ // get completion items
338
+ var completionItems = currentCommand.Service.GetCompletionItems(cursorOffset);
276
339
  var disabledItems = this.disabledCompletionItemsV2;
277
340
  if (this._languageSettings.disabledCompletionItems) {
278
341
  this._languageSettings.disabledCompletionItems.map(function (item) {
@@ -439,6 +502,62 @@ var KustoLanguageService = /** @class */ (function () {
439
502
  });
440
503
  });
441
504
  };
505
+ KustoLanguageService.prototype.getClusterReferences = function (document, cursorOffset) {
506
+ var _a;
507
+ var script = this.parseDocumentV2(document);
508
+ var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
509
+ var clusterReferences = (_a = currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.Service) === null || _a === void 0 ? void 0 : _a.GetClusterReferences();
510
+ if (!clusterReferences) {
511
+ return Promise.resolve([]);
512
+ }
513
+ var newClustersReferences = [];
514
+ var newClustersReferencesSet = new Set(); // used to remove duplicates
515
+ // Keep only unique clusters that aren't already exist in the Global State
516
+ for (var i = 0; i < clusterReferences.Count; i++) {
517
+ var clusterReference = clusterReferences.getItem(i);
518
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(clusterReference.Cluster);
519
+ // ignore duplicates
520
+ if (newClustersReferencesSet.has(clusterHostName)) {
521
+ continue;
522
+ }
523
+ newClustersReferencesSet.add(clusterHostName);
524
+ // ignore references that are already in the GlobalState.
525
+ if (!this._clustersSetInGlobalState.has(clusterHostName)) {
526
+ newClustersReferences.push({ clusterName: clusterHostName });
527
+ }
528
+ }
529
+ return Promise.resolve(newClustersReferences);
530
+ };
531
+ KustoLanguageService.prototype.getDatabaseReferences = function (document, cursorOffset) {
532
+ var _a;
533
+ var script = this.parseDocumentV2(document);
534
+ var currentBlock = this.getCurrentCommandV2(script, cursorOffset);
535
+ var databasesReferences = (_a = currentBlock === null || currentBlock === void 0 ? void 0 : currentBlock.Service) === null || _a === void 0 ? void 0 : _a.GetDatabaseReferences();
536
+ if (!databasesReferences) {
537
+ return Promise.resolve([]);
538
+ }
539
+ var newDatabasesReferences = [];
540
+ var newDatabasesReferencesSet = new Set();
541
+ for (var i1 = 0; i1 < databasesReferences.Count; i1++) {
542
+ var databaseReference = databasesReferences.getItem(i1);
543
+ var clusterHostName = Kusto.Language.KustoFacts.GetHostName(databaseReference.Cluster);
544
+ // ignore duplicates
545
+ var databaseReferenceUniqueId = this.createDatabaseUniqueName(clusterHostName, databaseReference.Database);
546
+ if (newDatabasesReferencesSet.has(databaseReferenceUniqueId)) {
547
+ continue;
548
+ }
549
+ newDatabasesReferencesSet.add(databaseReferenceUniqueId);
550
+ // ignore references that are already in the GlobalState.
551
+ var foundInGlobalState = this._nonEmptyDatabaseSetInGlobalState.has(databaseReferenceUniqueId);
552
+ if (!foundInGlobalState) {
553
+ newDatabasesReferences.push({
554
+ databaseName: databaseReference.Database,
555
+ clusterName: databaseReference.Cluster
556
+ });
557
+ }
558
+ }
559
+ return Promise.resolve(newDatabasesReferences);
560
+ };
442
561
  KustoLanguageService.prototype.doValidation = function (document, changeIntervals) {
443
562
  var _this = this;
444
563
  // didn't implement validation for v1.
@@ -579,6 +698,43 @@ var KustoLanguageService = /** @class */ (function () {
579
698
  : false;
580
699
  });
581
700
  };
701
+ KustoLanguageService.prototype.addClusterToSchema = function (document, clusterName, databaseNames) {
702
+ var clusterNameOnly = Kusto.Language.KustoFacts.GetHostName(clusterName);
703
+ var cluster = this._kustoJsSchemaV2.GetCluster$1(clusterNameOnly);
704
+ if (cluster) {
705
+ // add databases that are not already in the cluster.
706
+ databaseNames
707
+ .filter(function (databaseName) { return !cluster.GetDatabase(databaseName); })
708
+ .map(function (databaseName) {
709
+ var symbol = new sym.DatabaseSymbol.$ctor1(databaseName, undefined, false);
710
+ cluster = cluster.AddDatabase(symbol);
711
+ });
712
+ }
713
+ if (!cluster) {
714
+ var databaseSymbols = databaseNames
715
+ .map(function (databaseName) {
716
+ var symbol = new sym.DatabaseSymbol.$ctor1(databaseName, undefined, false);
717
+ return symbol;
718
+ });
719
+ var databaseSymbolsList = KustoLanguageService.toBridgeList(databaseSymbols);
720
+ cluster = new sym.ClusterSymbol.$ctor1(clusterNameOnly, databaseSymbolsList, false);
721
+ }
722
+ this._kustoJsSchemaV2 = this._kustoJsSchemaV2.AddOrReplaceCluster(cluster);
723
+ this._script = k2.CodeScript.From$1(document.getText(), this._kustoJsSchemaV2);
724
+ return Promise.resolve();
725
+ };
726
+ KustoLanguageService.prototype.addDatabaseToSchema = function (document, clusterName, databaseSchema) {
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
+ };
582
738
  KustoLanguageService.prototype.setSchema = function (schema) {
583
739
  var _this = this;
584
740
  this._schema = schema;
@@ -627,29 +783,37 @@ var KustoLanguageService = /** @class */ (function () {
627
783
  var databases = Object.keys(schema.Databases)
628
784
  .map(function (key) { return schema.Databases[key]; })
629
785
  .map(function (_a) {
630
- var Name = _a.Name, Tables = _a.Tables, Functions = _a.Functions, MinorVersion = _a.MinorVersion, MajorVersion = _a.MajorVersion;
786
+ var Name = _a.Name, Tables = _a.Tables, ExternalTables = _a.ExternalTables, MaterializedViews = _a.MaterializedViews, Functions = _a.Functions, MinorVersion = _a.MinorVersion, MajorVersion = _a.MajorVersion;
631
787
  return ({
632
788
  name: Name,
633
789
  minorVersion: MinorVersion,
634
790
  majorVersion: MajorVersion,
635
- tables: Object.keys(Tables)
636
- .map(function (key) { return Tables[key]; })
791
+ tables: [].concat.apply([], [[Tables, 'Table'], [MaterializedViews, 'MaterializedView'], [ExternalTables, 'ExternalTable']]
792
+ .filter(function (_a) {
793
+ var tableContainer = _a[0];
794
+ return tableContainer;
795
+ })
637
796
  .map(function (_a) {
638
- var Name = _a.Name, OrderedColumns = _a.OrderedColumns, DocString = _a.DocString, EntityType = _a.EntityType;
639
- return ({
640
- name: Name,
641
- docstring: DocString,
642
- entityType: EntityType,
643
- columns: OrderedColumns.map(function (_a) {
644
- var Name = _a.Name, Type = _a.Type, DocString = _a.DocString, CslType = _a.CslType;
645
- return ({
646
- name: Name,
647
- type: CslType,
648
- docstring: DocString,
649
- });
650
- }),
797
+ var tableContainer = _a[0], tableEntity = _a[1];
798
+ return Object
799
+ .values(tableContainer)
800
+ .map(function (_a) {
801
+ var Name = _a.Name, OrderedColumns = _a.OrderedColumns, DocString = _a.DocString;
802
+ return ({
803
+ name: Name,
804
+ docstring: DocString,
805
+ entityType: tableEntity,
806
+ columns: OrderedColumns.map(function (_a) {
807
+ var Name = _a.Name, Type = _a.Type, DocString = _a.DocString, CslType = _a.CslType;
808
+ return ({
809
+ name: Name,
810
+ type: CslType,
811
+ docstring: DocString,
812
+ });
813
+ }),
814
+ });
651
815
  });
652
- }),
816
+ })),
653
817
  functions: Object.keys(Functions)
654
818
  .map(function (key) { return Functions[key]; })
655
819
  .map(function (_a) {
@@ -1285,7 +1449,7 @@ var KustoLanguageService = /** @class */ (function () {
1285
1449
  var argumentType = new sym.TableSymbol.ctor(param.columns.map(function (col) { return KustoLanguageService.createColumnSymbol(col); }));
1286
1450
  return new sym.Parameter.$ctor2(param.name, argumentType);
1287
1451
  };
1288
- KustoLanguageService.convertToDatabaseSymbol = function (db, globalState, addFunctions) {
1452
+ KustoLanguageService.convertToDatabaseSymbol = function (db) {
1289
1453
  var createFunctionSymbol = function (fn) {
1290
1454
  var parameters = fn.inputParameters.map(function (param) {
1291
1455
  return KustoLanguageService.createParameter(param);
@@ -1342,7 +1506,7 @@ var KustoLanguageService = /** @class */ (function () {
1342
1506
  cachedDb.database.majorVersion < db.majorVersion ||
1343
1507
  (shouldIncludeFunctions && !cachedDb.includesFunctions)) {
1344
1508
  // only add functions for the database in context (it's very time consuming)
1345
- var databaseSymbol_1 = KustoLanguageService.convertToDatabaseSymbol(db, globalState, shouldIncludeFunctions);
1509
+ var databaseSymbol_1 = KustoLanguageService.convertToDatabaseSymbol(db);
1346
1510
  cached[db.name] = { database: db, symbol: databaseSymbol_1, includesFunctions: shouldIncludeFunctions };
1347
1511
  }
1348
1512
  var databaseSymbol = cached[db.name].symbol;
@@ -119,6 +119,50 @@ declare module monaco.languages.kusto {
119
119
  doCurrentCommandFormat(uri: string, caretPosition: ls.Position): Promise<ls.TextEdit[]>;
120
120
  doValidation(uri: string, intervals: { start: number; end: number }[]): Promise<ls.Diagnostic[]>;
121
121
  setParameters(parameters: ScalarParameter[]): void;
122
+ /**
123
+ * Get all the database references from the current command.
124
+ * If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
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
+ * @example
127
+ * If the current command includes: cluster('help').database('Samples')
128
+ * getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
129
+ */
130
+ getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
131
+ /**
132
+ * Get all the cluster references from the current command.
133
+ * If cluster's schema is already cached it will not be returned.
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.
136
+ * @example
137
+ * If the current command includes: cluster('help')
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' }]
142
+ */
143
+ getClusterReferences(uri: string, cursorOffset: number): Promise<ClusterReference[]>;
144
+ /**
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.
153
+ */
154
+ addDatabaseToSchema(uri: string, clusterName: string, databaseSchema: Database): Promise<void>;
155
+ /**
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.
164
+ */
165
+ addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
122
166
  }
123
167
 
124
168
  /**
@@ -234,6 +278,15 @@ declare module monaco.languages.kusto {
234
278
  location: { startOffset: number; endOffset: number };
235
279
  }
236
280
 
281
+ export interface DatabaseReference {
282
+ databaseName: string;
283
+ clusterName: string;
284
+ };
285
+
286
+ export interface ClusterReference {
287
+ clusterName: string;
288
+ }
289
+
237
290
  export type RenderOptionKeys = keyof RenderOptions;
238
291
 
239
292
  export type OnDidProvideCompletionItems = (list: ls.CompletionList) => Promise<ls.CompletionList>;
@@ -1,6 +1,6 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 4.0.5(undefined)
3
+ * monaco-kusto version: 4.1.2(undefined)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
@@ -1,10 +1,10 @@
1
1
  /*!-----------------------------------------------------------------------------
2
2
  * Copyright (c) Microsoft Corporation. All rights reserved.
3
- * monaco-kusto version: 4.0.5(undefined)
3
+ * monaco-kusto version: 4.1.2(undefined)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
7
- define("vs/language/kusto/languageService/schema",["require","exports"],(function(e,d){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.getInputParametersAsCslString=d.getExpression=d.getCallName=d.getEntityDataTypeFromCslType=d.getCslTypeNameFromClrType=void 0;var u={"System.SByte":"bool","System.Byte":"uint8","System.Int16":"int16","System.UInt16":"uint16","System.Int32":"int","System.UInt32":"uint","System.Int64":"long","System.UInt64":"ulong","System.String":"string","System.Single":"float","System.Double":"real","System.DateTime":"datetime","System.TimeSpan":"timespan","System.Guid":"guid","System.Boolean":"bool","Newtonsoft.Json.Linq.JArray":"dynamic","Newtonsoft.Json.Linq.JObject":"dynamic","Newtonsoft.Json.Linq.JToken":"dynamic","System.Object":"dynamic","System.Data.SqlTypes.SqlDecimal":"decimal"};d.getCslTypeNameFromClrType=function(e){return u[e]||e};var n={object:"Object",bool:"Boolean",uint8:"Byte",int16:"Int16",uint16:"UInt16",int:"Int32",uint:"UInt32",long:"Int64",ulong:"UInt64",float:"Single",real:"Double",decimal:"Decimal",datetime:"DateTime",string:"String",dynamic:"Dynamic",timespan:"TimeSpan"};d.getEntityDataTypeFromCslType=function(e){return n[e]||e},d.getCallName=function(e){return e.name+"("+e.inputParameters.map((function(e){return"{"+e.name+"}"})).join(",")+")"},d.getExpression=function(e){return"let "+e.name+" = "+d.getInputParametersAsCslString(e.inputParameters)+" "+e.body},d.getInputParametersAsCslString=function(e){return"("+e.map((function(e){return t(e)})).join(",")+")"};var t=function(e){if(e.columns&&e.columns.length>0){var u=e.columns.map((function(e){return e.name+":"+(e.cslType||d.getCslTypeNameFromClrType(e.type))})).join(",");return e.name+":"+(""===u?"*":u)}return e.name+":"+(e.cslType||d.getCslTypeNameFromClrType(e.type))}})),function(e){if("object"==typeof module&&"object"==typeof module.exports){var d=e(require,exports);void 0!==d&&(module.exports=d)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}((function(e,d){"use strict";var u,n,t,a,r,i,o,c,f,s,l,m,p;Object.defineProperty(d,"__esModule",{value:!0}),function(e){e.create=function(e,d){return{line:e,character:d}},e.is=function(e){var d=e;return _.objectLiteral(d)&&_.number(d.line)&&_.number(d.character)}}(u=d.Position||(d.Position={})),function(e){e.create=function(e,d,n,t){if(_.number(e)&&_.number(d)&&_.number(n)&&_.number(t))return{start:u.create(e,d),end:u.create(n,t)};if(u.is(e)&&u.is(d))return{start:e,end:d};throw new Error("Range#create called with invalid arguments["+e+", "+d+", "+n+", "+t+"]")},e.is=function(e){var d=e;return _.objectLiteral(d)&&u.is(d.start)&&u.is(d.end)}}(n=d.Range||(d.Range={})),function(e){e.create=function(e,d){return{uri:e,range:d}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.string(d.uri)||_.undefined(d.uri))}}(t=d.Location||(d.Location={})),function(e){e.create=function(e,d,u,n){return{targetUri:e,targetRange:d,targetSelectionRange:u,originSelectionRange:n}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.targetRange)&&_.string(d.targetUri)&&(n.is(d.targetSelectionRange)||_.undefined(d.targetSelectionRange))&&(n.is(d.originSelectionRange)||_.undefined(d.originSelectionRange))}}(d.LocationLink||(d.LocationLink={})),function(e){e.create=function(e,d,u,n){return{red:e,green:d,blue:u,alpha:n}},e.is=function(e){var d=e;return _.number(d.red)&&_.number(d.green)&&_.number(d.blue)&&_.number(d.alpha)}}(a=d.Color||(d.Color={})),function(e){e.create=function(e,d){return{range:e,color:d}},e.is=function(e){var d=e;return n.is(d.range)&&a.is(d.color)}}(d.ColorInformation||(d.ColorInformation={})),function(e){e.create=function(e,d,u){return{label:e,textEdit:d,additionalTextEdits:u}},e.is=function(e){var d=e;return _.string(d.label)&&(_.undefined(d.textEdit)||c.is(d))&&(_.undefined(d.additionalTextEdits)||_.typedArray(d.additionalTextEdits,c.is))}}(d.ColorPresentation||(d.ColorPresentation={})),function(e){e.Comment="comment",e.Imports="imports",e.Region="region"}(d.FoldingRangeKind||(d.FoldingRangeKind={})),function(e){e.create=function(e,d,u,n,t){var a={startLine:e,endLine:d};return _.defined(u)&&(a.startCharacter=u),_.defined(n)&&(a.endCharacter=n),_.defined(t)&&(a.kind=t),a},e.is=function(e){var d=e;return _.number(d.startLine)&&_.number(d.startLine)&&(_.undefined(d.startCharacter)||_.number(d.startCharacter))&&(_.undefined(d.endCharacter)||_.number(d.endCharacter))&&(_.undefined(d.kind)||_.string(d.kind))}}(d.FoldingRange||(d.FoldingRange={})),function(e){e.create=function(e,d){return{location:e,message:d}},e.is=function(e){var d=e;return _.defined(d)&&t.is(d.location)&&_.string(d.message)}}(r=d.DiagnosticRelatedInformation||(d.DiagnosticRelatedInformation={})),function(e){e.Error=1,e.Warning=2,e.Information=3,e.Hint=4}(d.DiagnosticSeverity||(d.DiagnosticSeverity={})),function(e){e.Unnecessary=1,e.Deprecated=2}(d.DiagnosticTag||(d.DiagnosticTag={})),function(e){e.create=function(e,d,u,n,t,a){var r={range:e,message:d};return _.defined(u)&&(r.severity=u),_.defined(n)&&(r.code=n),_.defined(t)&&(r.source=t),_.defined(a)&&(r.relatedInformation=a),r},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&_.string(d.message)&&(_.number(d.severity)||_.undefined(d.severity))&&(_.number(d.code)||_.string(d.code)||_.undefined(d.code))&&(_.string(d.source)||_.undefined(d.source))&&(_.undefined(d.relatedInformation)||_.typedArray(d.relatedInformation,r.is))}}(i=d.Diagnostic||(d.Diagnostic={})),function(e){e.create=function(e,d){for(var u=[],n=2;n<arguments.length;n++)u[n-2]=arguments[n];var t={title:e,command:d};return _.defined(u)&&u.length>0&&(t.arguments=u),t},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.title)&&_.string(d.command)}}(o=d.Command||(d.Command={})),function(e){e.replace=function(e,d){return{range:e,newText:d}},e.insert=function(e,d){return{range:{start:e,end:e},newText:d}},e.del=function(e){return{range:e,newText:""}},e.is=function(e){var d=e;return _.objectLiteral(d)&&_.string(d.newText)&&n.is(d.range)}}(c=d.TextEdit||(d.TextEdit={})),function(e){e.create=function(e,d){return{textDocument:e,edits:d}},e.is=function(e){var d=e;return _.defined(d)&&b.is(d.textDocument)&&Array.isArray(d.edits)}}(f=d.TextDocumentEdit||(d.TextDocumentEdit={})),function(e){e.create=function(e,d){var u={kind:"create",uri:e};return void 0===d||void 0===d.overwrite&&void 0===d.ignoreIfExists||(u.options=d),u},e.is=function(e){var d=e;return d&&"create"===d.kind&&_.string(d.uri)&&(void 0===d.options||(void 0===d.options.overwrite||_.boolean(d.options.overwrite))&&(void 0===d.options.ignoreIfExists||_.boolean(d.options.ignoreIfExists)))}}(s=d.CreateFile||(d.CreateFile={})),function(e){e.create=function(e,d,u){var n={kind:"rename",oldUri:e,newUri:d};return void 0===u||void 0===u.overwrite&&void 0===u.ignoreIfExists||(n.options=u),n},e.is=function(e){var d=e;return d&&"rename"===d.kind&&_.string(d.oldUri)&&_.string(d.newUri)&&(void 0===d.options||(void 0===d.options.overwrite||_.boolean(d.options.overwrite))&&(void 0===d.options.ignoreIfExists||_.boolean(d.options.ignoreIfExists)))}}(l=d.RenameFile||(d.RenameFile={})),function(e){e.create=function(e,d){var u={kind:"delete",uri:e};return void 0===d||void 0===d.recursive&&void 0===d.ignoreIfNotExists||(u.options=d),u},e.is=function(e){var d=e;return d&&"delete"===d.kind&&_.string(d.uri)&&(void 0===d.options||(void 0===d.options.recursive||_.boolean(d.options.recursive))&&(void 0===d.options.ignoreIfNotExists||_.boolean(d.options.ignoreIfNotExists)))}}(m=d.DeleteFile||(d.DeleteFile={})),function(e){e.is=function(e){var d=e;return d&&(void 0!==d.changes||void 0!==d.documentChanges)&&(void 0===d.documentChanges||d.documentChanges.every((function(e){return _.string(e.kind)?s.is(e)||l.is(e)||m.is(e):f.is(e)})))}}(p=d.WorkspaceEdit||(d.WorkspaceEdit={}));var b,g,h,v,y=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,d){this.edits.push(c.insert(e,d))},e.prototype.replace=function(e,d){this.edits.push(c.replace(e,d))},e.prototype.delete=function(e){this.edits.push(c.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),C=function(){function e(e){var d=this;this._textEditChanges=Object.create(null),e&&(this._workspaceEdit=e,e.documentChanges?e.documentChanges.forEach((function(e){if(f.is(e)){var u=new y(e.edits);d._textEditChanges[e.textDocument.uri]=u}})):e.changes&&Object.keys(e.changes).forEach((function(u){var n=new y(e.changes[u]);d._textEditChanges[u]=n})))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(b.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.");var d=e;if(!(n=this._textEditChanges[d.uri])){var u={textDocument:d,edits:t=[]};this._workspaceEdit.documentChanges.push(u),n=new y(t),this._textEditChanges[d.uri]=n}return n}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var n;if(!(n=this._textEditChanges[e])){var t=[];this._workspaceEdit.changes[e]=t,n=new y(t),this._textEditChanges[e]=n}return n},e.prototype.createFile=function(e,d){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(s.create(e,d))},e.prototype.renameFile=function(e,d,u){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(l.create(e,d,u))},e.prototype.deleteFile=function(e,d){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(m.create(e,d))},e.prototype.checkDocumentChanges=function(){if(!this._workspaceEdit||!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.")},e}();d.WorkspaceChange=C,function(e){e.create=function(e){return{uri:e}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)}}(d.TextDocumentIdentifier||(d.TextDocumentIdentifier={})),function(e){e.create=function(e,d){return{uri:e,version:d}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)&&(null===d.version||_.number(d.version))}}(b=d.VersionedTextDocumentIdentifier||(d.VersionedTextDocumentIdentifier={})),function(e){e.create=function(e,d,u,n){return{uri:e,languageId:d,version:u,text:n}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)&&_.string(d.languageId)&&_.number(d.version)&&_.string(d.text)}}(d.TextDocumentItem||(d.TextDocumentItem={})),function(e){e.PlainText="plaintext",e.Markdown="markdown"}(g=d.MarkupKind||(d.MarkupKind={})),function(e){e.is=function(d){var u=d;return u===e.PlainText||u===e.Markdown}}(g=d.MarkupKind||(d.MarkupKind={})),function(e){e.is=function(e){var d=e;return _.objectLiteral(e)&&g.is(d.kind)&&_.string(d.value)}}(h=d.MarkupContent||(d.MarkupContent={})),function(e){e.Text=1,e.Method=2,e.Function=3,e.Constructor=4,e.Field=5,e.Variable=6,e.Class=7,e.Interface=8,e.Module=9,e.Property=10,e.Unit=11,e.Value=12,e.Enum=13,e.Keyword=14,e.Snippet=15,e.Color=16,e.File=17,e.Reference=18,e.Folder=19,e.EnumMember=20,e.Constant=21,e.Struct=22,e.Event=23,e.Operator=24,e.TypeParameter=25}(d.CompletionItemKind||(d.CompletionItemKind={})),function(e){e.PlainText=1,e.Snippet=2}(d.InsertTextFormat||(d.InsertTextFormat={})),function(e){e.Deprecated=1}(d.CompletionItemTag||(d.CompletionItemTag={})),function(e){e.create=function(e){return{label:e}}}(d.CompletionItem||(d.CompletionItem={})),function(e){e.create=function(e,d){return{items:e||[],isIncomplete:!!d}}}(d.CompletionList||(d.CompletionList={})),function(e){e.fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},e.is=function(e){var d=e;return _.string(d)||_.objectLiteral(d)&&_.string(d.language)&&_.string(d.value)}}(v=d.MarkedString||(d.MarkedString={})),function(e){e.is=function(e){var d=e;return!!d&&_.objectLiteral(d)&&(h.is(d.contents)||v.is(d.contents)||_.typedArray(d.contents,v.is))&&(void 0===e.range||n.is(e.range))}}(d.Hover||(d.Hover={})),function(e){e.create=function(e,d){return d?{label:e,documentation:d}:{label:e}}}(d.ParameterInformation||(d.ParameterInformation={})),function(e){e.create=function(e,d){for(var u=[],n=2;n<arguments.length;n++)u[n-2]=arguments[n];var t={label:e};return _.defined(d)&&(t.documentation=d),_.defined(u)?t.parameters=u:t.parameters=[],t}}(d.SignatureInformation||(d.SignatureInformation={})),function(e){e.Text=1,e.Read=2,e.Write=3}(d.DocumentHighlightKind||(d.DocumentHighlightKind={})),function(e){e.create=function(e,d){var u={range:e};return _.number(d)&&(u.kind=d),u}}(d.DocumentHighlight||(d.DocumentHighlight={})),function(e){e.File=1,e.Module=2,e.Namespace=3,e.Package=4,e.Class=5,e.Method=6,e.Property=7,e.Field=8,e.Constructor=9,e.Enum=10,e.Interface=11,e.Function=12,e.Variable=13,e.Constant=14,e.String=15,e.Number=16,e.Boolean=17,e.Array=18,e.Object=19,e.Key=20,e.Null=21,e.EnumMember=22,e.Struct=23,e.Event=24,e.Operator=25,e.TypeParameter=26}(d.SymbolKind||(d.SymbolKind={})),function(e){e.Deprecated=1}(d.SymbolTag||(d.SymbolTag={})),function(e){e.create=function(e,d,u,n,t){var a={name:e,kind:d,location:{uri:n,range:u}};return t&&(a.containerName=t),a}}(d.SymbolInformation||(d.SymbolInformation={})),function(e){e.create=function(e,d,u,n,t,a){var r={name:e,detail:d,kind:u,range:n,selectionRange:t};return void 0!==a&&(r.children=a),r},e.is=function(e){var d=e;return d&&_.string(d.name)&&_.number(d.kind)&&n.is(d.range)&&n.is(d.selectionRange)&&(void 0===d.detail||_.string(d.detail))&&(void 0===d.deprecated||_.boolean(d.deprecated))&&(void 0===d.children||Array.isArray(d.children))}}(d.DocumentSymbol||(d.DocumentSymbol={})),function(e){e.Empty="",e.QuickFix="quickfix",e.Refactor="refactor",e.RefactorExtract="refactor.extract",e.RefactorInline="refactor.inline",e.RefactorRewrite="refactor.rewrite",e.Source="source",e.SourceOrganizeImports="source.organizeImports",e.SourceFixAll="source.fixAll"}(d.CodeActionKind||(d.CodeActionKind={})),function(e){e.create=function(e,d){var u={diagnostics:e};return null!=d&&(u.only=d),u},e.is=function(e){var d=e;return _.defined(d)&&_.typedArray(d.diagnostics,i.is)&&(void 0===d.only||_.typedArray(d.only,_.string))}}(d.CodeActionContext||(d.CodeActionContext={})),function(e){e.create=function(e,d,u){var n={title:e};return o.is(d)?n.command=d:n.edit=d,void 0!==u&&(n.kind=u),n},e.is=function(e){var d=e;return d&&_.string(d.title)&&(void 0===d.diagnostics||_.typedArray(d.diagnostics,i.is))&&(void 0===d.kind||_.string(d.kind))&&(void 0!==d.edit||void 0!==d.command)&&(void 0===d.command||o.is(d.command))&&(void 0===d.isPreferred||_.boolean(d.isPreferred))&&(void 0===d.edit||p.is(d.edit))}}(d.CodeAction||(d.CodeAction={})),function(e){e.create=function(e,d){var u={range:e};return _.defined(d)&&(u.data=d),u},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.undefined(d.command)||o.is(d.command))}}(d.CodeLens||(d.CodeLens={})),function(e){e.create=function(e,d){return{tabSize:e,insertSpaces:d}},e.is=function(e){var d=e;return _.defined(d)&&_.number(d.tabSize)&&_.boolean(d.insertSpaces)}}(d.FormattingOptions||(d.FormattingOptions={})),function(e){e.create=function(e,d,u){return{range:e,target:d,data:u}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.undefined(d.target)||_.string(d.target))}}(d.DocumentLink||(d.DocumentLink={})),function(e){e.create=function(e,d){return{range:e,parent:d}},e.is=function(d){var u=d;return void 0!==u&&n.is(u.range)&&(void 0===u.parent||e.is(u.parent))}}(d.SelectionRange||(d.SelectionRange={})),d.EOL=["\n","\r\n","\r"],function(e){e.create=function(e,d,u,n){return new I(e,d,u,n)},e.is=function(e){var d=e;return!!(_.defined(d)&&_.string(d.uri)&&(_.undefined(d.languageId)||_.string(d.languageId))&&_.number(d.lineCount)&&_.func(d.getText)&&_.func(d.positionAt)&&_.func(d.offsetAt))},e.applyEdits=function(e,d){for(var u=e.getText(),n=function e(d,u){if(d.length<=1)return d;var n=d.length/2|0,t=d.slice(0,n),a=d.slice(n);e(t,u),e(a,u);var r=0,i=0,o=0;for(;r<t.length&&i<a.length;){var c=u(t[r],a[i]);d[o++]=c<=0?t[r++]:a[i++]}for(;r<t.length;)d[o++]=t[r++];for(;i<a.length;)d[o++]=a[i++];return d}(d,(function(e,d){var u=e.range.start.line-d.range.start.line;return 0===u?e.range.start.character-d.range.start.character:u})),t=u.length,a=n.length-1;a>=0;a--){var r=n[a],i=e.offsetAt(r.range.start),o=e.offsetAt(r.range.end);if(!(o<=t))throw new Error("Overlapping edit");u=u.substring(0,i)+r.newText+u.substring(o,u.length),t=i}return u}}(d.TextDocument||(d.TextDocument={}));var _,I=function(){function e(e,d,u,n){this._uri=e,this._languageId=d,this._version=u,this._content=n,this._lineOffsets=void 0}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var d=this.offsetAt(e.start),u=this.offsetAt(e.end);return this._content.substring(d,u)}return this._content},e.prototype.update=function(e,d){this._content=e.text,this._version=d,this._lineOffsets=void 0},e.prototype.getLineOffsets=function(){if(void 0===this._lineOffsets){for(var e=[],d=this._content,u=!0,n=0;n<d.length;n++){u&&(e.push(n),u=!1);var t=d.charAt(n);u="\r"===t||"\n"===t,"\r"===t&&n+1<d.length&&"\n"===d.charAt(n+1)&&n++}u&&d.length>0&&e.push(d.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var d=this.getLineOffsets(),n=0,t=d.length;if(0===t)return u.create(0,e);for(;n<t;){var a=Math.floor((n+t)/2);d[a]>e?t=a:n=a+1}var r=n-1;return u.create(r,e-d[r])},e.prototype.offsetAt=function(e){var d=this.getLineOffsets();if(e.line>=d.length)return this._content.length;if(e.line<0)return 0;var u=d[e.line],n=e.line+1<d.length?d[e.line+1]:this._content.length;return Math.max(Math.min(u+e.character,n),u)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();!function(e){var d=Object.prototype.toString;e.defined=function(e){return void 0!==e},e.undefined=function(e){return void 0===e},e.boolean=function(e){return!0===e||!1===e},e.string=function(e){return"[object String]"===d.call(e)},e.number=function(e){return"[object Number]"===d.call(e)},e.func=function(e){return"[object Function]"===d.call(e)},e.objectLiteral=function(e){return null!==e&&"object"==typeof e},e.typedArray=function(e,d){return Array.isArray(e)&&e.every(d)}}(_||(_={}))})),define("vscode-languageserver-types",["vscode-languageserver-types/main"],(function(e){return e})),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("xregexp/xregexp-all",[],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).XRegExp=e()}}((function(){return function e(d,u,n){function t(r,i){if(!u[r]){if(!d[r]){var o="function"==typeof require&&require;if(!i&&o)return o(r,!0);if(a)return a(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var f=u[r]={exports:{}};d[r][0].call(f.exports,(function(e){var u=d[r][1][e];return t(u||e)}),f,f.exports,e,d,u,n)}return u[r].exports}for(var a="function"==typeof require&&require,r=0;r<n.length;r++)t(n[r]);return t}({1:[function(e,d,u){
7
+ define("vs/language/kusto/languageService/schema",["require","exports"],(function(e,d){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.getInputParametersAsCslString=d.getExpression=d.getCallName=d.getEntityDataTypeFromCslType=d.getCslTypeNameFromClrType=void 0;var u={"System.SByte":"bool","System.Byte":"uint8","System.Int16":"int16","System.UInt16":"uint16","System.Int32":"int","System.UInt32":"uint","System.Int64":"long","System.UInt64":"ulong","System.String":"string","System.Single":"float","System.Double":"real","System.DateTime":"datetime","System.TimeSpan":"timespan","System.Guid":"guid","System.Boolean":"bool","Newtonsoft.Json.Linq.JArray":"dynamic","Newtonsoft.Json.Linq.JObject":"dynamic","Newtonsoft.Json.Linq.JToken":"dynamic","System.Object":"dynamic","System.Data.SqlTypes.SqlDecimal":"decimal"};d.getCslTypeNameFromClrType=function(e){return u[e]||e};var n={object:"Object",bool:"Boolean",uint8:"Byte",int16:"Int16",uint16:"UInt16",int:"Int32",uint:"UInt32",long:"Int64",ulong:"UInt64",float:"Single",real:"Double",decimal:"Decimal",datetime:"DateTime",string:"String",dynamic:"Dynamic",timespan:"TimeSpan"};d.getEntityDataTypeFromCslType=function(e){return n[e]||e},d.getCallName=function(e){return e.name+"("+e.inputParameters.map((function(e){return"{"+e.name+"}"})).join(",")+")"},d.getExpression=function(e){return"let "+e.name+" = "+d.getInputParametersAsCslString(e.inputParameters)+" "+e.body},d.getInputParametersAsCslString=function(e){return"("+e.map((function(e){return t(e)})).join(",")+")"};var t=function(e){if(e.columns&&e.columns.length>0){var u=e.columns.map((function(e){return e.name+":"+(e.cslType||d.getCslTypeNameFromClrType(e.type))})).join(",");return e.name+":"+(""===u?"*":u)}return e.name+":"+(e.cslType||d.getCslTypeNameFromClrType(e.type))}})),function(e){if("object"==typeof module&&"object"==typeof module.exports){var d=e(require,exports);void 0!==d&&(module.exports=d)}else"function"==typeof define&&define.amd&&define("vscode-languageserver-types/main",["require","exports"],e)}((function(e,d){"use strict";var u,n,t,a,r,i,o,c,f,s,l,m,p;Object.defineProperty(d,"__esModule",{value:!0}),function(e){e.create=function(e,d){return{line:e,character:d}},e.is=function(e){var d=e;return _.objectLiteral(d)&&_.number(d.line)&&_.number(d.character)}}(u=d.Position||(d.Position={})),function(e){e.create=function(e,d,n,t){if(_.number(e)&&_.number(d)&&_.number(n)&&_.number(t))return{start:u.create(e,d),end:u.create(n,t)};if(u.is(e)&&u.is(d))return{start:e,end:d};throw new Error("Range#create called with invalid arguments["+e+", "+d+", "+n+", "+t+"]")},e.is=function(e){var d=e;return _.objectLiteral(d)&&u.is(d.start)&&u.is(d.end)}}(n=d.Range||(d.Range={})),function(e){e.create=function(e,d){return{uri:e,range:d}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.string(d.uri)||_.undefined(d.uri))}}(t=d.Location||(d.Location={})),function(e){e.create=function(e,d,u,n){return{targetUri:e,targetRange:d,targetSelectionRange:u,originSelectionRange:n}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.targetRange)&&_.string(d.targetUri)&&(n.is(d.targetSelectionRange)||_.undefined(d.targetSelectionRange))&&(n.is(d.originSelectionRange)||_.undefined(d.originSelectionRange))}}(d.LocationLink||(d.LocationLink={})),function(e){e.create=function(e,d,u,n){return{red:e,green:d,blue:u,alpha:n}},e.is=function(e){var d=e;return _.number(d.red)&&_.number(d.green)&&_.number(d.blue)&&_.number(d.alpha)}}(a=d.Color||(d.Color={})),function(e){e.create=function(e,d){return{range:e,color:d}},e.is=function(e){var d=e;return n.is(d.range)&&a.is(d.color)}}(d.ColorInformation||(d.ColorInformation={})),function(e){e.create=function(e,d,u){return{label:e,textEdit:d,additionalTextEdits:u}},e.is=function(e){var d=e;return _.string(d.label)&&(_.undefined(d.textEdit)||c.is(d))&&(_.undefined(d.additionalTextEdits)||_.typedArray(d.additionalTextEdits,c.is))}}(d.ColorPresentation||(d.ColorPresentation={})),function(e){e.Comment="comment",e.Imports="imports",e.Region="region"}(d.FoldingRangeKind||(d.FoldingRangeKind={})),function(e){e.create=function(e,d,u,n,t){var a={startLine:e,endLine:d};return _.defined(u)&&(a.startCharacter=u),_.defined(n)&&(a.endCharacter=n),_.defined(t)&&(a.kind=t),a},e.is=function(e){var d=e;return _.number(d.startLine)&&_.number(d.startLine)&&(_.undefined(d.startCharacter)||_.number(d.startCharacter))&&(_.undefined(d.endCharacter)||_.number(d.endCharacter))&&(_.undefined(d.kind)||_.string(d.kind))}}(d.FoldingRange||(d.FoldingRange={})),function(e){e.create=function(e,d){return{location:e,message:d}},e.is=function(e){var d=e;return _.defined(d)&&t.is(d.location)&&_.string(d.message)}}(r=d.DiagnosticRelatedInformation||(d.DiagnosticRelatedInformation={})),function(e){e.Error=1,e.Warning=2,e.Information=3,e.Hint=4}(d.DiagnosticSeverity||(d.DiagnosticSeverity={})),function(e){e.Unnecessary=1,e.Deprecated=2}(d.DiagnosticTag||(d.DiagnosticTag={})),function(e){e.create=function(e,d,u,n,t,a){var r={range:e,message:d};return _.defined(u)&&(r.severity=u),_.defined(n)&&(r.code=n),_.defined(t)&&(r.source=t),_.defined(a)&&(r.relatedInformation=a),r},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&_.string(d.message)&&(_.number(d.severity)||_.undefined(d.severity))&&(_.number(d.code)||_.string(d.code)||_.undefined(d.code))&&(_.string(d.source)||_.undefined(d.source))&&(_.undefined(d.relatedInformation)||_.typedArray(d.relatedInformation,r.is))}}(i=d.Diagnostic||(d.Diagnostic={})),function(e){e.create=function(e,d){for(var u=[],n=2;n<arguments.length;n++)u[n-2]=arguments[n];var t={title:e,command:d};return _.defined(u)&&u.length>0&&(t.arguments=u),t},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.title)&&_.string(d.command)}}(o=d.Command||(d.Command={})),function(e){e.replace=function(e,d){return{range:e,newText:d}},e.insert=function(e,d){return{range:{start:e,end:e},newText:d}},e.del=function(e){return{range:e,newText:""}},e.is=function(e){var d=e;return _.objectLiteral(d)&&_.string(d.newText)&&n.is(d.range)}}(c=d.TextEdit||(d.TextEdit={})),function(e){e.create=function(e,d){return{textDocument:e,edits:d}},e.is=function(e){var d=e;return _.defined(d)&&b.is(d.textDocument)&&Array.isArray(d.edits)}}(f=d.TextDocumentEdit||(d.TextDocumentEdit={})),function(e){e.create=function(e,d){var u={kind:"create",uri:e};return void 0===d||void 0===d.overwrite&&void 0===d.ignoreIfExists||(u.options=d),u},e.is=function(e){var d=e;return d&&"create"===d.kind&&_.string(d.uri)&&(void 0===d.options||(void 0===d.options.overwrite||_.boolean(d.options.overwrite))&&(void 0===d.options.ignoreIfExists||_.boolean(d.options.ignoreIfExists)))}}(s=d.CreateFile||(d.CreateFile={})),function(e){e.create=function(e,d,u){var n={kind:"rename",oldUri:e,newUri:d};return void 0===u||void 0===u.overwrite&&void 0===u.ignoreIfExists||(n.options=u),n},e.is=function(e){var d=e;return d&&"rename"===d.kind&&_.string(d.oldUri)&&_.string(d.newUri)&&(void 0===d.options||(void 0===d.options.overwrite||_.boolean(d.options.overwrite))&&(void 0===d.options.ignoreIfExists||_.boolean(d.options.ignoreIfExists)))}}(l=d.RenameFile||(d.RenameFile={})),function(e){e.create=function(e,d){var u={kind:"delete",uri:e};return void 0===d||void 0===d.recursive&&void 0===d.ignoreIfNotExists||(u.options=d),u},e.is=function(e){var d=e;return d&&"delete"===d.kind&&_.string(d.uri)&&(void 0===d.options||(void 0===d.options.recursive||_.boolean(d.options.recursive))&&(void 0===d.options.ignoreIfNotExists||_.boolean(d.options.ignoreIfNotExists)))}}(m=d.DeleteFile||(d.DeleteFile={})),function(e){e.is=function(e){var d=e;return d&&(void 0!==d.changes||void 0!==d.documentChanges)&&(void 0===d.documentChanges||d.documentChanges.every((function(e){return _.string(e.kind)?s.is(e)||l.is(e)||m.is(e):f.is(e)})))}}(p=d.WorkspaceEdit||(d.WorkspaceEdit={}));var b,g,h,v,y=function(){function e(e){this.edits=e}return e.prototype.insert=function(e,d){this.edits.push(c.insert(e,d))},e.prototype.replace=function(e,d){this.edits.push(c.replace(e,d))},e.prototype.delete=function(e){this.edits.push(c.del(e))},e.prototype.add=function(e){this.edits.push(e)},e.prototype.all=function(){return this.edits},e.prototype.clear=function(){this.edits.splice(0,this.edits.length)},e}(),C=function(){function e(e){var d=this;this._textEditChanges=Object.create(null),e&&(this._workspaceEdit=e,e.documentChanges?e.documentChanges.forEach((function(e){if(f.is(e)){var u=new y(e.edits);d._textEditChanges[e.textDocument.uri]=u}})):e.changes&&Object.keys(e.changes).forEach((function(u){var n=new y(e.changes[u]);d._textEditChanges[u]=n})))}return Object.defineProperty(e.prototype,"edit",{get:function(){return this._workspaceEdit},enumerable:!0,configurable:!0}),e.prototype.getTextEditChange=function(e){if(b.is(e)){if(this._workspaceEdit||(this._workspaceEdit={documentChanges:[]}),!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.");var d=e;if(!(n=this._textEditChanges[d.uri])){var u={textDocument:d,edits:t=[]};this._workspaceEdit.documentChanges.push(u),n=new y(t),this._textEditChanges[d.uri]=n}return n}if(this._workspaceEdit||(this._workspaceEdit={changes:Object.create(null)}),!this._workspaceEdit.changes)throw new Error("Workspace edit is not configured for normal text edit changes.");var n;if(!(n=this._textEditChanges[e])){var t=[];this._workspaceEdit.changes[e]=t,n=new y(t),this._textEditChanges[e]=n}return n},e.prototype.createFile=function(e,d){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(s.create(e,d))},e.prototype.renameFile=function(e,d,u){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(l.create(e,d,u))},e.prototype.deleteFile=function(e,d){this.checkDocumentChanges(),this._workspaceEdit.documentChanges.push(m.create(e,d))},e.prototype.checkDocumentChanges=function(){if(!this._workspaceEdit||!this._workspaceEdit.documentChanges)throw new Error("Workspace edit is not configured for document changes.")},e}();d.WorkspaceChange=C,function(e){e.create=function(e){return{uri:e}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)}}(d.TextDocumentIdentifier||(d.TextDocumentIdentifier={})),function(e){e.create=function(e,d){return{uri:e,version:d}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)&&(null===d.version||_.number(d.version))}}(b=d.VersionedTextDocumentIdentifier||(d.VersionedTextDocumentIdentifier={})),function(e){e.create=function(e,d,u,n){return{uri:e,languageId:d,version:u,text:n}},e.is=function(e){var d=e;return _.defined(d)&&_.string(d.uri)&&_.string(d.languageId)&&_.number(d.version)&&_.string(d.text)}}(d.TextDocumentItem||(d.TextDocumentItem={})),function(e){e.PlainText="plaintext",e.Markdown="markdown"}(g=d.MarkupKind||(d.MarkupKind={})),function(e){e.is=function(d){var u=d;return u===e.PlainText||u===e.Markdown}}(g=d.MarkupKind||(d.MarkupKind={})),function(e){e.is=function(e){var d=e;return _.objectLiteral(e)&&g.is(d.kind)&&_.string(d.value)}}(h=d.MarkupContent||(d.MarkupContent={})),function(e){e.Text=1,e.Method=2,e.Function=3,e.Constructor=4,e.Field=5,e.Variable=6,e.Class=7,e.Interface=8,e.Module=9,e.Property=10,e.Unit=11,e.Value=12,e.Enum=13,e.Keyword=14,e.Snippet=15,e.Color=16,e.File=17,e.Reference=18,e.Folder=19,e.EnumMember=20,e.Constant=21,e.Struct=22,e.Event=23,e.Operator=24,e.TypeParameter=25}(d.CompletionItemKind||(d.CompletionItemKind={})),function(e){e.PlainText=1,e.Snippet=2}(d.InsertTextFormat||(d.InsertTextFormat={})),function(e){e.Deprecated=1}(d.CompletionItemTag||(d.CompletionItemTag={})),function(e){e.create=function(e){return{label:e}}}(d.CompletionItem||(d.CompletionItem={})),function(e){e.create=function(e,d){return{items:e||[],isIncomplete:!!d}}}(d.CompletionList||(d.CompletionList={})),function(e){e.fromPlainText=function(e){return e.replace(/[\\`*_{}[\]()#+\-.!]/g,"\\$&")},e.is=function(e){var d=e;return _.string(d)||_.objectLiteral(d)&&_.string(d.language)&&_.string(d.value)}}(v=d.MarkedString||(d.MarkedString={})),function(e){e.is=function(e){var d=e;return!!d&&_.objectLiteral(d)&&(h.is(d.contents)||v.is(d.contents)||_.typedArray(d.contents,v.is))&&(void 0===e.range||n.is(e.range))}}(d.Hover||(d.Hover={})),function(e){e.create=function(e,d){return d?{label:e,documentation:d}:{label:e}}}(d.ParameterInformation||(d.ParameterInformation={})),function(e){e.create=function(e,d){for(var u=[],n=2;n<arguments.length;n++)u[n-2]=arguments[n];var t={label:e};return _.defined(d)&&(t.documentation=d),_.defined(u)?t.parameters=u:t.parameters=[],t}}(d.SignatureInformation||(d.SignatureInformation={})),function(e){e.Text=1,e.Read=2,e.Write=3}(d.DocumentHighlightKind||(d.DocumentHighlightKind={})),function(e){e.create=function(e,d){var u={range:e};return _.number(d)&&(u.kind=d),u}}(d.DocumentHighlight||(d.DocumentHighlight={})),function(e){e.File=1,e.Module=2,e.Namespace=3,e.Package=4,e.Class=5,e.Method=6,e.Property=7,e.Field=8,e.Constructor=9,e.Enum=10,e.Interface=11,e.Function=12,e.Variable=13,e.Constant=14,e.String=15,e.Number=16,e.Boolean=17,e.Array=18,e.Object=19,e.Key=20,e.Null=21,e.EnumMember=22,e.Struct=23,e.Event=24,e.Operator=25,e.TypeParameter=26}(d.SymbolKind||(d.SymbolKind={})),function(e){e.Deprecated=1}(d.SymbolTag||(d.SymbolTag={})),function(e){e.create=function(e,d,u,n,t){var a={name:e,kind:d,location:{uri:n,range:u}};return t&&(a.containerName=t),a}}(d.SymbolInformation||(d.SymbolInformation={})),function(e){e.create=function(e,d,u,n,t,a){var r={name:e,detail:d,kind:u,range:n,selectionRange:t};return void 0!==a&&(r.children=a),r},e.is=function(e){var d=e;return d&&_.string(d.name)&&_.number(d.kind)&&n.is(d.range)&&n.is(d.selectionRange)&&(void 0===d.detail||_.string(d.detail))&&(void 0===d.deprecated||_.boolean(d.deprecated))&&(void 0===d.children||Array.isArray(d.children))}}(d.DocumentSymbol||(d.DocumentSymbol={})),function(e){e.Empty="",e.QuickFix="quickfix",e.Refactor="refactor",e.RefactorExtract="refactor.extract",e.RefactorInline="refactor.inline",e.RefactorRewrite="refactor.rewrite",e.Source="source",e.SourceOrganizeImports="source.organizeImports",e.SourceFixAll="source.fixAll"}(d.CodeActionKind||(d.CodeActionKind={})),function(e){e.create=function(e,d){var u={diagnostics:e};return null!=d&&(u.only=d),u},e.is=function(e){var d=e;return _.defined(d)&&_.typedArray(d.diagnostics,i.is)&&(void 0===d.only||_.typedArray(d.only,_.string))}}(d.CodeActionContext||(d.CodeActionContext={})),function(e){e.create=function(e,d,u){var n={title:e};return o.is(d)?n.command=d:n.edit=d,void 0!==u&&(n.kind=u),n},e.is=function(e){var d=e;return d&&_.string(d.title)&&(void 0===d.diagnostics||_.typedArray(d.diagnostics,i.is))&&(void 0===d.kind||_.string(d.kind))&&(void 0!==d.edit||void 0!==d.command)&&(void 0===d.command||o.is(d.command))&&(void 0===d.isPreferred||_.boolean(d.isPreferred))&&(void 0===d.edit||p.is(d.edit))}}(d.CodeAction||(d.CodeAction={})),function(e){e.create=function(e,d){var u={range:e};return _.defined(d)&&(u.data=d),u},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.undefined(d.command)||o.is(d.command))}}(d.CodeLens||(d.CodeLens={})),function(e){e.create=function(e,d){return{tabSize:e,insertSpaces:d}},e.is=function(e){var d=e;return _.defined(d)&&_.number(d.tabSize)&&_.boolean(d.insertSpaces)}}(d.FormattingOptions||(d.FormattingOptions={})),function(e){e.create=function(e,d,u){return{range:e,target:d,data:u}},e.is=function(e){var d=e;return _.defined(d)&&n.is(d.range)&&(_.undefined(d.target)||_.string(d.target))}}(d.DocumentLink||(d.DocumentLink={})),function(e){e.create=function(e,d){return{range:e,parent:d}},e.is=function(d){var u=d;return void 0!==u&&n.is(u.range)&&(void 0===u.parent||e.is(u.parent))}}(d.SelectionRange||(d.SelectionRange={})),d.EOL=["\n","\r\n","\r"],function(e){e.create=function(e,d,u,n){return new S(e,d,u,n)},e.is=function(e){var d=e;return!!(_.defined(d)&&_.string(d.uri)&&(_.undefined(d.languageId)||_.string(d.languageId))&&_.number(d.lineCount)&&_.func(d.getText)&&_.func(d.positionAt)&&_.func(d.offsetAt))},e.applyEdits=function(e,d){for(var u=e.getText(),n=function e(d,u){if(d.length<=1)return d;var n=d.length/2|0,t=d.slice(0,n),a=d.slice(n);e(t,u),e(a,u);var r=0,i=0,o=0;for(;r<t.length&&i<a.length;){var c=u(t[r],a[i]);d[o++]=c<=0?t[r++]:a[i++]}for(;r<t.length;)d[o++]=t[r++];for(;i<a.length;)d[o++]=a[i++];return d}(d,(function(e,d){var u=e.range.start.line-d.range.start.line;return 0===u?e.range.start.character-d.range.start.character:u})),t=u.length,a=n.length-1;a>=0;a--){var r=n[a],i=e.offsetAt(r.range.start),o=e.offsetAt(r.range.end);if(!(o<=t))throw new Error("Overlapping edit");u=u.substring(0,i)+r.newText+u.substring(o,u.length),t=i}return u}}(d.TextDocument||(d.TextDocument={}));var _,S=function(){function e(e,d,u,n){this._uri=e,this._languageId=d,this._version=u,this._content=n,this._lineOffsets=void 0}return Object.defineProperty(e.prototype,"uri",{get:function(){return this._uri},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"languageId",{get:function(){return this._languageId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._version},enumerable:!0,configurable:!0}),e.prototype.getText=function(e){if(e){var d=this.offsetAt(e.start),u=this.offsetAt(e.end);return this._content.substring(d,u)}return this._content},e.prototype.update=function(e,d){this._content=e.text,this._version=d,this._lineOffsets=void 0},e.prototype.getLineOffsets=function(){if(void 0===this._lineOffsets){for(var e=[],d=this._content,u=!0,n=0;n<d.length;n++){u&&(e.push(n),u=!1);var t=d.charAt(n);u="\r"===t||"\n"===t,"\r"===t&&n+1<d.length&&"\n"===d.charAt(n+1)&&n++}u&&d.length>0&&e.push(d.length),this._lineOffsets=e}return this._lineOffsets},e.prototype.positionAt=function(e){e=Math.max(Math.min(e,this._content.length),0);var d=this.getLineOffsets(),n=0,t=d.length;if(0===t)return u.create(0,e);for(;n<t;){var a=Math.floor((n+t)/2);d[a]>e?t=a:n=a+1}var r=n-1;return u.create(r,e-d[r])},e.prototype.offsetAt=function(e){var d=this.getLineOffsets();if(e.line>=d.length)return this._content.length;if(e.line<0)return 0;var u=d[e.line],n=e.line+1<d.length?d[e.line+1]:this._content.length;return Math.max(Math.min(u+e.character,n),u)},Object.defineProperty(e.prototype,"lineCount",{get:function(){return this.getLineOffsets().length},enumerable:!0,configurable:!0}),e}();!function(e){var d=Object.prototype.toString;e.defined=function(e){return void 0!==e},e.undefined=function(e){return void 0===e},e.boolean=function(e){return!0===e||!1===e},e.string=function(e){return"[object String]"===d.call(e)},e.number=function(e){return"[object Number]"===d.call(e)},e.func=function(e){return"[object Function]"===d.call(e)},e.objectLiteral=function(e){return null!==e&&"object"==typeof e},e.typedArray=function(e,d){return Array.isArray(e)&&e.every(d)}}(_||(_={}))})),define("vscode-languageserver-types",["vscode-languageserver-types/main"],(function(e){return e})),function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define("xregexp/xregexp-all",[],e);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).XRegExp=e()}}((function(){return function e(d,u,n){function t(r,i){if(!u[r]){if(!d[r]){var o="function"==typeof require&&require;if(!i&&o)return o(r,!0);if(a)return a(r,!0);var c=new Error("Cannot find module '"+r+"'");throw c.code="MODULE_NOT_FOUND",c}var f=u[r]={exports:{}};d[r][0].call(f.exports,(function(e){var u=d[r][1][e];return t(u||e)}),f,f.exports,e,d,u,n)}return u[r].exports}for(var a="function"==typeof require&&require,r=0;r<n.length;r++)t(n[r]);return t}({1:[function(e,d,u){
8
8
  /*!
9
9
  * XRegExp.build 3.2.0
10
10
  * <xregexp.com>
@@ -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 I(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 x(e){return parseInt(e,10).toString(16)}function S(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=x,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&&S(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?S(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(x(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(/\(\?#[^)]*\)/,I,{leadChar:"("}),O.addToken(/\s+|#[^\n]*\n?/,I,{flag:"x"}),O.addToken(/\./,(function(){return"[\\s\\S]"}),{flag:"s",leadChar:"."}),O.addToken(/\\k<([\w$]+)>/,(function(e){var d=isNaN(e[1])?S(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(S(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.configure(u),this._newlineAppendPipePolicy=new Kusto.Data.IntelliSense.ApplyPolicy,this._newlineAppendPipePolicy.Text="\n| "}return 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.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=this.getCurrentCommandV2(t,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.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.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.Functions;return{name:d,minorVersion:e.MinorVersion,majorVersion:e.MajorVersion,tables:Object.keys(u).map((function(e){return u[e]})).map((function(e){var d=e.Name,u=e.OrderedColumns;return{name:d,docstring:e.DocString,entityType:e.EntityType,columns:u.map((function(e){var d=e.Name,u=(e.Type,e.DocString);return{name:d,type:e.CslType,docstring:u}}))}})),functions:Object.keys(n).map((function(e){return n[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,u,n){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,i=u[d.name];if(!i||i.database.majorVersion<d.majorVersion||n&&!i.includesFunctions){var o=e.convertToDatabaseSymbol(d,t,n);u[d.name]={database:d,symbol:o,includesFunctions:n}}var c=u[d.name].symbol;return d.name===a&&(r=c),c})),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.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._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),Promise.resolve())},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),Promise.resolve())},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 u?this._languageService.getClusterReferences(u,d):Promise.resolve(null)},e.prototype.getDatabaseReferences=function(e,d){var u=this._getTextDocument(e);return u?this._languageService.getDatabaseReferences(u,d):Promise.resolve(null)},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.0.5(undefined)
3
+ * monaco-kusto version: 4.1.2(undefined)
4
4
  * Released under the MIT license
5
5
  * https://https://github.com/Azure/monaco-kusto/blob/master/README.md
6
6
  *-----------------------------------------------------------------------------*/
@@ -119,6 +119,50 @@ declare module monaco.languages.kusto {
119
119
  doCurrentCommandFormat(uri: string, caretPosition: ls.Position): Promise<ls.TextEdit[]>;
120
120
  doValidation(uri: string, intervals: { start: number; end: number }[]): Promise<ls.Diagnostic[]>;
121
121
  setParameters(parameters: ScalarParameter[]): void;
122
+ /**
123
+ * Get all the database references from the current command.
124
+ * If database's schema is already cached in previous calls to setSchema or addDatabaseToSchema it will not be returned.
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
+ * @example
127
+ * If the current command includes: cluster('help').database('Samples')
128
+ * getDatabaseReferences will return [{ clusterName: 'help', databaseName 'Samples' }]
129
+ */
130
+ getDatabaseReferences(uri: string, cursorOffset: number): Promise<DatabaseReference[]>;
131
+ /**
132
+ * Get all the cluster references from the current command.
133
+ * If cluster's schema is already cached it will not be returned.
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.
136
+ * @example
137
+ * If the current command includes: cluster('help')
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' }]
142
+ */
143
+ getClusterReferences(uri: string, cursorOffset: number): Promise<ClusterReference[]>;
144
+ /**
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.
153
+ */
154
+ addDatabaseToSchema(uri: string, clusterName: string, databaseSchema: Database): Promise<void>;
155
+ /**
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.
164
+ */
165
+ addClusterToSchema(uri: string, clusterName: string, databasesNames: string[]): Promise<void>;
122
166
  }
123
167
 
124
168
  /**
@@ -234,6 +278,15 @@ declare module monaco.languages.kusto {
234
278
  location: { startOffset: number; endOffset: number };
235
279
  }
236
280
 
281
+ export interface DatabaseReference {
282
+ databaseName: string;
283
+ clusterName: string;
284
+ };
285
+
286
+ export interface ClusterReference {
287
+ clusterName: string;
288
+ }
289
+
237
290
  export type RenderOptionKeys = keyof RenderOptions;
238
291
 
239
292
  export type OnDidProvideCompletionItems = (list: ls.CompletionList) => Promise<ls.CompletionList>;