Actualizacion maquina principal
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-json / lib / server.js
1 (function(e, a) { for(var i in a) e[i] = a[i]; }(exports, /******/ (function(modules) { // webpackBootstrap
2 /******/        // The module cache
3 /******/        var installedModules = {};
4 /******/
5 /******/        // The require function
6 /******/        function __webpack_require__(moduleId) {
7 /******/
8 /******/                // Check if module is in cache
9 /******/                if(installedModules[moduleId]) {
10 /******/                        return installedModules[moduleId].exports;
11 /******/                }
12 /******/                // Create a new module (and put it into the cache)
13 /******/                var module = installedModules[moduleId] = {
14 /******/                        i: moduleId,
15 /******/                        l: false,
16 /******/                        exports: {}
17 /******/                };
18 /******/
19 /******/                // Execute the module function
20 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/                // Flag the module as loaded
23 /******/                module.l = true;
24 /******/
25 /******/                // Return the exports of the module
26 /******/                return module.exports;
27 /******/        }
28 /******/
29 /******/
30 /******/        // expose the modules object (__webpack_modules__)
31 /******/        __webpack_require__.m = modules;
32 /******/
33 /******/        // expose the module cache
34 /******/        __webpack_require__.c = installedModules;
35 /******/
36 /******/        // define getter function for harmony exports
37 /******/        __webpack_require__.d = function(exports, name, getter) {
38 /******/                if(!__webpack_require__.o(exports, name)) {
39 /******/                        Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/                }
41 /******/        };
42 /******/
43 /******/        // define __esModule on exports
44 /******/        __webpack_require__.r = function(exports) {
45 /******/                if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/                        Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/                }
48 /******/                Object.defineProperty(exports, '__esModule', { value: true });
49 /******/        };
50 /******/
51 /******/        // create a fake namespace object
52 /******/        // mode & 1: value is a module id, require it
53 /******/        // mode & 2: merge all properties of value into the ns
54 /******/        // mode & 4: return value when already ns object
55 /******/        // mode & 8|1: behave like require
56 /******/        __webpack_require__.t = function(value, mode) {
57 /******/                if(mode & 1) value = __webpack_require__(value);
58 /******/                if(mode & 8) return value;
59 /******/                if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/                var ns = Object.create(null);
61 /******/                __webpack_require__.r(ns);
62 /******/                Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/                if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/                return ns;
65 /******/        };
66 /******/
67 /******/        // getDefaultExport function for compatibility with non-harmony modules
68 /******/        __webpack_require__.n = function(module) {
69 /******/                var getter = module && module.__esModule ?
70 /******/                        function getDefault() { return module['default']; } :
71 /******/                        function getModuleExports() { return module; };
72 /******/                __webpack_require__.d(getter, 'a', getter);
73 /******/                return getter;
74 /******/        };
75 /******/
76 /******/        // Object.prototype.hasOwnProperty.call
77 /******/        __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/        // __webpack_public_path__
80 /******/        __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/        // Load entry module and return exports
84 /******/        return __webpack_require__(__webpack_require__.s = 33);
85 /******/ })
86 /************************************************************************/
87 /******/ ([
88 /* 0 */,
89 /* 1 */
90 /***/ (function(module, exports) {
91
92 module.exports = require("path");
93
94 /***/ }),
95 /* 2 */
96 /***/ (function(module, exports) {
97
98 module.exports = require("fs");
99
100 /***/ }),
101 /* 3 */
102 /***/ (function(module, exports, __webpack_require__) {
103
104 "use strict";
105 /* --------------------------------------------------------------------------------------------\r
106  * Copyright (c) Microsoft Corporation. All rights reserved.\r
107  * Licensed under the MIT License. See License.txt in the project root for license information.\r
108  * ------------------------------------------------------------------------------------------ */\r
109 \r
110 function __export(m) {\r
111     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
112 }\r
113 Object.defineProperty(exports, "__esModule", { value: true });\r
114 const vscode_jsonrpc_1 = __webpack_require__(4);\r
115 exports.ErrorCodes = vscode_jsonrpc_1.ErrorCodes;\r
116 exports.ResponseError = vscode_jsonrpc_1.ResponseError;\r
117 exports.CancellationToken = vscode_jsonrpc_1.CancellationToken;\r
118 exports.CancellationTokenSource = vscode_jsonrpc_1.CancellationTokenSource;\r
119 exports.Disposable = vscode_jsonrpc_1.Disposable;\r
120 exports.Event = vscode_jsonrpc_1.Event;\r
121 exports.Emitter = vscode_jsonrpc_1.Emitter;\r
122 exports.Trace = vscode_jsonrpc_1.Trace;\r
123 exports.TraceFormat = vscode_jsonrpc_1.TraceFormat;\r
124 exports.SetTraceNotification = vscode_jsonrpc_1.SetTraceNotification;\r
125 exports.LogTraceNotification = vscode_jsonrpc_1.LogTraceNotification;\r
126 exports.RequestType = vscode_jsonrpc_1.RequestType;\r
127 exports.RequestType0 = vscode_jsonrpc_1.RequestType0;\r
128 exports.NotificationType = vscode_jsonrpc_1.NotificationType;\r
129 exports.NotificationType0 = vscode_jsonrpc_1.NotificationType0;\r
130 exports.MessageReader = vscode_jsonrpc_1.MessageReader;\r
131 exports.MessageWriter = vscode_jsonrpc_1.MessageWriter;\r
132 exports.ConnectionStrategy = vscode_jsonrpc_1.ConnectionStrategy;\r
133 exports.StreamMessageReader = vscode_jsonrpc_1.StreamMessageReader;\r
134 exports.StreamMessageWriter = vscode_jsonrpc_1.StreamMessageWriter;\r
135 exports.IPCMessageReader = vscode_jsonrpc_1.IPCMessageReader;\r
136 exports.IPCMessageWriter = vscode_jsonrpc_1.IPCMessageWriter;\r
137 exports.createClientPipeTransport = vscode_jsonrpc_1.createClientPipeTransport;\r
138 exports.createServerPipeTransport = vscode_jsonrpc_1.createServerPipeTransport;\r
139 exports.generateRandomPipeName = vscode_jsonrpc_1.generateRandomPipeName;\r
140 exports.createClientSocketTransport = vscode_jsonrpc_1.createClientSocketTransport;\r
141 exports.createServerSocketTransport = vscode_jsonrpc_1.createServerSocketTransport;\r
142 __export(__webpack_require__(17));\r
143 __export(__webpack_require__(18));\r
144 const callHierarchy = __webpack_require__(27);\r
145 const progress = __webpack_require__(28);\r
146 const sr = __webpack_require__(29);\r
147 var Proposed;\r
148 (function (Proposed) {\r
149     let SelectionRangeRequest;\r
150     (function (SelectionRangeRequest) {\r
151         SelectionRangeRequest.type = sr.SelectionRangeRequest.type;\r
152     })(SelectionRangeRequest = Proposed.SelectionRangeRequest || (Proposed.SelectionRangeRequest = {}));\r
153     let CallHierarchyRequest;\r
154     (function (CallHierarchyRequest) {\r
155         CallHierarchyRequest.type = callHierarchy.CallHierarchyRequest.type;\r
156     })(CallHierarchyRequest = Proposed.CallHierarchyRequest || (Proposed.CallHierarchyRequest = {}));\r
157     let CallHierarchyDirection;\r
158     (function (CallHierarchyDirection) {\r
159         CallHierarchyDirection.CallsFrom = callHierarchy.CallHierarchyDirection.CallsFrom;\r
160         CallHierarchyDirection.CallsTo = callHierarchy.CallHierarchyDirection.CallsTo;\r
161     })(CallHierarchyDirection = Proposed.CallHierarchyDirection || (Proposed.CallHierarchyDirection = {}));\r
162     let ProgressStartNotification;\r
163     (function (ProgressStartNotification) {\r
164         ProgressStartNotification.type = progress.ProgressStartNotification.type;\r
165     })(ProgressStartNotification = Proposed.ProgressStartNotification || (Proposed.ProgressStartNotification = {}));\r
166     let ProgressReportNotification;\r
167     (function (ProgressReportNotification) {\r
168         ProgressReportNotification.type = progress.ProgressReportNotification.type;\r
169     })(ProgressReportNotification = Proposed.ProgressReportNotification || (Proposed.ProgressReportNotification = {}));\r
170     let ProgressDoneNotification;\r
171     (function (ProgressDoneNotification) {\r
172         ProgressDoneNotification.type = progress.ProgressDoneNotification.type;\r
173     })(ProgressDoneNotification = Proposed.ProgressDoneNotification || (Proposed.ProgressDoneNotification = {}));\r
174     let ProgressCancelNotification;\r
175     (function (ProgressCancelNotification) {\r
176         ProgressCancelNotification.type = progress.ProgressCancelNotification.type;\r
177     })(ProgressCancelNotification = Proposed.ProgressCancelNotification || (Proposed.ProgressCancelNotification = {}));\r
178 })(Proposed = exports.Proposed || (exports.Proposed = {}));\r
179 function createProtocolConnection(reader, writer, logger, strategy) {\r
180     return vscode_jsonrpc_1.createMessageConnection(reader, writer, logger, strategy);\r
181 }\r
182 exports.createProtocolConnection = createProtocolConnection;\r
183
184
185 /***/ }),
186 /* 4 */
187 /***/ (function(module, exports, __webpack_require__) {
188
189 "use strict";
190 /* --------------------------------------------------------------------------------------------\r
191  * Copyright (c) Microsoft Corporation. All rights reserved.\r
192  * Licensed under the MIT License. See License.txt in the project root for license information.\r
193  * ------------------------------------------------------------------------------------------ */\r
194 /// <reference path="./thenable.ts" />\r
195 \r
196 function __export(m) {\r
197     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
198 }\r
199 Object.defineProperty(exports, "__esModule", { value: true });\r
200 const Is = __webpack_require__(5);\r
201 const messages_1 = __webpack_require__(6);\r
202 exports.RequestType = messages_1.RequestType;\r
203 exports.RequestType0 = messages_1.RequestType0;\r
204 exports.RequestType1 = messages_1.RequestType1;\r
205 exports.RequestType2 = messages_1.RequestType2;\r
206 exports.RequestType3 = messages_1.RequestType3;\r
207 exports.RequestType4 = messages_1.RequestType4;\r
208 exports.RequestType5 = messages_1.RequestType5;\r
209 exports.RequestType6 = messages_1.RequestType6;\r
210 exports.RequestType7 = messages_1.RequestType7;\r
211 exports.RequestType8 = messages_1.RequestType8;\r
212 exports.RequestType9 = messages_1.RequestType9;\r
213 exports.ResponseError = messages_1.ResponseError;\r
214 exports.ErrorCodes = messages_1.ErrorCodes;\r
215 exports.NotificationType = messages_1.NotificationType;\r
216 exports.NotificationType0 = messages_1.NotificationType0;\r
217 exports.NotificationType1 = messages_1.NotificationType1;\r
218 exports.NotificationType2 = messages_1.NotificationType2;\r
219 exports.NotificationType3 = messages_1.NotificationType3;\r
220 exports.NotificationType4 = messages_1.NotificationType4;\r
221 exports.NotificationType5 = messages_1.NotificationType5;\r
222 exports.NotificationType6 = messages_1.NotificationType6;\r
223 exports.NotificationType7 = messages_1.NotificationType7;\r
224 exports.NotificationType8 = messages_1.NotificationType8;\r
225 exports.NotificationType9 = messages_1.NotificationType9;\r
226 const messageReader_1 = __webpack_require__(7);\r
227 exports.MessageReader = messageReader_1.MessageReader;\r
228 exports.StreamMessageReader = messageReader_1.StreamMessageReader;\r
229 exports.IPCMessageReader = messageReader_1.IPCMessageReader;\r
230 exports.SocketMessageReader = messageReader_1.SocketMessageReader;\r
231 const messageWriter_1 = __webpack_require__(9);\r
232 exports.MessageWriter = messageWriter_1.MessageWriter;\r
233 exports.StreamMessageWriter = messageWriter_1.StreamMessageWriter;\r
234 exports.IPCMessageWriter = messageWriter_1.IPCMessageWriter;\r
235 exports.SocketMessageWriter = messageWriter_1.SocketMessageWriter;\r
236 const events_1 = __webpack_require__(8);\r
237 exports.Disposable = events_1.Disposable;\r
238 exports.Event = events_1.Event;\r
239 exports.Emitter = events_1.Emitter;\r
240 const cancellation_1 = __webpack_require__(10);\r
241 exports.CancellationTokenSource = cancellation_1.CancellationTokenSource;\r
242 exports.CancellationToken = cancellation_1.CancellationToken;\r
243 const linkedMap_1 = __webpack_require__(11);\r
244 __export(__webpack_require__(12));\r
245 __export(__webpack_require__(16));\r
246 var CancelNotification;\r
247 (function (CancelNotification) {\r
248     CancelNotification.type = new messages_1.NotificationType('$/cancelRequest');\r
249 })(CancelNotification || (CancelNotification = {}));\r
250 exports.NullLogger = Object.freeze({\r
251     error: () => { },\r
252     warn: () => { },\r
253     info: () => { },\r
254     log: () => { }\r
255 });\r
256 var Trace;\r
257 (function (Trace) {\r
258     Trace[Trace["Off"] = 0] = "Off";\r
259     Trace[Trace["Messages"] = 1] = "Messages";\r
260     Trace[Trace["Verbose"] = 2] = "Verbose";\r
261 })(Trace = exports.Trace || (exports.Trace = {}));\r
262 (function (Trace) {\r
263     function fromString(value) {\r
264         value = value.toLowerCase();\r
265         switch (value) {\r
266             case 'off':\r
267                 return Trace.Off;\r
268             case 'messages':\r
269                 return Trace.Messages;\r
270             case 'verbose':\r
271                 return Trace.Verbose;\r
272             default:\r
273                 return Trace.Off;\r
274         }\r
275     }\r
276     Trace.fromString = fromString;\r
277     function toString(value) {\r
278         switch (value) {\r
279             case Trace.Off:\r
280                 return 'off';\r
281             case Trace.Messages:\r
282                 return 'messages';\r
283             case Trace.Verbose:\r
284                 return 'verbose';\r
285             default:\r
286                 return 'off';\r
287         }\r
288     }\r
289     Trace.toString = toString;\r
290 })(Trace = exports.Trace || (exports.Trace = {}));\r
291 var TraceFormat;\r
292 (function (TraceFormat) {\r
293     TraceFormat["Text"] = "text";\r
294     TraceFormat["JSON"] = "json";\r
295 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
296 (function (TraceFormat) {\r
297     function fromString(value) {\r
298         value = value.toLowerCase();\r
299         if (value === 'json') {\r
300             return TraceFormat.JSON;\r
301         }\r
302         else {\r
303             return TraceFormat.Text;\r
304         }\r
305     }\r
306     TraceFormat.fromString = fromString;\r
307 })(TraceFormat = exports.TraceFormat || (exports.TraceFormat = {}));\r
308 var SetTraceNotification;\r
309 (function (SetTraceNotification) {\r
310     SetTraceNotification.type = new messages_1.NotificationType('$/setTraceNotification');\r
311 })(SetTraceNotification = exports.SetTraceNotification || (exports.SetTraceNotification = {}));\r
312 var LogTraceNotification;\r
313 (function (LogTraceNotification) {\r
314     LogTraceNotification.type = new messages_1.NotificationType('$/logTraceNotification');\r
315 })(LogTraceNotification = exports.LogTraceNotification || (exports.LogTraceNotification = {}));\r
316 var ConnectionErrors;\r
317 (function (ConnectionErrors) {\r
318     /**\r
319      * The connection is closed.\r
320      */\r
321     ConnectionErrors[ConnectionErrors["Closed"] = 1] = "Closed";\r
322     /**\r
323      * The connection got disposed.\r
324      */\r
325     ConnectionErrors[ConnectionErrors["Disposed"] = 2] = "Disposed";\r
326     /**\r
327      * The connection is already in listening mode.\r
328      */\r
329     ConnectionErrors[ConnectionErrors["AlreadyListening"] = 3] = "AlreadyListening";\r
330 })(ConnectionErrors = exports.ConnectionErrors || (exports.ConnectionErrors = {}));\r
331 class ConnectionError extends Error {\r
332     constructor(code, message) {\r
333         super(message);\r
334         this.code = code;\r
335         Object.setPrototypeOf(this, ConnectionError.prototype);\r
336     }\r
337 }\r
338 exports.ConnectionError = ConnectionError;\r
339 var ConnectionStrategy;\r
340 (function (ConnectionStrategy) {\r
341     function is(value) {\r
342         let candidate = value;\r
343         return candidate && Is.func(candidate.cancelUndispatched);\r
344     }\r
345     ConnectionStrategy.is = is;\r
346 })(ConnectionStrategy = exports.ConnectionStrategy || (exports.ConnectionStrategy = {}));\r
347 var ConnectionState;\r
348 (function (ConnectionState) {\r
349     ConnectionState[ConnectionState["New"] = 1] = "New";\r
350     ConnectionState[ConnectionState["Listening"] = 2] = "Listening";\r
351     ConnectionState[ConnectionState["Closed"] = 3] = "Closed";\r
352     ConnectionState[ConnectionState["Disposed"] = 4] = "Disposed";\r
353 })(ConnectionState || (ConnectionState = {}));\r
354 function _createMessageConnection(messageReader, messageWriter, logger, strategy) {\r
355     let sequenceNumber = 0;\r
356     let notificationSquenceNumber = 0;\r
357     let unknownResponseSquenceNumber = 0;\r
358     const version = '2.0';\r
359     let starRequestHandler = undefined;\r
360     let requestHandlers = Object.create(null);\r
361     let starNotificationHandler = undefined;\r
362     let notificationHandlers = Object.create(null);\r
363     let timer;\r
364     let messageQueue = new linkedMap_1.LinkedMap();\r
365     let responsePromises = Object.create(null);\r
366     let requestTokens = Object.create(null);\r
367     let trace = Trace.Off;\r
368     let traceFormat = TraceFormat.Text;\r
369     let tracer;\r
370     let state = ConnectionState.New;\r
371     let errorEmitter = new events_1.Emitter();\r
372     let closeEmitter = new events_1.Emitter();\r
373     let unhandledNotificationEmitter = new events_1.Emitter();\r
374     let disposeEmitter = new events_1.Emitter();\r
375     function createRequestQueueKey(id) {\r
376         return 'req-' + id.toString();\r
377     }\r
378     function createResponseQueueKey(id) {\r
379         if (id === null) {\r
380             return 'res-unknown-' + (++unknownResponseSquenceNumber).toString();\r
381         }\r
382         else {\r
383             return 'res-' + id.toString();\r
384         }\r
385     }\r
386     function createNotificationQueueKey() {\r
387         return 'not-' + (++notificationSquenceNumber).toString();\r
388     }\r
389     function addMessageToQueue(queue, message) {\r
390         if (messages_1.isRequestMessage(message)) {\r
391             queue.set(createRequestQueueKey(message.id), message);\r
392         }\r
393         else if (messages_1.isResponseMessage(message)) {\r
394             queue.set(createResponseQueueKey(message.id), message);\r
395         }\r
396         else {\r
397             queue.set(createNotificationQueueKey(), message);\r
398         }\r
399     }\r
400     function cancelUndispatched(_message) {\r
401         return undefined;\r
402     }\r
403     function isListening() {\r
404         return state === ConnectionState.Listening;\r
405     }\r
406     function isClosed() {\r
407         return state === ConnectionState.Closed;\r
408     }\r
409     function isDisposed() {\r
410         return state === ConnectionState.Disposed;\r
411     }\r
412     function closeHandler() {\r
413         if (state === ConnectionState.New || state === ConnectionState.Listening) {\r
414             state = ConnectionState.Closed;\r
415             closeEmitter.fire(undefined);\r
416         }\r
417         // If the connection is disposed don't sent close events.\r
418     }\r
419     ;\r
420     function readErrorHandler(error) {\r
421         errorEmitter.fire([error, undefined, undefined]);\r
422     }\r
423     function writeErrorHandler(data) {\r
424         errorEmitter.fire(data);\r
425     }\r
426     messageReader.onClose(closeHandler);\r
427     messageReader.onError(readErrorHandler);\r
428     messageWriter.onClose(closeHandler);\r
429     messageWriter.onError(writeErrorHandler);\r
430     function triggerMessageQueue() {\r
431         if (timer || messageQueue.size === 0) {\r
432             return;\r
433         }\r
434         timer = setImmediate(() => {\r
435             timer = undefined;\r
436             processMessageQueue();\r
437         });\r
438     }\r
439     function processMessageQueue() {\r
440         if (messageQueue.size === 0) {\r
441             return;\r
442         }\r
443         let message = messageQueue.shift();\r
444         try {\r
445             if (messages_1.isRequestMessage(message)) {\r
446                 handleRequest(message);\r
447             }\r
448             else if (messages_1.isNotificationMessage(message)) {\r
449                 handleNotification(message);\r
450             }\r
451             else if (messages_1.isResponseMessage(message)) {\r
452                 handleResponse(message);\r
453             }\r
454             else {\r
455                 handleInvalidMessage(message);\r
456             }\r
457         }\r
458         finally {\r
459             triggerMessageQueue();\r
460         }\r
461     }\r
462     let callback = (message) => {\r
463         try {\r
464             // We have received a cancellation message. Check if the message is still in the queue\r
465             // and cancel it if allowed to do so.\r
466             if (messages_1.isNotificationMessage(message) && message.method === CancelNotification.type.method) {\r
467                 let key = createRequestQueueKey(message.params.id);\r
468                 let toCancel = messageQueue.get(key);\r
469                 if (messages_1.isRequestMessage(toCancel)) {\r
470                     let response = strategy && strategy.cancelUndispatched ? strategy.cancelUndispatched(toCancel, cancelUndispatched) : cancelUndispatched(toCancel);\r
471                     if (response && (response.error !== void 0 || response.result !== void 0)) {\r
472                         messageQueue.delete(key);\r
473                         response.id = toCancel.id;\r
474                         traceSendingResponse(response, message.method, Date.now());\r
475                         messageWriter.write(response);\r
476                         return;\r
477                     }\r
478                 }\r
479             }\r
480             addMessageToQueue(messageQueue, message);\r
481         }\r
482         finally {\r
483             triggerMessageQueue();\r
484         }\r
485     };\r
486     function handleRequest(requestMessage) {\r
487         if (isDisposed()) {\r
488             // we return here silently since we fired an event when the\r
489             // connection got disposed.\r
490             return;\r
491         }\r
492         function reply(resultOrError, method, startTime) {\r
493             let message = {\r
494                 jsonrpc: version,\r
495                 id: requestMessage.id\r
496             };\r
497             if (resultOrError instanceof messages_1.ResponseError) {\r
498                 message.error = resultOrError.toJson();\r
499             }\r
500             else {\r
501                 message.result = resultOrError === void 0 ? null : resultOrError;\r
502             }\r
503             traceSendingResponse(message, method, startTime);\r
504             messageWriter.write(message);\r
505         }\r
506         function replyError(error, method, startTime) {\r
507             let message = {\r
508                 jsonrpc: version,\r
509                 id: requestMessage.id,\r
510                 error: error.toJson()\r
511             };\r
512             traceSendingResponse(message, method, startTime);\r
513             messageWriter.write(message);\r
514         }\r
515         function replySuccess(result, method, startTime) {\r
516             // The JSON RPC defines that a response must either have a result or an error\r
517             // So we can't treat undefined as a valid response result.\r
518             if (result === void 0) {\r
519                 result = null;\r
520             }\r
521             let message = {\r
522                 jsonrpc: version,\r
523                 id: requestMessage.id,\r
524                 result: result\r
525             };\r
526             traceSendingResponse(message, method, startTime);\r
527             messageWriter.write(message);\r
528         }\r
529         traceReceivedRequest(requestMessage);\r
530         let element = requestHandlers[requestMessage.method];\r
531         let type;\r
532         let requestHandler;\r
533         if (element) {\r
534             type = element.type;\r
535             requestHandler = element.handler;\r
536         }\r
537         let startTime = Date.now();\r
538         if (requestHandler || starRequestHandler) {\r
539             let cancellationSource = new cancellation_1.CancellationTokenSource();\r
540             let tokenKey = String(requestMessage.id);\r
541             requestTokens[tokenKey] = cancellationSource;\r
542             try {\r
543                 let handlerResult;\r
544                 if (requestMessage.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
545                     handlerResult = requestHandler\r
546                         ? requestHandler(cancellationSource.token)\r
547                         : starRequestHandler(requestMessage.method, cancellationSource.token);\r
548                 }\r
549                 else if (Is.array(requestMessage.params) && (type === void 0 || type.numberOfParams > 1)) {\r
550                     handlerResult = requestHandler\r
551                         ? requestHandler(...requestMessage.params, cancellationSource.token)\r
552                         : starRequestHandler(requestMessage.method, ...requestMessage.params, cancellationSource.token);\r
553                 }\r
554                 else {\r
555                     handlerResult = requestHandler\r
556                         ? requestHandler(requestMessage.params, cancellationSource.token)\r
557                         : starRequestHandler(requestMessage.method, requestMessage.params, cancellationSource.token);\r
558                 }\r
559                 let promise = handlerResult;\r
560                 if (!handlerResult) {\r
561                     delete requestTokens[tokenKey];\r
562                     replySuccess(handlerResult, requestMessage.method, startTime);\r
563                 }\r
564                 else if (promise.then) {\r
565                     promise.then((resultOrError) => {\r
566                         delete requestTokens[tokenKey];\r
567                         reply(resultOrError, requestMessage.method, startTime);\r
568                     }, error => {\r
569                         delete requestTokens[tokenKey];\r
570                         if (error instanceof messages_1.ResponseError) {\r
571                             replyError(error, requestMessage.method, startTime);\r
572                         }\r
573                         else if (error && Is.string(error.message)) {\r
574                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
575                         }\r
576                         else {\r
577                             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
578                         }\r
579                     });\r
580                 }\r
581                 else {\r
582                     delete requestTokens[tokenKey];\r
583                     reply(handlerResult, requestMessage.method, startTime);\r
584                 }\r
585             }\r
586             catch (error) {\r
587                 delete requestTokens[tokenKey];\r
588                 if (error instanceof messages_1.ResponseError) {\r
589                     reply(error, requestMessage.method, startTime);\r
590                 }\r
591                 else if (error && Is.string(error.message)) {\r
592                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed with message: ${error.message}`), requestMessage.method, startTime);\r
593                 }\r
594                 else {\r
595                     replyError(new messages_1.ResponseError(messages_1.ErrorCodes.InternalError, `Request ${requestMessage.method} failed unexpectedly without providing any details.`), requestMessage.method, startTime);\r
596                 }\r
597             }\r
598         }\r
599         else {\r
600             replyError(new messages_1.ResponseError(messages_1.ErrorCodes.MethodNotFound, `Unhandled method ${requestMessage.method}`), requestMessage.method, startTime);\r
601         }\r
602     }\r
603     function handleResponse(responseMessage) {\r
604         if (isDisposed()) {\r
605             // See handle request.\r
606             return;\r
607         }\r
608         if (responseMessage.id === null) {\r
609             if (responseMessage.error) {\r
610                 logger.error(`Received response message without id: Error is: \n${JSON.stringify(responseMessage.error, undefined, 4)}`);\r
611             }\r
612             else {\r
613                 logger.error(`Received response message without id. No further error information provided.`);\r
614             }\r
615         }\r
616         else {\r
617             let key = String(responseMessage.id);\r
618             let responsePromise = responsePromises[key];\r
619             traceReceivedResponse(responseMessage, responsePromise);\r
620             if (responsePromise) {\r
621                 delete responsePromises[key];\r
622                 try {\r
623                     if (responseMessage.error) {\r
624                         let error = responseMessage.error;\r
625                         responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));\r
626                     }\r
627                     else if (responseMessage.result !== void 0) {\r
628                         responsePromise.resolve(responseMessage.result);\r
629                     }\r
630                     else {\r
631                         throw new Error('Should never happen.');\r
632                     }\r
633                 }\r
634                 catch (error) {\r
635                     if (error.message) {\r
636                         logger.error(`Response handler '${responsePromise.method}' failed with message: ${error.message}`);\r
637                     }\r
638                     else {\r
639                         logger.error(`Response handler '${responsePromise.method}' failed unexpectedly.`);\r
640                     }\r
641                 }\r
642             }\r
643         }\r
644     }\r
645     function handleNotification(message) {\r
646         if (isDisposed()) {\r
647             // See handle request.\r
648             return;\r
649         }\r
650         let type = undefined;\r
651         let notificationHandler;\r
652         if (message.method === CancelNotification.type.method) {\r
653             notificationHandler = (params) => {\r
654                 let id = params.id;\r
655                 let source = requestTokens[String(id)];\r
656                 if (source) {\r
657                     source.cancel();\r
658                 }\r
659             };\r
660         }\r
661         else {\r
662             let element = notificationHandlers[message.method];\r
663             if (element) {\r
664                 notificationHandler = element.handler;\r
665                 type = element.type;\r
666             }\r
667         }\r
668         if (notificationHandler || starNotificationHandler) {\r
669             try {\r
670                 traceReceivedNotification(message);\r
671                 if (message.params === void 0 || (type !== void 0 && type.numberOfParams === 0)) {\r
672                     notificationHandler ? notificationHandler() : starNotificationHandler(message.method);\r
673                 }\r
674                 else if (Is.array(message.params) && (type === void 0 || type.numberOfParams > 1)) {\r
675                     notificationHandler ? notificationHandler(...message.params) : starNotificationHandler(message.method, ...message.params);\r
676                 }\r
677                 else {\r
678                     notificationHandler ? notificationHandler(message.params) : starNotificationHandler(message.method, message.params);\r
679                 }\r
680             }\r
681             catch (error) {\r
682                 if (error.message) {\r
683                     logger.error(`Notification handler '${message.method}' failed with message: ${error.message}`);\r
684                 }\r
685                 else {\r
686                     logger.error(`Notification handler '${message.method}' failed unexpectedly.`);\r
687                 }\r
688             }\r
689         }\r
690         else {\r
691             unhandledNotificationEmitter.fire(message);\r
692         }\r
693     }\r
694     function handleInvalidMessage(message) {\r
695         if (!message) {\r
696             logger.error('Received empty message.');\r
697             return;\r
698         }\r
699         logger.error(`Received message which is neither a response nor a notification message:\n${JSON.stringify(message, null, 4)}`);\r
700         // Test whether we find an id to reject the promise\r
701         let responseMessage = message;\r
702         if (Is.string(responseMessage.id) || Is.number(responseMessage.id)) {\r
703             let key = String(responseMessage.id);\r
704             let responseHandler = responsePromises[key];\r
705             if (responseHandler) {\r
706                 responseHandler.reject(new Error('The received response has neither a result nor an error property.'));\r
707             }\r
708         }\r
709     }\r
710     function traceSendingRequest(message) {\r
711         if (trace === Trace.Off || !tracer) {\r
712             return;\r
713         }\r
714         if (traceFormat === TraceFormat.Text) {\r
715             let data = undefined;\r
716             if (trace === Trace.Verbose && message.params) {\r
717                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
718             }\r
719             tracer.log(`Sending request '${message.method} - (${message.id})'.`, data);\r
720         }\r
721         else {\r
722             logLSPMessage('send-request', message);\r
723         }\r
724     }\r
725     function traceSendingNotification(message) {\r
726         if (trace === Trace.Off || !tracer) {\r
727             return;\r
728         }\r
729         if (traceFormat === TraceFormat.Text) {\r
730             let data = undefined;\r
731             if (trace === Trace.Verbose) {\r
732                 if (message.params) {\r
733                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
734                 }\r
735                 else {\r
736                     data = 'No parameters provided.\n\n';\r
737                 }\r
738             }\r
739             tracer.log(`Sending notification '${message.method}'.`, data);\r
740         }\r
741         else {\r
742             logLSPMessage('send-notification', message);\r
743         }\r
744     }\r
745     function traceSendingResponse(message, method, startTime) {\r
746         if (trace === Trace.Off || !tracer) {\r
747             return;\r
748         }\r
749         if (traceFormat === TraceFormat.Text) {\r
750             let data = undefined;\r
751             if (trace === Trace.Verbose) {\r
752                 if (message.error && message.error.data) {\r
753                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
754                 }\r
755                 else {\r
756                     if (message.result) {\r
757                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
758                     }\r
759                     else if (message.error === void 0) {\r
760                         data = 'No result returned.\n\n';\r
761                     }\r
762                 }\r
763             }\r
764             tracer.log(`Sending response '${method} - (${message.id})'. Processing request took ${Date.now() - startTime}ms`, data);\r
765         }\r
766         else {\r
767             logLSPMessage('send-response', message);\r
768         }\r
769     }\r
770     function traceReceivedRequest(message) {\r
771         if (trace === Trace.Off || !tracer) {\r
772             return;\r
773         }\r
774         if (traceFormat === TraceFormat.Text) {\r
775             let data = undefined;\r
776             if (trace === Trace.Verbose && message.params) {\r
777                 data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
778             }\r
779             tracer.log(`Received request '${message.method} - (${message.id})'.`, data);\r
780         }\r
781         else {\r
782             logLSPMessage('receive-request', message);\r
783         }\r
784     }\r
785     function traceReceivedNotification(message) {\r
786         if (trace === Trace.Off || !tracer || message.method === LogTraceNotification.type.method) {\r
787             return;\r
788         }\r
789         if (traceFormat === TraceFormat.Text) {\r
790             let data = undefined;\r
791             if (trace === Trace.Verbose) {\r
792                 if (message.params) {\r
793                     data = `Params: ${JSON.stringify(message.params, null, 4)}\n\n`;\r
794                 }\r
795                 else {\r
796                     data = 'No parameters provided.\n\n';\r
797                 }\r
798             }\r
799             tracer.log(`Received notification '${message.method}'.`, data);\r
800         }\r
801         else {\r
802             logLSPMessage('receive-notification', message);\r
803         }\r
804     }\r
805     function traceReceivedResponse(message, responsePromise) {\r
806         if (trace === Trace.Off || !tracer) {\r
807             return;\r
808         }\r
809         if (traceFormat === TraceFormat.Text) {\r
810             let data = undefined;\r
811             if (trace === Trace.Verbose) {\r
812                 if (message.error && message.error.data) {\r
813                     data = `Error data: ${JSON.stringify(message.error.data, null, 4)}\n\n`;\r
814                 }\r
815                 else {\r
816                     if (message.result) {\r
817                         data = `Result: ${JSON.stringify(message.result, null, 4)}\n\n`;\r
818                     }\r
819                     else if (message.error === void 0) {\r
820                         data = 'No result returned.\n\n';\r
821                     }\r
822                 }\r
823             }\r
824             if (responsePromise) {\r
825                 let error = message.error ? ` Request failed: ${message.error.message} (${message.error.code}).` : '';\r
826                 tracer.log(`Received response '${responsePromise.method} - (${message.id})' in ${Date.now() - responsePromise.timerStart}ms.${error}`, data);\r
827             }\r
828             else {\r
829                 tracer.log(`Received response ${message.id} without active response promise.`, data);\r
830             }\r
831         }\r
832         else {\r
833             logLSPMessage('receive-response', message);\r
834         }\r
835     }\r
836     function logLSPMessage(type, message) {\r
837         if (!tracer || trace === Trace.Off) {\r
838             return;\r
839         }\r
840         const lspMessage = {\r
841             isLSPMessage: true,\r
842             type,\r
843             message,\r
844             timestamp: Date.now()\r
845         };\r
846         tracer.log(lspMessage);\r
847     }\r
848     function throwIfClosedOrDisposed() {\r
849         if (isClosed()) {\r
850             throw new ConnectionError(ConnectionErrors.Closed, 'Connection is closed.');\r
851         }\r
852         if (isDisposed()) {\r
853             throw new ConnectionError(ConnectionErrors.Disposed, 'Connection is disposed.');\r
854         }\r
855     }\r
856     function throwIfListening() {\r
857         if (isListening()) {\r
858             throw new ConnectionError(ConnectionErrors.AlreadyListening, 'Connection is already listening');\r
859         }\r
860     }\r
861     function throwIfNotListening() {\r
862         if (!isListening()) {\r
863             throw new Error('Call listen() first.');\r
864         }\r
865     }\r
866     function undefinedToNull(param) {\r
867         if (param === void 0) {\r
868             return null;\r
869         }\r
870         else {\r
871             return param;\r
872         }\r
873     }\r
874     function computeMessageParams(type, params) {\r
875         let result;\r
876         let numberOfParams = type.numberOfParams;\r
877         switch (numberOfParams) {\r
878             case 0:\r
879                 result = null;\r
880                 break;\r
881             case 1:\r
882                 result = undefinedToNull(params[0]);\r
883                 break;\r
884             default:\r
885                 result = [];\r
886                 for (let i = 0; i < params.length && i < numberOfParams; i++) {\r
887                     result.push(undefinedToNull(params[i]));\r
888                 }\r
889                 if (params.length < numberOfParams) {\r
890                     for (let i = params.length; i < numberOfParams; i++) {\r
891                         result.push(null);\r
892                     }\r
893                 }\r
894                 break;\r
895         }\r
896         return result;\r
897     }\r
898     let connection = {\r
899         sendNotification: (type, ...params) => {\r
900             throwIfClosedOrDisposed();\r
901             let method;\r
902             let messageParams;\r
903             if (Is.string(type)) {\r
904                 method = type;\r
905                 switch (params.length) {\r
906                     case 0:\r
907                         messageParams = null;\r
908                         break;\r
909                     case 1:\r
910                         messageParams = params[0];\r
911                         break;\r
912                     default:\r
913                         messageParams = params;\r
914                         break;\r
915                 }\r
916             }\r
917             else {\r
918                 method = type.method;\r
919                 messageParams = computeMessageParams(type, params);\r
920             }\r
921             let notificationMessage = {\r
922                 jsonrpc: version,\r
923                 method: method,\r
924                 params: messageParams\r
925             };\r
926             traceSendingNotification(notificationMessage);\r
927             messageWriter.write(notificationMessage);\r
928         },\r
929         onNotification: (type, handler) => {\r
930             throwIfClosedOrDisposed();\r
931             if (Is.func(type)) {\r
932                 starNotificationHandler = type;\r
933             }\r
934             else if (handler) {\r
935                 if (Is.string(type)) {\r
936                     notificationHandlers[type] = { type: undefined, handler };\r
937                 }\r
938                 else {\r
939                     notificationHandlers[type.method] = { type, handler };\r
940                 }\r
941             }\r
942         },\r
943         sendRequest: (type, ...params) => {\r
944             throwIfClosedOrDisposed();\r
945             throwIfNotListening();\r
946             let method;\r
947             let messageParams;\r
948             let token = undefined;\r
949             if (Is.string(type)) {\r
950                 method = type;\r
951                 switch (params.length) {\r
952                     case 0:\r
953                         messageParams = null;\r
954                         break;\r
955                     case 1:\r
956                         // The cancellation token is optional so it can also be undefined.\r
957                         if (cancellation_1.CancellationToken.is(params[0])) {\r
958                             messageParams = null;\r
959                             token = params[0];\r
960                         }\r
961                         else {\r
962                             messageParams = undefinedToNull(params[0]);\r
963                         }\r
964                         break;\r
965                     default:\r
966                         const last = params.length - 1;\r
967                         if (cancellation_1.CancellationToken.is(params[last])) {\r
968                             token = params[last];\r
969                             if (params.length === 2) {\r
970                                 messageParams = undefinedToNull(params[0]);\r
971                             }\r
972                             else {\r
973                                 messageParams = params.slice(0, last).map(value => undefinedToNull(value));\r
974                             }\r
975                         }\r
976                         else {\r
977                             messageParams = params.map(value => undefinedToNull(value));\r
978                         }\r
979                         break;\r
980                 }\r
981             }\r
982             else {\r
983                 method = type.method;\r
984                 messageParams = computeMessageParams(type, params);\r
985                 let numberOfParams = type.numberOfParams;\r
986                 token = cancellation_1.CancellationToken.is(params[numberOfParams]) ? params[numberOfParams] : undefined;\r
987             }\r
988             let id = sequenceNumber++;\r
989             let result = new Promise((resolve, reject) => {\r
990                 let requestMessage = {\r
991                     jsonrpc: version,\r
992                     id: id,\r
993                     method: method,\r
994                     params: messageParams\r
995                 };\r
996                 let responsePromise = { method: method, timerStart: Date.now(), resolve, reject };\r
997                 traceSendingRequest(requestMessage);\r
998                 try {\r
999                     messageWriter.write(requestMessage);\r
1000                 }\r
1001                 catch (e) {\r
1002                     // Writing the message failed. So we need to reject the promise.\r
1003                     responsePromise.reject(new messages_1.ResponseError(messages_1.ErrorCodes.MessageWriteError, e.message ? e.message : 'Unknown reason'));\r
1004                     responsePromise = null;\r
1005                 }\r
1006                 if (responsePromise) {\r
1007                     responsePromises[String(id)] = responsePromise;\r
1008                 }\r
1009             });\r
1010             if (token) {\r
1011                 token.onCancellationRequested(() => {\r
1012                     connection.sendNotification(CancelNotification.type, { id });\r
1013                 });\r
1014             }\r
1015             return result;\r
1016         },\r
1017         onRequest: (type, handler) => {\r
1018             throwIfClosedOrDisposed();\r
1019             if (Is.func(type)) {\r
1020                 starRequestHandler = type;\r
1021             }\r
1022             else if (handler) {\r
1023                 if (Is.string(type)) {\r
1024                     requestHandlers[type] = { type: undefined, handler };\r
1025                 }\r
1026                 else {\r
1027                     requestHandlers[type.method] = { type, handler };\r
1028                 }\r
1029             }\r
1030         },\r
1031         trace: (_value, _tracer, sendNotificationOrTraceOptions) => {\r
1032             let _sendNotification = false;\r
1033             let _traceFormat = TraceFormat.Text;\r
1034             if (sendNotificationOrTraceOptions !== void 0) {\r
1035                 if (Is.boolean(sendNotificationOrTraceOptions)) {\r
1036                     _sendNotification = sendNotificationOrTraceOptions;\r
1037                 }\r
1038                 else {\r
1039                     _sendNotification = sendNotificationOrTraceOptions.sendNotification || false;\r
1040                     _traceFormat = sendNotificationOrTraceOptions.traceFormat || TraceFormat.Text;\r
1041                 }\r
1042             }\r
1043             trace = _value;\r
1044             traceFormat = _traceFormat;\r
1045             if (trace === Trace.Off) {\r
1046                 tracer = undefined;\r
1047             }\r
1048             else {\r
1049                 tracer = _tracer;\r
1050             }\r
1051             if (_sendNotification && !isClosed() && !isDisposed()) {\r
1052                 connection.sendNotification(SetTraceNotification.type, { value: Trace.toString(_value) });\r
1053             }\r
1054         },\r
1055         onError: errorEmitter.event,\r
1056         onClose: closeEmitter.event,\r
1057         onUnhandledNotification: unhandledNotificationEmitter.event,\r
1058         onDispose: disposeEmitter.event,\r
1059         dispose: () => {\r
1060             if (isDisposed()) {\r
1061                 return;\r
1062             }\r
1063             state = ConnectionState.Disposed;\r
1064             disposeEmitter.fire(undefined);\r
1065             let error = new Error('Connection got disposed.');\r
1066             Object.keys(responsePromises).forEach((key) => {\r
1067                 responsePromises[key].reject(error);\r
1068             });\r
1069             responsePromises = Object.create(null);\r
1070             requestTokens = Object.create(null);\r
1071             messageQueue = new linkedMap_1.LinkedMap();\r
1072             // Test for backwards compatibility\r
1073             if (Is.func(messageWriter.dispose)) {\r
1074                 messageWriter.dispose();\r
1075             }\r
1076             if (Is.func(messageReader.dispose)) {\r
1077                 messageReader.dispose();\r
1078             }\r
1079         },\r
1080         listen: () => {\r
1081             throwIfClosedOrDisposed();\r
1082             throwIfListening();\r
1083             state = ConnectionState.Listening;\r
1084             messageReader.listen(callback);\r
1085         },\r
1086         inspect: () => {\r
1087             console.log("inspect");\r
1088         }\r
1089     };\r
1090     connection.onNotification(LogTraceNotification.type, (params) => {\r
1091         if (trace === Trace.Off || !tracer) {\r
1092             return;\r
1093         }\r
1094         tracer.log(params.message, trace === Trace.Verbose ? params.verbose : undefined);\r
1095     });\r
1096     return connection;\r
1097 }\r
1098 function isMessageReader(value) {\r
1099     return value.listen !== void 0 && value.read === void 0;\r
1100 }\r
1101 function isMessageWriter(value) {\r
1102     return value.write !== void 0 && value.end === void 0;\r
1103 }\r
1104 function createMessageConnection(input, output, logger, strategy) {\r
1105     if (!logger) {\r
1106         logger = exports.NullLogger;\r
1107     }\r
1108     let reader = isMessageReader(input) ? input : new messageReader_1.StreamMessageReader(input);\r
1109     let writer = isMessageWriter(output) ? output : new messageWriter_1.StreamMessageWriter(output);\r
1110     return _createMessageConnection(reader, writer, logger, strategy);\r
1111 }\r
1112 exports.createMessageConnection = createMessageConnection;\r
1113
1114
1115 /***/ }),
1116 /* 5 */
1117 /***/ (function(module, exports, __webpack_require__) {
1118
1119 "use strict";
1120 /* --------------------------------------------------------------------------------------------\r
1121  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1122  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1123  * ------------------------------------------------------------------------------------------ */\r
1124 \r
1125 Object.defineProperty(exports, "__esModule", { value: true });\r
1126 function boolean(value) {\r
1127     return value === true || value === false;\r
1128 }\r
1129 exports.boolean = boolean;\r
1130 function string(value) {\r
1131     return typeof value === 'string' || value instanceof String;\r
1132 }\r
1133 exports.string = string;\r
1134 function number(value) {\r
1135     return typeof value === 'number' || value instanceof Number;\r
1136 }\r
1137 exports.number = number;\r
1138 function error(value) {\r
1139     return value instanceof Error;\r
1140 }\r
1141 exports.error = error;\r
1142 function func(value) {\r
1143     return typeof value === 'function';\r
1144 }\r
1145 exports.func = func;\r
1146 function array(value) {\r
1147     return Array.isArray(value);\r
1148 }\r
1149 exports.array = array;\r
1150 function stringArray(value) {\r
1151     return array(value) && value.every(elem => string(elem));\r
1152 }\r
1153 exports.stringArray = stringArray;\r
1154
1155
1156 /***/ }),
1157 /* 6 */
1158 /***/ (function(module, exports, __webpack_require__) {
1159
1160 "use strict";
1161 /* --------------------------------------------------------------------------------------------\r
1162  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1163  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1164  * ------------------------------------------------------------------------------------------ */\r
1165 \r
1166 Object.defineProperty(exports, "__esModule", { value: true });\r
1167 const is = __webpack_require__(5);\r
1168 /**\r
1169  * Predefined error codes.\r
1170  */\r
1171 var ErrorCodes;\r
1172 (function (ErrorCodes) {\r
1173     // Defined by JSON RPC\r
1174     ErrorCodes.ParseError = -32700;\r
1175     ErrorCodes.InvalidRequest = -32600;\r
1176     ErrorCodes.MethodNotFound = -32601;\r
1177     ErrorCodes.InvalidParams = -32602;\r
1178     ErrorCodes.InternalError = -32603;\r
1179     ErrorCodes.serverErrorStart = -32099;\r
1180     ErrorCodes.serverErrorEnd = -32000;\r
1181     ErrorCodes.ServerNotInitialized = -32002;\r
1182     ErrorCodes.UnknownErrorCode = -32001;\r
1183     // Defined by the protocol.\r
1184     ErrorCodes.RequestCancelled = -32800;\r
1185     ErrorCodes.ContentModified = -32801;\r
1186     // Defined by VSCode library.\r
1187     ErrorCodes.MessageWriteError = 1;\r
1188     ErrorCodes.MessageReadError = 2;\r
1189 })(ErrorCodes = exports.ErrorCodes || (exports.ErrorCodes = {}));\r
1190 /**\r
1191  * An error object return in a response in case a request\r
1192  * has failed.\r
1193  */\r
1194 class ResponseError extends Error {\r
1195     constructor(code, message, data) {\r
1196         super(message);\r
1197         this.code = is.number(code) ? code : ErrorCodes.UnknownErrorCode;\r
1198         this.data = data;\r
1199         Object.setPrototypeOf(this, ResponseError.prototype);\r
1200     }\r
1201     toJson() {\r
1202         return {\r
1203             code: this.code,\r
1204             message: this.message,\r
1205             data: this.data,\r
1206         };\r
1207     }\r
1208 }\r
1209 exports.ResponseError = ResponseError;\r
1210 /**\r
1211  * An abstract implementation of a MessageType.\r
1212  */\r
1213 class AbstractMessageType {\r
1214     constructor(_method, _numberOfParams) {\r
1215         this._method = _method;\r
1216         this._numberOfParams = _numberOfParams;\r
1217     }\r
1218     get method() {\r
1219         return this._method;\r
1220     }\r
1221     get numberOfParams() {\r
1222         return this._numberOfParams;\r
1223     }\r
1224 }\r
1225 exports.AbstractMessageType = AbstractMessageType;\r
1226 /**\r
1227  * Classes to type request response pairs\r
1228  */\r
1229 class RequestType0 extends AbstractMessageType {\r
1230     constructor(method) {\r
1231         super(method, 0);\r
1232         this._ = undefined;\r
1233     }\r
1234 }\r
1235 exports.RequestType0 = RequestType0;\r
1236 class RequestType extends AbstractMessageType {\r
1237     constructor(method) {\r
1238         super(method, 1);\r
1239         this._ = undefined;\r
1240     }\r
1241 }\r
1242 exports.RequestType = RequestType;\r
1243 class RequestType1 extends AbstractMessageType {\r
1244     constructor(method) {\r
1245         super(method, 1);\r
1246         this._ = undefined;\r
1247     }\r
1248 }\r
1249 exports.RequestType1 = RequestType1;\r
1250 class RequestType2 extends AbstractMessageType {\r
1251     constructor(method) {\r
1252         super(method, 2);\r
1253         this._ = undefined;\r
1254     }\r
1255 }\r
1256 exports.RequestType2 = RequestType2;\r
1257 class RequestType3 extends AbstractMessageType {\r
1258     constructor(method) {\r
1259         super(method, 3);\r
1260         this._ = undefined;\r
1261     }\r
1262 }\r
1263 exports.RequestType3 = RequestType3;\r
1264 class RequestType4 extends AbstractMessageType {\r
1265     constructor(method) {\r
1266         super(method, 4);\r
1267         this._ = undefined;\r
1268     }\r
1269 }\r
1270 exports.RequestType4 = RequestType4;\r
1271 class RequestType5 extends AbstractMessageType {\r
1272     constructor(method) {\r
1273         super(method, 5);\r
1274         this._ = undefined;\r
1275     }\r
1276 }\r
1277 exports.RequestType5 = RequestType5;\r
1278 class RequestType6 extends AbstractMessageType {\r
1279     constructor(method) {\r
1280         super(method, 6);\r
1281         this._ = undefined;\r
1282     }\r
1283 }\r
1284 exports.RequestType6 = RequestType6;\r
1285 class RequestType7 extends AbstractMessageType {\r
1286     constructor(method) {\r
1287         super(method, 7);\r
1288         this._ = undefined;\r
1289     }\r
1290 }\r
1291 exports.RequestType7 = RequestType7;\r
1292 class RequestType8 extends AbstractMessageType {\r
1293     constructor(method) {\r
1294         super(method, 8);\r
1295         this._ = undefined;\r
1296     }\r
1297 }\r
1298 exports.RequestType8 = RequestType8;\r
1299 class RequestType9 extends AbstractMessageType {\r
1300     constructor(method) {\r
1301         super(method, 9);\r
1302         this._ = undefined;\r
1303     }\r
1304 }\r
1305 exports.RequestType9 = RequestType9;\r
1306 class NotificationType extends AbstractMessageType {\r
1307     constructor(method) {\r
1308         super(method, 1);\r
1309         this._ = undefined;\r
1310     }\r
1311 }\r
1312 exports.NotificationType = NotificationType;\r
1313 class NotificationType0 extends AbstractMessageType {\r
1314     constructor(method) {\r
1315         super(method, 0);\r
1316         this._ = undefined;\r
1317     }\r
1318 }\r
1319 exports.NotificationType0 = NotificationType0;\r
1320 class NotificationType1 extends AbstractMessageType {\r
1321     constructor(method) {\r
1322         super(method, 1);\r
1323         this._ = undefined;\r
1324     }\r
1325 }\r
1326 exports.NotificationType1 = NotificationType1;\r
1327 class NotificationType2 extends AbstractMessageType {\r
1328     constructor(method) {\r
1329         super(method, 2);\r
1330         this._ = undefined;\r
1331     }\r
1332 }\r
1333 exports.NotificationType2 = NotificationType2;\r
1334 class NotificationType3 extends AbstractMessageType {\r
1335     constructor(method) {\r
1336         super(method, 3);\r
1337         this._ = undefined;\r
1338     }\r
1339 }\r
1340 exports.NotificationType3 = NotificationType3;\r
1341 class NotificationType4 extends AbstractMessageType {\r
1342     constructor(method) {\r
1343         super(method, 4);\r
1344         this._ = undefined;\r
1345     }\r
1346 }\r
1347 exports.NotificationType4 = NotificationType4;\r
1348 class NotificationType5 extends AbstractMessageType {\r
1349     constructor(method) {\r
1350         super(method, 5);\r
1351         this._ = undefined;\r
1352     }\r
1353 }\r
1354 exports.NotificationType5 = NotificationType5;\r
1355 class NotificationType6 extends AbstractMessageType {\r
1356     constructor(method) {\r
1357         super(method, 6);\r
1358         this._ = undefined;\r
1359     }\r
1360 }\r
1361 exports.NotificationType6 = NotificationType6;\r
1362 class NotificationType7 extends AbstractMessageType {\r
1363     constructor(method) {\r
1364         super(method, 7);\r
1365         this._ = undefined;\r
1366     }\r
1367 }\r
1368 exports.NotificationType7 = NotificationType7;\r
1369 class NotificationType8 extends AbstractMessageType {\r
1370     constructor(method) {\r
1371         super(method, 8);\r
1372         this._ = undefined;\r
1373     }\r
1374 }\r
1375 exports.NotificationType8 = NotificationType8;\r
1376 class NotificationType9 extends AbstractMessageType {\r
1377     constructor(method) {\r
1378         super(method, 9);\r
1379         this._ = undefined;\r
1380     }\r
1381 }\r
1382 exports.NotificationType9 = NotificationType9;\r
1383 /**\r
1384  * Tests if the given message is a request message\r
1385  */\r
1386 function isRequestMessage(message) {\r
1387     let candidate = message;\r
1388     return candidate && is.string(candidate.method) && (is.string(candidate.id) || is.number(candidate.id));\r
1389 }\r
1390 exports.isRequestMessage = isRequestMessage;\r
1391 /**\r
1392  * Tests if the given message is a notification message\r
1393  */\r
1394 function isNotificationMessage(message) {\r
1395     let candidate = message;\r
1396     return candidate && is.string(candidate.method) && message.id === void 0;\r
1397 }\r
1398 exports.isNotificationMessage = isNotificationMessage;\r
1399 /**\r
1400  * Tests if the given message is a response message\r
1401  */\r
1402 function isResponseMessage(message) {\r
1403     let candidate = message;\r
1404     return candidate && (candidate.result !== void 0 || !!candidate.error) && (is.string(candidate.id) || is.number(candidate.id) || candidate.id === null);\r
1405 }\r
1406 exports.isResponseMessage = isResponseMessage;\r
1407
1408
1409 /***/ }),
1410 /* 7 */
1411 /***/ (function(module, exports, __webpack_require__) {
1412
1413 "use strict";
1414 /* --------------------------------------------------------------------------------------------\r
1415  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1416  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1417  * ------------------------------------------------------------------------------------------ */\r
1418 \r
1419 Object.defineProperty(exports, "__esModule", { value: true });\r
1420 const events_1 = __webpack_require__(8);\r
1421 const Is = __webpack_require__(5);\r
1422 let DefaultSize = 8192;\r
1423 let CR = Buffer.from('\r', 'ascii')[0];\r
1424 let LF = Buffer.from('\n', 'ascii')[0];\r
1425 let CRLF = '\r\n';\r
1426 class MessageBuffer {\r
1427     constructor(encoding = 'utf8') {\r
1428         this.encoding = encoding;\r
1429         this.index = 0;\r
1430         this.buffer = Buffer.allocUnsafe(DefaultSize);\r
1431     }\r
1432     append(chunk) {\r
1433         var toAppend = chunk;\r
1434         if (typeof (chunk) === 'string') {\r
1435             var str = chunk;\r
1436             var bufferLen = Buffer.byteLength(str, this.encoding);\r
1437             toAppend = Buffer.allocUnsafe(bufferLen);\r
1438             toAppend.write(str, 0, bufferLen, this.encoding);\r
1439         }\r
1440         if (this.buffer.length - this.index >= toAppend.length) {\r
1441             toAppend.copy(this.buffer, this.index, 0, toAppend.length);\r
1442         }\r
1443         else {\r
1444             var newSize = (Math.ceil((this.index + toAppend.length) / DefaultSize) + 1) * DefaultSize;\r
1445             if (this.index === 0) {\r
1446                 this.buffer = Buffer.allocUnsafe(newSize);\r
1447                 toAppend.copy(this.buffer, 0, 0, toAppend.length);\r
1448             }\r
1449             else {\r
1450                 this.buffer = Buffer.concat([this.buffer.slice(0, this.index), toAppend], newSize);\r
1451             }\r
1452         }\r
1453         this.index += toAppend.length;\r
1454     }\r
1455     tryReadHeaders() {\r
1456         let result = undefined;\r
1457         let current = 0;\r
1458         while (current + 3 < this.index && (this.buffer[current] !== CR || this.buffer[current + 1] !== LF || this.buffer[current + 2] !== CR || this.buffer[current + 3] !== LF)) {\r
1459             current++;\r
1460         }\r
1461         // No header / body separator found (e.g CRLFCRLF)\r
1462         if (current + 3 >= this.index) {\r
1463             return result;\r
1464         }\r
1465         result = Object.create(null);\r
1466         let headers = this.buffer.toString('ascii', 0, current).split(CRLF);\r
1467         headers.forEach((header) => {\r
1468             let index = header.indexOf(':');\r
1469             if (index === -1) {\r
1470                 throw new Error('Message header must separate key and value using :');\r
1471             }\r
1472             let key = header.substr(0, index);\r
1473             let value = header.substr(index + 1).trim();\r
1474             result[key] = value;\r
1475         });\r
1476         let nextStart = current + 4;\r
1477         this.buffer = this.buffer.slice(nextStart);\r
1478         this.index = this.index - nextStart;\r
1479         return result;\r
1480     }\r
1481     tryReadContent(length) {\r
1482         if (this.index < length) {\r
1483             return null;\r
1484         }\r
1485         let result = this.buffer.toString(this.encoding, 0, length);\r
1486         let nextStart = length;\r
1487         this.buffer.copy(this.buffer, 0, nextStart);\r
1488         this.index = this.index - nextStart;\r
1489         return result;\r
1490     }\r
1491     get numberOfBytes() {\r
1492         return this.index;\r
1493     }\r
1494 }\r
1495 var MessageReader;\r
1496 (function (MessageReader) {\r
1497     function is(value) {\r
1498         let candidate = value;\r
1499         return candidate && Is.func(candidate.listen) && Is.func(candidate.dispose) &&\r
1500             Is.func(candidate.onError) && Is.func(candidate.onClose) && Is.func(candidate.onPartialMessage);\r
1501     }\r
1502     MessageReader.is = is;\r
1503 })(MessageReader = exports.MessageReader || (exports.MessageReader = {}));\r
1504 class AbstractMessageReader {\r
1505     constructor() {\r
1506         this.errorEmitter = new events_1.Emitter();\r
1507         this.closeEmitter = new events_1.Emitter();\r
1508         this.partialMessageEmitter = new events_1.Emitter();\r
1509     }\r
1510     dispose() {\r
1511         this.errorEmitter.dispose();\r
1512         this.closeEmitter.dispose();\r
1513     }\r
1514     get onError() {\r
1515         return this.errorEmitter.event;\r
1516     }\r
1517     fireError(error) {\r
1518         this.errorEmitter.fire(this.asError(error));\r
1519     }\r
1520     get onClose() {\r
1521         return this.closeEmitter.event;\r
1522     }\r
1523     fireClose() {\r
1524         this.closeEmitter.fire(undefined);\r
1525     }\r
1526     get onPartialMessage() {\r
1527         return this.partialMessageEmitter.event;\r
1528     }\r
1529     firePartialMessage(info) {\r
1530         this.partialMessageEmitter.fire(info);\r
1531     }\r
1532     asError(error) {\r
1533         if (error instanceof Error) {\r
1534             return error;\r
1535         }\r
1536         else {\r
1537             return new Error(`Reader received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
1538         }\r
1539     }\r
1540 }\r
1541 exports.AbstractMessageReader = AbstractMessageReader;\r
1542 class StreamMessageReader extends AbstractMessageReader {\r
1543     constructor(readable, encoding = 'utf8') {\r
1544         super();\r
1545         this.readable = readable;\r
1546         this.buffer = new MessageBuffer(encoding);\r
1547         this._partialMessageTimeout = 10000;\r
1548     }\r
1549     set partialMessageTimeout(timeout) {\r
1550         this._partialMessageTimeout = timeout;\r
1551     }\r
1552     get partialMessageTimeout() {\r
1553         return this._partialMessageTimeout;\r
1554     }\r
1555     listen(callback) {\r
1556         this.nextMessageLength = -1;\r
1557         this.messageToken = 0;\r
1558         this.partialMessageTimer = undefined;\r
1559         this.callback = callback;\r
1560         this.readable.on('data', (data) => {\r
1561             this.onData(data);\r
1562         });\r
1563         this.readable.on('error', (error) => this.fireError(error));\r
1564         this.readable.on('close', () => this.fireClose());\r
1565     }\r
1566     onData(data) {\r
1567         this.buffer.append(data);\r
1568         while (true) {\r
1569             if (this.nextMessageLength === -1) {\r
1570                 let headers = this.buffer.tryReadHeaders();\r
1571                 if (!headers) {\r
1572                     return;\r
1573                 }\r
1574                 let contentLength = headers['Content-Length'];\r
1575                 if (!contentLength) {\r
1576                     throw new Error('Header must provide a Content-Length property.');\r
1577                 }\r
1578                 let length = parseInt(contentLength);\r
1579                 if (isNaN(length)) {\r
1580                     throw new Error('Content-Length value must be a number.');\r
1581                 }\r
1582                 this.nextMessageLength = length;\r
1583                 // Take the encoding form the header. For compatibility\r
1584                 // treat both utf-8 and utf8 as node utf8\r
1585             }\r
1586             var msg = this.buffer.tryReadContent(this.nextMessageLength);\r
1587             if (msg === null) {\r
1588                 /** We haven't received the full message yet. */\r
1589                 this.setPartialMessageTimer();\r
1590                 return;\r
1591             }\r
1592             this.clearPartialMessageTimer();\r
1593             this.nextMessageLength = -1;\r
1594             this.messageToken++;\r
1595             var json = JSON.parse(msg);\r
1596             this.callback(json);\r
1597         }\r
1598     }\r
1599     clearPartialMessageTimer() {\r
1600         if (this.partialMessageTimer) {\r
1601             clearTimeout(this.partialMessageTimer);\r
1602             this.partialMessageTimer = undefined;\r
1603         }\r
1604     }\r
1605     setPartialMessageTimer() {\r
1606         this.clearPartialMessageTimer();\r
1607         if (this._partialMessageTimeout <= 0) {\r
1608             return;\r
1609         }\r
1610         this.partialMessageTimer = setTimeout((token, timeout) => {\r
1611             this.partialMessageTimer = undefined;\r
1612             if (token === this.messageToken) {\r
1613                 this.firePartialMessage({ messageToken: token, waitingTime: timeout });\r
1614                 this.setPartialMessageTimer();\r
1615             }\r
1616         }, this._partialMessageTimeout, this.messageToken, this._partialMessageTimeout);\r
1617     }\r
1618 }\r
1619 exports.StreamMessageReader = StreamMessageReader;\r
1620 class IPCMessageReader extends AbstractMessageReader {\r
1621     constructor(process) {\r
1622         super();\r
1623         this.process = process;\r
1624         let eventEmitter = this.process;\r
1625         eventEmitter.on('error', (error) => this.fireError(error));\r
1626         eventEmitter.on('close', () => this.fireClose());\r
1627     }\r
1628     listen(callback) {\r
1629         this.process.on('message', callback);\r
1630     }\r
1631 }\r
1632 exports.IPCMessageReader = IPCMessageReader;\r
1633 class SocketMessageReader extends StreamMessageReader {\r
1634     constructor(socket, encoding = 'utf-8') {\r
1635         super(socket, encoding);\r
1636     }\r
1637 }\r
1638 exports.SocketMessageReader = SocketMessageReader;\r
1639
1640
1641 /***/ }),
1642 /* 8 */
1643 /***/ (function(module, exports, __webpack_require__) {
1644
1645 "use strict";
1646 /* --------------------------------------------------------------------------------------------\r
1647  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1648  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1649  * ------------------------------------------------------------------------------------------ */\r
1650 \r
1651 Object.defineProperty(exports, "__esModule", { value: true });\r
1652 var Disposable;\r
1653 (function (Disposable) {\r
1654     function create(func) {\r
1655         return {\r
1656             dispose: func\r
1657         };\r
1658     }\r
1659     Disposable.create = create;\r
1660 })(Disposable = exports.Disposable || (exports.Disposable = {}));\r
1661 var Event;\r
1662 (function (Event) {\r
1663     const _disposable = { dispose() { } };\r
1664     Event.None = function () { return _disposable; };\r
1665 })(Event = exports.Event || (exports.Event = {}));\r
1666 class CallbackList {\r
1667     add(callback, context = null, bucket) {\r
1668         if (!this._callbacks) {\r
1669             this._callbacks = [];\r
1670             this._contexts = [];\r
1671         }\r
1672         this._callbacks.push(callback);\r
1673         this._contexts.push(context);\r
1674         if (Array.isArray(bucket)) {\r
1675             bucket.push({ dispose: () => this.remove(callback, context) });\r
1676         }\r
1677     }\r
1678     remove(callback, context = null) {\r
1679         if (!this._callbacks) {\r
1680             return;\r
1681         }\r
1682         var foundCallbackWithDifferentContext = false;\r
1683         for (var i = 0, len = this._callbacks.length; i < len; i++) {\r
1684             if (this._callbacks[i] === callback) {\r
1685                 if (this._contexts[i] === context) {\r
1686                     // callback & context match => remove it\r
1687                     this._callbacks.splice(i, 1);\r
1688                     this._contexts.splice(i, 1);\r
1689                     return;\r
1690                 }\r
1691                 else {\r
1692                     foundCallbackWithDifferentContext = true;\r
1693                 }\r
1694             }\r
1695         }\r
1696         if (foundCallbackWithDifferentContext) {\r
1697             throw new Error('When adding a listener with a context, you should remove it with the same context');\r
1698         }\r
1699     }\r
1700     invoke(...args) {\r
1701         if (!this._callbacks) {\r
1702             return [];\r
1703         }\r
1704         var ret = [], callbacks = this._callbacks.slice(0), contexts = this._contexts.slice(0);\r
1705         for (var i = 0, len = callbacks.length; i < len; i++) {\r
1706             try {\r
1707                 ret.push(callbacks[i].apply(contexts[i], args));\r
1708             }\r
1709             catch (e) {\r
1710                 console.error(e);\r
1711             }\r
1712         }\r
1713         return ret;\r
1714     }\r
1715     isEmpty() {\r
1716         return !this._callbacks || this._callbacks.length === 0;\r
1717     }\r
1718     dispose() {\r
1719         this._callbacks = undefined;\r
1720         this._contexts = undefined;\r
1721     }\r
1722 }\r
1723 class Emitter {\r
1724     constructor(_options) {\r
1725         this._options = _options;\r
1726     }\r
1727     /**\r
1728      * For the public to allow to subscribe\r
1729      * to events from this Emitter\r
1730      */\r
1731     get event() {\r
1732         if (!this._event) {\r
1733             this._event = (listener, thisArgs, disposables) => {\r
1734                 if (!this._callbacks) {\r
1735                     this._callbacks = new CallbackList();\r
1736                 }\r
1737                 if (this._options && this._options.onFirstListenerAdd && this._callbacks.isEmpty()) {\r
1738                     this._options.onFirstListenerAdd(this);\r
1739                 }\r
1740                 this._callbacks.add(listener, thisArgs);\r
1741                 let result;\r
1742                 result = {\r
1743                     dispose: () => {\r
1744                         this._callbacks.remove(listener, thisArgs);\r
1745                         result.dispose = Emitter._noop;\r
1746                         if (this._options && this._options.onLastListenerRemove && this._callbacks.isEmpty()) {\r
1747                             this._options.onLastListenerRemove(this);\r
1748                         }\r
1749                     }\r
1750                 };\r
1751                 if (Array.isArray(disposables)) {\r
1752                     disposables.push(result);\r
1753                 }\r
1754                 return result;\r
1755             };\r
1756         }\r
1757         return this._event;\r
1758     }\r
1759     /**\r
1760      * To be kept private to fire an event to\r
1761      * subscribers\r
1762      */\r
1763     fire(event) {\r
1764         if (this._callbacks) {\r
1765             this._callbacks.invoke.call(this._callbacks, event);\r
1766         }\r
1767     }\r
1768     dispose() {\r
1769         if (this._callbacks) {\r
1770             this._callbacks.dispose();\r
1771             this._callbacks = undefined;\r
1772         }\r
1773     }\r
1774 }\r
1775 Emitter._noop = function () { };\r
1776 exports.Emitter = Emitter;\r
1777
1778
1779 /***/ }),
1780 /* 9 */
1781 /***/ (function(module, exports, __webpack_require__) {
1782
1783 "use strict";
1784 /* --------------------------------------------------------------------------------------------\r
1785  * Copyright (c) Microsoft Corporation. All rights reserved.\r
1786  * Licensed under the MIT License. See License.txt in the project root for license information.\r
1787  * ------------------------------------------------------------------------------------------ */\r
1788 \r
1789 Object.defineProperty(exports, "__esModule", { value: true });\r
1790 const events_1 = __webpack_require__(8);\r
1791 const Is = __webpack_require__(5);\r
1792 let ContentLength = 'Content-Length: ';\r
1793 let CRLF = '\r\n';\r
1794 var MessageWriter;\r
1795 (function (MessageWriter) {\r
1796     function is(value) {\r
1797         let candidate = value;\r
1798         return candidate && Is.func(candidate.dispose) && Is.func(candidate.onClose) &&\r
1799             Is.func(candidate.onError) && Is.func(candidate.write);\r
1800     }\r
1801     MessageWriter.is = is;\r
1802 })(MessageWriter = exports.MessageWriter || (exports.MessageWriter = {}));\r
1803 class AbstractMessageWriter {\r
1804     constructor() {\r
1805         this.errorEmitter = new events_1.Emitter();\r
1806         this.closeEmitter = new events_1.Emitter();\r
1807     }\r
1808     dispose() {\r
1809         this.errorEmitter.dispose();\r
1810         this.closeEmitter.dispose();\r
1811     }\r
1812     get onError() {\r
1813         return this.errorEmitter.event;\r
1814     }\r
1815     fireError(error, message, count) {\r
1816         this.errorEmitter.fire([this.asError(error), message, count]);\r
1817     }\r
1818     get onClose() {\r
1819         return this.closeEmitter.event;\r
1820     }\r
1821     fireClose() {\r
1822         this.closeEmitter.fire(undefined);\r
1823     }\r
1824     asError(error) {\r
1825         if (error instanceof Error) {\r
1826             return error;\r
1827         }\r
1828         else {\r
1829             return new Error(`Writer received error. Reason: ${Is.string(error.message) ? error.message : 'unknown'}`);\r
1830         }\r
1831     }\r
1832 }\r
1833 exports.AbstractMessageWriter = AbstractMessageWriter;\r
1834 class StreamMessageWriter extends AbstractMessageWriter {\r
1835     constructor(writable, encoding = 'utf8') {\r
1836         super();\r
1837         this.writable = writable;\r
1838         this.encoding = encoding;\r
1839         this.errorCount = 0;\r
1840         this.writable.on('error', (error) => this.fireError(error));\r
1841         this.writable.on('close', () => this.fireClose());\r
1842     }\r
1843     write(msg) {\r
1844         let json = JSON.stringify(msg);\r
1845         let contentLength = Buffer.byteLength(json, this.encoding);\r
1846         let headers = [\r
1847             ContentLength, contentLength.toString(), CRLF,\r
1848             CRLF\r
1849         ];\r
1850         try {\r
1851             // Header must be written in ASCII encoding\r
1852             this.writable.write(headers.join(''), 'ascii');\r
1853             // Now write the content. This can be written in any encoding\r
1854             this.writable.write(json, this.encoding);\r
1855             this.errorCount = 0;\r
1856         }\r
1857         catch (error) {\r
1858             this.errorCount++;\r
1859             this.fireError(error, msg, this.errorCount);\r
1860         }\r
1861     }\r
1862 }\r
1863 exports.StreamMessageWriter = StreamMessageWriter;\r
1864 class IPCMessageWriter extends AbstractMessageWriter {\r
1865     constructor(process) {\r
1866         super();\r
1867         this.process = process;\r
1868         this.errorCount = 0;\r
1869         this.queue = [];\r
1870         this.sending = false;\r
1871         let eventEmitter = this.process;\r
1872         eventEmitter.on('error', (error) => this.fireError(error));\r
1873         eventEmitter.on('close', () => this.fireClose);\r
1874     }\r
1875     write(msg) {\r
1876         if (!this.sending && this.queue.length === 0) {\r
1877             // See https://github.com/nodejs/node/issues/7657\r
1878             this.doWriteMessage(msg);\r
1879         }\r
1880         else {\r
1881             this.queue.push(msg);\r
1882         }\r
1883     }\r
1884     doWriteMessage(msg) {\r
1885         try {\r
1886             if (this.process.send) {\r
1887                 this.sending = true;\r
1888                 this.process.send(msg, undefined, undefined, (error) => {\r
1889                     this.sending = false;\r
1890                     if (error) {\r
1891                         this.errorCount++;\r
1892                         this.fireError(error, msg, this.errorCount);\r
1893                     }\r
1894                     else {\r
1895                         this.errorCount = 0;\r
1896                     }\r
1897                     if (this.queue.length > 0) {\r
1898                         this.doWriteMessage(this.queue.shift());\r
1899                     }\r
1900                 });\r
1901             }\r
1902         }\r
1903         catch (error) {\r
1904             this.errorCount++;\r
1905             this.fireError(error, msg, this.errorCount);\r
1906         }\r
1907     }\r
1908 }\r
1909 exports.IPCMessageWriter = IPCMessageWriter;\r
1910 class SocketMessageWriter extends AbstractMessageWriter {\r
1911     constructor(socket, encoding = 'utf8') {\r
1912         super();\r
1913         this.socket = socket;\r
1914         this.queue = [];\r
1915         this.sending = false;\r
1916         this.encoding = encoding;\r
1917         this.errorCount = 0;\r
1918         this.socket.on('error', (error) => this.fireError(error));\r
1919         this.socket.on('close', () => this.fireClose());\r
1920     }\r
1921     dispose() {\r
1922         super.dispose();\r
1923         this.socket.destroy();\r
1924     }\r
1925     write(msg) {\r
1926         if (!this.sending && this.queue.length === 0) {\r
1927             // See https://github.com/nodejs/node/issues/7657\r
1928             this.doWriteMessage(msg);\r
1929         }\r
1930         else {\r
1931             this.queue.push(msg);\r
1932         }\r
1933     }\r
1934     doWriteMessage(msg) {\r
1935         let json = JSON.stringify(msg);\r
1936         let contentLength = Buffer.byteLength(json, this.encoding);\r
1937         let headers = [\r
1938             ContentLength, contentLength.toString(), CRLF,\r
1939             CRLF\r
1940         ];\r
1941         try {\r
1942             // Header must be written in ASCII encoding\r
1943             this.sending = true;\r
1944             this.socket.write(headers.join(''), 'ascii', (error) => {\r
1945                 if (error) {\r
1946                     this.handleError(error, msg);\r
1947                 }\r
1948                 try {\r
1949                     // Now write the content. This can be written in any encoding\r
1950                     this.socket.write(json, this.encoding, (error) => {\r
1951                         this.sending = false;\r
1952                         if (error) {\r
1953                             this.handleError(error, msg);\r
1954                         }\r
1955                         else {\r
1956                             this.errorCount = 0;\r
1957                         }\r
1958                         if (this.queue.length > 0) {\r
1959                             this.doWriteMessage(this.queue.shift());\r
1960                         }\r
1961                     });\r
1962                 }\r
1963                 catch (error) {\r
1964                     this.handleError(error, msg);\r
1965                 }\r
1966             });\r
1967         }\r
1968         catch (error) {\r
1969             this.handleError(error, msg);\r
1970         }\r
1971     }\r
1972     handleError(error, msg) {\r
1973         this.errorCount++;\r
1974         this.fireError(error, msg, this.errorCount);\r
1975     }\r
1976 }\r
1977 exports.SocketMessageWriter = SocketMessageWriter;\r
1978
1979
1980 /***/ }),
1981 /* 10 */
1982 /***/ (function(module, exports, __webpack_require__) {
1983
1984 "use strict";
1985 /*---------------------------------------------------------------------------------------------\r
1986  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
1987  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
1988  *--------------------------------------------------------------------------------------------*/\r
1989 \r
1990 Object.defineProperty(exports, "__esModule", { value: true });\r
1991 const events_1 = __webpack_require__(8);\r
1992 const Is = __webpack_require__(5);\r
1993 var CancellationToken;\r
1994 (function (CancellationToken) {\r
1995     CancellationToken.None = Object.freeze({\r
1996         isCancellationRequested: false,\r
1997         onCancellationRequested: events_1.Event.None\r
1998     });\r
1999     CancellationToken.Cancelled = Object.freeze({\r
2000         isCancellationRequested: true,\r
2001         onCancellationRequested: events_1.Event.None\r
2002     });\r
2003     function is(value) {\r
2004         let candidate = value;\r
2005         return candidate && (candidate === CancellationToken.None\r
2006             || candidate === CancellationToken.Cancelled\r
2007             || (Is.boolean(candidate.isCancellationRequested) && !!candidate.onCancellationRequested));\r
2008     }\r
2009     CancellationToken.is = is;\r
2010 })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));\r
2011 const shortcutEvent = Object.freeze(function (callback, context) {\r
2012     let handle = setTimeout(callback.bind(context), 0);\r
2013     return { dispose() { clearTimeout(handle); } };\r
2014 });\r
2015 class MutableToken {\r
2016     constructor() {\r
2017         this._isCancelled = false;\r
2018     }\r
2019     cancel() {\r
2020         if (!this._isCancelled) {\r
2021             this._isCancelled = true;\r
2022             if (this._emitter) {\r
2023                 this._emitter.fire(undefined);\r
2024                 this.dispose();\r
2025             }\r
2026         }\r
2027     }\r
2028     get isCancellationRequested() {\r
2029         return this._isCancelled;\r
2030     }\r
2031     get onCancellationRequested() {\r
2032         if (this._isCancelled) {\r
2033             return shortcutEvent;\r
2034         }\r
2035         if (!this._emitter) {\r
2036             this._emitter = new events_1.Emitter();\r
2037         }\r
2038         return this._emitter.event;\r
2039     }\r
2040     dispose() {\r
2041         if (this._emitter) {\r
2042             this._emitter.dispose();\r
2043             this._emitter = undefined;\r
2044         }\r
2045     }\r
2046 }\r
2047 class CancellationTokenSource {\r
2048     get token() {\r
2049         if (!this._token) {\r
2050             // be lazy and create the token only when\r
2051             // actually needed\r
2052             this._token = new MutableToken();\r
2053         }\r
2054         return this._token;\r
2055     }\r
2056     cancel() {\r
2057         if (!this._token) {\r
2058             // save an object by returning the default\r
2059             // cancelled token when cancellation happens\r
2060             // before someone asks for the token\r
2061             this._token = CancellationToken.Cancelled;\r
2062         }\r
2063         else {\r
2064             this._token.cancel();\r
2065         }\r
2066     }\r
2067     dispose() {\r
2068         if (!this._token) {\r
2069             // ensure to initialize with an empty token if we had none\r
2070             this._token = CancellationToken.None;\r
2071         }\r
2072         else if (this._token instanceof MutableToken) {\r
2073             // actually dispose\r
2074             this._token.dispose();\r
2075         }\r
2076     }\r
2077 }\r
2078 exports.CancellationTokenSource = CancellationTokenSource;\r
2079
2080
2081 /***/ }),
2082 /* 11 */
2083 /***/ (function(module, exports, __webpack_require__) {
2084
2085 "use strict";
2086 \r
2087 /*---------------------------------------------------------------------------------------------\r
2088  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
2089  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
2090  *--------------------------------------------------------------------------------------------*/\r
2091 Object.defineProperty(exports, "__esModule", { value: true });\r
2092 var Touch;\r
2093 (function (Touch) {\r
2094     Touch.None = 0;\r
2095     Touch.First = 1;\r
2096     Touch.Last = 2;\r
2097 })(Touch = exports.Touch || (exports.Touch = {}));\r
2098 class LinkedMap {\r
2099     constructor() {\r
2100         this._map = new Map();\r
2101         this._head = undefined;\r
2102         this._tail = undefined;\r
2103         this._size = 0;\r
2104     }\r
2105     clear() {\r
2106         this._map.clear();\r
2107         this._head = undefined;\r
2108         this._tail = undefined;\r
2109         this._size = 0;\r
2110     }\r
2111     isEmpty() {\r
2112         return !this._head && !this._tail;\r
2113     }\r
2114     get size() {\r
2115         return this._size;\r
2116     }\r
2117     has(key) {\r
2118         return this._map.has(key);\r
2119     }\r
2120     get(key) {\r
2121         const item = this._map.get(key);\r
2122         if (!item) {\r
2123             return undefined;\r
2124         }\r
2125         return item.value;\r
2126     }\r
2127     set(key, value, touch = Touch.None) {\r
2128         let item = this._map.get(key);\r
2129         if (item) {\r
2130             item.value = value;\r
2131             if (touch !== Touch.None) {\r
2132                 this.touch(item, touch);\r
2133             }\r
2134         }\r
2135         else {\r
2136             item = { key, value, next: undefined, previous: undefined };\r
2137             switch (touch) {\r
2138                 case Touch.None:\r
2139                     this.addItemLast(item);\r
2140                     break;\r
2141                 case Touch.First:\r
2142                     this.addItemFirst(item);\r
2143                     break;\r
2144                 case Touch.Last:\r
2145                     this.addItemLast(item);\r
2146                     break;\r
2147                 default:\r
2148                     this.addItemLast(item);\r
2149                     break;\r
2150             }\r
2151             this._map.set(key, item);\r
2152             this._size++;\r
2153         }\r
2154     }\r
2155     delete(key) {\r
2156         const item = this._map.get(key);\r
2157         if (!item) {\r
2158             return false;\r
2159         }\r
2160         this._map.delete(key);\r
2161         this.removeItem(item);\r
2162         this._size--;\r
2163         return true;\r
2164     }\r
2165     shift() {\r
2166         if (!this._head && !this._tail) {\r
2167             return undefined;\r
2168         }\r
2169         if (!this._head || !this._tail) {\r
2170             throw new Error('Invalid list');\r
2171         }\r
2172         const item = this._head;\r
2173         this._map.delete(item.key);\r
2174         this.removeItem(item);\r
2175         this._size--;\r
2176         return item.value;\r
2177     }\r
2178     forEach(callbackfn, thisArg) {\r
2179         let current = this._head;\r
2180         while (current) {\r
2181             if (thisArg) {\r
2182                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
2183             }\r
2184             else {\r
2185                 callbackfn(current.value, current.key, this);\r
2186             }\r
2187             current = current.next;\r
2188         }\r
2189     }\r
2190     forEachReverse(callbackfn, thisArg) {\r
2191         let current = this._tail;\r
2192         while (current) {\r
2193             if (thisArg) {\r
2194                 callbackfn.bind(thisArg)(current.value, current.key, this);\r
2195             }\r
2196             else {\r
2197                 callbackfn(current.value, current.key, this);\r
2198             }\r
2199             current = current.previous;\r
2200         }\r
2201     }\r
2202     values() {\r
2203         let result = [];\r
2204         let current = this._head;\r
2205         while (current) {\r
2206             result.push(current.value);\r
2207             current = current.next;\r
2208         }\r
2209         return result;\r
2210     }\r
2211     keys() {\r
2212         let result = [];\r
2213         let current = this._head;\r
2214         while (current) {\r
2215             result.push(current.key);\r
2216             current = current.next;\r
2217         }\r
2218         return result;\r
2219     }\r
2220     /* JSON RPC run on es5 which has no Symbol.iterator\r
2221     public keys(): IterableIterator<K> {\r
2222         let current = this._head;\r
2223         let iterator: IterableIterator<K> = {\r
2224             [Symbol.iterator]() {\r
2225                 return iterator;\r
2226             },\r
2227             next():IteratorResult<K> {\r
2228                 if (current) {\r
2229                     let result = { value: current.key, done: false };\r
2230                     current = current.next;\r
2231                     return result;\r
2232                 } else {\r
2233                     return { value: undefined, done: true };\r
2234                 }\r
2235             }\r
2236         };\r
2237         return iterator;\r
2238     }\r
2239 \r
2240     public values(): IterableIterator<V> {\r
2241         let current = this._head;\r
2242         let iterator: IterableIterator<V> = {\r
2243             [Symbol.iterator]() {\r
2244                 return iterator;\r
2245             },\r
2246             next():IteratorResult<V> {\r
2247                 if (current) {\r
2248                     let result = { value: current.value, done: false };\r
2249                     current = current.next;\r
2250                     return result;\r
2251                 } else {\r
2252                     return { value: undefined, done: true };\r
2253                 }\r
2254             }\r
2255         };\r
2256         return iterator;\r
2257     }\r
2258     */\r
2259     addItemFirst(item) {\r
2260         // First time Insert\r
2261         if (!this._head && !this._tail) {\r
2262             this._tail = item;\r
2263         }\r
2264         else if (!this._head) {\r
2265             throw new Error('Invalid list');\r
2266         }\r
2267         else {\r
2268             item.next = this._head;\r
2269             this._head.previous = item;\r
2270         }\r
2271         this._head = item;\r
2272     }\r
2273     addItemLast(item) {\r
2274         // First time Insert\r
2275         if (!this._head && !this._tail) {\r
2276             this._head = item;\r
2277         }\r
2278         else if (!this._tail) {\r
2279             throw new Error('Invalid list');\r
2280         }\r
2281         else {\r
2282             item.previous = this._tail;\r
2283             this._tail.next = item;\r
2284         }\r
2285         this._tail = item;\r
2286     }\r
2287     removeItem(item) {\r
2288         if (item === this._head && item === this._tail) {\r
2289             this._head = undefined;\r
2290             this._tail = undefined;\r
2291         }\r
2292         else if (item === this._head) {\r
2293             this._head = item.next;\r
2294         }\r
2295         else if (item === this._tail) {\r
2296             this._tail = item.previous;\r
2297         }\r
2298         else {\r
2299             const next = item.next;\r
2300             const previous = item.previous;\r
2301             if (!next || !previous) {\r
2302                 throw new Error('Invalid list');\r
2303             }\r
2304             next.previous = previous;\r
2305             previous.next = next;\r
2306         }\r
2307     }\r
2308     touch(item, touch) {\r
2309         if (!this._head || !this._tail) {\r
2310             throw new Error('Invalid list');\r
2311         }\r
2312         if ((touch !== Touch.First && touch !== Touch.Last)) {\r
2313             return;\r
2314         }\r
2315         if (touch === Touch.First) {\r
2316             if (item === this._head) {\r
2317                 return;\r
2318             }\r
2319             const next = item.next;\r
2320             const previous = item.previous;\r
2321             // Unlink the item\r
2322             if (item === this._tail) {\r
2323                 // previous must be defined since item was not head but is tail\r
2324                 // So there are more than on item in the map\r
2325                 previous.next = undefined;\r
2326                 this._tail = previous;\r
2327             }\r
2328             else {\r
2329                 // Both next and previous are not undefined since item was neither head nor tail.\r
2330                 next.previous = previous;\r
2331                 previous.next = next;\r
2332             }\r
2333             // Insert the node at head\r
2334             item.previous = undefined;\r
2335             item.next = this._head;\r
2336             this._head.previous = item;\r
2337             this._head = item;\r
2338         }\r
2339         else if (touch === Touch.Last) {\r
2340             if (item === this._tail) {\r
2341                 return;\r
2342             }\r
2343             const next = item.next;\r
2344             const previous = item.previous;\r
2345             // Unlink the item.\r
2346             if (item === this._head) {\r
2347                 // next must be defined since item was not tail but is head\r
2348                 // So there are more than on item in the map\r
2349                 next.previous = undefined;\r
2350                 this._head = next;\r
2351             }\r
2352             else {\r
2353                 // Both next and previous are not undefined since item was neither head nor tail.\r
2354                 next.previous = previous;\r
2355                 previous.next = next;\r
2356             }\r
2357             item.next = undefined;\r
2358             item.previous = this._tail;\r
2359             this._tail.next = item;\r
2360             this._tail = item;\r
2361         }\r
2362     }\r
2363 }\r
2364 exports.LinkedMap = LinkedMap;\r
2365
2366
2367 /***/ }),
2368 /* 12 */
2369 /***/ (function(module, exports, __webpack_require__) {
2370
2371 "use strict";
2372 /* --------------------------------------------------------------------------------------------\r
2373  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2374  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2375  * ------------------------------------------------------------------------------------------ */\r
2376 \r
2377 Object.defineProperty(exports, "__esModule", { value: true });\r
2378 const path_1 = __webpack_require__(1);\r
2379 const os_1 = __webpack_require__(13);\r
2380 const crypto_1 = __webpack_require__(14);\r
2381 const net_1 = __webpack_require__(15);\r
2382 const messageReader_1 = __webpack_require__(7);\r
2383 const messageWriter_1 = __webpack_require__(9);\r
2384 function generateRandomPipeName() {\r
2385     const randomSuffix = crypto_1.randomBytes(21).toString('hex');\r
2386     if (process.platform === 'win32') {\r
2387         return `\\\\.\\pipe\\vscode-jsonrpc-${randomSuffix}-sock`;\r
2388     }\r
2389     else {\r
2390         // Mac/Unix: use socket file\r
2391         return path_1.join(os_1.tmpdir(), `vscode-${randomSuffix}.sock`);\r
2392     }\r
2393 }\r
2394 exports.generateRandomPipeName = generateRandomPipeName;\r
2395 function createClientPipeTransport(pipeName, encoding = 'utf-8') {\r
2396     let connectResolve;\r
2397     let connected = new Promise((resolve, _reject) => {\r
2398         connectResolve = resolve;\r
2399     });\r
2400     return new Promise((resolve, reject) => {\r
2401         let server = net_1.createServer((socket) => {\r
2402             server.close();\r
2403             connectResolve([\r
2404                 new messageReader_1.SocketMessageReader(socket, encoding),\r
2405                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2406             ]);\r
2407         });\r
2408         server.on('error', reject);\r
2409         server.listen(pipeName, () => {\r
2410             server.removeListener('error', reject);\r
2411             resolve({\r
2412                 onConnected: () => { return connected; }\r
2413             });\r
2414         });\r
2415     });\r
2416 }\r
2417 exports.createClientPipeTransport = createClientPipeTransport;\r
2418 function createServerPipeTransport(pipeName, encoding = 'utf-8') {\r
2419     const socket = net_1.createConnection(pipeName);\r
2420     return [\r
2421         new messageReader_1.SocketMessageReader(socket, encoding),\r
2422         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2423     ];\r
2424 }\r
2425 exports.createServerPipeTransport = createServerPipeTransport;\r
2426
2427
2428 /***/ }),
2429 /* 13 */
2430 /***/ (function(module, exports) {
2431
2432 module.exports = require("os");
2433
2434 /***/ }),
2435 /* 14 */
2436 /***/ (function(module, exports) {
2437
2438 module.exports = require("crypto");
2439
2440 /***/ }),
2441 /* 15 */
2442 /***/ (function(module, exports) {
2443
2444 module.exports = require("net");
2445
2446 /***/ }),
2447 /* 16 */
2448 /***/ (function(module, exports, __webpack_require__) {
2449
2450 "use strict";
2451 /* --------------------------------------------------------------------------------------------\r
2452  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2453  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2454  * ------------------------------------------------------------------------------------------ */\r
2455 \r
2456 Object.defineProperty(exports, "__esModule", { value: true });\r
2457 const net_1 = __webpack_require__(15);\r
2458 const messageReader_1 = __webpack_require__(7);\r
2459 const messageWriter_1 = __webpack_require__(9);\r
2460 function createClientSocketTransport(port, encoding = 'utf-8') {\r
2461     let connectResolve;\r
2462     let connected = new Promise((resolve, _reject) => {\r
2463         connectResolve = resolve;\r
2464     });\r
2465     return new Promise((resolve, reject) => {\r
2466         let server = net_1.createServer((socket) => {\r
2467             server.close();\r
2468             connectResolve([\r
2469                 new messageReader_1.SocketMessageReader(socket, encoding),\r
2470                 new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2471             ]);\r
2472         });\r
2473         server.on('error', reject);\r
2474         server.listen(port, '127.0.0.1', () => {\r
2475             server.removeListener('error', reject);\r
2476             resolve({\r
2477                 onConnected: () => { return connected; }\r
2478             });\r
2479         });\r
2480     });\r
2481 }\r
2482 exports.createClientSocketTransport = createClientSocketTransport;\r
2483 function createServerSocketTransport(port, encoding = 'utf-8') {\r
2484     const socket = net_1.createConnection(port, '127.0.0.1');\r
2485     return [\r
2486         new messageReader_1.SocketMessageReader(socket, encoding),\r
2487         new messageWriter_1.SocketMessageWriter(socket, encoding)\r
2488     ];\r
2489 }\r
2490 exports.createServerSocketTransport = createServerSocketTransport;\r
2491
2492
2493 /***/ }),
2494 /* 17 */
2495 /***/ (function(module, __webpack_exports__, __webpack_require__) {
2496
2497 "use strict";
2498 __webpack_require__.r(__webpack_exports__);
2499 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
2500 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
2501 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
2502 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
2503 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
2504 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
2505 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
2506 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
2507 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
2508 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
2509 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
2510 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
2511 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
2512 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
2513 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
2514 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
2515 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
2516 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
2517 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
2518 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
2519 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
2520 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
2521 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
2522 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
2523 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
2524 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
2525 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
2526 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
2527 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
2528 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
2529 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
2530 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
2531 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
2532 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
2533 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
2534 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
2535 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
2536 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
2537 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
2538 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
2539 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
2540 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
2541 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
2542 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
2543 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
2544 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
2545 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
2546 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
2547 /* --------------------------------------------------------------------------------------------\r
2548  * Copyright (c) Microsoft Corporation. All rights reserved.\r
2549  * Licensed under the MIT License. See License.txt in the project root for license information.\r
2550  * ------------------------------------------------------------------------------------------ */\r
2551 \r
2552 /**\r
2553  * The Position namespace provides helper functions to work with\r
2554  * [Position](#Position) literals.\r
2555  */\r
2556 var Position;\r
2557 (function (Position) {\r
2558     /**\r
2559      * Creates a new Position literal from the given line and character.\r
2560      * @param line The position's line.\r
2561      * @param character The position's character.\r
2562      */\r
2563     function create(line, character) {\r
2564         return { line: line, character: character };\r
2565     }\r
2566     Position.create = create;\r
2567     /**\r
2568      * Checks whether the given liternal conforms to the [Position](#Position) interface.\r
2569      */\r
2570     function is(value) {\r
2571         var candidate = value;\r
2572         return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);\r
2573     }\r
2574     Position.is = is;\r
2575 })(Position || (Position = {}));\r
2576 /**\r
2577  * The Range namespace provides helper functions to work with\r
2578  * [Range](#Range) literals.\r
2579  */\r
2580 var Range;\r
2581 (function (Range) {\r
2582     function create(one, two, three, four) {\r
2583         if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {\r
2584             return { start: Position.create(one, two), end: Position.create(three, four) };\r
2585         }\r
2586         else if (Position.is(one) && Position.is(two)) {\r
2587             return { start: one, end: two };\r
2588         }\r
2589         else {\r
2590             throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");\r
2591         }\r
2592     }\r
2593     Range.create = create;\r
2594     /**\r
2595      * Checks whether the given literal conforms to the [Range](#Range) interface.\r
2596      */\r
2597     function is(value) {\r
2598         var candidate = value;\r
2599         return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);\r
2600     }\r
2601     Range.is = is;\r
2602 })(Range || (Range = {}));\r
2603 /**\r
2604  * The Location namespace provides helper functions to work with\r
2605  * [Location](#Location) literals.\r
2606  */\r
2607 var Location;\r
2608 (function (Location) {\r
2609     /**\r
2610      * Creates a Location literal.\r
2611      * @param uri The location's uri.\r
2612      * @param range The location's range.\r
2613      */\r
2614     function create(uri, range) {\r
2615         return { uri: uri, range: range };\r
2616     }\r
2617     Location.create = create;\r
2618     /**\r
2619      * Checks whether the given literal conforms to the [Location](#Location) interface.\r
2620      */\r
2621     function is(value) {\r
2622         var candidate = value;\r
2623         return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));\r
2624     }\r
2625     Location.is = is;\r
2626 })(Location || (Location = {}));\r
2627 /**\r
2628  * The LocationLink namespace provides helper functions to work with\r
2629  * [LocationLink](#LocationLink) literals.\r
2630  */\r
2631 var LocationLink;\r
2632 (function (LocationLink) {\r
2633     /**\r
2634      * Creates a LocationLink literal.\r
2635      * @param targetUri The definition's uri.\r
2636      * @param targetRange The full range of the definition.\r
2637      * @param targetSelectionRange The span of the symbol definition at the target.\r
2638      * @param originSelectionRange The span of the symbol being defined in the originating source file.\r
2639      */\r
2640     function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {\r
2641         return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };\r
2642     }\r
2643     LocationLink.create = create;\r
2644     /**\r
2645      * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.\r
2646      */\r
2647     function is(value) {\r
2648         var candidate = value;\r
2649         return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)\r
2650             && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))\r
2651             && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));\r
2652     }\r
2653     LocationLink.is = is;\r
2654 })(LocationLink || (LocationLink = {}));\r
2655 /**\r
2656  * The Color namespace provides helper functions to work with\r
2657  * [Color](#Color) literals.\r
2658  */\r
2659 var Color;\r
2660 (function (Color) {\r
2661     /**\r
2662      * Creates a new Color literal.\r
2663      */\r
2664     function create(red, green, blue, alpha) {\r
2665         return {\r
2666             red: red,\r
2667             green: green,\r
2668             blue: blue,\r
2669             alpha: alpha,\r
2670         };\r
2671     }\r
2672     Color.create = create;\r
2673     /**\r
2674      * Checks whether the given literal conforms to the [Color](#Color) interface.\r
2675      */\r
2676     function is(value) {\r
2677         var candidate = value;\r
2678         return Is.number(candidate.red)\r
2679             && Is.number(candidate.green)\r
2680             && Is.number(candidate.blue)\r
2681             && Is.number(candidate.alpha);\r
2682     }\r
2683     Color.is = is;\r
2684 })(Color || (Color = {}));\r
2685 /**\r
2686  * The ColorInformation namespace provides helper functions to work with\r
2687  * [ColorInformation](#ColorInformation) literals.\r
2688  */\r
2689 var ColorInformation;\r
2690 (function (ColorInformation) {\r
2691     /**\r
2692      * Creates a new ColorInformation literal.\r
2693      */\r
2694     function create(range, color) {\r
2695         return {\r
2696             range: range,\r
2697             color: color,\r
2698         };\r
2699     }\r
2700     ColorInformation.create = create;\r
2701     /**\r
2702      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
2703      */\r
2704     function is(value) {\r
2705         var candidate = value;\r
2706         return Range.is(candidate.range) && Color.is(candidate.color);\r
2707     }\r
2708     ColorInformation.is = is;\r
2709 })(ColorInformation || (ColorInformation = {}));\r
2710 /**\r
2711  * The Color namespace provides helper functions to work with\r
2712  * [ColorPresentation](#ColorPresentation) literals.\r
2713  */\r
2714 var ColorPresentation;\r
2715 (function (ColorPresentation) {\r
2716     /**\r
2717      * Creates a new ColorInformation literal.\r
2718      */\r
2719     function create(label, textEdit, additionalTextEdits) {\r
2720         return {\r
2721             label: label,\r
2722             textEdit: textEdit,\r
2723             additionalTextEdits: additionalTextEdits,\r
2724         };\r
2725     }\r
2726     ColorPresentation.create = create;\r
2727     /**\r
2728      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.\r
2729      */\r
2730     function is(value) {\r
2731         var candidate = value;\r
2732         return Is.string(candidate.label)\r
2733             && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))\r
2734             && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));\r
2735     }\r
2736     ColorPresentation.is = is;\r
2737 })(ColorPresentation || (ColorPresentation = {}));\r
2738 /**\r
2739  * Enum of known range kinds\r
2740  */\r
2741 var FoldingRangeKind;\r
2742 (function (FoldingRangeKind) {\r
2743     /**\r
2744      * Folding range for a comment\r
2745      */\r
2746     FoldingRangeKind["Comment"] = "comment";\r
2747     /**\r
2748      * Folding range for a imports or includes\r
2749      */\r
2750     FoldingRangeKind["Imports"] = "imports";\r
2751     /**\r
2752      * Folding range for a region (e.g. `#region`)\r
2753      */\r
2754     FoldingRangeKind["Region"] = "region";\r
2755 })(FoldingRangeKind || (FoldingRangeKind = {}));\r
2756 /**\r
2757  * The folding range namespace provides helper functions to work with\r
2758  * [FoldingRange](#FoldingRange) literals.\r
2759  */\r
2760 var FoldingRange;\r
2761 (function (FoldingRange) {\r
2762     /**\r
2763      * Creates a new FoldingRange literal.\r
2764      */\r
2765     function create(startLine, endLine, startCharacter, endCharacter, kind) {\r
2766         var result = {\r
2767             startLine: startLine,\r
2768             endLine: endLine\r
2769         };\r
2770         if (Is.defined(startCharacter)) {\r
2771             result.startCharacter = startCharacter;\r
2772         }\r
2773         if (Is.defined(endCharacter)) {\r
2774             result.endCharacter = endCharacter;\r
2775         }\r
2776         if (Is.defined(kind)) {\r
2777             result.kind = kind;\r
2778         }\r
2779         return result;\r
2780     }\r
2781     FoldingRange.create = create;\r
2782     /**\r
2783      * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.\r
2784      */\r
2785     function is(value) {\r
2786         var candidate = value;\r
2787         return Is.number(candidate.startLine) && Is.number(candidate.startLine)\r
2788             && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))\r
2789             && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))\r
2790             && (Is.undefined(candidate.kind) || Is.string(candidate.kind));\r
2791     }\r
2792     FoldingRange.is = is;\r
2793 })(FoldingRange || (FoldingRange = {}));\r
2794 /**\r
2795  * The DiagnosticRelatedInformation namespace provides helper functions to work with\r
2796  * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.\r
2797  */\r
2798 var DiagnosticRelatedInformation;\r
2799 (function (DiagnosticRelatedInformation) {\r
2800     /**\r
2801      * Creates a new DiagnosticRelatedInformation literal.\r
2802      */\r
2803     function create(location, message) {\r
2804         return {\r
2805             location: location,\r
2806             message: message\r
2807         };\r
2808     }\r
2809     DiagnosticRelatedInformation.create = create;\r
2810     /**\r
2811      * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.\r
2812      */\r
2813     function is(value) {\r
2814         var candidate = value;\r
2815         return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);\r
2816     }\r
2817     DiagnosticRelatedInformation.is = is;\r
2818 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));\r
2819 /**\r
2820  * The diagnostic's severity.\r
2821  */\r
2822 var DiagnosticSeverity;\r
2823 (function (DiagnosticSeverity) {\r
2824     /**\r
2825      * Reports an error.\r
2826      */\r
2827     DiagnosticSeverity.Error = 1;\r
2828     /**\r
2829      * Reports a warning.\r
2830      */\r
2831     DiagnosticSeverity.Warning = 2;\r
2832     /**\r
2833      * Reports an information.\r
2834      */\r
2835     DiagnosticSeverity.Information = 3;\r
2836     /**\r
2837      * Reports a hint.\r
2838      */\r
2839     DiagnosticSeverity.Hint = 4;\r
2840 })(DiagnosticSeverity || (DiagnosticSeverity = {}));\r
2841 var DiagnosticTag;\r
2842 (function (DiagnosticTag) {\r
2843     /**\r
2844      * Unused or unnecessary code.\r
2845      *\r
2846      * Clients are allowed to render diagnostics with this tag faded out instead of having\r
2847      * an error squiggle.\r
2848      */\r
2849     DiagnosticTag.Unnecessary = 1;\r
2850 })(DiagnosticTag || (DiagnosticTag = {}));\r
2851 /**\r
2852  * The Diagnostic namespace provides helper functions to work with\r
2853  * [Diagnostic](#Diagnostic) literals.\r
2854  */\r
2855 var Diagnostic;\r
2856 (function (Diagnostic) {\r
2857     /**\r
2858      * Creates a new Diagnostic literal.\r
2859      */\r
2860     function create(range, message, severity, code, source, relatedInformation) {\r
2861         var result = { range: range, message: message };\r
2862         if (Is.defined(severity)) {\r
2863             result.severity = severity;\r
2864         }\r
2865         if (Is.defined(code)) {\r
2866             result.code = code;\r
2867         }\r
2868         if (Is.defined(source)) {\r
2869             result.source = source;\r
2870         }\r
2871         if (Is.defined(relatedInformation)) {\r
2872             result.relatedInformation = relatedInformation;\r
2873         }\r
2874         return result;\r
2875     }\r
2876     Diagnostic.create = create;\r
2877     /**\r
2878      * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.\r
2879      */\r
2880     function is(value) {\r
2881         var candidate = value;\r
2882         return Is.defined(candidate)\r
2883             && Range.is(candidate.range)\r
2884             && Is.string(candidate.message)\r
2885             && (Is.number(candidate.severity) || Is.undefined(candidate.severity))\r
2886             && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))\r
2887             && (Is.string(candidate.source) || Is.undefined(candidate.source))\r
2888             && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));\r
2889     }\r
2890     Diagnostic.is = is;\r
2891 })(Diagnostic || (Diagnostic = {}));\r
2892 /**\r
2893  * The Command namespace provides helper functions to work with\r
2894  * [Command](#Command) literals.\r
2895  */\r
2896 var Command;\r
2897 (function (Command) {\r
2898     /**\r
2899      * Creates a new Command literal.\r
2900      */\r
2901     function create(title, command) {\r
2902         var args = [];\r
2903         for (var _i = 2; _i < arguments.length; _i++) {\r
2904             args[_i - 2] = arguments[_i];\r
2905         }\r
2906         var result = { title: title, command: command };\r
2907         if (Is.defined(args) && args.length > 0) {\r
2908             result.arguments = args;\r
2909         }\r
2910         return result;\r
2911     }\r
2912     Command.create = create;\r
2913     /**\r
2914      * Checks whether the given literal conforms to the [Command](#Command) interface.\r
2915      */\r
2916     function is(value) {\r
2917         var candidate = value;\r
2918         return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);\r
2919     }\r
2920     Command.is = is;\r
2921 })(Command || (Command = {}));\r
2922 /**\r
2923  * The TextEdit namespace provides helper function to create replace,\r
2924  * insert and delete edits more easily.\r
2925  */\r
2926 var TextEdit;\r
2927 (function (TextEdit) {\r
2928     /**\r
2929      * Creates a replace text edit.\r
2930      * @param range The range of text to be replaced.\r
2931      * @param newText The new text.\r
2932      */\r
2933     function replace(range, newText) {\r
2934         return { range: range, newText: newText };\r
2935     }\r
2936     TextEdit.replace = replace;\r
2937     /**\r
2938      * Creates a insert text edit.\r
2939      * @param position The position to insert the text at.\r
2940      * @param newText The text to be inserted.\r
2941      */\r
2942     function insert(position, newText) {\r
2943         return { range: { start: position, end: position }, newText: newText };\r
2944     }\r
2945     TextEdit.insert = insert;\r
2946     /**\r
2947      * Creates a delete text edit.\r
2948      * @param range The range of text to be deleted.\r
2949      */\r
2950     function del(range) {\r
2951         return { range: range, newText: '' };\r
2952     }\r
2953     TextEdit.del = del;\r
2954     function is(value) {\r
2955         var candidate = value;\r
2956         return Is.objectLiteral(candidate)\r
2957             && Is.string(candidate.newText)\r
2958             && Range.is(candidate.range);\r
2959     }\r
2960     TextEdit.is = is;\r
2961 })(TextEdit || (TextEdit = {}));\r
2962 /**\r
2963  * The TextDocumentEdit namespace provides helper function to create\r
2964  * an edit that manipulates a text document.\r
2965  */\r
2966 var TextDocumentEdit;\r
2967 (function (TextDocumentEdit) {\r
2968     /**\r
2969      * Creates a new `TextDocumentEdit`\r
2970      */\r
2971     function create(textDocument, edits) {\r
2972         return { textDocument: textDocument, edits: edits };\r
2973     }\r
2974     TextDocumentEdit.create = create;\r
2975     function is(value) {\r
2976         var candidate = value;\r
2977         return Is.defined(candidate)\r
2978             && VersionedTextDocumentIdentifier.is(candidate.textDocument)\r
2979             && Array.isArray(candidate.edits);\r
2980     }\r
2981     TextDocumentEdit.is = is;\r
2982 })(TextDocumentEdit || (TextDocumentEdit = {}));\r
2983 var CreateFile;\r
2984 (function (CreateFile) {\r
2985     function create(uri, options) {\r
2986         var result = {\r
2987             kind: 'create',\r
2988             uri: uri\r
2989         };\r
2990         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
2991             result.options = options;\r
2992         }\r
2993         return result;\r
2994     }\r
2995     CreateFile.create = create;\r
2996     function is(value) {\r
2997         var candidate = value;\r
2998         return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&\r
2999             (candidate.options === void 0 ||\r
3000                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
3001     }\r
3002     CreateFile.is = is;\r
3003 })(CreateFile || (CreateFile = {}));\r
3004 var RenameFile;\r
3005 (function (RenameFile) {\r
3006     function create(oldUri, newUri, options) {\r
3007         var result = {\r
3008             kind: 'rename',\r
3009             oldUri: oldUri,\r
3010             newUri: newUri\r
3011         };\r
3012         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {\r
3013             result.options = options;\r
3014         }\r
3015         return result;\r
3016     }\r
3017     RenameFile.create = create;\r
3018     function is(value) {\r
3019         var candidate = value;\r
3020         return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&\r
3021             (candidate.options === void 0 ||\r
3022                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));\r
3023     }\r
3024     RenameFile.is = is;\r
3025 })(RenameFile || (RenameFile = {}));\r
3026 var DeleteFile;\r
3027 (function (DeleteFile) {\r
3028     function create(uri, options) {\r
3029         var result = {\r
3030             kind: 'delete',\r
3031             uri: uri\r
3032         };\r
3033         if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {\r
3034             result.options = options;\r
3035         }\r
3036         return result;\r
3037     }\r
3038     DeleteFile.create = create;\r
3039     function is(value) {\r
3040         var candidate = value;\r
3041         return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&\r
3042             (candidate.options === void 0 ||\r
3043                 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));\r
3044     }\r
3045     DeleteFile.is = is;\r
3046 })(DeleteFile || (DeleteFile = {}));\r
3047 var WorkspaceEdit;\r
3048 (function (WorkspaceEdit) {\r
3049     function is(value) {\r
3050         var candidate = value;\r
3051         return candidate &&\r
3052             (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&\r
3053             (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {\r
3054                 if (Is.string(change.kind)) {\r
3055                     return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);\r
3056                 }\r
3057                 else {\r
3058                     return TextDocumentEdit.is(change);\r
3059                 }\r
3060             }));\r
3061     }\r
3062     WorkspaceEdit.is = is;\r
3063 })(WorkspaceEdit || (WorkspaceEdit = {}));\r
3064 var TextEditChangeImpl = /** @class */ (function () {\r
3065     function TextEditChangeImpl(edits) {\r
3066         this.edits = edits;\r
3067     }\r
3068     TextEditChangeImpl.prototype.insert = function (position, newText) {\r
3069         this.edits.push(TextEdit.insert(position, newText));\r
3070     };\r
3071     TextEditChangeImpl.prototype.replace = function (range, newText) {\r
3072         this.edits.push(TextEdit.replace(range, newText));\r
3073     };\r
3074     TextEditChangeImpl.prototype.delete = function (range) {\r
3075         this.edits.push(TextEdit.del(range));\r
3076     };\r
3077     TextEditChangeImpl.prototype.add = function (edit) {\r
3078         this.edits.push(edit);\r
3079     };\r
3080     TextEditChangeImpl.prototype.all = function () {\r
3081         return this.edits;\r
3082     };\r
3083     TextEditChangeImpl.prototype.clear = function () {\r
3084         this.edits.splice(0, this.edits.length);\r
3085     };\r
3086     return TextEditChangeImpl;\r
3087 }());\r
3088 /**\r
3089  * A workspace change helps constructing changes to a workspace.\r
3090  */\r
3091 var WorkspaceChange = /** @class */ (function () {\r
3092     function WorkspaceChange(workspaceEdit) {\r
3093         var _this = this;\r
3094         this._textEditChanges = Object.create(null);\r
3095         if (workspaceEdit) {\r
3096             this._workspaceEdit = workspaceEdit;\r
3097             if (workspaceEdit.documentChanges) {\r
3098                 workspaceEdit.documentChanges.forEach(function (change) {\r
3099                     if (TextDocumentEdit.is(change)) {\r
3100                         var textEditChange = new TextEditChangeImpl(change.edits);\r
3101                         _this._textEditChanges[change.textDocument.uri] = textEditChange;\r
3102                     }\r
3103                 });\r
3104             }\r
3105             else if (workspaceEdit.changes) {\r
3106                 Object.keys(workspaceEdit.changes).forEach(function (key) {\r
3107                     var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);\r
3108                     _this._textEditChanges[key] = textEditChange;\r
3109                 });\r
3110             }\r
3111         }\r
3112     }\r
3113     Object.defineProperty(WorkspaceChange.prototype, "edit", {\r
3114         /**\r
3115          * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal\r
3116          * use to be returned from a workspace edit operation like rename.\r
3117          */\r
3118         get: function () {\r
3119             return this._workspaceEdit;\r
3120         },\r
3121         enumerable: true,\r
3122         configurable: true\r
3123     });\r
3124     WorkspaceChange.prototype.getTextEditChange = function (key) {\r
3125         if (VersionedTextDocumentIdentifier.is(key)) {\r
3126             if (!this._workspaceEdit) {\r
3127                 this._workspaceEdit = {\r
3128                     documentChanges: []\r
3129                 };\r
3130             }\r
3131             if (!this._workspaceEdit.documentChanges) {\r
3132                 throw new Error('Workspace edit is not configured for document changes.');\r
3133             }\r
3134             var textDocument = key;\r
3135             var result = this._textEditChanges[textDocument.uri];\r
3136             if (!result) {\r
3137                 var edits = [];\r
3138                 var textDocumentEdit = {\r
3139                     textDocument: textDocument,\r
3140                     edits: edits\r
3141                 };\r
3142                 this._workspaceEdit.documentChanges.push(textDocumentEdit);\r
3143                 result = new TextEditChangeImpl(edits);\r
3144                 this._textEditChanges[textDocument.uri] = result;\r
3145             }\r
3146             return result;\r
3147         }\r
3148         else {\r
3149             if (!this._workspaceEdit) {\r
3150                 this._workspaceEdit = {\r
3151                     changes: Object.create(null)\r
3152                 };\r
3153             }\r
3154             if (!this._workspaceEdit.changes) {\r
3155                 throw new Error('Workspace edit is not configured for normal text edit changes.');\r
3156             }\r
3157             var result = this._textEditChanges[key];\r
3158             if (!result) {\r
3159                 var edits = [];\r
3160                 this._workspaceEdit.changes[key] = edits;\r
3161                 result = new TextEditChangeImpl(edits);\r
3162                 this._textEditChanges[key] = result;\r
3163             }\r
3164             return result;\r
3165         }\r
3166     };\r
3167     WorkspaceChange.prototype.createFile = function (uri, options) {\r
3168         this.checkDocumentChanges();\r
3169         this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));\r
3170     };\r
3171     WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {\r
3172         this.checkDocumentChanges();\r
3173         this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));\r
3174     };\r
3175     WorkspaceChange.prototype.deleteFile = function (uri, options) {\r
3176         this.checkDocumentChanges();\r
3177         this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));\r
3178     };\r
3179     WorkspaceChange.prototype.checkDocumentChanges = function () {\r
3180         if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {\r
3181             throw new Error('Workspace edit is not configured for document changes.');\r
3182         }\r
3183     };\r
3184     return WorkspaceChange;\r
3185 }());\r
3186 \r
3187 /**\r
3188  * The TextDocumentIdentifier namespace provides helper functions to work with\r
3189  * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.\r
3190  */\r
3191 var TextDocumentIdentifier;\r
3192 (function (TextDocumentIdentifier) {\r
3193     /**\r
3194      * Creates a new TextDocumentIdentifier literal.\r
3195      * @param uri The document's uri.\r
3196      */\r
3197     function create(uri) {\r
3198         return { uri: uri };\r
3199     }\r
3200     TextDocumentIdentifier.create = create;\r
3201     /**\r
3202      * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.\r
3203      */\r
3204     function is(value) {\r
3205         var candidate = value;\r
3206         return Is.defined(candidate) && Is.string(candidate.uri);\r
3207     }\r
3208     TextDocumentIdentifier.is = is;\r
3209 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));\r
3210 /**\r
3211  * The VersionedTextDocumentIdentifier namespace provides helper functions to work with\r
3212  * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.\r
3213  */\r
3214 var VersionedTextDocumentIdentifier;\r
3215 (function (VersionedTextDocumentIdentifier) {\r
3216     /**\r
3217      * Creates a new VersionedTextDocumentIdentifier literal.\r
3218      * @param uri The document's uri.\r
3219      * @param uri The document's text.\r
3220      */\r
3221     function create(uri, version) {\r
3222         return { uri: uri, version: version };\r
3223     }\r
3224     VersionedTextDocumentIdentifier.create = create;\r
3225     /**\r
3226      * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.\r
3227      */\r
3228     function is(value) {\r
3229         var candidate = value;\r
3230         return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));\r
3231     }\r
3232     VersionedTextDocumentIdentifier.is = is;\r
3233 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));\r
3234 /**\r
3235  * The TextDocumentItem namespace provides helper functions to work with\r
3236  * [TextDocumentItem](#TextDocumentItem) literals.\r
3237  */\r
3238 var TextDocumentItem;\r
3239 (function (TextDocumentItem) {\r
3240     /**\r
3241      * Creates a new TextDocumentItem literal.\r
3242      * @param uri The document's uri.\r
3243      * @param languageId The document's language identifier.\r
3244      * @param version The document's version number.\r
3245      * @param text The document's text.\r
3246      */\r
3247     function create(uri, languageId, version, text) {\r
3248         return { uri: uri, languageId: languageId, version: version, text: text };\r
3249     }\r
3250     TextDocumentItem.create = create;\r
3251     /**\r
3252      * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.\r
3253      */\r
3254     function is(value) {\r
3255         var candidate = value;\r
3256         return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);\r
3257     }\r
3258     TextDocumentItem.is = is;\r
3259 })(TextDocumentItem || (TextDocumentItem = {}));\r
3260 /**\r
3261  * Describes the content type that a client supports in various\r
3262  * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.\r
3263  *\r
3264  * Please note that `MarkupKinds` must not start with a `$`. This kinds\r
3265  * are reserved for internal usage.\r
3266  */\r
3267 var MarkupKind;\r
3268 (function (MarkupKind) {\r
3269     /**\r
3270      * Plain text is supported as a content format\r
3271      */\r
3272     MarkupKind.PlainText = 'plaintext';\r
3273     /**\r
3274      * Markdown is supported as a content format\r
3275      */\r
3276     MarkupKind.Markdown = 'markdown';\r
3277 })(MarkupKind || (MarkupKind = {}));\r
3278 (function (MarkupKind) {\r
3279     /**\r
3280      * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.\r
3281      */\r
3282     function is(value) {\r
3283         var candidate = value;\r
3284         return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;\r
3285     }\r
3286     MarkupKind.is = is;\r
3287 })(MarkupKind || (MarkupKind = {}));\r
3288 var MarkupContent;\r
3289 (function (MarkupContent) {\r
3290     /**\r
3291      * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.\r
3292      */\r
3293     function is(value) {\r
3294         var candidate = value;\r
3295         return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);\r
3296     }\r
3297     MarkupContent.is = is;\r
3298 })(MarkupContent || (MarkupContent = {}));\r
3299 /**\r
3300  * The kind of a completion entry.\r
3301  */\r
3302 var CompletionItemKind;\r
3303 (function (CompletionItemKind) {\r
3304     CompletionItemKind.Text = 1;\r
3305     CompletionItemKind.Method = 2;\r
3306     CompletionItemKind.Function = 3;\r
3307     CompletionItemKind.Constructor = 4;\r
3308     CompletionItemKind.Field = 5;\r
3309     CompletionItemKind.Variable = 6;\r
3310     CompletionItemKind.Class = 7;\r
3311     CompletionItemKind.Interface = 8;\r
3312     CompletionItemKind.Module = 9;\r
3313     CompletionItemKind.Property = 10;\r
3314     CompletionItemKind.Unit = 11;\r
3315     CompletionItemKind.Value = 12;\r
3316     CompletionItemKind.Enum = 13;\r
3317     CompletionItemKind.Keyword = 14;\r
3318     CompletionItemKind.Snippet = 15;\r
3319     CompletionItemKind.Color = 16;\r
3320     CompletionItemKind.File = 17;\r
3321     CompletionItemKind.Reference = 18;\r
3322     CompletionItemKind.Folder = 19;\r
3323     CompletionItemKind.EnumMember = 20;\r
3324     CompletionItemKind.Constant = 21;\r
3325     CompletionItemKind.Struct = 22;\r
3326     CompletionItemKind.Event = 23;\r
3327     CompletionItemKind.Operator = 24;\r
3328     CompletionItemKind.TypeParameter = 25;\r
3329 })(CompletionItemKind || (CompletionItemKind = {}));\r
3330 /**\r
3331  * Defines whether the insert text in a completion item should be interpreted as\r
3332  * plain text or a snippet.\r
3333  */\r
3334 var InsertTextFormat;\r
3335 (function (InsertTextFormat) {\r
3336     /**\r
3337      * The primary text to be inserted is treated as a plain string.\r
3338      */\r
3339     InsertTextFormat.PlainText = 1;\r
3340     /**\r
3341      * The primary text to be inserted is treated as a snippet.\r
3342      *\r
3343      * A snippet can define tab stops and placeholders with `$1`, `$2`\r
3344      * and `${3:foo}`. `$0` defines the final tab stop, it defaults to\r
3345      * the end of the snippet. Placeholders with equal identifiers are linked,\r
3346      * that is typing in one will update others too.\r
3347      *\r
3348      * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md\r
3349      */\r
3350     InsertTextFormat.Snippet = 2;\r
3351 })(InsertTextFormat || (InsertTextFormat = {}));\r
3352 /**\r
3353  * The CompletionItem namespace provides functions to deal with\r
3354  * completion items.\r
3355  */\r
3356 var CompletionItem;\r
3357 (function (CompletionItem) {\r
3358     /**\r
3359      * Create a completion item and seed it with a label.\r
3360      * @param label The completion item's label\r
3361      */\r
3362     function create(label) {\r
3363         return { label: label };\r
3364     }\r
3365     CompletionItem.create = create;\r
3366 })(CompletionItem || (CompletionItem = {}));\r
3367 /**\r
3368  * The CompletionList namespace provides functions to deal with\r
3369  * completion lists.\r
3370  */\r
3371 var CompletionList;\r
3372 (function (CompletionList) {\r
3373     /**\r
3374      * Creates a new completion list.\r
3375      *\r
3376      * @param items The completion items.\r
3377      * @param isIncomplete The list is not complete.\r
3378      */\r
3379     function create(items, isIncomplete) {\r
3380         return { items: items ? items : [], isIncomplete: !!isIncomplete };\r
3381     }\r
3382     CompletionList.create = create;\r
3383 })(CompletionList || (CompletionList = {}));\r
3384 var MarkedString;\r
3385 (function (MarkedString) {\r
3386     /**\r
3387      * Creates a marked string from plain text.\r
3388      *\r
3389      * @param plainText The plain text.\r
3390      */\r
3391     function fromPlainText(plainText) {\r
3392         return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash\r
3393     }\r
3394     MarkedString.fromPlainText = fromPlainText;\r
3395     /**\r
3396      * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.\r
3397      */\r
3398     function is(value) {\r
3399         var candidate = value;\r
3400         return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));\r
3401     }\r
3402     MarkedString.is = is;\r
3403 })(MarkedString || (MarkedString = {}));\r
3404 var Hover;\r
3405 (function (Hover) {\r
3406     /**\r
3407      * Checks whether the given value conforms to the [Hover](#Hover) interface.\r
3408      */\r
3409     function is(value) {\r
3410         var candidate = value;\r
3411         return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||\r
3412             MarkedString.is(candidate.contents) ||\r
3413             Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));\r
3414     }\r
3415     Hover.is = is;\r
3416 })(Hover || (Hover = {}));\r
3417 /**\r
3418  * The ParameterInformation namespace provides helper functions to work with\r
3419  * [ParameterInformation](#ParameterInformation) literals.\r
3420  */\r
3421 var ParameterInformation;\r
3422 (function (ParameterInformation) {\r
3423     /**\r
3424      * Creates a new parameter information literal.\r
3425      *\r
3426      * @param label A label string.\r
3427      * @param documentation A doc string.\r
3428      */\r
3429     function create(label, documentation) {\r
3430         return documentation ? { label: label, documentation: documentation } : { label: label };\r
3431     }\r
3432     ParameterInformation.create = create;\r
3433     ;\r
3434 })(ParameterInformation || (ParameterInformation = {}));\r
3435 /**\r
3436  * The SignatureInformation namespace provides helper functions to work with\r
3437  * [SignatureInformation](#SignatureInformation) literals.\r
3438  */\r
3439 var SignatureInformation;\r
3440 (function (SignatureInformation) {\r
3441     function create(label, documentation) {\r
3442         var parameters = [];\r
3443         for (var _i = 2; _i < arguments.length; _i++) {\r
3444             parameters[_i - 2] = arguments[_i];\r
3445         }\r
3446         var result = { label: label };\r
3447         if (Is.defined(documentation)) {\r
3448             result.documentation = documentation;\r
3449         }\r
3450         if (Is.defined(parameters)) {\r
3451             result.parameters = parameters;\r
3452         }\r
3453         else {\r
3454             result.parameters = [];\r
3455         }\r
3456         return result;\r
3457     }\r
3458     SignatureInformation.create = create;\r
3459 })(SignatureInformation || (SignatureInformation = {}));\r
3460 /**\r
3461  * A document highlight kind.\r
3462  */\r
3463 var DocumentHighlightKind;\r
3464 (function (DocumentHighlightKind) {\r
3465     /**\r
3466      * A textual occurrence.\r
3467      */\r
3468     DocumentHighlightKind.Text = 1;\r
3469     /**\r
3470      * Read-access of a symbol, like reading a variable.\r
3471      */\r
3472     DocumentHighlightKind.Read = 2;\r
3473     /**\r
3474      * Write-access of a symbol, like writing to a variable.\r
3475      */\r
3476     DocumentHighlightKind.Write = 3;\r
3477 })(DocumentHighlightKind || (DocumentHighlightKind = {}));\r
3478 /**\r
3479  * DocumentHighlight namespace to provide helper functions to work with\r
3480  * [DocumentHighlight](#DocumentHighlight) literals.\r
3481  */\r
3482 var DocumentHighlight;\r
3483 (function (DocumentHighlight) {\r
3484     /**\r
3485      * Create a DocumentHighlight object.\r
3486      * @param range The range the highlight applies to.\r
3487      */\r
3488     function create(range, kind) {\r
3489         var result = { range: range };\r
3490         if (Is.number(kind)) {\r
3491             result.kind = kind;\r
3492         }\r
3493         return result;\r
3494     }\r
3495     DocumentHighlight.create = create;\r
3496 })(DocumentHighlight || (DocumentHighlight = {}));\r
3497 /**\r
3498  * A symbol kind.\r
3499  */\r
3500 var SymbolKind;\r
3501 (function (SymbolKind) {\r
3502     SymbolKind.File = 1;\r
3503     SymbolKind.Module = 2;\r
3504     SymbolKind.Namespace = 3;\r
3505     SymbolKind.Package = 4;\r
3506     SymbolKind.Class = 5;\r
3507     SymbolKind.Method = 6;\r
3508     SymbolKind.Property = 7;\r
3509     SymbolKind.Field = 8;\r
3510     SymbolKind.Constructor = 9;\r
3511     SymbolKind.Enum = 10;\r
3512     SymbolKind.Interface = 11;\r
3513     SymbolKind.Function = 12;\r
3514     SymbolKind.Variable = 13;\r
3515     SymbolKind.Constant = 14;\r
3516     SymbolKind.String = 15;\r
3517     SymbolKind.Number = 16;\r
3518     SymbolKind.Boolean = 17;\r
3519     SymbolKind.Array = 18;\r
3520     SymbolKind.Object = 19;\r
3521     SymbolKind.Key = 20;\r
3522     SymbolKind.Null = 21;\r
3523     SymbolKind.EnumMember = 22;\r
3524     SymbolKind.Struct = 23;\r
3525     SymbolKind.Event = 24;\r
3526     SymbolKind.Operator = 25;\r
3527     SymbolKind.TypeParameter = 26;\r
3528 })(SymbolKind || (SymbolKind = {}));\r
3529 var SymbolInformation;\r
3530 (function (SymbolInformation) {\r
3531     /**\r
3532      * Creates a new symbol information literal.\r
3533      *\r
3534      * @param name The name of the symbol.\r
3535      * @param kind The kind of the symbol.\r
3536      * @param range The range of the location of the symbol.\r
3537      * @param uri The resource of the location of symbol, defaults to the current document.\r
3538      * @param containerName The name of the symbol containing the symbol.\r
3539      */\r
3540     function create(name, kind, range, uri, containerName) {\r
3541         var result = {\r
3542             name: name,\r
3543             kind: kind,\r
3544             location: { uri: uri, range: range }\r
3545         };\r
3546         if (containerName) {\r
3547             result.containerName = containerName;\r
3548         }\r
3549         return result;\r
3550     }\r
3551     SymbolInformation.create = create;\r
3552 })(SymbolInformation || (SymbolInformation = {}));\r
3553 /**\r
3554  * Represents programming constructs like variables, classes, interfaces etc.\r
3555  * that appear in a document. Document symbols can be hierarchical and they\r
3556  * have two ranges: one that encloses its definition and one that points to\r
3557  * its most interesting range, e.g. the range of an identifier.\r
3558  */\r
3559 var DocumentSymbol = /** @class */ (function () {\r
3560     function DocumentSymbol() {\r
3561     }\r
3562     return DocumentSymbol;\r
3563 }());\r
3564 \r
3565 (function (DocumentSymbol) {\r
3566     /**\r
3567      * Creates a new symbol information literal.\r
3568      *\r
3569      * @param name The name of the symbol.\r
3570      * @param detail The detail of the symbol.\r
3571      * @param kind The kind of the symbol.\r
3572      * @param range The range of the symbol.\r
3573      * @param selectionRange The selectionRange of the symbol.\r
3574      * @param children Children of the symbol.\r
3575      */\r
3576     function create(name, detail, kind, range, selectionRange, children) {\r
3577         var result = {\r
3578             name: name,\r
3579             detail: detail,\r
3580             kind: kind,\r
3581             range: range,\r
3582             selectionRange: selectionRange\r
3583         };\r
3584         if (children !== void 0) {\r
3585             result.children = children;\r
3586         }\r
3587         return result;\r
3588     }\r
3589     DocumentSymbol.create = create;\r
3590     /**\r
3591      * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.\r
3592      */\r
3593     function is(value) {\r
3594         var candidate = value;\r
3595         return candidate &&\r
3596             Is.string(candidate.name) && Is.number(candidate.kind) &&\r
3597             Range.is(candidate.range) && Range.is(candidate.selectionRange) &&\r
3598             (candidate.detail === void 0 || Is.string(candidate.detail)) &&\r
3599             (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&\r
3600             (candidate.children === void 0 || Array.isArray(candidate.children));\r
3601     }\r
3602     DocumentSymbol.is = is;\r
3603 })(DocumentSymbol || (DocumentSymbol = {}));\r
3604 /**\r
3605  * A set of predefined code action kinds\r
3606  */\r
3607 var CodeActionKind;\r
3608 (function (CodeActionKind) {\r
3609     /**\r
3610      * Base kind for quickfix actions: 'quickfix'\r
3611      */\r
3612     CodeActionKind.QuickFix = 'quickfix';\r
3613     /**\r
3614      * Base kind for refactoring actions: 'refactor'\r
3615      */\r
3616     CodeActionKind.Refactor = 'refactor';\r
3617     /**\r
3618      * Base kind for refactoring extraction actions: 'refactor.extract'\r
3619      *\r
3620      * Example extract actions:\r
3621      *\r
3622      * - Extract method\r
3623      * - Extract function\r
3624      * - Extract variable\r
3625      * - Extract interface from class\r
3626      * - ...\r
3627      */\r
3628     CodeActionKind.RefactorExtract = 'refactor.extract';\r
3629     /**\r
3630      * Base kind for refactoring inline actions: 'refactor.inline'\r
3631      *\r
3632      * Example inline actions:\r
3633      *\r
3634      * - Inline function\r
3635      * - Inline variable\r
3636      * - Inline constant\r
3637      * - ...\r
3638      */\r
3639     CodeActionKind.RefactorInline = 'refactor.inline';\r
3640     /**\r
3641      * Base kind for refactoring rewrite actions: 'refactor.rewrite'\r
3642      *\r
3643      * Example rewrite actions:\r
3644      *\r
3645      * - Convert JavaScript function to class\r
3646      * - Add or remove parameter\r
3647      * - Encapsulate field\r
3648      * - Make method static\r
3649      * - Move method to base class\r
3650      * - ...\r
3651      */\r
3652     CodeActionKind.RefactorRewrite = 'refactor.rewrite';\r
3653     /**\r
3654      * Base kind for source actions: `source`\r
3655      *\r
3656      * Source code actions apply to the entire file.\r
3657      */\r
3658     CodeActionKind.Source = 'source';\r
3659     /**\r
3660      * Base kind for an organize imports source action: `source.organizeImports`\r
3661      */\r
3662     CodeActionKind.SourceOrganizeImports = 'source.organizeImports';\r
3663 })(CodeActionKind || (CodeActionKind = {}));\r
3664 /**\r
3665  * The CodeActionContext namespace provides helper functions to work with\r
3666  * [CodeActionContext](#CodeActionContext) literals.\r
3667  */\r
3668 var CodeActionContext;\r
3669 (function (CodeActionContext) {\r
3670     /**\r
3671      * Creates a new CodeActionContext literal.\r
3672      */\r
3673     function create(diagnostics, only) {\r
3674         var result = { diagnostics: diagnostics };\r
3675         if (only !== void 0 && only !== null) {\r
3676             result.only = only;\r
3677         }\r
3678         return result;\r
3679     }\r
3680     CodeActionContext.create = create;\r
3681     /**\r
3682      * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.\r
3683      */\r
3684     function is(value) {\r
3685         var candidate = value;\r
3686         return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));\r
3687     }\r
3688     CodeActionContext.is = is;\r
3689 })(CodeActionContext || (CodeActionContext = {}));\r
3690 var CodeAction;\r
3691 (function (CodeAction) {\r
3692     function create(title, commandOrEdit, kind) {\r
3693         var result = { title: title };\r
3694         if (Command.is(commandOrEdit)) {\r
3695             result.command = commandOrEdit;\r
3696         }\r
3697         else {\r
3698             result.edit = commandOrEdit;\r
3699         }\r
3700         if (kind !== void null) {\r
3701             result.kind = kind;\r
3702         }\r
3703         return result;\r
3704     }\r
3705     CodeAction.create = create;\r
3706     function is(value) {\r
3707         var candidate = value;\r
3708         return candidate && Is.string(candidate.title) &&\r
3709             (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&\r
3710             (candidate.kind === void 0 || Is.string(candidate.kind)) &&\r
3711             (candidate.edit !== void 0 || candidate.command !== void 0) &&\r
3712             (candidate.command === void 0 || Command.is(candidate.command)) &&\r
3713             (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));\r
3714     }\r
3715     CodeAction.is = is;\r
3716 })(CodeAction || (CodeAction = {}));\r
3717 /**\r
3718  * The CodeLens namespace provides helper functions to work with\r
3719  * [CodeLens](#CodeLens) literals.\r
3720  */\r
3721 var CodeLens;\r
3722 (function (CodeLens) {\r
3723     /**\r
3724      * Creates a new CodeLens literal.\r
3725      */\r
3726     function create(range, data) {\r
3727         var result = { range: range };\r
3728         if (Is.defined(data))\r
3729             result.data = data;\r
3730         return result;\r
3731     }\r
3732     CodeLens.create = create;\r
3733     /**\r
3734      * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.\r
3735      */\r
3736     function is(value) {\r
3737         var candidate = value;\r
3738         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));\r
3739     }\r
3740     CodeLens.is = is;\r
3741 })(CodeLens || (CodeLens = {}));\r
3742 /**\r
3743  * The FormattingOptions namespace provides helper functions to work with\r
3744  * [FormattingOptions](#FormattingOptions) literals.\r
3745  */\r
3746 var FormattingOptions;\r
3747 (function (FormattingOptions) {\r
3748     /**\r
3749      * Creates a new FormattingOptions literal.\r
3750      */\r
3751     function create(tabSize, insertSpaces) {\r
3752         return { tabSize: tabSize, insertSpaces: insertSpaces };\r
3753     }\r
3754     FormattingOptions.create = create;\r
3755     /**\r
3756      * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.\r
3757      */\r
3758     function is(value) {\r
3759         var candidate = value;\r
3760         return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);\r
3761     }\r
3762     FormattingOptions.is = is;\r
3763 })(FormattingOptions || (FormattingOptions = {}));\r
3764 /**\r
3765  * A document link is a range in a text document that links to an internal or external resource, like another\r
3766  * text document or a web site.\r
3767  */\r
3768 var DocumentLink = /** @class */ (function () {\r
3769     function DocumentLink() {\r
3770     }\r
3771     return DocumentLink;\r
3772 }());\r
3773 \r
3774 /**\r
3775  * The DocumentLink namespace provides helper functions to work with\r
3776  * [DocumentLink](#DocumentLink) literals.\r
3777  */\r
3778 (function (DocumentLink) {\r
3779     /**\r
3780      * Creates a new DocumentLink literal.\r
3781      */\r
3782     function create(range, target, data) {\r
3783         return { range: range, target: target, data: data };\r
3784     }\r
3785     DocumentLink.create = create;\r
3786     /**\r
3787      * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.\r
3788      */\r
3789     function is(value) {\r
3790         var candidate = value;\r
3791         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));\r
3792     }\r
3793     DocumentLink.is = is;\r
3794 })(DocumentLink || (DocumentLink = {}));\r
3795 var EOL = ['\n', '\r\n', '\r'];\r
3796 var TextDocument;\r
3797 (function (TextDocument) {\r
3798     /**\r
3799      * Creates a new ITextDocument literal from the given uri and content.\r
3800      * @param uri The document's uri.\r
3801      * @param languageId  The document's language Id.\r
3802      * @param content The document's content.\r
3803      */\r
3804     function create(uri, languageId, version, content) {\r
3805         return new FullTextDocument(uri, languageId, version, content);\r
3806     }\r
3807     TextDocument.create = create;\r
3808     /**\r
3809      * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.\r
3810      */\r
3811     function is(value) {\r
3812         var candidate = value;\r
3813         return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)\r
3814             && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;\r
3815     }\r
3816     TextDocument.is = is;\r
3817     function applyEdits(document, edits) {\r
3818         var text = document.getText();\r
3819         var sortedEdits = mergeSort(edits, function (a, b) {\r
3820             var diff = a.range.start.line - b.range.start.line;\r
3821             if (diff === 0) {\r
3822                 return a.range.start.character - b.range.start.character;\r
3823             }\r
3824             return diff;\r
3825         });\r
3826         var lastModifiedOffset = text.length;\r
3827         for (var i = sortedEdits.length - 1; i >= 0; i--) {\r
3828             var e = sortedEdits[i];\r
3829             var startOffset = document.offsetAt(e.range.start);\r
3830             var endOffset = document.offsetAt(e.range.end);\r
3831             if (endOffset <= lastModifiedOffset) {\r
3832                 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);\r
3833             }\r
3834             else {\r
3835                 throw new Error('Overlapping edit');\r
3836             }\r
3837             lastModifiedOffset = startOffset;\r
3838         }\r
3839         return text;\r
3840     }\r
3841     TextDocument.applyEdits = applyEdits;\r
3842     function mergeSort(data, compare) {\r
3843         if (data.length <= 1) {\r
3844             // sorted\r
3845             return data;\r
3846         }\r
3847         var p = (data.length / 2) | 0;\r
3848         var left = data.slice(0, p);\r
3849         var right = data.slice(p);\r
3850         mergeSort(left, compare);\r
3851         mergeSort(right, compare);\r
3852         var leftIdx = 0;\r
3853         var rightIdx = 0;\r
3854         var i = 0;\r
3855         while (leftIdx < left.length && rightIdx < right.length) {\r
3856             var ret = compare(left[leftIdx], right[rightIdx]);\r
3857             if (ret <= 0) {\r
3858                 // smaller_equal -> take left to preserve order\r
3859                 data[i++] = left[leftIdx++];\r
3860             }\r
3861             else {\r
3862                 // greater -> take right\r
3863                 data[i++] = right[rightIdx++];\r
3864             }\r
3865         }\r
3866         while (leftIdx < left.length) {\r
3867             data[i++] = left[leftIdx++];\r
3868         }\r
3869         while (rightIdx < right.length) {\r
3870             data[i++] = right[rightIdx++];\r
3871         }\r
3872         return data;\r
3873     }\r
3874 })(TextDocument || (TextDocument = {}));\r
3875 /**\r
3876  * Represents reasons why a text document is saved.\r
3877  */\r
3878 var TextDocumentSaveReason;\r
3879 (function (TextDocumentSaveReason) {\r
3880     /**\r
3881      * Manually triggered, e.g. by the user pressing save, by starting debugging,\r
3882      * or by an API call.\r
3883      */\r
3884     TextDocumentSaveReason.Manual = 1;\r
3885     /**\r
3886      * Automatic after a delay.\r
3887      */\r
3888     TextDocumentSaveReason.AfterDelay = 2;\r
3889     /**\r
3890      * When the editor lost focus.\r
3891      */\r
3892     TextDocumentSaveReason.FocusOut = 3;\r
3893 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));\r
3894 var FullTextDocument = /** @class */ (function () {\r
3895     function FullTextDocument(uri, languageId, version, content) {\r
3896         this._uri = uri;\r
3897         this._languageId = languageId;\r
3898         this._version = version;\r
3899         this._content = content;\r
3900         this._lineOffsets = null;\r
3901     }\r
3902     Object.defineProperty(FullTextDocument.prototype, "uri", {\r
3903         get: function () {\r
3904             return this._uri;\r
3905         },\r
3906         enumerable: true,\r
3907         configurable: true\r
3908     });\r
3909     Object.defineProperty(FullTextDocument.prototype, "languageId", {\r
3910         get: function () {\r
3911             return this._languageId;\r
3912         },\r
3913         enumerable: true,\r
3914         configurable: true\r
3915     });\r
3916     Object.defineProperty(FullTextDocument.prototype, "version", {\r
3917         get: function () {\r
3918             return this._version;\r
3919         },\r
3920         enumerable: true,\r
3921         configurable: true\r
3922     });\r
3923     FullTextDocument.prototype.getText = function (range) {\r
3924         if (range) {\r
3925             var start = this.offsetAt(range.start);\r
3926             var end = this.offsetAt(range.end);\r
3927             return this._content.substring(start, end);\r
3928         }\r
3929         return this._content;\r
3930     };\r
3931     FullTextDocument.prototype.update = function (event, version) {\r
3932         this._content = event.text;\r
3933         this._version = version;\r
3934         this._lineOffsets = null;\r
3935     };\r
3936     FullTextDocument.prototype.getLineOffsets = function () {\r
3937         if (this._lineOffsets === null) {\r
3938             var lineOffsets = [];\r
3939             var text = this._content;\r
3940             var isLineStart = true;\r
3941             for (var i = 0; i < text.length; i++) {\r
3942                 if (isLineStart) {\r
3943                     lineOffsets.push(i);\r
3944                     isLineStart = false;\r
3945                 }\r
3946                 var ch = text.charAt(i);\r
3947                 isLineStart = (ch === '\r' || ch === '\n');\r
3948                 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {\r
3949                     i++;\r
3950                 }\r
3951             }\r
3952             if (isLineStart && text.length > 0) {\r
3953                 lineOffsets.push(text.length);\r
3954             }\r
3955             this._lineOffsets = lineOffsets;\r
3956         }\r
3957         return this._lineOffsets;\r
3958     };\r
3959     FullTextDocument.prototype.positionAt = function (offset) {\r
3960         offset = Math.max(Math.min(offset, this._content.length), 0);\r
3961         var lineOffsets = this.getLineOffsets();\r
3962         var low = 0, high = lineOffsets.length;\r
3963         if (high === 0) {\r
3964             return Position.create(0, offset);\r
3965         }\r
3966         while (low < high) {\r
3967             var mid = Math.floor((low + high) / 2);\r
3968             if (lineOffsets[mid] > offset) {\r
3969                 high = mid;\r
3970             }\r
3971             else {\r
3972                 low = mid + 1;\r
3973             }\r
3974         }\r
3975         // low is the least x for which the line offset is larger than the current offset\r
3976         // or array.length if no line offset is larger than the current offset\r
3977         var line = low - 1;\r
3978         return Position.create(line, offset - lineOffsets[line]);\r
3979     };\r
3980     FullTextDocument.prototype.offsetAt = function (position) {\r
3981         var lineOffsets = this.getLineOffsets();\r
3982         if (position.line >= lineOffsets.length) {\r
3983             return this._content.length;\r
3984         }\r
3985         else if (position.line < 0) {\r
3986             return 0;\r
3987         }\r
3988         var lineOffset = lineOffsets[position.line];\r
3989         var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;\r
3990         return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);\r
3991     };\r
3992     Object.defineProperty(FullTextDocument.prototype, "lineCount", {\r
3993         get: function () {\r
3994             return this.getLineOffsets().length;\r
3995         },\r
3996         enumerable: true,\r
3997         configurable: true\r
3998     });\r
3999     return FullTextDocument;\r
4000 }());\r
4001 var Is;\r
4002 (function (Is) {\r
4003     var toString = Object.prototype.toString;\r
4004     function defined(value) {\r
4005         return typeof value !== 'undefined';\r
4006     }\r
4007     Is.defined = defined;\r
4008     function undefined(value) {\r
4009         return typeof value === 'undefined';\r
4010     }\r
4011     Is.undefined = undefined;\r
4012     function boolean(value) {\r
4013         return value === true || value === false;\r
4014     }\r
4015     Is.boolean = boolean;\r
4016     function string(value) {\r
4017         return toString.call(value) === '[object String]';\r
4018     }\r
4019     Is.string = string;\r
4020     function number(value) {\r
4021         return toString.call(value) === '[object Number]';\r
4022     }\r
4023     Is.number = number;\r
4024     function func(value) {\r
4025         return toString.call(value) === '[object Function]';\r
4026     }\r
4027     Is.func = func;\r
4028     function objectLiteral(value) {\r
4029         // Strictly speaking class instances pass this check as well. Since the LSP\r
4030         // doesn't use classes we ignore this for now. If we do we need to add something\r
4031         // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`\r
4032         return value !== null && typeof value === 'object';\r
4033     }\r
4034     Is.objectLiteral = objectLiteral;\r
4035     function typedArray(value, check) {\r
4036         return Array.isArray(value) && value.every(check);\r
4037     }\r
4038     Is.typedArray = typedArray;\r
4039 })(Is || (Is = {}));\r
4040
4041
4042 /***/ }),
4043 /* 18 */
4044 /***/ (function(module, exports, __webpack_require__) {
4045
4046 "use strict";
4047 /* --------------------------------------------------------------------------------------------\r
4048  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4049  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4050  * ------------------------------------------------------------------------------------------ */\r
4051 \r
4052 Object.defineProperty(exports, "__esModule", { value: true });\r
4053 const Is = __webpack_require__(19);\r
4054 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4055 const protocol_implementation_1 = __webpack_require__(20);\r
4056 exports.ImplementationRequest = protocol_implementation_1.ImplementationRequest;\r
4057 const protocol_typeDefinition_1 = __webpack_require__(21);\r
4058 exports.TypeDefinitionRequest = protocol_typeDefinition_1.TypeDefinitionRequest;\r
4059 const protocol_workspaceFolders_1 = __webpack_require__(22);\r
4060 exports.WorkspaceFoldersRequest = protocol_workspaceFolders_1.WorkspaceFoldersRequest;\r
4061 exports.DidChangeWorkspaceFoldersNotification = protocol_workspaceFolders_1.DidChangeWorkspaceFoldersNotification;\r
4062 const protocol_configuration_1 = __webpack_require__(23);\r
4063 exports.ConfigurationRequest = protocol_configuration_1.ConfigurationRequest;\r
4064 const protocol_colorProvider_1 = __webpack_require__(24);\r
4065 exports.DocumentColorRequest = protocol_colorProvider_1.DocumentColorRequest;\r
4066 exports.ColorPresentationRequest = protocol_colorProvider_1.ColorPresentationRequest;\r
4067 const protocol_foldingRange_1 = __webpack_require__(25);\r
4068 exports.FoldingRangeRequest = protocol_foldingRange_1.FoldingRangeRequest;\r
4069 const protocol_declaration_1 = __webpack_require__(26);\r
4070 exports.DeclarationRequest = protocol_declaration_1.DeclarationRequest;\r
4071 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
4072 let __noDynamicImport;\r
4073 var DocumentFilter;\r
4074 (function (DocumentFilter) {\r
4075     function is(value) {\r
4076         let candidate = value;\r
4077         return Is.string(candidate.language) || Is.string(candidate.scheme) || Is.string(candidate.pattern);\r
4078     }\r
4079     DocumentFilter.is = is;\r
4080 })(DocumentFilter = exports.DocumentFilter || (exports.DocumentFilter = {}));\r
4081 /**\r
4082  * The `client/registerCapability` request is sent from the server to the client to register a new capability\r
4083  * handler on the client side.\r
4084  */\r
4085 var RegistrationRequest;\r
4086 (function (RegistrationRequest) {\r
4087     RegistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/registerCapability');\r
4088 })(RegistrationRequest = exports.RegistrationRequest || (exports.RegistrationRequest = {}));\r
4089 /**\r
4090  * The `client/unregisterCapability` request is sent from the server to the client to unregister a previously registered capability\r
4091  * handler on the client side.\r
4092  */\r
4093 var UnregistrationRequest;\r
4094 (function (UnregistrationRequest) {\r
4095     UnregistrationRequest.type = new vscode_jsonrpc_1.RequestType('client/unregisterCapability');\r
4096 })(UnregistrationRequest = exports.UnregistrationRequest || (exports.UnregistrationRequest = {}));\r
4097 var ResourceOperationKind;\r
4098 (function (ResourceOperationKind) {\r
4099     /**\r
4100      * Supports creating new files and folders.\r
4101      */\r
4102     ResourceOperationKind.Create = 'create';\r
4103     /**\r
4104      * Supports renaming existing files and folders.\r
4105      */\r
4106     ResourceOperationKind.Rename = 'rename';\r
4107     /**\r
4108      * Supports deleting existing files and folders.\r
4109      */\r
4110     ResourceOperationKind.Delete = 'delete';\r
4111 })(ResourceOperationKind = exports.ResourceOperationKind || (exports.ResourceOperationKind = {}));\r
4112 var FailureHandlingKind;\r
4113 (function (FailureHandlingKind) {\r
4114     /**\r
4115      * Applying the workspace change is simply aborted if one of the changes provided\r
4116      * fails. All operations executed before the failing operation stay executed.\r
4117      */\r
4118     FailureHandlingKind.Abort = 'abort';\r
4119     /**\r
4120      * All operations are executed transactional. That means they either all\r
4121      * succeed or no changes at all are applied to the workspace.\r
4122      */\r
4123     FailureHandlingKind.Transactional = 'transactional';\r
4124     /**\r
4125      * If the workspace edit contains only textual file changes they are executed transactional.\r
4126      * If resource changes (create, rename or delete file) are part of the change the failure\r
4127      * handling startegy is abort.\r
4128      */\r
4129     FailureHandlingKind.TextOnlyTransactional = 'textOnlyTransactional';\r
4130     /**\r
4131      * The client tries to undo the operations already executed. But there is no\r
4132      * guaruntee that this is succeeding.\r
4133      */\r
4134     FailureHandlingKind.Undo = 'undo';\r
4135 })(FailureHandlingKind = exports.FailureHandlingKind || (exports.FailureHandlingKind = {}));\r
4136 /**\r
4137  * Defines how the host (editor) should sync\r
4138  * document changes to the language server.\r
4139  */\r
4140 var TextDocumentSyncKind;\r
4141 (function (TextDocumentSyncKind) {\r
4142     /**\r
4143      * Documents should not be synced at all.\r
4144      */\r
4145     TextDocumentSyncKind.None = 0;\r
4146     /**\r
4147      * Documents are synced by always sending the full content\r
4148      * of the document.\r
4149      */\r
4150     TextDocumentSyncKind.Full = 1;\r
4151     /**\r
4152      * Documents are synced by sending the full content on open.\r
4153      * After that only incremental updates to the document are\r
4154      * send.\r
4155      */\r
4156     TextDocumentSyncKind.Incremental = 2;\r
4157 })(TextDocumentSyncKind = exports.TextDocumentSyncKind || (exports.TextDocumentSyncKind = {}));\r
4158 /**\r
4159  * The initialize request is sent from the client to the server.\r
4160  * It is sent once as the request after starting up the server.\r
4161  * The requests parameter is of type [InitializeParams](#InitializeParams)\r
4162  * the response if of type [InitializeResult](#InitializeResult) of a Thenable that\r
4163  * resolves to such.\r
4164  */\r
4165 var InitializeRequest;\r
4166 (function (InitializeRequest) {\r
4167     InitializeRequest.type = new vscode_jsonrpc_1.RequestType('initialize');\r
4168 })(InitializeRequest = exports.InitializeRequest || (exports.InitializeRequest = {}));\r
4169 /**\r
4170  * Known error codes for an `InitializeError`;\r
4171  */\r
4172 var InitializeError;\r
4173 (function (InitializeError) {\r
4174     /**\r
4175      * If the protocol version provided by the client can't be handled by the server.\r
4176      * @deprecated This initialize error got replaced by client capabilities. There is\r
4177      * no version handshake in version 3.0x\r
4178      */\r
4179     InitializeError.unknownProtocolVersion = 1;\r
4180 })(InitializeError = exports.InitializeError || (exports.InitializeError = {}));\r
4181 /**\r
4182  * The intialized notification is sent from the client to the\r
4183  * server after the client is fully initialized and the server\r
4184  * is allowed to send requests from the server to the client.\r
4185  */\r
4186 var InitializedNotification;\r
4187 (function (InitializedNotification) {\r
4188     InitializedNotification.type = new vscode_jsonrpc_1.NotificationType('initialized');\r
4189 })(InitializedNotification = exports.InitializedNotification || (exports.InitializedNotification = {}));\r
4190 //---- Shutdown Method ----\r
4191 /**\r
4192  * A shutdown request is sent from the client to the server.\r
4193  * It is sent once when the client decides to shutdown the\r
4194  * server. The only notification that is sent after a shutdown request\r
4195  * is the exit event.\r
4196  */\r
4197 var ShutdownRequest;\r
4198 (function (ShutdownRequest) {\r
4199     ShutdownRequest.type = new vscode_jsonrpc_1.RequestType0('shutdown');\r
4200 })(ShutdownRequest = exports.ShutdownRequest || (exports.ShutdownRequest = {}));\r
4201 //---- Exit Notification ----\r
4202 /**\r
4203  * The exit event is sent from the client to the server to\r
4204  * ask the server to exit its process.\r
4205  */\r
4206 var ExitNotification;\r
4207 (function (ExitNotification) {\r
4208     ExitNotification.type = new vscode_jsonrpc_1.NotificationType0('exit');\r
4209 })(ExitNotification = exports.ExitNotification || (exports.ExitNotification = {}));\r
4210 //---- Configuration notification ----\r
4211 /**\r
4212  * The configuration change notification is sent from the client to the server\r
4213  * when the client's configuration has changed. The notification contains\r
4214  * the changed configuration as defined by the language client.\r
4215  */\r
4216 var DidChangeConfigurationNotification;\r
4217 (function (DidChangeConfigurationNotification) {\r
4218     DidChangeConfigurationNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeConfiguration');\r
4219 })(DidChangeConfigurationNotification = exports.DidChangeConfigurationNotification || (exports.DidChangeConfigurationNotification = {}));\r
4220 //---- Message show and log notifications ----\r
4221 /**\r
4222  * The message type\r
4223  */\r
4224 var MessageType;\r
4225 (function (MessageType) {\r
4226     /**\r
4227      * An error message.\r
4228      */\r
4229     MessageType.Error = 1;\r
4230     /**\r
4231      * A warning message.\r
4232      */\r
4233     MessageType.Warning = 2;\r
4234     /**\r
4235      * An information message.\r
4236      */\r
4237     MessageType.Info = 3;\r
4238     /**\r
4239      * A log message.\r
4240      */\r
4241     MessageType.Log = 4;\r
4242 })(MessageType = exports.MessageType || (exports.MessageType = {}));\r
4243 /**\r
4244  * The show message notification is sent from a server to a client to ask\r
4245  * the client to display a particular message in the user interface.\r
4246  */\r
4247 var ShowMessageNotification;\r
4248 (function (ShowMessageNotification) {\r
4249     ShowMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/showMessage');\r
4250 })(ShowMessageNotification = exports.ShowMessageNotification || (exports.ShowMessageNotification = {}));\r
4251 /**\r
4252  * The show message request is sent from the server to the client to show a message\r
4253  * and a set of options actions to the user.\r
4254  */\r
4255 var ShowMessageRequest;\r
4256 (function (ShowMessageRequest) {\r
4257     ShowMessageRequest.type = new vscode_jsonrpc_1.RequestType('window/showMessageRequest');\r
4258 })(ShowMessageRequest = exports.ShowMessageRequest || (exports.ShowMessageRequest = {}));\r
4259 /**\r
4260  * The log message notification is sent from the server to the client to ask\r
4261  * the client to log a particular message.\r
4262  */\r
4263 var LogMessageNotification;\r
4264 (function (LogMessageNotification) {\r
4265     LogMessageNotification.type = new vscode_jsonrpc_1.NotificationType('window/logMessage');\r
4266 })(LogMessageNotification = exports.LogMessageNotification || (exports.LogMessageNotification = {}));\r
4267 //---- Telemetry notification\r
4268 /**\r
4269  * The telemetry event notification is sent from the server to the client to ask\r
4270  * the client to log telemetry data.\r
4271  */\r
4272 var TelemetryEventNotification;\r
4273 (function (TelemetryEventNotification) {\r
4274     TelemetryEventNotification.type = new vscode_jsonrpc_1.NotificationType('telemetry/event');\r
4275 })(TelemetryEventNotification = exports.TelemetryEventNotification || (exports.TelemetryEventNotification = {}));\r
4276 /**\r
4277  * The document open notification is sent from the client to the server to signal\r
4278  * newly opened text documents. The document's truth is now managed by the client\r
4279  * and the server must not try to read the document's truth using the document's\r
4280  * uri. Open in this sense means it is managed by the client. It doesn't necessarily\r
4281  * mean that its content is presented in an editor. An open notification must not\r
4282  * be sent more than once without a corresponding close notification send before.\r
4283  * This means open and close notification must be balanced and the max open count\r
4284  * is one.\r
4285  */\r
4286 var DidOpenTextDocumentNotification;\r
4287 (function (DidOpenTextDocumentNotification) {\r
4288     DidOpenTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didOpen');\r
4289 })(DidOpenTextDocumentNotification = exports.DidOpenTextDocumentNotification || (exports.DidOpenTextDocumentNotification = {}));\r
4290 /**\r
4291  * The document change notification is sent from the client to the server to signal\r
4292  * changes to a text document.\r
4293  */\r
4294 var DidChangeTextDocumentNotification;\r
4295 (function (DidChangeTextDocumentNotification) {\r
4296     DidChangeTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didChange');\r
4297 })(DidChangeTextDocumentNotification = exports.DidChangeTextDocumentNotification || (exports.DidChangeTextDocumentNotification = {}));\r
4298 /**\r
4299  * The document close notification is sent from the client to the server when\r
4300  * the document got closed in the client. The document's truth now exists where\r
4301  * the document's uri points to (e.g. if the document's uri is a file uri the\r
4302  * truth now exists on disk). As with the open notification the close notification\r
4303  * is about managing the document's content. Receiving a close notification\r
4304  * doesn't mean that the document was open in an editor before. A close\r
4305  * notification requires a previous open notification to be sent.\r
4306  */\r
4307 var DidCloseTextDocumentNotification;\r
4308 (function (DidCloseTextDocumentNotification) {\r
4309     DidCloseTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didClose');\r
4310 })(DidCloseTextDocumentNotification = exports.DidCloseTextDocumentNotification || (exports.DidCloseTextDocumentNotification = {}));\r
4311 /**\r
4312  * The document save notification is sent from the client to the server when\r
4313  * the document got saved in the client.\r
4314  */\r
4315 var DidSaveTextDocumentNotification;\r
4316 (function (DidSaveTextDocumentNotification) {\r
4317     DidSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/didSave');\r
4318 })(DidSaveTextDocumentNotification = exports.DidSaveTextDocumentNotification || (exports.DidSaveTextDocumentNotification = {}));\r
4319 /**\r
4320  * A document will save notification is sent from the client to the server before\r
4321  * the document is actually saved.\r
4322  */\r
4323 var WillSaveTextDocumentNotification;\r
4324 (function (WillSaveTextDocumentNotification) {\r
4325     WillSaveTextDocumentNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/willSave');\r
4326 })(WillSaveTextDocumentNotification = exports.WillSaveTextDocumentNotification || (exports.WillSaveTextDocumentNotification = {}));\r
4327 /**\r
4328  * A document will save request is sent from the client to the server before\r
4329  * the document is actually saved. The request can return an array of TextEdits\r
4330  * which will be applied to the text document before it is saved. Please note that\r
4331  * clients might drop results if computing the text edits took too long or if a\r
4332  * server constantly fails on this request. This is done to keep the save fast and\r
4333  * reliable.\r
4334  */\r
4335 var WillSaveTextDocumentWaitUntilRequest;\r
4336 (function (WillSaveTextDocumentWaitUntilRequest) {\r
4337     WillSaveTextDocumentWaitUntilRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/willSaveWaitUntil');\r
4338 })(WillSaveTextDocumentWaitUntilRequest = exports.WillSaveTextDocumentWaitUntilRequest || (exports.WillSaveTextDocumentWaitUntilRequest = {}));\r
4339 //---- File eventing ----\r
4340 /**\r
4341  * The watched files notification is sent from the client to the server when\r
4342  * the client detects changes to file watched by the language client.\r
4343  */\r
4344 var DidChangeWatchedFilesNotification;\r
4345 (function (DidChangeWatchedFilesNotification) {\r
4346     DidChangeWatchedFilesNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWatchedFiles');\r
4347 })(DidChangeWatchedFilesNotification = exports.DidChangeWatchedFilesNotification || (exports.DidChangeWatchedFilesNotification = {}));\r
4348 /**\r
4349  * The file event type\r
4350  */\r
4351 var FileChangeType;\r
4352 (function (FileChangeType) {\r
4353     /**\r
4354      * The file got created.\r
4355      */\r
4356     FileChangeType.Created = 1;\r
4357     /**\r
4358      * The file got changed.\r
4359      */\r
4360     FileChangeType.Changed = 2;\r
4361     /**\r
4362      * The file got deleted.\r
4363      */\r
4364     FileChangeType.Deleted = 3;\r
4365 })(FileChangeType = exports.FileChangeType || (exports.FileChangeType = {}));\r
4366 var WatchKind;\r
4367 (function (WatchKind) {\r
4368     /**\r
4369      * Interested in create events.\r
4370      */\r
4371     WatchKind.Create = 1;\r
4372     /**\r
4373      * Interested in change events\r
4374      */\r
4375     WatchKind.Change = 2;\r
4376     /**\r
4377      * Interested in delete events\r
4378      */\r
4379     WatchKind.Delete = 4;\r
4380 })(WatchKind = exports.WatchKind || (exports.WatchKind = {}));\r
4381 //---- Diagnostic notification ----\r
4382 /**\r
4383  * Diagnostics notification are sent from the server to the client to signal\r
4384  * results of validation runs.\r
4385  */\r
4386 var PublishDiagnosticsNotification;\r
4387 (function (PublishDiagnosticsNotification) {\r
4388     PublishDiagnosticsNotification.type = new vscode_jsonrpc_1.NotificationType('textDocument/publishDiagnostics');\r
4389 })(PublishDiagnosticsNotification = exports.PublishDiagnosticsNotification || (exports.PublishDiagnosticsNotification = {}));\r
4390 /**\r
4391  * How a completion was triggered\r
4392  */\r
4393 var CompletionTriggerKind;\r
4394 (function (CompletionTriggerKind) {\r
4395     /**\r
4396      * Completion was triggered by typing an identifier (24x7 code\r
4397      * complete), manual invocation (e.g Ctrl+Space) or via API.\r
4398      */\r
4399     CompletionTriggerKind.Invoked = 1;\r
4400     /**\r
4401      * Completion was triggered by a trigger character specified by\r
4402      * the `triggerCharacters` properties of the `CompletionRegistrationOptions`.\r
4403      */\r
4404     CompletionTriggerKind.TriggerCharacter = 2;\r
4405     /**\r
4406      * Completion was re-triggered as current completion list is incomplete\r
4407      */\r
4408     CompletionTriggerKind.TriggerForIncompleteCompletions = 3;\r
4409 })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));\r
4410 /**\r
4411  * Request to request completion at a given text document position. The request's\r
4412  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response\r
4413  * is of type [CompletionItem[]](#CompletionItem) or [CompletionList](#CompletionList)\r
4414  * or a Thenable that resolves to such.\r
4415  *\r
4416  * The request can delay the computation of the [`detail`](#CompletionItem.detail)\r
4417  * and [`documentation`](#CompletionItem.documentation) properties to the `completionItem/resolve`\r
4418  * request. However, properties that are needed for the initial sorting and filtering, like `sortText`,\r
4419  * `filterText`, `insertText`, and `textEdit`, must not be changed during resolve.\r
4420  */\r
4421 var CompletionRequest;\r
4422 (function (CompletionRequest) {\r
4423     CompletionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/completion');\r
4424 })(CompletionRequest = exports.CompletionRequest || (exports.CompletionRequest = {}));\r
4425 /**\r
4426  * Request to resolve additional information for a given completion item.The request's\r
4427  * parameter is of type [CompletionItem](#CompletionItem) the response\r
4428  * is of type [CompletionItem](#CompletionItem) or a Thenable that resolves to such.\r
4429  */\r
4430 var CompletionResolveRequest;\r
4431 (function (CompletionResolveRequest) {\r
4432     CompletionResolveRequest.type = new vscode_jsonrpc_1.RequestType('completionItem/resolve');\r
4433 })(CompletionResolveRequest = exports.CompletionResolveRequest || (exports.CompletionResolveRequest = {}));\r
4434 //---- Hover Support -------------------------------\r
4435 /**\r
4436  * Request to request hover information at a given text document position. The request's\r
4437  * parameter is of type [TextDocumentPosition](#TextDocumentPosition) the response is of\r
4438  * type [Hover](#Hover) or a Thenable that resolves to such.\r
4439  */\r
4440 var HoverRequest;\r
4441 (function (HoverRequest) {\r
4442     HoverRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/hover');\r
4443 })(HoverRequest = exports.HoverRequest || (exports.HoverRequest = {}));\r
4444 var SignatureHelpRequest;\r
4445 (function (SignatureHelpRequest) {\r
4446     SignatureHelpRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/signatureHelp');\r
4447 })(SignatureHelpRequest = exports.SignatureHelpRequest || (exports.SignatureHelpRequest = {}));\r
4448 //---- Goto Definition -------------------------------------\r
4449 /**\r
4450  * A request to resolve the definition location of a symbol at a given text\r
4451  * document position. The request's parameter is of type [TextDocumentPosition]\r
4452  * (#TextDocumentPosition) the response is of either type [Definition](#Definition)\r
4453  * or a typed array of [DefinitionLink](#DefinitionLink) or a Thenable that resolves\r
4454  * to such.\r
4455  */\r
4456 var DefinitionRequest;\r
4457 (function (DefinitionRequest) {\r
4458     DefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/definition');\r
4459 })(DefinitionRequest = exports.DefinitionRequest || (exports.DefinitionRequest = {}));\r
4460 /**\r
4461  * A request to resolve project-wide references for the symbol denoted\r
4462  * by the given text document position. The request's parameter is of\r
4463  * type [ReferenceParams](#ReferenceParams) the response is of type\r
4464  * [Location[]](#Location) or a Thenable that resolves to such.\r
4465  */\r
4466 var ReferencesRequest;\r
4467 (function (ReferencesRequest) {\r
4468     ReferencesRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/references');\r
4469 })(ReferencesRequest = exports.ReferencesRequest || (exports.ReferencesRequest = {}));\r
4470 //---- Document Highlight ----------------------------------\r
4471 /**\r
4472  * Request to resolve a [DocumentHighlight](#DocumentHighlight) for a given\r
4473  * text document position. The request's parameter is of type [TextDocumentPosition]\r
4474  * (#TextDocumentPosition) the request response is of type [DocumentHighlight[]]\r
4475  * (#DocumentHighlight) or a Thenable that resolves to such.\r
4476  */\r
4477 var DocumentHighlightRequest;\r
4478 (function (DocumentHighlightRequest) {\r
4479     DocumentHighlightRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentHighlight');\r
4480 })(DocumentHighlightRequest = exports.DocumentHighlightRequest || (exports.DocumentHighlightRequest = {}));\r
4481 //---- Document Symbol Provider ---------------------------\r
4482 /**\r
4483  * A request to list all symbols found in a given text document. The request's\r
4484  * parameter is of type [TextDocumentIdentifier](#TextDocumentIdentifier) the\r
4485  * response is of type [SymbolInformation[]](#SymbolInformation) or a Thenable\r
4486  * that resolves to such.\r
4487  */\r
4488 var DocumentSymbolRequest;\r
4489 (function (DocumentSymbolRequest) {\r
4490     DocumentSymbolRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentSymbol');\r
4491 })(DocumentSymbolRequest = exports.DocumentSymbolRequest || (exports.DocumentSymbolRequest = {}));\r
4492 //---- Workspace Symbol Provider ---------------------------\r
4493 /**\r
4494  * A request to list project-wide symbols matching the query string given\r
4495  * by the [WorkspaceSymbolParams](#WorkspaceSymbolParams). The response is\r
4496  * of type [SymbolInformation[]](#SymbolInformation) or a Thenable that\r
4497  * resolves to such.\r
4498  */\r
4499 var WorkspaceSymbolRequest;\r
4500 (function (WorkspaceSymbolRequest) {\r
4501     WorkspaceSymbolRequest.type = new vscode_jsonrpc_1.RequestType('workspace/symbol');\r
4502 })(WorkspaceSymbolRequest = exports.WorkspaceSymbolRequest || (exports.WorkspaceSymbolRequest = {}));\r
4503 /**\r
4504  * A request to provide commands for the given text document and range.\r
4505  */\r
4506 var CodeActionRequest;\r
4507 (function (CodeActionRequest) {\r
4508     CodeActionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeAction');\r
4509 })(CodeActionRequest = exports.CodeActionRequest || (exports.CodeActionRequest = {}));\r
4510 /**\r
4511  * A request to provide code lens for the given text document.\r
4512  */\r
4513 var CodeLensRequest;\r
4514 (function (CodeLensRequest) {\r
4515     CodeLensRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/codeLens');\r
4516 })(CodeLensRequest = exports.CodeLensRequest || (exports.CodeLensRequest = {}));\r
4517 /**\r
4518  * A request to resolve a command for a given code lens.\r
4519  */\r
4520 var CodeLensResolveRequest;\r
4521 (function (CodeLensResolveRequest) {\r
4522     CodeLensResolveRequest.type = new vscode_jsonrpc_1.RequestType('codeLens/resolve');\r
4523 })(CodeLensResolveRequest = exports.CodeLensResolveRequest || (exports.CodeLensResolveRequest = {}));\r
4524 /**\r
4525  * A request to to format a whole document.\r
4526  */\r
4527 var DocumentFormattingRequest;\r
4528 (function (DocumentFormattingRequest) {\r
4529     DocumentFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/formatting');\r
4530 })(DocumentFormattingRequest = exports.DocumentFormattingRequest || (exports.DocumentFormattingRequest = {}));\r
4531 /**\r
4532  * A request to to format a range in a document.\r
4533  */\r
4534 var DocumentRangeFormattingRequest;\r
4535 (function (DocumentRangeFormattingRequest) {\r
4536     DocumentRangeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rangeFormatting');\r
4537 })(DocumentRangeFormattingRequest = exports.DocumentRangeFormattingRequest || (exports.DocumentRangeFormattingRequest = {}));\r
4538 /**\r
4539  * A request to format a document on type.\r
4540  */\r
4541 var DocumentOnTypeFormattingRequest;\r
4542 (function (DocumentOnTypeFormattingRequest) {\r
4543     DocumentOnTypeFormattingRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/onTypeFormatting');\r
4544 })(DocumentOnTypeFormattingRequest = exports.DocumentOnTypeFormattingRequest || (exports.DocumentOnTypeFormattingRequest = {}));\r
4545 /**\r
4546  * A request to rename a symbol.\r
4547  */\r
4548 var RenameRequest;\r
4549 (function (RenameRequest) {\r
4550     RenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/rename');\r
4551 })(RenameRequest = exports.RenameRequest || (exports.RenameRequest = {}));\r
4552 /**\r
4553  * A request to test and perform the setup necessary for a rename.\r
4554  */\r
4555 var PrepareRenameRequest;\r
4556 (function (PrepareRenameRequest) {\r
4557     PrepareRenameRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/prepareRename');\r
4558 })(PrepareRenameRequest = exports.PrepareRenameRequest || (exports.PrepareRenameRequest = {}));\r
4559 /**\r
4560  * A request to provide document links\r
4561  */\r
4562 var DocumentLinkRequest;\r
4563 (function (DocumentLinkRequest) {\r
4564     DocumentLinkRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentLink');\r
4565 })(DocumentLinkRequest = exports.DocumentLinkRequest || (exports.DocumentLinkRequest = {}));\r
4566 /**\r
4567  * Request to resolve additional information for a given document link. The request's\r
4568  * parameter is of type [DocumentLink](#DocumentLink) the response\r
4569  * is of type [DocumentLink](#DocumentLink) or a Thenable that resolves to such.\r
4570  */\r
4571 var DocumentLinkResolveRequest;\r
4572 (function (DocumentLinkResolveRequest) {\r
4573     DocumentLinkResolveRequest.type = new vscode_jsonrpc_1.RequestType('documentLink/resolve');\r
4574 })(DocumentLinkResolveRequest = exports.DocumentLinkResolveRequest || (exports.DocumentLinkResolveRequest = {}));\r
4575 /**\r
4576  * A request send from the client to the server to execute a command. The request might return\r
4577  * a workspace edit which the client will apply to the workspace.\r
4578  */\r
4579 var ExecuteCommandRequest;\r
4580 (function (ExecuteCommandRequest) {\r
4581     ExecuteCommandRequest.type = new vscode_jsonrpc_1.RequestType('workspace/executeCommand');\r
4582 })(ExecuteCommandRequest = exports.ExecuteCommandRequest || (exports.ExecuteCommandRequest = {}));\r
4583 /**\r
4584  * A request sent from the server to the client to modified certain resources.\r
4585  */\r
4586 var ApplyWorkspaceEditRequest;\r
4587 (function (ApplyWorkspaceEditRequest) {\r
4588     ApplyWorkspaceEditRequest.type = new vscode_jsonrpc_1.RequestType('workspace/applyEdit');\r
4589 })(ApplyWorkspaceEditRequest = exports.ApplyWorkspaceEditRequest || (exports.ApplyWorkspaceEditRequest = {}));\r
4590
4591
4592 /***/ }),
4593 /* 19 */
4594 /***/ (function(module, exports, __webpack_require__) {
4595
4596 "use strict";
4597 /* --------------------------------------------------------------------------------------------\r
4598  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4599  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4600  * ------------------------------------------------------------------------------------------ */\r
4601 \r
4602 Object.defineProperty(exports, "__esModule", { value: true });\r
4603 function boolean(value) {\r
4604     return value === true || value === false;\r
4605 }\r
4606 exports.boolean = boolean;\r
4607 function string(value) {\r
4608     return typeof value === 'string' || value instanceof String;\r
4609 }\r
4610 exports.string = string;\r
4611 function number(value) {\r
4612     return typeof value === 'number' || value instanceof Number;\r
4613 }\r
4614 exports.number = number;\r
4615 function error(value) {\r
4616     return value instanceof Error;\r
4617 }\r
4618 exports.error = error;\r
4619 function func(value) {\r
4620     return typeof value === 'function';\r
4621 }\r
4622 exports.func = func;\r
4623 function array(value) {\r
4624     return Array.isArray(value);\r
4625 }\r
4626 exports.array = array;\r
4627 function stringArray(value) {\r
4628     return array(value) && value.every(elem => string(elem));\r
4629 }\r
4630 exports.stringArray = stringArray;\r
4631 function typedArray(value, check) {\r
4632     return Array.isArray(value) && value.every(check);\r
4633 }\r
4634 exports.typedArray = typedArray;\r
4635 function thenable(value) {\r
4636     return value && func(value.then);\r
4637 }\r
4638 exports.thenable = thenable;\r
4639
4640
4641 /***/ }),
4642 /* 20 */
4643 /***/ (function(module, exports, __webpack_require__) {
4644
4645 "use strict";
4646 /* --------------------------------------------------------------------------------------------\r
4647  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4648  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4649  * ------------------------------------------------------------------------------------------ */\r
4650 \r
4651 Object.defineProperty(exports, "__esModule", { value: true });\r
4652 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4653 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
4654 let __noDynamicImport;\r
4655 /**\r
4656  * A request to resolve the implementation locations of a symbol at a given text\r
4657  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
4658  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
4659  * Thenable that resolves to such.\r
4660  */\r
4661 var ImplementationRequest;\r
4662 (function (ImplementationRequest) {\r
4663     ImplementationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/implementation');\r
4664 })(ImplementationRequest = exports.ImplementationRequest || (exports.ImplementationRequest = {}));\r
4665
4666
4667 /***/ }),
4668 /* 21 */
4669 /***/ (function(module, exports, __webpack_require__) {
4670
4671 "use strict";
4672 /* --------------------------------------------------------------------------------------------\r
4673  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4674  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4675  * ------------------------------------------------------------------------------------------ */\r
4676 \r
4677 Object.defineProperty(exports, "__esModule", { value: true });\r
4678 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4679 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
4680 let __noDynamicImport;\r
4681 /**\r
4682  * A request to resolve the type definition locations of a symbol at a given text\r
4683  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
4684  * (#TextDocumentPositionParams) the response is of type [Definition](#Definition) or a\r
4685  * Thenable that resolves to such.\r
4686  */\r
4687 var TypeDefinitionRequest;\r
4688 (function (TypeDefinitionRequest) {\r
4689     TypeDefinitionRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/typeDefinition');\r
4690 })(TypeDefinitionRequest = exports.TypeDefinitionRequest || (exports.TypeDefinitionRequest = {}));\r
4691
4692
4693 /***/ }),
4694 /* 22 */
4695 /***/ (function(module, exports, __webpack_require__) {
4696
4697 "use strict";
4698 /* --------------------------------------------------------------------------------------------\r
4699  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4700  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4701  * ------------------------------------------------------------------------------------------ */\r
4702 \r
4703 Object.defineProperty(exports, "__esModule", { value: true });\r
4704 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4705 /**\r
4706  * The `workspace/workspaceFolders` is sent from the server to the client to fetch the open workspace folders.\r
4707  */\r
4708 var WorkspaceFoldersRequest;\r
4709 (function (WorkspaceFoldersRequest) {\r
4710     WorkspaceFoldersRequest.type = new vscode_jsonrpc_1.RequestType0('workspace/workspaceFolders');\r
4711 })(WorkspaceFoldersRequest = exports.WorkspaceFoldersRequest || (exports.WorkspaceFoldersRequest = {}));\r
4712 /**\r
4713  * The `workspace/didChangeWorkspaceFolders` notification is sent from the client to the server when the workspace\r
4714  * folder configuration changes.\r
4715  */\r
4716 var DidChangeWorkspaceFoldersNotification;\r
4717 (function (DidChangeWorkspaceFoldersNotification) {\r
4718     DidChangeWorkspaceFoldersNotification.type = new vscode_jsonrpc_1.NotificationType('workspace/didChangeWorkspaceFolders');\r
4719 })(DidChangeWorkspaceFoldersNotification = exports.DidChangeWorkspaceFoldersNotification || (exports.DidChangeWorkspaceFoldersNotification = {}));\r
4720
4721
4722 /***/ }),
4723 /* 23 */
4724 /***/ (function(module, exports, __webpack_require__) {
4725
4726 "use strict";
4727 /* --------------------------------------------------------------------------------------------\r
4728  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4729  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4730  * ------------------------------------------------------------------------------------------ */\r
4731 \r
4732 Object.defineProperty(exports, "__esModule", { value: true });\r
4733 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4734 /**\r
4735  * The 'workspace/configuration' request is sent from the server to the client to fetch a certain\r
4736  * configuration setting.\r
4737  *\r
4738  * This pull model replaces the old push model were the client signaled configuration change via an\r
4739  * event. If the server still needs to react to configuration changes (since the server caches the\r
4740  * result of `workspace/configuration` requests) the server should register for an empty configuration\r
4741  * change event and empty the cache if such an event is received.\r
4742  */\r
4743 var ConfigurationRequest;\r
4744 (function (ConfigurationRequest) {\r
4745     ConfigurationRequest.type = new vscode_jsonrpc_1.RequestType('workspace/configuration');\r
4746 })(ConfigurationRequest = exports.ConfigurationRequest || (exports.ConfigurationRequest = {}));\r
4747
4748
4749 /***/ }),
4750 /* 24 */
4751 /***/ (function(module, exports, __webpack_require__) {
4752
4753 "use strict";
4754 /* --------------------------------------------------------------------------------------------\r
4755  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4756  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4757  * ------------------------------------------------------------------------------------------ */\r
4758 \r
4759 Object.defineProperty(exports, "__esModule", { value: true });\r
4760 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4761 /**\r
4762  * A request to list all color symbols found in a given text document. The request's\r
4763  * parameter is of type [DocumentColorParams](#DocumentColorParams) the\r
4764  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
4765  * that resolves to such.\r
4766  */\r
4767 var DocumentColorRequest;\r
4768 (function (DocumentColorRequest) {\r
4769     DocumentColorRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/documentColor');\r
4770 })(DocumentColorRequest = exports.DocumentColorRequest || (exports.DocumentColorRequest = {}));\r
4771 /**\r
4772  * A request to list all presentation for a color. The request's\r
4773  * parameter is of type [ColorPresentationParams](#ColorPresentationParams) the\r
4774  * response is of type [ColorInformation[]](#ColorInformation) or a Thenable\r
4775  * that resolves to such.\r
4776  */\r
4777 var ColorPresentationRequest;\r
4778 (function (ColorPresentationRequest) {\r
4779     ColorPresentationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/colorPresentation');\r
4780 })(ColorPresentationRequest = exports.ColorPresentationRequest || (exports.ColorPresentationRequest = {}));\r
4781
4782
4783 /***/ }),
4784 /* 25 */
4785 /***/ (function(module, exports, __webpack_require__) {
4786
4787 "use strict";
4788 \r
4789 /*---------------------------------------------------------------------------------------------\r
4790  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
4791  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
4792  *--------------------------------------------------------------------------------------------*/\r
4793 Object.defineProperty(exports, "__esModule", { value: true });\r
4794 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4795 /**\r
4796  * Enum of known range kinds\r
4797  */\r
4798 var FoldingRangeKind;\r
4799 (function (FoldingRangeKind) {\r
4800     /**\r
4801      * Folding range for a comment\r
4802      */\r
4803     FoldingRangeKind["Comment"] = "comment";\r
4804     /**\r
4805      * Folding range for a imports or includes\r
4806      */\r
4807     FoldingRangeKind["Imports"] = "imports";\r
4808     /**\r
4809      * Folding range for a region (e.g. `#region`)\r
4810      */\r
4811     FoldingRangeKind["Region"] = "region";\r
4812 })(FoldingRangeKind = exports.FoldingRangeKind || (exports.FoldingRangeKind = {}));\r
4813 /**\r
4814  * A request to provide folding ranges in a document. The request's\r
4815  * parameter is of type [FoldingRangeParams](#FoldingRangeParams), the\r
4816  * response is of type [FoldingRangeList](#FoldingRangeList) or a Thenable\r
4817  * that resolves to such.\r
4818  */\r
4819 var FoldingRangeRequest;\r
4820 (function (FoldingRangeRequest) {\r
4821     FoldingRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/foldingRange');\r
4822 })(FoldingRangeRequest = exports.FoldingRangeRequest || (exports.FoldingRangeRequest = {}));\r
4823
4824
4825 /***/ }),
4826 /* 26 */
4827 /***/ (function(module, exports, __webpack_require__) {
4828
4829 "use strict";
4830 /* --------------------------------------------------------------------------------------------\r
4831  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4832  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4833  * ------------------------------------------------------------------------------------------ */\r
4834 \r
4835 Object.defineProperty(exports, "__esModule", { value: true });\r
4836 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4837 // @ts-ignore: to avoid inlining LocatioLink as dynamic import\r
4838 let __noDynamicImport;\r
4839 /**\r
4840  * A request to resolve the type definition locations of a symbol at a given text\r
4841  * document position. The request's parameter is of type [TextDocumentPositioParams]\r
4842  * (#TextDocumentPositionParams) the response is of type [Declaration](#Declaration)\r
4843  * or a typed array of [DeclarationLink](#DeclarationLink) or a Thenable that resolves\r
4844  * to such.\r
4845  */\r
4846 var DeclarationRequest;\r
4847 (function (DeclarationRequest) {\r
4848     DeclarationRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/declaration');\r
4849 })(DeclarationRequest = exports.DeclarationRequest || (exports.DeclarationRequest = {}));\r
4850
4851
4852 /***/ }),
4853 /* 27 */
4854 /***/ (function(module, exports, __webpack_require__) {
4855
4856 "use strict";
4857 /* --------------------------------------------------------------------------------------------\r
4858  * Copyright (c) TypeFox and others. All rights reserved.\r
4859  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4860  * ------------------------------------------------------------------------------------------ */\r
4861 \r
4862 Object.defineProperty(exports, "__esModule", { value: true });\r
4863 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4864 /**\r
4865  * The direction of a call hierarchy request.\r
4866  */\r
4867 var CallHierarchyDirection;\r
4868 (function (CallHierarchyDirection) {\r
4869     /**\r
4870      * The callers\r
4871      */\r
4872     CallHierarchyDirection.CallsFrom = 1;\r
4873     /**\r
4874      * The callees\r
4875      */\r
4876     CallHierarchyDirection.CallsTo = 2;\r
4877 })(CallHierarchyDirection = exports.CallHierarchyDirection || (exports.CallHierarchyDirection = {}));\r
4878 /**\r
4879  * Request to provide the call hierarchy at a given text document position.\r
4880  *\r
4881  * The request's parameter is of type [CallHierarchyParams](#CallHierarchyParams). The response\r
4882  * is of type [CallHierarchyCall[]](#CallHierarchyCall) or a Thenable that resolves to such.\r
4883  *\r
4884  * Evaluates the symbol defined (or referenced) at the given position, and returns all incoming or outgoing calls to the symbol(s).\r
4885  */\r
4886 var CallHierarchyRequest;\r
4887 (function (CallHierarchyRequest) {\r
4888     CallHierarchyRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/callHierarchy');\r
4889 })(CallHierarchyRequest = exports.CallHierarchyRequest || (exports.CallHierarchyRequest = {}));\r
4890
4891
4892 /***/ }),
4893 /* 28 */
4894 /***/ (function(module, exports, __webpack_require__) {
4895
4896 "use strict";
4897 /* --------------------------------------------------------------------------------------------\r
4898  * Copyright (c) Microsoft Corporation. All rights reserved.\r
4899  * Licensed under the MIT License. See License.txt in the project root for license information.\r
4900  * ------------------------------------------------------------------------------------------ */\r
4901 \r
4902 Object.defineProperty(exports, "__esModule", { value: true });\r
4903 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4904 /**\r
4905  * The `window/progress/start` notification is sent from the server to the client\r
4906  * to initiate a progress.\r
4907  */\r
4908 var ProgressStartNotification;\r
4909 (function (ProgressStartNotification) {\r
4910     ProgressStartNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/start');\r
4911 })(ProgressStartNotification = exports.ProgressStartNotification || (exports.ProgressStartNotification = {}));\r
4912 /**\r
4913  * The `window/progress/report` notification is sent from the server to the client\r
4914  * to initiate a progress.\r
4915  */\r
4916 var ProgressReportNotification;\r
4917 (function (ProgressReportNotification) {\r
4918     ProgressReportNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/report');\r
4919 })(ProgressReportNotification = exports.ProgressReportNotification || (exports.ProgressReportNotification = {}));\r
4920 /**\r
4921  * The `window/progress/done` notification is sent from the server to the client\r
4922  * to initiate a progress.\r
4923  */\r
4924 var ProgressDoneNotification;\r
4925 (function (ProgressDoneNotification) {\r
4926     ProgressDoneNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/done');\r
4927 })(ProgressDoneNotification = exports.ProgressDoneNotification || (exports.ProgressDoneNotification = {}));\r
4928 /**\r
4929  * The `window/progress/cancel` notification is sent client to the server to cancel a progress\r
4930  * initiated on the server side.\r
4931  */\r
4932 var ProgressCancelNotification;\r
4933 (function (ProgressCancelNotification) {\r
4934     ProgressCancelNotification.type = new vscode_jsonrpc_1.NotificationType('window/progress/cancel');\r
4935 })(ProgressCancelNotification = exports.ProgressCancelNotification || (exports.ProgressCancelNotification = {}));\r
4936
4937
4938 /***/ }),
4939 /* 29 */
4940 /***/ (function(module, exports, __webpack_require__) {
4941
4942 "use strict";
4943 \r
4944 /*---------------------------------------------------------------------------------------------\r
4945  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
4946  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
4947  *--------------------------------------------------------------------------------------------*/\r
4948 Object.defineProperty(exports, "__esModule", { value: true });\r
4949 const vscode_jsonrpc_1 = __webpack_require__(4);\r
4950 const vscode_languageserver_types_1 = __webpack_require__(17);\r
4951 /**\r
4952  * The SelectionRange namespace provides helper function to work with\r
4953  * SelectionRange literals.\r
4954  */\r
4955 var SelectionRange;\r
4956 (function (SelectionRange) {\r
4957     /**\r
4958      * Creates a new SelectionRange\r
4959      * @param range the range.\r
4960      * @param parent an optional parent.\r
4961      */\r
4962     function create(range, parent) {\r
4963         return { range, parent };\r
4964     }\r
4965     SelectionRange.create = create;\r
4966     function is(value) {\r
4967         let candidate = value;\r
4968         return candidate !== undefined && vscode_languageserver_types_1.Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));\r
4969     }\r
4970     SelectionRange.is = is;\r
4971 })(SelectionRange = exports.SelectionRange || (exports.SelectionRange = {}));\r
4972 /**\r
4973  * A request to provide selection ranges in a document. The request's\r
4974  * parameter is of type [SelectionRangeParams](#SelectionRangeParams), the\r
4975  * response is of type [SelectionRange[]](#SelectionRange[]) or a Thenable\r
4976  * that resolves to such.\r
4977  */\r
4978 var SelectionRangeRequest;\r
4979 (function (SelectionRangeRequest) {\r
4980     SelectionRangeRequest.type = new vscode_jsonrpc_1.RequestType('textDocument/selectionRange');\r
4981 })(SelectionRangeRequest = exports.SelectionRangeRequest || (exports.SelectionRangeRequest = {}));\r
4982
4983
4984 /***/ }),
4985 /* 30 */,
4986 /* 31 */,
4987 /* 32 */,
4988 /* 33 */
4989 /***/ (function(module, exports, __webpack_require__) {
4990
4991 "use strict";
4992
4993 /*---------------------------------------------------------------------------------------------
4994  *  Copyright (c) Microsoft Corporation. All rights reserved.
4995  *  Licensed under the MIT License. See License.txt in the project root for license information.
4996  *--------------------------------------------------------------------------------------------*/
4997 var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4998     return new (P || (P = Promise))(function (resolve, reject) {
4999         function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5000         function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
5001         function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
5002         step((generator = generator.apply(thisArg, _arguments || [])).next());
5003     });
5004 };
5005 var __importStar = (this && this.__importStar) || function (mod) {
5006     if (mod && mod.__esModule) return mod;
5007     var result = {};
5008     if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
5009     result["default"] = mod;
5010     return result;
5011 };
5012 Object.defineProperty(exports, "__esModule", { value: true });
5013 const vscode_languageserver_1 = __webpack_require__(34);
5014 const request_light_1 = __webpack_require__(49);
5015 const fs = __importStar(__webpack_require__(2));
5016 const vscode_uri_1 = __webpack_require__(77);
5017 const URL = __importStar(__webpack_require__(40));
5018 const runner_1 = __webpack_require__(78);
5019 const vscode_json_languageservice_1 = __webpack_require__(79);
5020 const languageModelCache_1 = __webpack_require__(101);
5021 var SchemaAssociationNotification;
5022 (function (SchemaAssociationNotification) {
5023     SchemaAssociationNotification.type = new vscode_languageserver_1.NotificationType('json/schemaAssociations');
5024 })(SchemaAssociationNotification || (SchemaAssociationNotification = {}));
5025 var VSCodeContentRequest;
5026 (function (VSCodeContentRequest) {
5027     VSCodeContentRequest.type = new vscode_languageserver_1.RequestType('vscode/content');
5028 })(VSCodeContentRequest || (VSCodeContentRequest = {}));
5029 var SchemaContentChangeNotification;
5030 (function (SchemaContentChangeNotification) {
5031     SchemaContentChangeNotification.type = new vscode_languageserver_1.NotificationType('json/schemaContent');
5032 })(SchemaContentChangeNotification || (SchemaContentChangeNotification = {}));
5033 var ForceValidateRequest;
5034 (function (ForceValidateRequest) {
5035     ForceValidateRequest.type = new vscode_languageserver_1.RequestType('json/validate');
5036 })(ForceValidateRequest || (ForceValidateRequest = {}));
5037 // Create a connection for the server
5038 const connection = vscode_languageserver_1.createConnection();
5039 process.on('unhandledRejection', (e) => {
5040     console.error(runner_1.formatError(`Unhandled exception`, e));
5041 });
5042 process.on('uncaughtException', (e) => {
5043     console.error(runner_1.formatError(`Unhandled exception`, e));
5044 });
5045 console.log = connection.console.log.bind(connection.console);
5046 console.error = connection.console.error.bind(connection.console);
5047 const workspaceContext = {
5048     resolveRelativePath: (relativePath, resource) => {
5049         return URL.resolve(resource, relativePath);
5050     }
5051 };
5052 function getSchemaRequestService(handledSchemas) {
5053     return (uri) => {
5054         const protocol = uri.substr(0, uri.indexOf(':'));
5055         if (!handledSchemas || handledSchemas[protocol]) {
5056             if (protocol === 'file') {
5057                 const fsPath = vscode_uri_1.URI.parse(uri).fsPath;
5058                 return new Promise((c, e) => {
5059                     fs.readFile(fsPath, 'UTF-8', (err, result) => {
5060                         err ? e(err.message || err.toString()) : c(result.toString());
5061                     });
5062                 });
5063             }
5064             else if (protocol === 'http' || protocol === 'https') {
5065                 if (uri.indexOf('//schema.management.azure.com/') !== -1) {
5066                     /* __GDPR__
5067                         "json.schema" : {
5068                             "schemaURL" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
5069                         }
5070                      */
5071                     connection.telemetry.logEvent({
5072                         key: 'json.schema',
5073                         value: {
5074                             schemaURL: uri
5075                         }
5076                     });
5077                 }
5078                 const headers = { 'Accept-Encoding': 'gzip, deflate' };
5079                 return request_light_1.xhr({ url: uri, followRedirects: 5, headers }).then(response => {
5080                     return response.responseText;
5081                 }, (error) => {
5082                     return Promise.reject(error.responseText || request_light_1.getErrorStatusDescription(error.status) || error.toString());
5083                 });
5084             }
5085         }
5086         return connection.sendRequest(VSCodeContentRequest.type, uri).then(responseText => {
5087             return responseText;
5088         }, error => {
5089             return Promise.reject(error.message);
5090         });
5091     };
5092 }
5093 // create the JSON language service
5094 let languageService = vscode_json_languageservice_1.getLanguageService({
5095     workspaceContext,
5096     contributions: [],
5097 });
5098 // Create a simple text document manager. The text document manager
5099 // supports full document sync only
5100 const documents = new vscode_languageserver_1.TextDocuments();
5101 // Make the text document manager listen on the connection
5102 // for open, change and close text document events
5103 documents.listen(connection);
5104 let clientSnippetSupport = false;
5105 let clientDynamicRegisterSupport = false;
5106 let foldingRangeLimit = Number.MAX_VALUE;
5107 let hierarchicalDocumentSymbolSupport = false;
5108 // After the server has started the client sends an initialize request. The server receives
5109 // in the passed params the rootPath of the workspace plus the client capabilities.
5110 connection.onInitialize((params) => {
5111     const handledProtocols = params.initializationOptions && params.initializationOptions['handledSchemaProtocols'];
5112     languageService = vscode_json_languageservice_1.getLanguageService({
5113         schemaRequestService: getSchemaRequestService(handledProtocols),
5114         workspaceContext,
5115         contributions: [],
5116         clientCapabilities: params.capabilities
5117     });
5118     function getClientCapability(name, def) {
5119         const keys = name.split('.');
5120         let c = params.capabilities;
5121         for (let i = 0; c && i < keys.length; i++) {
5122             if (!c.hasOwnProperty(keys[i])) {
5123                 return def;
5124             }
5125             c = c[keys[i]];
5126         }
5127         return c;
5128     }
5129     clientSnippetSupport = getClientCapability('textDocument.completion.completionItem.snippetSupport', false);
5130     clientDynamicRegisterSupport = getClientCapability('workspace.symbol.dynamicRegistration', false);
5131     foldingRangeLimit = getClientCapability('textDocument.foldingRange.rangeLimit', Number.MAX_VALUE);
5132     hierarchicalDocumentSymbolSupport = getClientCapability('textDocument.documentSymbol.hierarchicalDocumentSymbolSupport', false);
5133     const capabilities = {
5134         // Tell the client that the server works in FULL text document sync mode
5135         textDocumentSync: documents.syncKind,
5136         completionProvider: clientSnippetSupport ? { resolveProvider: true, triggerCharacters: ['"', ':'] } : undefined,
5137         hoverProvider: true,
5138         documentSymbolProvider: true,
5139         documentRangeFormattingProvider: false,
5140         colorProvider: {},
5141         foldingRangeProvider: true
5142     };
5143     return { capabilities };
5144 });
5145 let jsonConfigurationSettings = undefined;
5146 let schemaAssociations = undefined;
5147 let formatterRegistration = null;
5148 // The settings have changed. Is send on server activation as well.
5149 connection.onDidChangeConfiguration((change) => {
5150     let settings = change.settings;
5151     request_light_1.configure(settings.http && settings.http.proxy, settings.http && settings.http.proxyStrictSSL);
5152     jsonConfigurationSettings = settings.json && settings.json.schemas;
5153     updateConfiguration();
5154     // dynamically enable & disable the formatter
5155     if (clientDynamicRegisterSupport) {
5156         const enableFormatter = settings && settings.json && settings.json.format && settings.json.format.enable;
5157         if (enableFormatter) {
5158             if (!formatterRegistration) {
5159                 formatterRegistration = connection.client.register(vscode_languageserver_1.DocumentRangeFormattingRequest.type, { documentSelector: [{ language: 'json' }, { language: 'jsonc' }] });
5160             }
5161         }
5162         else if (formatterRegistration) {
5163             formatterRegistration.then(r => r.dispose());
5164             formatterRegistration = null;
5165         }
5166     }
5167 });
5168 // The jsonValidation extension configuration has changed
5169 connection.onNotification(SchemaAssociationNotification.type, associations => {
5170     schemaAssociations = associations;
5171     updateConfiguration();
5172 });
5173 // A schema has changed
5174 connection.onNotification(SchemaContentChangeNotification.type, uri => {
5175     languageService.resetSchema(uri);
5176 });
5177 // Retry schema validation on all open documents
5178 connection.onRequest(ForceValidateRequest.type, uri => {
5179     return new Promise(resolve => {
5180         const document = documents.get(uri);
5181         if (document) {
5182             updateConfiguration();
5183             validateTextDocument(document, diagnostics => {
5184                 resolve(diagnostics);
5185             });
5186         }
5187         else {
5188             resolve([]);
5189         }
5190     });
5191 });
5192 function updateConfiguration() {
5193     const languageSettings = {
5194         validate: true,
5195         allowComments: true,
5196         schemas: new Array()
5197     };
5198     if (schemaAssociations) {
5199         for (const pattern in schemaAssociations) {
5200             const association = schemaAssociations[pattern];
5201             if (Array.isArray(association)) {
5202                 association.forEach(uri => {
5203                     languageSettings.schemas.push({ uri, fileMatch: [pattern] });
5204                 });
5205             }
5206         }
5207     }
5208     if (jsonConfigurationSettings) {
5209         jsonConfigurationSettings.forEach((schema, index) => {
5210             let uri = schema.url;
5211             if (!uri && schema.schema) {
5212                 uri = schema.schema.id || `vscode://schemas/custom/${index}`;
5213             }
5214             if (uri) {
5215                 languageSettings.schemas.push({ uri, fileMatch: schema.fileMatch, schema: schema.schema });
5216             }
5217         });
5218     }
5219     languageService.configure(languageSettings);
5220     // Revalidate any open text documents
5221     documents.all().forEach(triggerValidation);
5222 }
5223 // The content of a text document has changed. This event is emitted
5224 // when the text document first opened or when its content has changed.
5225 documents.onDidChangeContent((change) => {
5226     triggerValidation(change.document);
5227 });
5228 // a document has closed: clear all diagnostics
5229 documents.onDidClose(event => {
5230     cleanPendingValidation(event.document);
5231     connection.sendDiagnostics({ uri: event.document.uri, diagnostics: [] });
5232 });
5233 const pendingValidationRequests = {};
5234 const validationDelayMs = 500;
5235 function cleanPendingValidation(textDocument) {
5236     const request = pendingValidationRequests[textDocument.uri];
5237     if (request) {
5238         clearTimeout(request);
5239         delete pendingValidationRequests[textDocument.uri];
5240     }
5241 }
5242 function triggerValidation(textDocument) {
5243     cleanPendingValidation(textDocument);
5244     pendingValidationRequests[textDocument.uri] = setTimeout(() => {
5245         delete pendingValidationRequests[textDocument.uri];
5246         validateTextDocument(textDocument);
5247     }, validationDelayMs);
5248 }
5249 function validateTextDocument(textDocument, callback) {
5250     const respond = (diagnostics) => {
5251         connection.sendDiagnostics({ uri: textDocument.uri, diagnostics });
5252         if (callback) {
5253             callback(diagnostics);
5254         }
5255     };
5256     if (textDocument.getText().length === 0) {
5257         respond([]); // ignore empty documents
5258         return;
5259     }
5260     const jsonDocument = getJSONDocument(textDocument);
5261     const version = textDocument.version;
5262     const documentSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' };
5263     languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
5264         setTimeout(() => {
5265             const currDocument = documents.get(textDocument.uri);
5266             if (currDocument && currDocument.version === version) {
5267                 respond(diagnostics); // Send the computed diagnostics to VSCode.
5268             }
5269         }, 100);
5270     }, error => {
5271         connection.console.error(runner_1.formatError(`Error while validating ${textDocument.uri}`, error));
5272     });
5273 }
5274 connection.onDidChangeWatchedFiles((change) => {
5275     // Monitored files have changed in VSCode
5276     let hasChanges = false;
5277     change.changes.forEach(c => {
5278         if (languageService.resetSchema(c.uri)) {
5279             hasChanges = true;
5280         }
5281     });
5282     if (hasChanges) {
5283         documents.all().forEach(triggerValidation);
5284     }
5285 });
5286 const jsonDocuments = languageModelCache_1.getLanguageModelCache(10, 60, document => languageService.parseJSONDocument(document));
5287 documents.onDidClose(e => {
5288     jsonDocuments.onDocumentRemoved(e.document);
5289 });
5290 connection.onShutdown(() => {
5291     jsonDocuments.dispose();
5292 });
5293 function getJSONDocument(document) {
5294     return jsonDocuments.get(document);
5295 }
5296 connection.onCompletion((textDocumentPosition, token) => {
5297     return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
5298         const document = documents.get(textDocumentPosition.textDocument.uri);
5299         if (document) {
5300             const jsonDocument = getJSONDocument(document);
5301             return languageService.doComplete(document, textDocumentPosition.position, jsonDocument);
5302         }
5303         return null;
5304     }), null, `Error while computing completions for ${textDocumentPosition.textDocument.uri}`, token);
5305 });
5306 connection.onCompletionResolve((completionItem, token) => {
5307     return runner_1.runSafeAsync(() => {
5308         return languageService.doResolve(completionItem);
5309     }, completionItem, `Error while resolving completion proposal`, token);
5310 });
5311 connection.onHover((textDocumentPositionParams, token) => {
5312     return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
5313         const document = documents.get(textDocumentPositionParams.textDocument.uri);
5314         if (document) {
5315             const jsonDocument = getJSONDocument(document);
5316             return languageService.doHover(document, textDocumentPositionParams.position, jsonDocument);
5317         }
5318         return null;
5319     }), null, `Error while computing hover for ${textDocumentPositionParams.textDocument.uri}`, token);
5320 });
5321 connection.onDocumentSymbol((documentSymbolParams, token) => {
5322     return runner_1.runSafe(() => {
5323         const document = documents.get(documentSymbolParams.textDocument.uri);
5324         if (document) {
5325             const jsonDocument = getJSONDocument(document);
5326             if (hierarchicalDocumentSymbolSupport) {
5327                 return languageService.findDocumentSymbols2(document, jsonDocument);
5328             }
5329             else {
5330                 return languageService.findDocumentSymbols(document, jsonDocument);
5331             }
5332         }
5333         return [];
5334     }, [], `Error while computing document symbols for ${documentSymbolParams.textDocument.uri}`, token);
5335 });
5336 connection.onDocumentRangeFormatting((formatParams, token) => {
5337     return runner_1.runSafe(() => {
5338         const document = documents.get(formatParams.textDocument.uri);
5339         if (document) {
5340             return languageService.format(document, formatParams.range, formatParams.options);
5341         }
5342         return [];
5343     }, [], `Error while formatting range for ${formatParams.textDocument.uri}`, token);
5344 });
5345 connection.onDocumentColor((params, token) => {
5346     return runner_1.runSafeAsync(() => __awaiter(this, void 0, void 0, function* () {
5347         const document = documents.get(params.textDocument.uri);
5348         if (document) {
5349             const jsonDocument = getJSONDocument(document);
5350             return languageService.findDocumentColors(document, jsonDocument);
5351         }
5352         return [];
5353     }), [], `Error while computing document colors for ${params.textDocument.uri}`, token);
5354 });
5355 connection.onColorPresentation((params, token) => {
5356     return runner_1.runSafe(() => {
5357         const document = documents.get(params.textDocument.uri);
5358         if (document) {
5359             const jsonDocument = getJSONDocument(document);
5360             return languageService.getColorPresentations(document, jsonDocument, params.color, params.range);
5361         }
5362         return [];
5363     }, [], `Error while computing color presentations for ${params.textDocument.uri}`, token);
5364 });
5365 connection.onFoldingRanges((params, token) => {
5366     return runner_1.runSafe(() => {
5367         const document = documents.get(params.textDocument.uri);
5368         if (document) {
5369             return languageService.getFoldingRanges(document, { rangeLimit: foldingRangeLimit });
5370         }
5371         return null;
5372     }, null, `Error while computing folding ranges for ${params.textDocument.uri}`, token);
5373 });
5374 connection.onRequest('$/textDocument/selectionRanges', (params, token) => __awaiter(this, void 0, void 0, function* () {
5375     return runner_1.runSafe(() => {
5376         const document = documents.get(params.textDocument.uri);
5377         if (document) {
5378             const jsonDocument = getJSONDocument(document);
5379             return languageService.getSelectionRanges(document, params.positions, jsonDocument);
5380         }
5381         return [];
5382     }, [], `Error while computing selection ranges for ${params.textDocument.uri}`, token);
5383 }));
5384 // Listen on the connection
5385 connection.listen();
5386
5387
5388 /***/ }),
5389 /* 34 */
5390 /***/ (function(module, exports, __webpack_require__) {
5391
5392 "use strict";
5393 /* --------------------------------------------------------------------------------------------\r
5394  * Copyright (c) Microsoft Corporation. All rights reserved.\r
5395  * Licensed under the MIT License. See License.txt in the project root for license information.\r
5396  * ------------------------------------------------------------------------------------------ */\r
5397 /// <reference path="./thenable.ts" />\r
5398 \r
5399 function __export(m) {\r
5400     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r
5401 }\r
5402 Object.defineProperty(exports, "__esModule", { value: true });\r
5403 const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
5404 exports.Event = vscode_languageserver_protocol_1.Event;\r
5405 const configuration_1 = __webpack_require__(35);\r
5406 const workspaceFolders_1 = __webpack_require__(37);\r
5407 const Is = __webpack_require__(36);\r
5408 const UUID = __webpack_require__(38);\r
5409 // ------------- Reexport the API surface of the language worker API ----------------------\r
5410 __export(__webpack_require__(3));\r
5411 const fm = __webpack_require__(39);\r
5412 const vscode_textbuffer_1 = __webpack_require__(42);\r
5413 const range_1 = __webpack_require__(47);\r
5414 var Files;\r
5415 (function (Files) {\r
5416     Files.uriToFilePath = fm.uriToFilePath;\r
5417     Files.resolveGlobalNodePath = fm.resolveGlobalNodePath;\r
5418     Files.resolveGlobalYarnPath = fm.resolveGlobalYarnPath;\r
5419     Files.resolve = fm.resolve;\r
5420     Files.resolveModulePath = fm.resolveModulePath;\r
5421 })(Files = exports.Files || (exports.Files = {}));\r
5422 let shutdownReceived = false;\r
5423 let exitTimer = undefined;\r
5424 function setupExitTimer() {\r
5425     const argName = '--clientProcessId';\r
5426     function runTimer(value) {\r
5427         try {\r
5428             let processId = parseInt(value);\r
5429             if (!isNaN(processId)) {\r
5430                 exitTimer = setInterval(() => {\r
5431                     try {\r
5432                         process.kill(processId, 0);\r
5433                     }\r
5434                     catch (ex) {\r
5435                         // Parent process doesn't exist anymore. Exit the server.\r
5436                         process.exit(shutdownReceived ? 0 : 1);\r
5437                     }\r
5438                 }, 3000);\r
5439             }\r
5440         }\r
5441         catch (e) {\r
5442             // Ignore errors;\r
5443         }\r
5444     }\r
5445     for (let i = 2; i < process.argv.length; i++) {\r
5446         let arg = process.argv[i];\r
5447         if (arg === argName && i + 1 < process.argv.length) {\r
5448             runTimer(process.argv[i + 1]);\r
5449             return;\r
5450         }\r
5451         else {\r
5452             let args = arg.split('=');\r
5453             if (args[0] === argName) {\r
5454                 runTimer(args[1]);\r
5455             }\r
5456         }\r
5457     }\r
5458 }\r
5459 setupExitTimer();\r
5460 function null2Undefined(value) {\r
5461     if (value === null) {\r
5462         return void 0;\r
5463     }\r
5464     return value;\r
5465 }\r
5466 /**\r
5467  * Incrementally-synchronized Text Document implementation that leverages a\r
5468  * "Piece Tree" as text buffer. See the following for details:\r
5469  *  - https://github.com/microsoft/vscode-textbuffer\r
5470  *  - https://code.visualstudio.com/blogs/2018/03/23/text-buffer-reimplementation\r
5471  *\r
5472  * This text document implementation only supports "Incremental" text document\r
5473  * sync. If you wish to use "Full" text document sync, use FullTextDocument, as it\r
5474  * uses a simple JS string as an underlying text buffer, since the full text gets\r
5475  * swapped out on every update.\r
5476  */\r
5477 class IncrementalTextDocument {\r
5478     constructor(uri, languageId, version, content) {\r
5479         this._uri = uri;\r
5480         this._languageId = languageId;\r
5481         this._version = version;\r
5482         // Prepare Piece Tree\r
5483         const ptBuilder = new vscode_textbuffer_1.PieceTreeTextBufferBuilder();\r
5484         ptBuilder.acceptChunk(content);\r
5485         const ptFactory = ptBuilder.finish(true);\r
5486         this._tree = ptFactory.create(1 /* LF */);\r
5487     }\r
5488     get uri() {\r
5489         return this._uri;\r
5490     }\r
5491     get languageId() {\r
5492         return this._languageId;\r
5493     }\r
5494     get version() {\r
5495         return this._version;\r
5496     }\r
5497     getText(range) {\r
5498         if (range) {\r
5499             const { start, end } = range;\r
5500             // Clamp last line and last character appropriately when\r
5501             // given range is beyond the document's end\r
5502             const [clampedEndLine, clampedEndChar] = end.line + 1 > this.lineCount\r
5503                 ? [this.lineCount, this._tree.getLineLength(this.lineCount) + 1]\r
5504                 : [end.line + 1, end.character + 1];\r
5505             const ptRange = new range_1.Range(start.line + 1, start.character + 1, clampedEndLine, clampedEndChar);\r
5506             return this._tree.getValueInRange(ptRange);\r
5507         }\r
5508         return this._tree.getLinesRawContent();\r
5509     }\r
5510     update(event, version) {\r
5511         const { text, range } = event;\r
5512         if (range == null) {\r
5513             throw new Error(`FullPieceTreeTextDocument#update called with invalid event range ${range}`);\r
5514         }\r
5515         const startOffset = this.offsetAt(range.start);\r
5516         const endOffset = this.offsetAt(range.end);\r
5517         // Delete previous text at range and insert new text at appropriate offset\r
5518         this._tree.delete(startOffset, endOffset - startOffset);\r
5519         this._tree.insert(startOffset, text);\r
5520         this._version = version;\r
5521     }\r
5522     positionAt(offset) {\r
5523         const clampedOffset = Math.min(offset, this._tree.getLength());\r
5524         const ptPosition = this._tree.getPositionAt(clampedOffset);\r
5525         return vscode_languageserver_protocol_1.Position.create(ptPosition.lineNumber - 1, ptPosition.column - 1);\r
5526     }\r
5527     offsetAt(position) {\r
5528         if (position.line < 0) {\r
5529             return 0;\r
5530         }\r
5531         const clampedChar = Math.max(1, position.character + 1);\r
5532         return Math.min(this._tree.getOffsetAt(position.line + 1, clampedChar), this._tree.getLength());\r
5533     }\r
5534     get lineCount() {\r
5535         return this._tree.getLineCount();\r
5536     }\r
5537 }\r
5538 /**\r
5539  * A manager for simple text documents\r
5540  */\r
5541 class TextDocuments {\r
5542     /**\r
5543      * Create a new text document manager.\r
5544      */\r
5545     constructor(syncKind = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full) {\r
5546         this._documents = Object.create(null);\r
5547         this._syncKind = syncKind;\r
5548         this._onDidChangeContent = new vscode_languageserver_protocol_1.Emitter();\r
5549         this._onDidOpen = new vscode_languageserver_protocol_1.Emitter();\r
5550         this._onDidClose = new vscode_languageserver_protocol_1.Emitter();\r
5551         this._onDidSave = new vscode_languageserver_protocol_1.Emitter();\r
5552         this._onWillSave = new vscode_languageserver_protocol_1.Emitter();\r
5553     }\r
5554     /**\r
5555      * Returns the [TextDocumentSyncKind](#TextDocumentSyncKind) used by\r
5556      * this text document manager.\r
5557      */\r
5558     get syncKind() {\r
5559         return this._syncKind;\r
5560     }\r
5561     /**\r
5562      * An event that fires when a text document managed by this manager\r
5563      * has been opened or the content changes.\r
5564      */\r
5565     get onDidChangeContent() {\r
5566         return this._onDidChangeContent.event;\r
5567     }\r
5568     /**\r
5569      * An event that fires when a text document managed by this manager\r
5570      * has been opened.\r
5571      */\r
5572     get onDidOpen() {\r
5573         return this._onDidOpen.event;\r
5574     }\r
5575     /**\r
5576      * An event that fires when a text document managed by this manager\r
5577      * will be saved.\r
5578      */\r
5579     get onWillSave() {\r
5580         return this._onWillSave.event;\r
5581     }\r
5582     /**\r
5583      * Sets a handler that will be called if a participant wants to provide\r
5584      * edits during a text document save.\r
5585      */\r
5586     onWillSaveWaitUntil(handler) {\r
5587         this._willSaveWaitUntil = handler;\r
5588     }\r
5589     /**\r
5590      * An event that fires when a text document managed by this manager\r
5591      * has been saved.\r
5592      */\r
5593     get onDidSave() {\r
5594         return this._onDidSave.event;\r
5595     }\r
5596     /**\r
5597      * An event that fires when a text document managed by this manager\r
5598      * has been closed.\r
5599      */\r
5600     get onDidClose() {\r
5601         return this._onDidClose.event;\r
5602     }\r
5603     /**\r
5604      * Returns the document for the given URI. Returns undefined if\r
5605      * the document is not mananged by this instance.\r
5606      *\r
5607      * @param uri The text document's URI to retrieve.\r
5608      * @return the text document or `undefined`.\r
5609      */\r
5610     get(uri) {\r
5611         return this._documents[uri];\r
5612     }\r
5613     /**\r
5614      * Returns all text documents managed by this instance.\r
5615      *\r
5616      * @return all text documents.\r
5617      */\r
5618     all() {\r
5619         return Object.keys(this._documents).map(key => this._documents[key]);\r
5620     }\r
5621     /**\r
5622      * Returns the URIs of all text documents managed by this instance.\r
5623      *\r
5624      * @return the URI's of all text documents.\r
5625      */\r
5626     keys() {\r
5627         return Object.keys(this._documents);\r
5628     }\r
5629     /**\r
5630      * Listens for `low level` notification on the given connection to\r
5631      * update the text documents managed by this instance.\r
5632      *\r
5633      * @param connection The connection to listen on.\r
5634      */\r
5635     listen(connection) {\r
5636         function isUpdateableDocument(value) {\r
5637             return Is.func(value.update);\r
5638         }\r
5639         connection.__textDocumentSync = vscode_languageserver_protocol_1.TextDocumentSyncKind.Full;\r
5640         connection.onDidOpenTextDocument((event) => {\r
5641             let td = event.textDocument;\r
5642             let document;\r
5643             switch (this.syncKind) {\r
5644                 case vscode_languageserver_protocol_1.TextDocumentSyncKind.Full:\r
5645                     document = vscode_languageserver_protocol_1.TextDocument.create(td.uri, td.languageId, td.version, td.text);\r
5646                     break;\r
5647                 case vscode_languageserver_protocol_1.TextDocumentSyncKind.Incremental:\r
5648                     document = new IncrementalTextDocument(td.uri, td.languageId, td.version, td.text);\r
5649                     break;\r
5650                 default:\r
5651                     throw new Error(`Invalid TextDocumentSyncKind: ${this.syncKind}`);\r
5652             }\r
5653             this._documents[td.uri] = document;\r
5654             let toFire = Object.freeze({ document });\r
5655             this._onDidOpen.fire(toFire);\r
5656             this._onDidChangeContent.fire(toFire);\r
5657         });\r
5658         connection.onDidChangeTextDocument((event) => {\r
5659             let td = event.textDocument;\r
5660             let changes = event.contentChanges;\r
5661             if (changes.length === 0) {\r
5662                 return;\r
5663             }\r
5664             let document = this._documents[td.uri];\r
5665             if (!document || !isUpdateableDocument(document)) {\r
5666                 return;\r
5667             }\r
5668             const { version } = td;\r
5669             if (version == null || version === void 0) {\r
5670                 throw new Error(`Received document change event for ${td.uri} without valid version identifier`);\r
5671             }\r
5672             switch (this.syncKind) {\r
5673                 case vscode_languageserver_protocol_1.TextDocumentSyncKind.Full:\r
5674                     let last = changes[changes.length - 1];\r
5675                     document.update(last, version);\r
5676                     this._onDidChangeContent.fire(Object.freeze({ document }));\r
5677                     break;\r
5678                 case vscode_languageserver_protocol_1.TextDocumentSyncKind.Incremental:\r
5679                     let updatedDoc = changes.reduce((workingTextDoc, change) => {\r
5680                         workingTextDoc.update(change, version);\r
5681                         return workingTextDoc;\r
5682                     }, document);\r
5683                     this._onDidChangeContent.fire(Object.freeze({ document: updatedDoc }));\r
5684                     break;\r
5685                 case vscode_languageserver_protocol_1.TextDocumentSyncKind.None:\r
5686                     break;\r
5687             }\r
5688         });\r
5689         connection.onDidCloseTextDocument((event) => {\r
5690             let document = this._documents[event.textDocument.uri];\r
5691             if (document) {\r
5692                 delete this._documents[event.textDocument.uri];\r
5693                 this._onDidClose.fire(Object.freeze({ document }));\r
5694             }\r
5695         });\r
5696         connection.onWillSaveTextDocument((event) => {\r
5697             let document = this._documents[event.textDocument.uri];\r
5698             if (document) {\r
5699                 this._onWillSave.fire(Object.freeze({ document, reason: event.reason }));\r
5700             }\r
5701         });\r
5702         connection.onWillSaveTextDocumentWaitUntil((event, token) => {\r
5703             let document = this._documents[event.textDocument.uri];\r
5704             if (document && this._willSaveWaitUntil) {\r
5705                 return this._willSaveWaitUntil(Object.freeze({ document, reason: event.reason }), token);\r
5706             }\r
5707             else {\r
5708                 return [];\r
5709             }\r
5710         });\r
5711         connection.onDidSaveTextDocument((event) => {\r
5712             let document = this._documents[event.textDocument.uri];\r
5713             if (document) {\r
5714                 this._onDidSave.fire(Object.freeze({ document }));\r
5715             }\r
5716         });\r
5717     }\r
5718 }\r
5719 exports.TextDocuments = TextDocuments;\r
5720 /**\r
5721  * Helps tracking error message. Equal occurences of the same\r
5722  * message are only stored once. This class is for example\r
5723  * useful if text documents are validated in a loop and equal\r
5724  * error message should be folded into one.\r
5725  */\r
5726 class ErrorMessageTracker {\r
5727     constructor() {\r
5728         this._messages = Object.create(null);\r
5729     }\r
5730     /**\r
5731      * Add a message to the tracker.\r
5732      *\r
5733      * @param message The message to add.\r
5734      */\r
5735     add(message) {\r
5736         let count = this._messages[message];\r
5737         if (!count) {\r
5738             count = 0;\r
5739         }\r
5740         count++;\r
5741         this._messages[message] = count;\r
5742     }\r
5743     /**\r
5744      * Send all tracked messages to the connection's window.\r
5745      *\r
5746      * @param connection The connection established between client and server.\r
5747      */\r
5748     sendErrors(connection) {\r
5749         Object.keys(this._messages).forEach(message => {\r
5750             connection.window.showErrorMessage(message);\r
5751         });\r
5752     }\r
5753 }\r
5754 exports.ErrorMessageTracker = ErrorMessageTracker;\r
5755 var BulkRegistration;\r
5756 (function (BulkRegistration) {\r
5757     /**\r
5758      * Creates a new bulk registration.\r
5759      * @return an empty bulk registration.\r
5760      */\r
5761     function create() {\r
5762         return new BulkRegistrationImpl();\r
5763     }\r
5764     BulkRegistration.create = create;\r
5765 })(BulkRegistration = exports.BulkRegistration || (exports.BulkRegistration = {}));\r
5766 class BulkRegistrationImpl {\r
5767     constructor() {\r
5768         this._registrations = [];\r
5769         this._registered = new Set();\r
5770     }\r
5771     add(type, registerOptions) {\r
5772         const method = Is.string(type) ? type : type.method;\r
5773         if (this._registered.has(method)) {\r
5774             throw new Error(`${method} is already added to this registration`);\r
5775         }\r
5776         const id = UUID.generateUuid();\r
5777         this._registrations.push({\r
5778             id: id,\r
5779             method: method,\r
5780             registerOptions: registerOptions || {}\r
5781         });\r
5782         this._registered.add(method);\r
5783     }\r
5784     asRegistrationParams() {\r
5785         return {\r
5786             registrations: this._registrations\r
5787         };\r
5788     }\r
5789 }\r
5790 var BulkUnregistration;\r
5791 (function (BulkUnregistration) {\r
5792     function create() {\r
5793         return new BulkUnregistrationImpl(undefined, []);\r
5794     }\r
5795     BulkUnregistration.create = create;\r
5796 })(BulkUnregistration = exports.BulkUnregistration || (exports.BulkUnregistration = {}));\r
5797 class BulkUnregistrationImpl {\r
5798     constructor(_connection, unregistrations) {\r
5799         this._connection = _connection;\r
5800         this._unregistrations = new Map();\r
5801         unregistrations.forEach(unregistration => {\r
5802             this._unregistrations.set(unregistration.method, unregistration);\r
5803         });\r
5804     }\r
5805     get isAttached() {\r
5806         return !!this._connection;\r
5807     }\r
5808     attach(connection) {\r
5809         this._connection = connection;\r
5810     }\r
5811     add(unregistration) {\r
5812         this._unregistrations.set(unregistration.method, unregistration);\r
5813     }\r
5814     dispose() {\r
5815         let unregistrations = [];\r
5816         for (let unregistration of this._unregistrations.values()) {\r
5817             unregistrations.push(unregistration);\r
5818         }\r
5819         let params = {\r
5820             unregisterations: unregistrations\r
5821         };\r
5822         this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
5823             this._connection.console.info(`Bulk unregistration failed.`);\r
5824         });\r
5825     }\r
5826     disposeSingle(arg) {\r
5827         const method = Is.string(arg) ? arg : arg.method;\r
5828         const unregistration = this._unregistrations.get(method);\r
5829         if (!unregistration) {\r
5830             return false;\r
5831         }\r
5832         let params = {\r
5833             unregisterations: [unregistration]\r
5834         };\r
5835         this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(() => {\r
5836             this._unregistrations.delete(method);\r
5837         }, (_error) => {\r
5838             this._connection.console.info(`Unregistering request handler for ${unregistration.id} failed.`);\r
5839         });\r
5840         return true;\r
5841     }\r
5842 }\r
5843 class ConnectionLogger {\r
5844     constructor() {\r
5845     }\r
5846     rawAttach(connection) {\r
5847         this._rawConnection = connection;\r
5848     }\r
5849     attach(connection) {\r
5850         this._connection = connection;\r
5851     }\r
5852     get connection() {\r
5853         if (!this._connection) {\r
5854             throw new Error('Remote is not attached to a connection yet.');\r
5855         }\r
5856         return this._connection;\r
5857     }\r
5858     fillServerCapabilities(_capabilities) {\r
5859     }\r
5860     initialize(_capabilities) {\r
5861     }\r
5862     error(message) {\r
5863         this.send(vscode_languageserver_protocol_1.MessageType.Error, message);\r
5864     }\r
5865     warn(message) {\r
5866         this.send(vscode_languageserver_protocol_1.MessageType.Warning, message);\r
5867     }\r
5868     info(message) {\r
5869         this.send(vscode_languageserver_protocol_1.MessageType.Info, message);\r
5870     }\r
5871     log(message) {\r
5872         this.send(vscode_languageserver_protocol_1.MessageType.Log, message);\r
5873     }\r
5874     send(type, message) {\r
5875         if (this._rawConnection) {\r
5876             this._rawConnection.sendNotification(vscode_languageserver_protocol_1.LogMessageNotification.type, { type, message });\r
5877         }\r
5878     }\r
5879 }\r
5880 class RemoteWindowImpl {\r
5881     constructor() {\r
5882     }\r
5883     attach(connection) {\r
5884         this._connection = connection;\r
5885     }\r
5886     get connection() {\r
5887         if (!this._connection) {\r
5888             throw new Error('Remote is not attached to a connection yet.');\r
5889         }\r
5890         return this._connection;\r
5891     }\r
5892     initialize(_capabilities) {\r
5893     }\r
5894     fillServerCapabilities(_capabilities) {\r
5895     }\r
5896     showErrorMessage(message, ...actions) {\r
5897         let params = { type: vscode_languageserver_protocol_1.MessageType.Error, message, actions };\r
5898         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
5899     }\r
5900     showWarningMessage(message, ...actions) {\r
5901         let params = { type: vscode_languageserver_protocol_1.MessageType.Warning, message, actions };\r
5902         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
5903     }\r
5904     showInformationMessage(message, ...actions) {\r
5905         let params = { type: vscode_languageserver_protocol_1.MessageType.Info, message, actions };\r
5906         return this._connection.sendRequest(vscode_languageserver_protocol_1.ShowMessageRequest.type, params).then(null2Undefined);\r
5907     }\r
5908 }\r
5909 class RemoteClientImpl {\r
5910     attach(connection) {\r
5911         this._connection = connection;\r
5912     }\r
5913     get connection() {\r
5914         if (!this._connection) {\r
5915             throw new Error('Remote is not attached to a connection yet.');\r
5916         }\r
5917         return this._connection;\r
5918     }\r
5919     initialize(_capabilities) {\r
5920     }\r
5921     fillServerCapabilities(_capabilities) {\r
5922     }\r
5923     register(typeOrRegistrations, registerOptionsOrType, registerOptions) {\r
5924         if (typeOrRegistrations instanceof BulkRegistrationImpl) {\r
5925             return this.registerMany(typeOrRegistrations);\r
5926         }\r
5927         else if (typeOrRegistrations instanceof BulkUnregistrationImpl) {\r
5928             return this.registerSingle1(typeOrRegistrations, registerOptionsOrType, registerOptions);\r
5929         }\r
5930         else {\r
5931             return this.registerSingle2(typeOrRegistrations, registerOptionsOrType);\r
5932         }\r
5933     }\r
5934     registerSingle1(unregistration, type, registerOptions) {\r
5935         const method = Is.string(type) ? type : type.method;\r
5936         const id = UUID.generateUuid();\r
5937         let params = {\r
5938             registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
5939         };\r
5940         if (!unregistration.isAttached) {\r
5941             unregistration.attach(this._connection);\r
5942         }\r
5943         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
5944             unregistration.add({ id: id, method: method });\r
5945             return unregistration;\r
5946         }, (_error) => {\r
5947             this.connection.console.info(`Registering request handler for ${method} failed.`);\r
5948             return Promise.reject(_error);\r
5949         });\r
5950     }\r
5951     registerSingle2(type, registerOptions) {\r
5952         const method = Is.string(type) ? type : type.method;\r
5953         const id = UUID.generateUuid();\r
5954         let params = {\r
5955             registrations: [{ id, method, registerOptions: registerOptions || {} }]\r
5956         };\r
5957         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then((_result) => {\r
5958             return vscode_languageserver_protocol_1.Disposable.create(() => {\r
5959                 this.unregisterSingle(id, method);\r
5960             });\r
5961         }, (_error) => {\r
5962             this.connection.console.info(`Registering request handler for ${method} failed.`);\r
5963             return Promise.reject(_error);\r
5964         });\r
5965     }\r
5966     unregisterSingle(id, method) {\r
5967         let params = {\r
5968             unregisterations: [{ id, method }]\r
5969         };\r
5970         return this._connection.sendRequest(vscode_languageserver_protocol_1.UnregistrationRequest.type, params).then(undefined, (_error) => {\r
5971             this.connection.console.info(`Unregistering request handler for ${id} failed.`);\r
5972         });\r
5973     }\r
5974     registerMany(registrations) {\r
5975         let params = registrations.asRegistrationParams();\r
5976         return this._connection.sendRequest(vscode_languageserver_protocol_1.RegistrationRequest.type, params).then(() => {\r
5977             return new BulkUnregistrationImpl(this._connection, params.registrations.map(registration => { return { id: registration.id, method: registration.method }; }));\r
5978         }, (_error) => {\r
5979             this.connection.console.info(`Bulk registration failed.`);\r
5980             return Promise.reject(_error);\r
5981         });\r
5982     }\r
5983 }\r
5984 class _RemoteWorkspaceImpl {\r
5985     constructor() {\r
5986     }\r
5987     attach(connection) {\r
5988         this._connection = connection;\r
5989     }\r
5990     get connection() {\r
5991         if (!this._connection) {\r
5992             throw new Error('Remote is not attached to a connection yet.');\r
5993         }\r
5994         return this._connection;\r
5995     }\r
5996     initialize(_capabilities) {\r
5997     }\r
5998     fillServerCapabilities(_capabilities) {\r
5999     }\r
6000     applyEdit(paramOrEdit) {\r
6001         function isApplyWorkspaceEditParams(value) {\r
6002             return value && !!value.edit;\r
6003         }\r
6004         let params = isApplyWorkspaceEditParams(paramOrEdit) ? paramOrEdit : { edit: paramOrEdit };\r
6005         return this._connection.sendRequest(vscode_languageserver_protocol_1.ApplyWorkspaceEditRequest.type, params);\r
6006     }\r
6007 }\r
6008 const RemoteWorkspaceImpl = workspaceFolders_1.WorkspaceFoldersFeature(configuration_1.ConfigurationFeature(_RemoteWorkspaceImpl));\r
6009 class TracerImpl {\r
6010     constructor() {\r
6011         this._trace = vscode_languageserver_protocol_1.Trace.Off;\r
6012     }\r
6013     attach(connection) {\r
6014         this._connection = connection;\r
6015     }\r
6016     get connection() {\r
6017         if (!this._connection) {\r
6018             throw new Error('Remote is not attached to a connection yet.');\r
6019         }\r
6020         return this._connection;\r
6021     }\r
6022     initialize(_capabilities) {\r
6023     }\r
6024     fillServerCapabilities(_capabilities) {\r
6025     }\r
6026     set trace(value) {\r
6027         this._trace = value;\r
6028     }\r
6029     log(message, verbose) {\r
6030         if (this._trace === vscode_languageserver_protocol_1.Trace.Off) {\r
6031             return;\r
6032         }\r
6033         this._connection.sendNotification(vscode_languageserver_protocol_1.LogTraceNotification.type, {\r
6034             message: message,\r
6035             verbose: this._trace === vscode_languageserver_protocol_1.Trace.Verbose ? verbose : undefined\r
6036         });\r
6037     }\r
6038 }\r
6039 class TelemetryImpl {\r
6040     constructor() {\r
6041     }\r
6042     attach(connection) {\r
6043         this._connection = connection;\r
6044     }\r
6045     get connection() {\r
6046         if (!this._connection) {\r
6047             throw new Error('Remote is not attached to a connection yet.');\r
6048         }\r
6049         return this._connection;\r
6050     }\r
6051     initialize(_capabilities) {\r
6052     }\r
6053     fillServerCapabilities(_capabilities) {\r
6054     }\r
6055     logEvent(data) {\r
6056         this._connection.sendNotification(vscode_languageserver_protocol_1.TelemetryEventNotification.type, data);\r
6057     }\r
6058 }\r
6059 function combineConsoleFeatures(one, two) {\r
6060     return function (Base) {\r
6061         return two(one(Base));\r
6062     };\r
6063 }\r
6064 exports.combineConsoleFeatures = combineConsoleFeatures;\r
6065 function combineTelemetryFeatures(one, two) {\r
6066     return function (Base) {\r
6067         return two(one(Base));\r
6068     };\r
6069 }\r
6070 exports.combineTelemetryFeatures = combineTelemetryFeatures;\r
6071 function combineTracerFeatures(one, two) {\r
6072     return function (Base) {\r
6073         return two(one(Base));\r
6074     };\r
6075 }\r
6076 exports.combineTracerFeatures = combineTracerFeatures;\r
6077 function combineClientFeatures(one, two) {\r
6078     return function (Base) {\r
6079         return two(one(Base));\r
6080     };\r
6081 }\r
6082 exports.combineClientFeatures = combineClientFeatures;\r
6083 function combineWindowFeatures(one, two) {\r
6084     return function (Base) {\r
6085         return two(one(Base));\r
6086     };\r
6087 }\r
6088 exports.combineWindowFeatures = combineWindowFeatures;\r
6089 function combineWorkspaceFeatures(one, two) {\r
6090     return function (Base) {\r
6091         return two(one(Base));\r
6092     };\r
6093 }\r
6094 exports.combineWorkspaceFeatures = combineWorkspaceFeatures;\r
6095 function combineFeatures(one, two) {\r
6096     function combine(one, two, func) {\r
6097         if (one && two) {\r
6098             return func(one, two);\r
6099         }\r
6100         else if (one) {\r
6101             return one;\r
6102         }\r
6103         else {\r
6104             return two;\r
6105         }\r
6106     }\r
6107     let result = {\r
6108         __brand: 'features',\r
6109         console: combine(one.console, two.console, combineConsoleFeatures),\r
6110         tracer: combine(one.tracer, two.tracer, combineTracerFeatures),\r
6111         telemetry: combine(one.telemetry, two.telemetry, combineTelemetryFeatures),\r
6112         client: combine(one.client, two.client, combineClientFeatures),\r
6113         window: combine(one.window, two.window, combineWindowFeatures),\r
6114         workspace: combine(one.workspace, two.workspace, combineWorkspaceFeatures)\r
6115     };\r
6116     return result;\r
6117 }\r
6118 exports.combineFeatures = combineFeatures;\r
6119 function createConnection(arg1, arg2, arg3, arg4) {\r
6120     let factories;\r
6121     let input;\r
6122     let output;\r
6123     let strategy;\r
6124     if (arg1 !== void 0 && arg1.__brand === 'features') {\r
6125         factories = arg1;\r
6126         arg1 = arg2;\r
6127         arg2 = arg3;\r
6128         arg3 = arg4;\r
6129     }\r
6130     if (vscode_languageserver_protocol_1.ConnectionStrategy.is(arg1)) {\r
6131         strategy = arg1;\r
6132     }\r
6133     else {\r
6134         input = arg1;\r
6135         output = arg2;\r
6136         strategy = arg3;\r
6137     }\r
6138     return _createConnection(input, output, strategy, factories);\r
6139 }\r
6140 exports.createConnection = createConnection;\r
6141 function _createConnection(input, output, strategy, factories) {\r
6142     if (!input && !output && process.argv.length > 2) {\r
6143         let port = void 0;\r
6144         let pipeName = void 0;\r
6145         let argv = process.argv.slice(2);\r
6146         for (let i = 0; i < argv.length; i++) {\r
6147             let arg = argv[i];\r
6148             if (arg === '--node-ipc') {\r
6149                 input = new vscode_languageserver_protocol_1.IPCMessageReader(process);\r
6150                 output = new vscode_languageserver_protocol_1.IPCMessageWriter(process);\r
6151                 break;\r
6152             }\r
6153             else if (arg === '--stdio') {\r
6154                 input = process.stdin;\r
6155                 output = process.stdout;\r
6156                 break;\r
6157             }\r
6158             else if (arg === '--socket') {\r
6159                 port = parseInt(argv[i + 1]);\r
6160                 break;\r
6161             }\r
6162             else if (arg === '--pipe') {\r
6163                 pipeName = argv[i + 1];\r
6164                 break;\r
6165             }\r
6166             else {\r
6167                 var args = arg.split('=');\r
6168                 if (args[0] === '--socket') {\r
6169                     port = parseInt(args[1]);\r
6170                     break;\r
6171                 }\r
6172                 else if (args[0] === '--pipe') {\r
6173                     pipeName = args[1];\r
6174                     break;\r
6175                 }\r
6176             }\r
6177         }\r
6178         if (port) {\r
6179             let transport = vscode_languageserver_protocol_1.createServerSocketTransport(port);\r
6180             input = transport[0];\r
6181             output = transport[1];\r
6182         }\r
6183         else if (pipeName) {\r
6184             let transport = vscode_languageserver_protocol_1.createServerPipeTransport(pipeName);\r
6185             input = transport[0];\r
6186             output = transport[1];\r
6187         }\r
6188     }\r
6189     var commandLineMessage = "Use arguments of createConnection or set command line parameters: '--node-ipc', '--stdio' or '--socket={number}'";\r
6190     if (!input) {\r
6191         throw new Error("Connection input stream is not set. " + commandLineMessage);\r
6192     }\r
6193     if (!output) {\r
6194         throw new Error("Connection output stream is not set. " + commandLineMessage);\r
6195     }\r
6196     // Backwards compatibility\r
6197     if (Is.func(input.read) && Is.func(input.on)) {\r
6198         let inputStream = input;\r
6199         inputStream.on('end', () => {\r
6200             process.exit(shutdownReceived ? 0 : 1);\r
6201         });\r
6202         inputStream.on('close', () => {\r
6203             process.exit(shutdownReceived ? 0 : 1);\r
6204         });\r
6205     }\r
6206     const logger = (factories && factories.console ? new (factories.console(ConnectionLogger))() : new ConnectionLogger());\r
6207     const connection = vscode_languageserver_protocol_1.createProtocolConnection(input, output, logger, strategy);\r
6208     logger.rawAttach(connection);\r
6209     const tracer = (factories && factories.tracer ? new (factories.tracer(TracerImpl))() : new TracerImpl());\r
6210     const telemetry = (factories && factories.telemetry ? new (factories.telemetry(TelemetryImpl))() : new TelemetryImpl());\r
6211     const client = (factories && factories.client ? new (factories.client(RemoteClientImpl))() : new RemoteClientImpl());\r
6212     const remoteWindow = (factories && factories.window ? new (factories.window(RemoteWindowImpl))() : new RemoteWindowImpl());\r
6213     const workspace = (factories && factories.workspace ? new (factories.workspace(RemoteWorkspaceImpl))() : new RemoteWorkspaceImpl());\r
6214     const allRemotes = [logger, tracer, telemetry, client, remoteWindow, workspace];\r
6215     function asThenable(value) {\r
6216         if (Is.thenable(value)) {\r
6217             return value;\r
6218         }\r
6219         else {\r
6220             return Promise.resolve(value);\r
6221         }\r
6222     }\r
6223     let shutdownHandler = undefined;\r
6224     let initializeHandler = undefined;\r
6225     let exitHandler = undefined;\r
6226     let protocolConnection = {\r
6227         listen: () => connection.listen(),\r
6228         sendRequest: (type, ...params) => connection.sendRequest(Is.string(type) ? type : type.method, ...params),\r
6229         onRequest: (type, handler) => connection.onRequest(type, handler),\r
6230         sendNotification: (type, param) => {\r
6231             const method = Is.string(type) ? type : type.method;\r
6232             if (arguments.length === 1) {\r
6233                 connection.sendNotification(method);\r
6234             }\r
6235             else {\r
6236                 connection.sendNotification(method, param);\r
6237             }\r
6238         },\r
6239         onNotification: (type, handler) => connection.onNotification(type, handler),\r
6240         onInitialize: (handler) => initializeHandler = handler,\r
6241         onInitialized: (handler) => connection.onNotification(vscode_languageserver_protocol_1.InitializedNotification.type, handler),\r
6242         onShutdown: (handler) => shutdownHandler = handler,\r
6243         onExit: (handler) => exitHandler = handler,\r
6244         get console() { return logger; },\r
6245         get telemetry() { return telemetry; },\r
6246         get tracer() { return tracer; },\r
6247         get client() { return client; },\r
6248         get window() { return remoteWindow; },\r
6249         get workspace() { return workspace; },\r
6250         onDidChangeConfiguration: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeConfigurationNotification.type, handler),\r
6251         onDidChangeWatchedFiles: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeWatchedFilesNotification.type, handler),\r
6252         __textDocumentSync: undefined,\r
6253         onDidOpenTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidOpenTextDocumentNotification.type, handler),\r
6254         onDidChangeTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidChangeTextDocumentNotification.type, handler),\r
6255         onDidCloseTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidCloseTextDocumentNotification.type, handler),\r
6256         onWillSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.WillSaveTextDocumentNotification.type, handler),\r
6257         onWillSaveTextDocumentWaitUntil: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WillSaveTextDocumentWaitUntilRequest.type, handler),\r
6258         onDidSaveTextDocument: (handler) => connection.onNotification(vscode_languageserver_protocol_1.DidSaveTextDocumentNotification.type, handler),\r
6259         sendDiagnostics: (params) => connection.sendNotification(vscode_languageserver_protocol_1.PublishDiagnosticsNotification.type, params),\r
6260         onHover: (handler) => connection.onRequest(vscode_languageserver_protocol_1.HoverRequest.type, handler),\r
6261         onCompletion: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionRequest.type, handler),\r
6262         onCompletionResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CompletionResolveRequest.type, handler),\r
6263         onSignatureHelp: (handler) => connection.onRequest(vscode_languageserver_protocol_1.SignatureHelpRequest.type, handler),\r
6264         onDeclaration: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DeclarationRequest.type, handler),\r
6265         onDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DefinitionRequest.type, handler),\r
6266         onTypeDefinition: (handler) => connection.onRequest(vscode_languageserver_protocol_1.TypeDefinitionRequest.type, handler),\r
6267         onImplementation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ImplementationRequest.type, handler),\r
6268         onReferences: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ReferencesRequest.type, handler),\r
6269         onDocumentHighlight: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentHighlightRequest.type, handler),\r
6270         onDocumentSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentSymbolRequest.type, handler),\r
6271         onWorkspaceSymbol: (handler) => connection.onRequest(vscode_languageserver_protocol_1.WorkspaceSymbolRequest.type, handler),\r
6272         onCodeAction: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeActionRequest.type, handler),\r
6273         onCodeLens: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensRequest.type, handler),\r
6274         onCodeLensResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.CodeLensResolveRequest.type, handler),\r
6275         onDocumentFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentFormattingRequest.type, handler),\r
6276         onDocumentRangeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentRangeFormattingRequest.type, handler),\r
6277         onDocumentOnTypeFormatting: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentOnTypeFormattingRequest.type, handler),\r
6278         onRenameRequest: (handler) => connection.onRequest(vscode_languageserver_protocol_1.RenameRequest.type, handler),\r
6279         onPrepareRename: (handler) => connection.onRequest(vscode_languageserver_protocol_1.PrepareRenameRequest.type, handler),\r
6280         onDocumentLinks: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkRequest.type, handler),\r
6281         onDocumentLinkResolve: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentLinkResolveRequest.type, handler),\r
6282         onDocumentColor: (handler) => connection.onRequest(vscode_languageserver_protocol_1.DocumentColorRequest.type, handler),\r
6283         onColorPresentation: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ColorPresentationRequest.type, handler),\r
6284         onFoldingRanges: (handler) => connection.onRequest(vscode_languageserver_protocol_1.FoldingRangeRequest.type, handler),\r
6285         onExecuteCommand: (handler) => connection.onRequest(vscode_languageserver_protocol_1.ExecuteCommandRequest.type, handler),\r
6286         dispose: () => connection.dispose()\r
6287     };\r
6288     for (let remote of allRemotes) {\r
6289         remote.attach(protocolConnection);\r
6290     }\r
6291     connection.onRequest(vscode_languageserver_protocol_1.InitializeRequest.type, (params) => {\r
6292         const processId = params.processId;\r
6293         if (Is.number(processId) && exitTimer === void 0) {\r
6294             // We received a parent process id. Set up a timer to periodically check\r
6295             // if the parent is still alive.\r
6296             setInterval(() => {\r
6297                 try {\r
6298                     process.kill(processId, 0);\r
6299                 }\r
6300                 catch (ex) {\r
6301                     // Parent process doesn't exist anymore. Exit the server.\r
6302                     process.exit(shutdownReceived ? 0 : 1);\r
6303                 }\r
6304             }, 3000);\r
6305         }\r
6306         if (Is.string(params.trace)) {\r
6307             tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.trace);\r
6308         }\r
6309         for (let remote of allRemotes) {\r
6310             remote.initialize(params.capabilities);\r
6311         }\r
6312         if (initializeHandler) {\r
6313             let result = initializeHandler(params, new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
6314             return asThenable(result).then((value) => {\r
6315                 if (value instanceof vscode_languageserver_protocol_1.ResponseError) {\r
6316                     return value;\r
6317                 }\r
6318                 let result = value;\r
6319                 if (!result) {\r
6320                     result = { capabilities: {} };\r
6321                 }\r
6322                 let capabilities = result.capabilities;\r
6323                 if (!capabilities) {\r
6324                     capabilities = {};\r
6325                     result.capabilities = capabilities;\r
6326                 }\r
6327                 if (capabilities.textDocumentSync === void 0 || capabilities.textDocumentSync === null) {\r
6328                     capabilities.textDocumentSync = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
6329                 }\r
6330                 else if (!Is.number(capabilities.textDocumentSync) && !Is.number(capabilities.textDocumentSync.change)) {\r
6331                     capabilities.textDocumentSync.change = Is.number(protocolConnection.__textDocumentSync) ? protocolConnection.__textDocumentSync : vscode_languageserver_protocol_1.TextDocumentSyncKind.None;\r
6332                 }\r
6333                 for (let remote of allRemotes) {\r
6334                     remote.fillServerCapabilities(capabilities);\r
6335                 }\r
6336                 return result;\r
6337             });\r
6338         }\r
6339         else {\r
6340             let result = { capabilities: { textDocumentSync: vscode_languageserver_protocol_1.TextDocumentSyncKind.None } };\r
6341             for (let remote of allRemotes) {\r
6342                 remote.fillServerCapabilities(result.capabilities);\r
6343             }\r
6344             return result;\r
6345         }\r
6346     });\r
6347     connection.onRequest(vscode_languageserver_protocol_1.ShutdownRequest.type, () => {\r
6348         shutdownReceived = true;\r
6349         if (shutdownHandler) {\r
6350             return shutdownHandler(new vscode_languageserver_protocol_1.CancellationTokenSource().token);\r
6351         }\r
6352         else {\r
6353             return undefined;\r
6354         }\r
6355     });\r
6356     connection.onNotification(vscode_languageserver_protocol_1.ExitNotification.type, () => {\r
6357         try {\r
6358             if (exitHandler) {\r
6359                 exitHandler();\r
6360             }\r
6361         }\r
6362         finally {\r
6363             if (shutdownReceived) {\r
6364                 process.exit(0);\r
6365             }\r
6366             else {\r
6367                 process.exit(1);\r
6368             }\r
6369         }\r
6370     });\r
6371     connection.onNotification(vscode_languageserver_protocol_1.SetTraceNotification.type, (params) => {\r
6372         tracer.trace = vscode_languageserver_protocol_1.Trace.fromString(params.value);\r
6373     });\r
6374     return protocolConnection;\r
6375 }\r
6376 // Export the protocol currently in proposed state.\r
6377 const proposed_progress_1 = __webpack_require__(48);\r
6378 var ProposedFeatures;\r
6379 (function (ProposedFeatures) {\r
6380     ProposedFeatures.all = {\r
6381         __brand: 'features',\r
6382         window: proposed_progress_1.ProgressFeature\r
6383     };\r
6384 })(ProposedFeatures = exports.ProposedFeatures || (exports.ProposedFeatures = {}));\r
6385
6386
6387 /***/ }),
6388 /* 35 */
6389 /***/ (function(module, exports, __webpack_require__) {
6390
6391 "use strict";
6392 /* --------------------------------------------------------------------------------------------\r
6393  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6394  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6395  * ------------------------------------------------------------------------------------------ */\r
6396 \r
6397 Object.defineProperty(exports, "__esModule", { value: true });\r
6398 const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
6399 const Is = __webpack_require__(36);\r
6400 exports.ConfigurationFeature = (Base) => {\r
6401     return class extends Base {\r
6402         getConfiguration(arg) {\r
6403             if (!arg) {\r
6404                 return this._getConfiguration({});\r
6405             }\r
6406             else if (Is.string(arg)) {\r
6407                 return this._getConfiguration({ section: arg });\r
6408             }\r
6409             else {\r
6410                 return this._getConfiguration(arg);\r
6411             }\r
6412         }\r
6413         _getConfiguration(arg) {\r
6414             let params = {\r
6415                 items: Array.isArray(arg) ? arg : [arg]\r
6416             };\r
6417             return this.connection.sendRequest(vscode_languageserver_protocol_1.ConfigurationRequest.type, params).then((result) => {\r
6418                 return Array.isArray(arg) ? result : result[0];\r
6419             });\r
6420         }\r
6421     };\r
6422 };\r
6423
6424
6425 /***/ }),
6426 /* 36 */
6427 /***/ (function(module, exports, __webpack_require__) {
6428
6429 "use strict";
6430 /* --------------------------------------------------------------------------------------------\r
6431  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6432  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6433  * ------------------------------------------------------------------------------------------ */\r
6434 \r
6435 Object.defineProperty(exports, "__esModule", { value: true });\r
6436 function boolean(value) {\r
6437     return value === true || value === false;\r
6438 }\r
6439 exports.boolean = boolean;\r
6440 function string(value) {\r
6441     return typeof value === 'string' || value instanceof String;\r
6442 }\r
6443 exports.string = string;\r
6444 function number(value) {\r
6445     return typeof value === 'number' || value instanceof Number;\r
6446 }\r
6447 exports.number = number;\r
6448 function error(value) {\r
6449     return value instanceof Error;\r
6450 }\r
6451 exports.error = error;\r
6452 function func(value) {\r
6453     return typeof value === 'function';\r
6454 }\r
6455 exports.func = func;\r
6456 function array(value) {\r
6457     return Array.isArray(value);\r
6458 }\r
6459 exports.array = array;\r
6460 function stringArray(value) {\r
6461     return array(value) && value.every(elem => string(elem));\r
6462 }\r
6463 exports.stringArray = stringArray;\r
6464 function typedArray(value, check) {\r
6465     return Array.isArray(value) && value.every(check);\r
6466 }\r
6467 exports.typedArray = typedArray;\r
6468 function thenable(value) {\r
6469     return value && func(value.then);\r
6470 }\r
6471 exports.thenable = thenable;\r
6472
6473
6474 /***/ }),
6475 /* 37 */
6476 /***/ (function(module, exports, __webpack_require__) {
6477
6478 "use strict";
6479 /* --------------------------------------------------------------------------------------------\r
6480  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6481  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6482  * ------------------------------------------------------------------------------------------ */\r
6483 \r
6484 Object.defineProperty(exports, "__esModule", { value: true });\r
6485 const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
6486 exports.WorkspaceFoldersFeature = (Base) => {\r
6487     return class extends Base {\r
6488         initialize(capabilities) {\r
6489             let workspaceCapabilities = capabilities.workspace;\r
6490             if (workspaceCapabilities && workspaceCapabilities.workspaceFolders) {\r
6491                 this._onDidChangeWorkspaceFolders = new vscode_languageserver_protocol_1.Emitter();\r
6492                 this.connection.onNotification(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type, (params) => {\r
6493                     this._onDidChangeWorkspaceFolders.fire(params.event);\r
6494                 });\r
6495             }\r
6496         }\r
6497         getWorkspaceFolders() {\r
6498             return this.connection.sendRequest(vscode_languageserver_protocol_1.WorkspaceFoldersRequest.type);\r
6499         }\r
6500         get onDidChangeWorkspaceFolders() {\r
6501             if (!this._onDidChangeWorkspaceFolders) {\r
6502                 throw new Error('Client doesn\'t support sending workspace folder change events.');\r
6503             }\r
6504             if (!this._unregistration) {\r
6505                 this._unregistration = this.connection.client.register(vscode_languageserver_protocol_1.DidChangeWorkspaceFoldersNotification.type);\r
6506             }\r
6507             return this._onDidChangeWorkspaceFolders.event;\r
6508         }\r
6509     };\r
6510 };\r
6511
6512
6513 /***/ }),
6514 /* 38 */
6515 /***/ (function(module, exports, __webpack_require__) {
6516
6517 "use strict";
6518 /*---------------------------------------------------------------------------------------------\r
6519  *  Copyright (c) Microsoft Corporation. All rights reserved.\r
6520  *  Licensed under the MIT License. See License.txt in the project root for license information.\r
6521  *--------------------------------------------------------------------------------------------*/\r
6522 \r
6523 Object.defineProperty(exports, "__esModule", { value: true });\r
6524 class ValueUUID {\r
6525     constructor(_value) {\r
6526         this._value = _value;\r
6527         // empty\r
6528     }\r
6529     asHex() {\r
6530         return this._value;\r
6531     }\r
6532     equals(other) {\r
6533         return this.asHex() === other.asHex();\r
6534     }\r
6535 }\r
6536 class V4UUID extends ValueUUID {\r
6537     constructor() {\r
6538         super([\r
6539             V4UUID._randomHex(),\r
6540             V4UUID._randomHex(),\r
6541             V4UUID._randomHex(),\r
6542             V4UUID._randomHex(),\r
6543             V4UUID._randomHex(),\r
6544             V4UUID._randomHex(),\r
6545             V4UUID._randomHex(),\r
6546             V4UUID._randomHex(),\r
6547             '-',\r
6548             V4UUID._randomHex(),\r
6549             V4UUID._randomHex(),\r
6550             V4UUID._randomHex(),\r
6551             V4UUID._randomHex(),\r
6552             '-',\r
6553             '4',\r
6554             V4UUID._randomHex(),\r
6555             V4UUID._randomHex(),\r
6556             V4UUID._randomHex(),\r
6557             '-',\r
6558             V4UUID._oneOf(V4UUID._timeHighBits),\r
6559             V4UUID._randomHex(),\r
6560             V4UUID._randomHex(),\r
6561             V4UUID._randomHex(),\r
6562             '-',\r
6563             V4UUID._randomHex(),\r
6564             V4UUID._randomHex(),\r
6565             V4UUID._randomHex(),\r
6566             V4UUID._randomHex(),\r
6567             V4UUID._randomHex(),\r
6568             V4UUID._randomHex(),\r
6569             V4UUID._randomHex(),\r
6570             V4UUID._randomHex(),\r
6571             V4UUID._randomHex(),\r
6572             V4UUID._randomHex(),\r
6573             V4UUID._randomHex(),\r
6574             V4UUID._randomHex(),\r
6575         ].join(''));\r
6576     }\r
6577     static _oneOf(array) {\r
6578         return array[Math.floor(array.length * Math.random())];\r
6579     }\r
6580     static _randomHex() {\r
6581         return V4UUID._oneOf(V4UUID._chars);\r
6582     }\r
6583 }\r
6584 V4UUID._chars = ['0', '1', '2', '3', '4', '5', '6', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'];\r
6585 V4UUID._timeHighBits = ['8', '9', 'a', 'b'];\r
6586 /**\r
6587  * An empty UUID that contains only zeros.\r
6588  */\r
6589 exports.empty = new ValueUUID('00000000-0000-0000-0000-000000000000');\r
6590 function v4() {\r
6591     return new V4UUID();\r
6592 }\r
6593 exports.v4 = v4;\r
6594 const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;\r
6595 function isUUID(value) {\r
6596     return _UUIDPattern.test(value);\r
6597 }\r
6598 exports.isUUID = isUUID;\r
6599 /**\r
6600  * Parses a UUID that is of the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.\r
6601  * @param value A uuid string.\r
6602  */\r
6603 function parse(value) {\r
6604     if (!isUUID(value)) {\r
6605         throw new Error('invalid uuid');\r
6606     }\r
6607     return new ValueUUID(value);\r
6608 }\r
6609 exports.parse = parse;\r
6610 function generateUuid() {\r
6611     return v4().asHex();\r
6612 }\r
6613 exports.generateUuid = generateUuid;\r
6614
6615
6616 /***/ }),
6617 /* 39 */
6618 /***/ (function(module, exports, __webpack_require__) {
6619
6620 "use strict";
6621 /* WEBPACK VAR INJECTION */(function(__filename) {/* --------------------------------------------------------------------------------------------\r
6622  * Copyright (c) Microsoft Corporation. All rights reserved.\r
6623  * Licensed under the MIT License. See License.txt in the project root for license information.\r
6624  * ------------------------------------------------------------------------------------------ */\r
6625 \r
6626 Object.defineProperty(exports, "__esModule", { value: true });\r
6627 const url = __webpack_require__(40);\r
6628 const path = __webpack_require__(1);\r
6629 const fs = __webpack_require__(2);\r
6630 const child_process_1 = __webpack_require__(41);\r
6631 /**\r
6632  * @deprecated Use the `vscode-uri` npm module which provides a more\r
6633  * complete implementation of handling VS Code URIs.\r
6634  */\r
6635 function uriToFilePath(uri) {\r
6636     let parsed = url.parse(uri);\r
6637     if (parsed.protocol !== 'file:' || !parsed.path) {\r
6638         return undefined;\r
6639     }\r
6640     let segments = parsed.path.split('/');\r
6641     for (var i = 0, len = segments.length; i < len; i++) {\r
6642         segments[i] = decodeURIComponent(segments[i]);\r
6643     }\r
6644     if (process.platform === 'win32' && segments.length > 1) {\r
6645         let first = segments[0];\r
6646         let second = segments[1];\r
6647         // Do we have a drive letter and we started with a / which is the\r
6648         // case if the first segement is empty (see split above)\r
6649         if (first.length === 0 && second.length > 1 && second[1] === ':') {\r
6650             // Remove first slash\r
6651             segments.shift();\r
6652         }\r
6653     }\r
6654     return path.normalize(segments.join('/'));\r
6655 }\r
6656 exports.uriToFilePath = uriToFilePath;\r
6657 function isWindows() {\r
6658     return process.platform === 'win32';\r
6659 }\r
6660 function resolve(moduleName, nodePath, cwd, tracer) {\r
6661     const nodePathKey = 'NODE_PATH';\r
6662     const app = [\r
6663         "var p = process;",\r
6664         "p.on('message',function(m){",\r
6665         "if(m.c==='e'){",\r
6666         "p.exit(0);",\r
6667         "}",\r
6668         "else if(m.c==='rs'){",\r
6669         "try{",\r
6670         "var r=require.resolve(m.a);",\r
6671         "p.send({c:'r',s:true,r:r});",\r
6672         "}",\r
6673         "catch(err){",\r
6674         "p.send({c:'r',s:false});",\r
6675         "}",\r
6676         "}",\r
6677         "});"\r
6678     ].join('');\r
6679     return new Promise((resolve, reject) => {\r
6680         let env = process.env;\r
6681         let newEnv = Object.create(null);\r
6682         Object.keys(env).forEach(key => newEnv[key] = env[key]);\r
6683         if (nodePath) {\r
6684             if (newEnv[nodePathKey]) {\r
6685                 newEnv[nodePathKey] = nodePath + path.delimiter + newEnv[nodePathKey];\r
6686             }\r
6687             else {\r
6688                 newEnv[nodePathKey] = nodePath;\r
6689             }\r
6690             if (tracer) {\r
6691                 tracer(`NODE_PATH value is: ${newEnv[nodePathKey]}`);\r
6692             }\r
6693         }\r
6694         newEnv['ELECTRON_RUN_AS_NODE'] = '1';\r
6695         try {\r
6696             let cp = child_process_1.fork('', [], {\r
6697                 cwd: cwd,\r
6698                 env: newEnv,\r
6699                 execArgv: ['-e', app]\r
6700             });\r
6701             if (cp.pid === void 0) {\r
6702                 reject(new Error(`Starting process to resolve node module  ${moduleName} failed`));\r
6703                 return;\r
6704             }\r
6705             cp.on('error', (error) => {\r
6706                 reject(error);\r
6707             });\r
6708             cp.on('message', (message) => {\r
6709                 if (message.c === 'r') {\r
6710                     cp.send({ c: 'e' });\r
6711                     if (message.s) {\r
6712                         resolve(message.r);\r
6713                     }\r
6714                     else {\r
6715                         reject(new Error(`Failed to resolve module: ${moduleName}`));\r
6716                     }\r
6717                 }\r
6718             });\r
6719             let message = {\r
6720                 c: 'rs',\r
6721                 a: moduleName\r
6722             };\r
6723             cp.send(message);\r
6724         }\r
6725         catch (error) {\r
6726             reject(error);\r
6727         }\r
6728     });\r
6729 }\r
6730 exports.resolve = resolve;\r
6731 function resolveGlobalNodePath(tracer) {\r
6732     let npmCommand = 'npm';\r
6733     let options = {\r
6734         encoding: 'utf8'\r
6735     };\r
6736     if (isWindows()) {\r
6737         npmCommand = 'npm.cmd';\r
6738         options.shell = true;\r
6739     }\r
6740     let handler = () => { };\r
6741     try {\r
6742         process.on('SIGPIPE', handler);\r
6743         let stdout = child_process_1.spawnSync(npmCommand, ['config', 'get', 'prefix'], options).stdout;\r
6744         if (!stdout) {\r
6745             if (tracer) {\r
6746                 tracer(`'npm config get prefix' didn't return a value.`);\r
6747             }\r
6748             return undefined;\r
6749         }\r
6750         let prefix = stdout.trim();\r
6751         if (tracer) {\r
6752             tracer(`'npm config get prefix' value is: ${prefix}`);\r
6753         }\r
6754         if (prefix.length > 0) {\r
6755             if (isWindows()) {\r
6756                 return path.join(prefix, 'node_modules');\r
6757             }\r
6758             else {\r
6759                 return path.join(prefix, 'lib', 'node_modules');\r
6760             }\r
6761         }\r
6762         return undefined;\r
6763     }\r
6764     catch (err) {\r
6765         return undefined;\r
6766     }\r
6767     finally {\r
6768         process.removeListener('SIGPIPE', handler);\r
6769     }\r
6770 }\r
6771 exports.resolveGlobalNodePath = resolveGlobalNodePath;\r
6772 function resolveGlobalYarnPath(tracer) {\r
6773     let yarnCommand = 'yarn';\r
6774     let options = {\r
6775         encoding: 'utf8'\r
6776     };\r
6777     if (isWindows()) {\r
6778         yarnCommand = 'yarn.cmd';\r
6779         options.shell = true;\r
6780     }\r
6781     let handler = () => { };\r
6782     try {\r
6783         process.on('SIGPIPE', handler);\r
6784         let results = child_process_1.spawnSync(yarnCommand, ['global', 'dir', '--json'], options);\r
6785         let stdout = results.stdout;\r
6786         if (!stdout) {\r
6787             if (tracer) {\r
6788                 tracer(`'yarn global dir' didn't return a value.`);\r
6789                 if (results.stderr) {\r
6790                     tracer(results.stderr);\r
6791                 }\r
6792             }\r
6793             return undefined;\r
6794         }\r
6795         let lines = stdout.trim().split(/\r?\n/);\r
6796         for (let line of lines) {\r
6797             try {\r
6798                 let yarn = JSON.parse(line);\r
6799                 if (yarn.type === 'log') {\r
6800                     return path.join(yarn.data, 'node_modules');\r
6801                 }\r
6802             }\r
6803             catch (e) {\r
6804                 // Do nothing. Ignore the line\r
6805             }\r
6806         }\r
6807         return undefined;\r
6808     }\r
6809     catch (err) {\r
6810         return undefined;\r
6811     }\r
6812     finally {\r
6813         process.removeListener('SIGPIPE', handler);\r
6814     }\r
6815 }\r
6816 exports.resolveGlobalYarnPath = resolveGlobalYarnPath;\r
6817 var FileSystem;\r
6818 (function (FileSystem) {\r
6819     let _isCaseSensitive = undefined;\r
6820     function isCaseSensitive() {\r
6821         if (_isCaseSensitive !== void 0) {\r
6822             return _isCaseSensitive;\r
6823         }\r
6824         if (process.platform === 'win32') {\r
6825             _isCaseSensitive = false;\r
6826         }\r
6827         else {\r
6828             // convert current file name to upper case / lower case and check if file exists\r
6829             // (guards against cases when name is already all uppercase or lowercase)\r
6830             _isCaseSensitive = !fs.existsSync(__filename.toUpperCase()) || !fs.existsSync(__filename.toLowerCase());\r
6831         }\r
6832         return _isCaseSensitive;\r
6833     }\r
6834     FileSystem.isCaseSensitive = isCaseSensitive;\r
6835     function isParent(parent, child) {\r
6836         if (isCaseSensitive()) {\r
6837             return path.normalize(child).indexOf(path.normalize(parent)) === 0;\r
6838         }\r
6839         else {\r
6840             return path.normalize(child).toLowerCase().indexOf(path.normalize(parent).toLowerCase()) == 0;\r
6841         }\r
6842     }\r
6843     FileSystem.isParent = isParent;\r
6844 })(FileSystem = exports.FileSystem || (exports.FileSystem = {}));\r
6845 function resolveModulePath(workspaceRoot, moduleName, nodePath, tracer) {\r
6846     if (nodePath) {\r
6847         if (!path.isAbsolute(nodePath)) {\r
6848             nodePath = path.join(workspaceRoot, nodePath);\r
6849         }\r
6850         return resolve(moduleName, nodePath, nodePath, tracer).then((value) => {\r
6851             if (FileSystem.isParent(nodePath, value)) {\r
6852                 return value;\r
6853             }\r
6854             else {\r
6855                 return Promise.reject(new Error(`Failed to load ${moduleName} from node path location.`));\r
6856             }\r
6857         }).then(undefined, (_error) => {\r
6858             return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
6859         });\r
6860     }\r
6861     else {\r
6862         return resolve(moduleName, resolveGlobalNodePath(tracer), workspaceRoot, tracer);\r
6863     }\r
6864 }\r
6865 exports.resolveModulePath = resolveModulePath;\r
6866
6867 /* WEBPACK VAR INJECTION */}.call(this, "/index.js"))
6868
6869 /***/ }),
6870 /* 40 */
6871 /***/ (function(module, exports) {
6872
6873 module.exports = require("url");
6874
6875 /***/ }),
6876 /* 41 */
6877 /***/ (function(module, exports) {
6878
6879 module.exports = require("child_process");
6880
6881 /***/ }),
6882 /* 42 */
6883 /***/ (function(module, exports, __webpack_require__) {
6884
6885 "use strict";
6886
6887 function __export(m) {
6888     for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
6889 }
6890 Object.defineProperty(exports, "__esModule", { value: true });
6891 __export(__webpack_require__(43));
6892 __export(__webpack_require__(46));
6893
6894
6895 /***/ }),
6896 /* 43 */
6897 /***/ (function(module, exports, __webpack_require__) {
6898
6899 "use strict";
6900
6901 /*---------------------------------------------------------------------------------------------
6902  *  Copyright (c) Microsoft Corporation. All rights reserved.
6903  *  Licensed under the MIT License. See License.txt in the project root for license information.
6904  *--------------------------------------------------------------------------------------------*/
6905 Object.defineProperty(exports, "__esModule", { value: true });
6906 const position_1 = __webpack_require__(44);
6907 const rbTreeBase_1 = __webpack_require__(45);
6908 // const lfRegex = new RegExp(/\r\n|\r|\n/g);
6909 exports.AverageBufferSize = 65535;
6910 function createUintArray(arr) {
6911     let r;
6912     if (arr[arr.length - 1] < 65536) {
6913         r = new Uint16Array(arr.length);
6914     }
6915     else {
6916         r = new Uint32Array(arr.length);
6917     }
6918     r.set(arr, 0);
6919     return r;
6920 }
6921 exports.createUintArray = createUintArray;
6922 class LineStarts {
6923     constructor(lineStarts, cr, lf, crlf, isBasicASCII) {
6924         this.lineStarts = lineStarts;
6925         this.cr = cr;
6926         this.lf = lf;
6927         this.crlf = crlf;
6928         this.isBasicASCII = isBasicASCII;
6929     }
6930 }
6931 exports.LineStarts = LineStarts;
6932 function createLineStartsFast(str, readonly = true) {
6933     let r = [0], rLength = 1;
6934     for (let i = 0, len = str.length; i < len; i++) {
6935         const chr = str.charCodeAt(i);
6936         if (chr === 13 /* CarriageReturn */) {
6937             if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
6938                 // \r\n... case
6939                 r[rLength++] = i + 2;
6940                 i++; // skip \n
6941             }
6942             else {
6943                 // \r... case
6944                 r[rLength++] = i + 1;
6945             }
6946         }
6947         else if (chr === 10 /* LineFeed */) {
6948             r[rLength++] = i + 1;
6949         }
6950     }
6951     if (readonly) {
6952         return createUintArray(r);
6953     }
6954     else {
6955         return r;
6956     }
6957 }
6958 exports.createLineStartsFast = createLineStartsFast;
6959 function createLineStarts(r, str) {
6960     r.length = 0;
6961     r[0] = 0;
6962     let rLength = 1;
6963     let cr = 0, lf = 0, crlf = 0;
6964     let isBasicASCII = true;
6965     for (let i = 0, len = str.length; i < len; i++) {
6966         const chr = str.charCodeAt(i);
6967         if (chr === 13 /* CarriageReturn */) {
6968             if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
6969                 // \r\n... case
6970                 crlf++;
6971                 r[rLength++] = i + 2;
6972                 i++; // skip \n
6973             }
6974             else {
6975                 cr++;
6976                 // \r... case
6977                 r[rLength++] = i + 1;
6978             }
6979         }
6980         else if (chr === 10 /* LineFeed */) {
6981             lf++;
6982             r[rLength++] = i + 1;
6983         }
6984         else {
6985             if (isBasicASCII) {
6986                 if (chr !== 9 /* Tab */ && (chr < 32 || chr > 126)) {
6987                     isBasicASCII = false;
6988                 }
6989             }
6990         }
6991     }
6992     const result = new LineStarts(createUintArray(r), cr, lf, crlf, isBasicASCII);
6993     r.length = 0;
6994     return result;
6995 }
6996 exports.createLineStarts = createLineStarts;
6997 class Piece {
6998     constructor(bufferIndex, start, end, lineFeedCnt, length) {
6999         this.bufferIndex = bufferIndex;
7000         this.start = start;
7001         this.end = end;
7002         this.lineFeedCnt = lineFeedCnt;
7003         this.length = length;
7004     }
7005 }
7006 exports.Piece = Piece;
7007 class StringBuffer {
7008     constructor(buffer, lineStarts) {
7009         this.buffer = buffer;
7010         this.lineStarts = lineStarts;
7011     }
7012 }
7013 exports.StringBuffer = StringBuffer;
7014 /**
7015  * Readonly snapshot for piece tree.
7016  * In a real multiple thread environment, to make snapshot reading always work correctly, we need to
7017  * 1. Make TreeNode.piece immutable, then reading and writing can run in parallel.
7018  * 2. TreeNode/Buffers normalization should not happen during snapshot reading.
7019  */
7020 class PieceTreeSnapshot {
7021     constructor(tree, BOM) {
7022         this._pieces = [];
7023         this._tree = tree;
7024         this._BOM = BOM;
7025         this._index = 0;
7026         if (tree.root !== rbTreeBase_1.SENTINEL) {
7027             tree.iterate(tree.root, node => {
7028                 if (node !== rbTreeBase_1.SENTINEL) {
7029                     this._pieces.push(node.piece);
7030                 }
7031                 return true;
7032             });
7033         }
7034     }
7035     read() {
7036         if (this._pieces.length === 0) {
7037             if (this._index === 0) {
7038                 this._index++;
7039                 return this._BOM;
7040             }
7041             else {
7042                 return null;
7043             }
7044         }
7045         if (this._index > this._pieces.length - 1) {
7046             return null;
7047         }
7048         if (this._index === 0) {
7049             return this._BOM + this._tree.getPieceContent(this._pieces[this._index++]);
7050         }
7051         return this._tree.getPieceContent(this._pieces[this._index++]);
7052     }
7053 }
7054 class PieceTreeSearchCache {
7055     constructor(limit) {
7056         this._limit = limit;
7057         this._cache = [];
7058     }
7059     get(offset) {
7060         for (let i = this._cache.length - 1; i >= 0; i--) {
7061             let nodePos = this._cache[i];
7062             if (nodePos.nodeStartOffset <= offset && nodePos.nodeStartOffset + nodePos.node.piece.length >= offset) {
7063                 return nodePos;
7064             }
7065         }
7066         return null;
7067     }
7068     get2(lineNumber) {
7069         for (let i = this._cache.length - 1; i >= 0; i--) {
7070             let nodePos = this._cache[i];
7071             if (nodePos.nodeStartLineNumber && nodePos.nodeStartLineNumber < lineNumber && nodePos.nodeStartLineNumber + nodePos.node.piece.lineFeedCnt >= lineNumber) {
7072                 return nodePos;
7073             }
7074         }
7075         return null;
7076     }
7077     set(nodePosition) {
7078         if (this._cache.length >= this._limit) {
7079             this._cache.shift();
7080         }
7081         this._cache.push(nodePosition);
7082     }
7083     valdiate(offset) {
7084         let hasInvalidVal = false;
7085         let tmp = this._cache;
7086         for (let i = 0; i < tmp.length; i++) {
7087             let nodePos = tmp[i];
7088             if (nodePos.node.parent === null || nodePos.nodeStartOffset >= offset) {
7089                 tmp[i] = null;
7090                 hasInvalidVal = true;
7091                 continue;
7092             }
7093         }
7094         if (hasInvalidVal) {
7095             let newArr = [];
7096             for (const entry of tmp) {
7097                 if (entry !== null) {
7098                     newArr.push(entry);
7099                 }
7100             }
7101             this._cache = newArr;
7102         }
7103     }
7104 }
7105 class PieceTreeBase {
7106     constructor(chunks, eol, eolNormalized) {
7107         this.create(chunks, eol, eolNormalized);
7108     }
7109     create(chunks, eol, eolNormalized) {
7110         this._buffers = [
7111             new StringBuffer('', [0])
7112         ];
7113         this._lastChangeBufferPos = { line: 0, column: 0 };
7114         this.root = rbTreeBase_1.SENTINEL;
7115         this._lineCnt = 1;
7116         this._length = 0;
7117         this._EOL = eol;
7118         this._EOLLength = eol.length;
7119         this._EOLNormalized = eolNormalized;
7120         let lastNode = null;
7121         for (let i = 0, len = chunks.length; i < len; i++) {
7122             if (chunks[i].buffer.length > 0) {
7123                 if (!chunks[i].lineStarts) {
7124                     chunks[i].lineStarts = createLineStartsFast(chunks[i].buffer);
7125                 }
7126                 let piece = new Piece(i + 1, { line: 0, column: 0 }, { line: chunks[i].lineStarts.length - 1, column: chunks[i].buffer.length - chunks[i].lineStarts[chunks[i].lineStarts.length - 1] }, chunks[i].lineStarts.length - 1, chunks[i].buffer.length);
7127                 this._buffers.push(chunks[i]);
7128                 lastNode = this.rbInsertRight(lastNode, piece);
7129             }
7130         }
7131         this._searchCache = new PieceTreeSearchCache(1);
7132         this._lastVisitedLine = { lineNumber: 0, value: '' };
7133         this.computeBufferMetadata();
7134     }
7135     normalizeEOL(eol) {
7136         let averageBufferSize = exports.AverageBufferSize;
7137         let min = averageBufferSize - Math.floor(averageBufferSize / 3);
7138         let max = min * 2;
7139         let tempChunk = '';
7140         let tempChunkLen = 0;
7141         let chunks = [];
7142         this.iterate(this.root, node => {
7143             let str = this.getNodeContent(node);
7144             let len = str.length;
7145             if (tempChunkLen <= min || tempChunkLen + len < max) {
7146                 tempChunk += str;
7147                 tempChunkLen += len;
7148                 return true;
7149             }
7150             // flush anyways
7151             let text = tempChunk.replace(/\r\n|\r|\n/g, eol);
7152             chunks.push(new StringBuffer(text, createLineStartsFast(text)));
7153             tempChunk = str;
7154             tempChunkLen = len;
7155             return true;
7156         });
7157         if (tempChunkLen > 0) {
7158             let text = tempChunk.replace(/\r\n|\r|\n/g, eol);
7159             chunks.push(new StringBuffer(text, createLineStartsFast(text)));
7160         }
7161         this.create(chunks, eol, true);
7162     }
7163     // #region Buffer API
7164     getEOL() {
7165         return this._EOL;
7166     }
7167     setEOL(newEOL) {
7168         this._EOL = newEOL;
7169         this._EOLLength = this._EOL.length;
7170         this.normalizeEOL(newEOL);
7171     }
7172     createSnapshot(BOM) {
7173         return new PieceTreeSnapshot(this, BOM);
7174     }
7175     equal(other) {
7176         if (this.getLength() !== other.getLength()) {
7177             return false;
7178         }
7179         if (this.getLineCount() !== other.getLineCount()) {
7180             return false;
7181         }
7182         let offset = 0;
7183         let ret = this.iterate(this.root, node => {
7184             if (node === rbTreeBase_1.SENTINEL) {
7185                 return true;
7186             }
7187             let str = this.getNodeContent(node);
7188             let len = str.length;
7189             let startPosition = other.nodeAt(offset);
7190             let endPosition = other.nodeAt(offset + len);
7191             let val = other.getValueInRange2(startPosition, endPosition);
7192             return str === val;
7193         });
7194         return ret;
7195     }
7196     getOffsetAt(lineNumber, column) {
7197         let leftLen = 0; // inorder
7198         let x = this.root;
7199         while (x !== rbTreeBase_1.SENTINEL) {
7200             if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left + 1 >= lineNumber) {
7201                 x = x.left;
7202             }
7203             else if (x.lf_left + x.piece.lineFeedCnt + 1 >= lineNumber) {
7204                 leftLen += x.size_left;
7205                 // lineNumber >= 2
7206                 let accumualtedValInCurrentIndex = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
7207                 return leftLen += accumualtedValInCurrentIndex + column - 1;
7208             }
7209             else {
7210                 lineNumber -= x.lf_left + x.piece.lineFeedCnt;
7211                 leftLen += x.size_left + x.piece.length;
7212                 x = x.right;
7213             }
7214         }
7215         return leftLen;
7216     }
7217     getPositionAt(offset) {
7218         offset = Math.floor(offset);
7219         offset = Math.max(0, offset);
7220         let x = this.root;
7221         let lfCnt = 0;
7222         let originalOffset = offset;
7223         while (x !== rbTreeBase_1.SENTINEL) {
7224             if (x.size_left !== 0 && x.size_left >= offset) {
7225                 x = x.left;
7226             }
7227             else if (x.size_left + x.piece.length >= offset) {
7228                 let out = this.getIndexOf(x, offset - x.size_left);
7229                 lfCnt += x.lf_left + out.index;
7230                 if (out.index === 0) {
7231                     let lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
7232                     let column = originalOffset - lineStartOffset;
7233                     return new position_1.Position(lfCnt + 1, column + 1);
7234                 }
7235                 return new position_1.Position(lfCnt + 1, out.remainder + 1);
7236             }
7237             else {
7238                 offset -= x.size_left + x.piece.length;
7239                 lfCnt += x.lf_left + x.piece.lineFeedCnt;
7240                 if (x.right === rbTreeBase_1.SENTINEL) {
7241                     // last node
7242                     let lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
7243                     let column = originalOffset - offset - lineStartOffset;
7244                     return new position_1.Position(lfCnt + 1, column + 1);
7245                 }
7246                 else {
7247                     x = x.right;
7248                 }
7249             }
7250         }
7251         return new position_1.Position(1, 1);
7252     }
7253     getValueInRange(range, eol) {
7254         if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
7255             return '';
7256         }
7257         let startPosition = this.nodeAt2(range.startLineNumber, range.startColumn);
7258         let endPosition = this.nodeAt2(range.endLineNumber, range.endColumn);
7259         let value = this.getValueInRange2(startPosition, endPosition);
7260         if (eol) {
7261             if (eol !== this._EOL || !this._EOLNormalized) {
7262                 return value.replace(/\r\n|\r|\n/g, eol);
7263             }
7264             if (eol === this.getEOL() && this._EOLNormalized) {
7265                 if (eol === '\r\n') {
7266                 }
7267                 return value;
7268             }
7269             return value.replace(/\r\n|\r|\n/g, eol);
7270         }
7271         return value;
7272     }
7273     getValueInRange2(startPosition, endPosition) {
7274         if (startPosition.node === endPosition.node) {
7275             let node = startPosition.node;
7276             let buffer = this._buffers[node.piece.bufferIndex].buffer;
7277             let startOffset = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start);
7278             return buffer.substring(startOffset + startPosition.remainder, startOffset + endPosition.remainder);
7279         }
7280         let x = startPosition.node;
7281         let buffer = this._buffers[x.piece.bufferIndex].buffer;
7282         let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7283         let ret = buffer.substring(startOffset + startPosition.remainder, startOffset + x.piece.length);
7284         x = x.next();
7285         while (x !== rbTreeBase_1.SENTINEL) {
7286             let buffer = this._buffers[x.piece.bufferIndex].buffer;
7287             let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7288             if (x === endPosition.node) {
7289                 ret += buffer.substring(startOffset, startOffset + endPosition.remainder);
7290                 break;
7291             }
7292             else {
7293                 ret += buffer.substr(startOffset, x.piece.length);
7294             }
7295             x = x.next();
7296         }
7297         return ret;
7298     }
7299     getLinesContent() {
7300         return this.getContentOfSubTree(this.root).split(/\r\n|\r|\n/);
7301     }
7302     getLength() {
7303         return this._length;
7304     }
7305     getLineCount() {
7306         return this._lineCnt;
7307     }
7308     /**
7309      * @param lineNumber 1 based
7310      */
7311     getLineContent(lineNumber) {
7312         if (this._lastVisitedLine.lineNumber === lineNumber) {
7313             return this._lastVisitedLine.value;
7314         }
7315         this._lastVisitedLine.lineNumber = lineNumber;
7316         if (lineNumber === this._lineCnt) {
7317             this._lastVisitedLine.value = this.getLineRawContent(lineNumber);
7318         }
7319         else if (this._EOLNormalized) {
7320             this._lastVisitedLine.value = this.getLineRawContent(lineNumber, this._EOLLength);
7321         }
7322         else {
7323             this._lastVisitedLine.value = this.getLineRawContent(lineNumber).replace(/(\r\n|\r|\n)$/, '');
7324         }
7325         return this._lastVisitedLine.value;
7326     }
7327     getLineCharCode(lineNumber, index) {
7328         let nodePos = this.nodeAt2(lineNumber, index + 1);
7329         if (nodePos.remainder === nodePos.node.piece.length) {
7330             // the char we want to fetch is at the head of next node.
7331             let matchingNode = nodePos.node.next();
7332             if (!matchingNode) {
7333                 return 0;
7334             }
7335             let buffer = this._buffers[matchingNode.piece.bufferIndex];
7336             let startOffset = this.offsetInBuffer(matchingNode.piece.bufferIndex, matchingNode.piece.start);
7337             return buffer.buffer.charCodeAt(startOffset);
7338         }
7339         else {
7340             let buffer = this._buffers[nodePos.node.piece.bufferIndex];
7341             let startOffset = this.offsetInBuffer(nodePos.node.piece.bufferIndex, nodePos.node.piece.start);
7342             let targetOffset = startOffset + nodePos.remainder;
7343             return buffer.buffer.charCodeAt(targetOffset);
7344         }
7345     }
7346     getLineLength(lineNumber) {
7347         if (lineNumber === this.getLineCount()) {
7348             let startOffset = this.getOffsetAt(lineNumber, 1);
7349             return this.getLength() - startOffset;
7350         }
7351         return this.getOffsetAt(lineNumber + 1, 1) - this.getOffsetAt(lineNumber, 1) - this._EOLLength;
7352     }
7353     // #endregion
7354     // #region Piece Table
7355     insert(offset, value, eolNormalized = false) {
7356         this._EOLNormalized = this._EOLNormalized && eolNormalized;
7357         this._lastVisitedLine.lineNumber = 0;
7358         this._lastVisitedLine.value = '';
7359         if (this.root !== rbTreeBase_1.SENTINEL) {
7360             let { node, remainder, nodeStartOffset } = this.nodeAt(offset);
7361             let piece = node.piece;
7362             let bufferIndex = piece.bufferIndex;
7363             let insertPosInBuffer = this.positionInBuffer(node, remainder);
7364             if (node.piece.bufferIndex === 0 &&
7365                 piece.end.line === this._lastChangeBufferPos.line &&
7366                 piece.end.column === this._lastChangeBufferPos.column &&
7367                 (nodeStartOffset + piece.length === offset) &&
7368                 value.length < exports.AverageBufferSize) {
7369                 // changed buffer
7370                 this.appendToNode(node, value);
7371                 this.computeBufferMetadata();
7372                 return;
7373             }
7374             if (nodeStartOffset === offset) {
7375                 this.insertContentToNodeLeft(value, node);
7376                 this._searchCache.valdiate(offset);
7377             }
7378             else if (nodeStartOffset + node.piece.length > offset) {
7379                 // we are inserting into the middle of a node.
7380                 let nodesToDel = [];
7381                 let newRightPiece = new Piece(piece.bufferIndex, insertPosInBuffer, piece.end, this.getLineFeedCnt(piece.bufferIndex, insertPosInBuffer, piece.end), this.offsetInBuffer(bufferIndex, piece.end) - this.offsetInBuffer(bufferIndex, insertPosInBuffer));
7382                 if (this.shouldCheckCRLF() && this.endWithCR(value)) {
7383                     let headOfRight = this.nodeCharCodeAt(node, remainder);
7384                     if (headOfRight === 10 /** \n */) {
7385                         let newStart = { line: newRightPiece.start.line + 1, column: 0 };
7386                         newRightPiece = new Piece(newRightPiece.bufferIndex, newStart, newRightPiece.end, this.getLineFeedCnt(newRightPiece.bufferIndex, newStart, newRightPiece.end), newRightPiece.length - 1);
7387                         value += '\n';
7388                     }
7389                 }
7390                 // reuse node for content before insertion point.
7391                 if (this.shouldCheckCRLF() && this.startWithLF(value)) {
7392                     let tailOfLeft = this.nodeCharCodeAt(node, remainder - 1);
7393                     if (tailOfLeft === 13 /** \r */) {
7394                         let previousPos = this.positionInBuffer(node, remainder - 1);
7395                         this.deleteNodeTail(node, previousPos);
7396                         value = '\r' + value;
7397                         if (node.piece.length === 0) {
7398                             nodesToDel.push(node);
7399                         }
7400                     }
7401                     else {
7402                         this.deleteNodeTail(node, insertPosInBuffer);
7403                     }
7404                 }
7405                 else {
7406                     this.deleteNodeTail(node, insertPosInBuffer);
7407                 }
7408                 let newPieces = this.createNewPieces(value);
7409                 if (newRightPiece.length > 0) {
7410                     this.rbInsertRight(node, newRightPiece);
7411                 }
7412                 let tmpNode = node;
7413                 for (let k = 0; k < newPieces.length; k++) {
7414                     tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
7415                 }
7416                 this.deleteNodes(nodesToDel);
7417             }
7418             else {
7419                 this.insertContentToNodeRight(value, node);
7420             }
7421         }
7422         else {
7423             // insert new node
7424             let pieces = this.createNewPieces(value);
7425             let node = this.rbInsertLeft(null, pieces[0]);
7426             for (let k = 1; k < pieces.length; k++) {
7427                 node = this.rbInsertRight(node, pieces[k]);
7428             }
7429         }
7430         // todo, this is too brutal. Total line feed count should be updated the same way as lf_left.
7431         this.computeBufferMetadata();
7432     }
7433     delete(offset, cnt) {
7434         this._lastVisitedLine.lineNumber = 0;
7435         this._lastVisitedLine.value = '';
7436         if (cnt <= 0 || this.root === rbTreeBase_1.SENTINEL) {
7437             return;
7438         }
7439         let startPosition = this.nodeAt(offset);
7440         let endPosition = this.nodeAt(offset + cnt);
7441         let startNode = startPosition.node;
7442         let endNode = endPosition.node;
7443         if (startNode === endNode) {
7444             let startSplitPosInBuffer = this.positionInBuffer(startNode, startPosition.remainder);
7445             let endSplitPosInBuffer = this.positionInBuffer(startNode, endPosition.remainder);
7446             if (startPosition.nodeStartOffset === offset) {
7447                 if (cnt === startNode.piece.length) { // delete node
7448                     let next = startNode.next();
7449                     rbTreeBase_1.rbDelete(this, startNode);
7450                     this.validateCRLFWithPrevNode(next);
7451                     this.computeBufferMetadata();
7452                     return;
7453                 }
7454                 this.deleteNodeHead(startNode, endSplitPosInBuffer);
7455                 this._searchCache.valdiate(offset);
7456                 this.validateCRLFWithPrevNode(startNode);
7457                 this.computeBufferMetadata();
7458                 return;
7459             }
7460             if (startPosition.nodeStartOffset + startNode.piece.length === offset + cnt) {
7461                 this.deleteNodeTail(startNode, startSplitPosInBuffer);
7462                 this.validateCRLFWithNextNode(startNode);
7463                 this.computeBufferMetadata();
7464                 return;
7465             }
7466             // delete content in the middle, this node will be splitted to nodes
7467             this.shrinkNode(startNode, startSplitPosInBuffer, endSplitPosInBuffer);
7468             this.computeBufferMetadata();
7469             return;
7470         }
7471         let nodesToDel = [];
7472         let startSplitPosInBuffer = this.positionInBuffer(startNode, startPosition.remainder);
7473         this.deleteNodeTail(startNode, startSplitPosInBuffer);
7474         this._searchCache.valdiate(offset);
7475         if (startNode.piece.length === 0) {
7476             nodesToDel.push(startNode);
7477         }
7478         // update last touched node
7479         let endSplitPosInBuffer = this.positionInBuffer(endNode, endPosition.remainder);
7480         this.deleteNodeHead(endNode, endSplitPosInBuffer);
7481         if (endNode.piece.length === 0) {
7482             nodesToDel.push(endNode);
7483         }
7484         // delete nodes in between
7485         let secondNode = startNode.next();
7486         for (let node = secondNode; node !== rbTreeBase_1.SENTINEL && node !== endNode; node = node.next()) {
7487             nodesToDel.push(node);
7488         }
7489         let prev = startNode.piece.length === 0 ? startNode.prev() : startNode;
7490         this.deleteNodes(nodesToDel);
7491         this.validateCRLFWithNextNode(prev);
7492         this.computeBufferMetadata();
7493     }
7494     insertContentToNodeLeft(value, node) {
7495         // we are inserting content to the beginning of node
7496         let nodesToDel = [];
7497         if (this.shouldCheckCRLF() && this.endWithCR(value) && this.startWithLF(node)) {
7498             // move `\n` to new node.
7499             let piece = node.piece;
7500             let newStart = { line: piece.start.line + 1, column: 0 };
7501             let nPiece = new Piece(piece.bufferIndex, newStart, piece.end, this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end), piece.length - 1);
7502             node.piece = nPiece;
7503             value += '\n';
7504             rbTreeBase_1.updateTreeMetadata(this, node, -1, -1);
7505             if (node.piece.length === 0) {
7506                 nodesToDel.push(node);
7507             }
7508         }
7509         let newPieces = this.createNewPieces(value);
7510         let newNode = this.rbInsertLeft(node, newPieces[newPieces.length - 1]);
7511         for (let k = newPieces.length - 2; k >= 0; k--) {
7512             newNode = this.rbInsertLeft(newNode, newPieces[k]);
7513         }
7514         this.validateCRLFWithPrevNode(newNode);
7515         this.deleteNodes(nodesToDel);
7516     }
7517     insertContentToNodeRight(value, node) {
7518         // we are inserting to the right of this node.
7519         if (this.adjustCarriageReturnFromNext(value, node)) {
7520             // move \n to the new node.
7521             value += '\n';
7522         }
7523         let newPieces = this.createNewPieces(value);
7524         let newNode = this.rbInsertRight(node, newPieces[0]);
7525         let tmpNode = newNode;
7526         for (let k = 1; k < newPieces.length; k++) {
7527             tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
7528         }
7529         this.validateCRLFWithPrevNode(newNode);
7530     }
7531     positionInBuffer(node, remainder, ret) {
7532         let piece = node.piece;
7533         let bufferIndex = node.piece.bufferIndex;
7534         let lineStarts = this._buffers[bufferIndex].lineStarts;
7535         let startOffset = lineStarts[piece.start.line] + piece.start.column;
7536         let offset = startOffset + remainder;
7537         // binary search offset between startOffset and endOffset
7538         let low = piece.start.line;
7539         let high = piece.end.line;
7540         let mid = 0;
7541         let midStop = 0;
7542         let midStart = 0;
7543         while (low <= high) {
7544             mid = low + ((high - low) / 2) | 0;
7545             midStart = lineStarts[mid];
7546             if (mid === high) {
7547                 break;
7548             }
7549             midStop = lineStarts[mid + 1];
7550             if (offset < midStart) {
7551                 high = mid - 1;
7552             }
7553             else if (offset >= midStop) {
7554                 low = mid + 1;
7555             }
7556             else {
7557                 break;
7558             }
7559         }
7560         if (ret) {
7561             ret.line = mid;
7562             ret.column = offset - midStart;
7563             return null;
7564         }
7565         return {
7566             line: mid,
7567             column: offset - midStart
7568         };
7569     }
7570     getLineFeedCnt(bufferIndex, start, end) {
7571         // we don't need to worry about start: abc\r|\n, or abc|\r, or abc|\n, or abc|\r\n doesn't change the fact that, there is one line break after start.
7572         // now let's take care of end: abc\r|\n, if end is in between \r and \n, we need to add line feed count by 1
7573         if (end.column === 0) {
7574             return end.line - start.line;
7575         }
7576         let lineStarts = this._buffers[bufferIndex].lineStarts;
7577         if (end.line === lineStarts.length - 1) { // it means, there is no \n after end, otherwise, there will be one more lineStart.
7578             return end.line - start.line;
7579         }
7580         let nextLineStartOffset = lineStarts[end.line + 1];
7581         let endOffset = lineStarts[end.line] + end.column;
7582         if (nextLineStartOffset > endOffset + 1) { // there are more than 1 character after end, which means it can't be \n
7583             return end.line - start.line;
7584         }
7585         // endOffset + 1 === nextLineStartOffset
7586         // character at endOffset is \n, so we check the character before first
7587         // if character at endOffset is \r, end.column is 0 and we can't get here.
7588         let previousCharOffset = endOffset - 1; // end.column > 0 so it's okay.
7589         let buffer = this._buffers[bufferIndex].buffer;
7590         if (buffer.charCodeAt(previousCharOffset) === 13) {
7591             return end.line - start.line + 1;
7592         }
7593         else {
7594             return end.line - start.line;
7595         }
7596     }
7597     offsetInBuffer(bufferIndex, cursor) {
7598         let lineStarts = this._buffers[bufferIndex].lineStarts;
7599         return lineStarts[cursor.line] + cursor.column;
7600     }
7601     deleteNodes(nodes) {
7602         for (let i = 0; i < nodes.length; i++) {
7603             rbTreeBase_1.rbDelete(this, nodes[i]);
7604         }
7605     }
7606     createNewPieces(text) {
7607         if (text.length > exports.AverageBufferSize) {
7608             // the content is large, operations like substring, charCode becomes slow
7609             // so here we split it into smaller chunks, just like what we did for CR/LF normalization
7610             let newPieces = [];
7611             while (text.length > exports.AverageBufferSize) {
7612                 const lastChar = text.charCodeAt(exports.AverageBufferSize - 1);
7613                 let splitText;
7614                 if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
7615                     // last character is \r or a high surrogate => keep it back
7616                     splitText = text.substring(0, exports.AverageBufferSize - 1);
7617                     text = text.substring(exports.AverageBufferSize - 1);
7618                 }
7619                 else {
7620                     splitText = text.substring(0, exports.AverageBufferSize);
7621                     text = text.substring(exports.AverageBufferSize);
7622                 }
7623                 let lineStarts = createLineStartsFast(splitText);
7624                 newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts.length - 1, column: splitText.length - lineStarts[lineStarts.length - 1] }, lineStarts.length - 1, splitText.length));
7625                 this._buffers.push(new StringBuffer(splitText, lineStarts));
7626             }
7627             let lineStarts = createLineStartsFast(text);
7628             newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts.length - 1, column: text.length - lineStarts[lineStarts.length - 1] }, lineStarts.length - 1, text.length));
7629             this._buffers.push(new StringBuffer(text, lineStarts));
7630             return newPieces;
7631         }
7632         let startOffset = this._buffers[0].buffer.length;
7633         const lineStarts = createLineStartsFast(text, false);
7634         let start = this._lastChangeBufferPos;
7635         if (this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 1] === startOffset
7636             && startOffset !== 0
7637             && this.startWithLF(text)
7638             && this.endWithCR(this._buffers[0].buffer) // todo, we can check this._lastChangeBufferPos's column as it's the last one
7639         ) {
7640             this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line, column: this._lastChangeBufferPos.column + 1 };
7641             start = this._lastChangeBufferPos;
7642             for (let i = 0; i < lineStarts.length; i++) {
7643                 lineStarts[i] += startOffset + 1;
7644             }
7645             this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
7646             this._buffers[0].buffer += '_' + text;
7647             startOffset += 1;
7648         }
7649         else {
7650             if (startOffset !== 0) {
7651                 for (let i = 0; i < lineStarts.length; i++) {
7652                     lineStarts[i] += startOffset;
7653                 }
7654             }
7655             this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
7656             this._buffers[0].buffer += text;
7657         }
7658         const endOffset = this._buffers[0].buffer.length;
7659         let endIndex = this._buffers[0].lineStarts.length - 1;
7660         let endColumn = endOffset - this._buffers[0].lineStarts[endIndex];
7661         let endPos = { line: endIndex, column: endColumn };
7662         let newPiece = new Piece(0, /** todo@peng */ start, endPos, this.getLineFeedCnt(0, start, endPos), endOffset - startOffset);
7663         this._lastChangeBufferPos = endPos;
7664         return [newPiece];
7665     }
7666     getLinesRawContent() {
7667         return this.getContentOfSubTree(this.root);
7668     }
7669     getLineRawContent(lineNumber, endOffset = 0) {
7670         let x = this.root;
7671         let ret = '';
7672         let cache = this._searchCache.get2(lineNumber);
7673         if (cache) {
7674             x = cache.node;
7675             let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber - 1);
7676             let buffer = this._buffers[x.piece.bufferIndex].buffer;
7677             let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7678             if (cache.nodeStartLineNumber + x.piece.lineFeedCnt === lineNumber) {
7679                 ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
7680             }
7681             else {
7682                 let accumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber);
7683                 return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
7684             }
7685         }
7686         else {
7687             let nodeStartOffset = 0;
7688             const originalLineNumber = lineNumber;
7689             while (x !== rbTreeBase_1.SENTINEL) {
7690                 if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
7691                     x = x.left;
7692                 }
7693                 else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
7694                     let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
7695                     let accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
7696                     let buffer = this._buffers[x.piece.bufferIndex].buffer;
7697                     let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7698                     nodeStartOffset += x.size_left;
7699                     this._searchCache.set({
7700                         node: x,
7701                         nodeStartOffset,
7702                         nodeStartLineNumber: originalLineNumber - (lineNumber - 1 - x.lf_left)
7703                     });
7704                     return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
7705                 }
7706                 else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
7707                     let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
7708                     let buffer = this._buffers[x.piece.bufferIndex].buffer;
7709                     let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7710                     ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
7711                     break;
7712                 }
7713                 else {
7714                     lineNumber -= x.lf_left + x.piece.lineFeedCnt;
7715                     nodeStartOffset += x.size_left + x.piece.length;
7716                     x = x.right;
7717                 }
7718             }
7719         }
7720         // search in order, to find the node contains end column
7721         x = x.next();
7722         while (x !== rbTreeBase_1.SENTINEL) {
7723             let buffer = this._buffers[x.piece.bufferIndex].buffer;
7724             if (x.piece.lineFeedCnt > 0) {
7725                 let accumualtedValue = this.getAccumulatedValue(x, 0);
7726                 let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7727                 ret += buffer.substring(startOffset, startOffset + accumualtedValue - endOffset);
7728                 return ret;
7729             }
7730             else {
7731                 let startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
7732                 ret += buffer.substr(startOffset, x.piece.length);
7733             }
7734             x = x.next();
7735         }
7736         return ret;
7737     }
7738     computeBufferMetadata() {
7739         let x = this.root;
7740         let lfCnt = 1;
7741         let len = 0;
7742         while (x !== rbTreeBase_1.SENTINEL) {
7743             lfCnt += x.lf_left + x.piece.lineFeedCnt;
7744             len += x.size_left + x.piece.length;
7745             x = x.right;
7746         }
7747         this._lineCnt = lfCnt;
7748         this._length = len;
7749         this._searchCache.valdiate(this._length);
7750     }
7751     // #region node operations
7752     getIndexOf(node, accumulatedValue) {
7753         let piece = node.piece;
7754         let pos = this.positionInBuffer(node, accumulatedValue);
7755         let lineCnt = pos.line - piece.start.line;
7756         if (this.offsetInBuffer(piece.bufferIndex, piece.end) - this.offsetInBuffer(piece.bufferIndex, piece.start) === accumulatedValue) {
7757             // we are checking the end of this node, so a CRLF check is necessary.
7758             let realLineCnt = this.getLineFeedCnt(node.piece.bufferIndex, piece.start, pos);
7759             if (realLineCnt !== lineCnt) {
7760                 // aha yes, CRLF
7761                 return { index: realLineCnt, remainder: 0 };
7762             }
7763         }
7764         return { index: lineCnt, remainder: pos.column };
7765     }
7766     getAccumulatedValue(node, index) {
7767         if (index < 0) {
7768             return 0;
7769         }
7770         let piece = node.piece;
7771         let lineStarts = this._buffers[piece.bufferIndex].lineStarts;
7772         let expectedLineStartIndex = piece.start.line + index + 1;
7773         if (expectedLineStartIndex > piece.end.line) {
7774             return lineStarts[piece.end.line] + piece.end.column - lineStarts[piece.start.line] - piece.start.column;
7775         }
7776         else {
7777             return lineStarts[expectedLineStartIndex] - lineStarts[piece.start.line] - piece.start.column;
7778         }
7779     }
7780     deleteNodeTail(node, pos) {
7781         const piece = node.piece;
7782         const originalLFCnt = piece.lineFeedCnt;
7783         const originalEndOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
7784         const newEnd = pos;
7785         const newEndOffset = this.offsetInBuffer(piece.bufferIndex, newEnd);
7786         const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
7787         const lf_delta = newLineFeedCnt - originalLFCnt;
7788         const size_delta = newEndOffset - originalEndOffset;
7789         const newLength = piece.length + size_delta;
7790         node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
7791         rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
7792     }
7793     deleteNodeHead(node, pos) {
7794         const piece = node.piece;
7795         const originalLFCnt = piece.lineFeedCnt;
7796         const originalStartOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
7797         const newStart = pos;
7798         const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
7799         const newStartOffset = this.offsetInBuffer(piece.bufferIndex, newStart);
7800         const lf_delta = newLineFeedCnt - originalLFCnt;
7801         const size_delta = originalStartOffset - newStartOffset;
7802         const newLength = piece.length + size_delta;
7803         node.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
7804         rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
7805     }
7806     shrinkNode(node, start, end) {
7807         const piece = node.piece;
7808         const originalStartPos = piece.start;
7809         const originalEndPos = piece.end;
7810         // old piece, originalStartPos, start
7811         const oldLength = piece.length;
7812         const oldLFCnt = piece.lineFeedCnt;
7813         const newEnd = start;
7814         const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
7815         const newLength = this.offsetInBuffer(piece.bufferIndex, start) - this.offsetInBuffer(piece.bufferIndex, originalStartPos);
7816         node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
7817         rbTreeBase_1.updateTreeMetadata(this, node, newLength - oldLength, newLineFeedCnt - oldLFCnt);
7818         // new right piece, end, originalEndPos
7819         let newPiece = new Piece(piece.bufferIndex, end, originalEndPos, this.getLineFeedCnt(piece.bufferIndex, end, originalEndPos), this.offsetInBuffer(piece.bufferIndex, originalEndPos) - this.offsetInBuffer(piece.bufferIndex, end));
7820         let newNode = this.rbInsertRight(node, newPiece);
7821         this.validateCRLFWithPrevNode(newNode);
7822     }
7823     appendToNode(node, value) {
7824         if (this.adjustCarriageReturnFromNext(value, node)) {
7825             value += '\n';
7826         }
7827         const hitCRLF = this.shouldCheckCRLF() && this.startWithLF(value) && this.endWithCR(node);
7828         const startOffset = this._buffers[0].buffer.length;
7829         this._buffers[0].buffer += value;
7830         const lineStarts = createLineStartsFast(value, false);
7831         for (let i = 0; i < lineStarts.length; i++) {
7832             lineStarts[i] += startOffset;
7833         }
7834         if (hitCRLF) {
7835             let prevStartOffset = this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 2];
7836             this._buffers[0].lineStarts.pop();
7837             // _lastChangeBufferPos is already wrong
7838             this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line - 1, column: startOffset - prevStartOffset };
7839         }
7840         this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
7841         const endIndex = this._buffers[0].lineStarts.length - 1;
7842         const endColumn = this._buffers[0].buffer.length - this._buffers[0].lineStarts[endIndex];
7843         const newEnd = { line: endIndex, column: endColumn };
7844         const newLength = node.piece.length + value.length;
7845         const oldLineFeedCnt = node.piece.lineFeedCnt;
7846         const newLineFeedCnt = this.getLineFeedCnt(0, node.piece.start, newEnd);
7847         const lf_delta = newLineFeedCnt - oldLineFeedCnt;
7848         node.piece = new Piece(node.piece.bufferIndex, node.piece.start, newEnd, newLineFeedCnt, newLength);
7849         this._lastChangeBufferPos = newEnd;
7850         rbTreeBase_1.updateTreeMetadata(this, node, value.length, lf_delta);
7851     }
7852     nodeAt(offset) {
7853         let x = this.root;
7854         let cache = this._searchCache.get(offset);
7855         if (cache) {
7856             return {
7857                 node: cache.node,
7858                 nodeStartOffset: cache.nodeStartOffset,
7859                 remainder: offset - cache.nodeStartOffset
7860             };
7861         }
7862         let nodeStartOffset = 0;
7863         while (x !== rbTreeBase_1.SENTINEL) {
7864             if (x.size_left > offset) {
7865                 x = x.left;
7866             }
7867             else if (x.size_left + x.piece.length >= offset) {
7868                 nodeStartOffset += x.size_left;
7869                 let ret = {
7870                     node: x,
7871                     remainder: offset - x.size_left,
7872                     nodeStartOffset
7873                 };
7874                 this._searchCache.set(ret);
7875                 return ret;
7876             }
7877             else {
7878                 offset -= x.size_left + x.piece.length;
7879                 nodeStartOffset += x.size_left + x.piece.length;
7880                 x = x.right;
7881             }
7882         }
7883         return null;
7884     }
7885     nodeAt2(lineNumber, column) {
7886         let x = this.root;
7887         let nodeStartOffset = 0;
7888         while (x !== rbTreeBase_1.SENTINEL) {
7889             if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
7890                 x = x.left;
7891             }
7892             else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
7893                 let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
7894                 let accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
7895                 nodeStartOffset += x.size_left;
7896                 return {
7897                     node: x,
7898                     remainder: Math.min(prevAccumualtedValue + column - 1, accumualtedValue),
7899                     nodeStartOffset
7900                 };
7901             }
7902             else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
7903                 let prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
7904                 if (prevAccumualtedValue + column - 1 <= x.piece.length) {
7905                     return {
7906                         node: x,
7907                         remainder: prevAccumualtedValue + column - 1,
7908                         nodeStartOffset
7909                     };
7910                 }
7911                 else {
7912                     column -= x.piece.length - prevAccumualtedValue;
7913                     break;
7914                 }
7915             }
7916             else {
7917                 lineNumber -= x.lf_left + x.piece.lineFeedCnt;
7918                 nodeStartOffset += x.size_left + x.piece.length;
7919                 x = x.right;
7920             }
7921         }
7922         // search in order, to find the node contains position.column
7923         x = x.next();
7924         while (x !== rbTreeBase_1.SENTINEL) {
7925             if (x.piece.lineFeedCnt > 0) {
7926                 let accumualtedValue = this.getAccumulatedValue(x, 0);
7927                 let nodeStartOffset = this.offsetOfNode(x);
7928                 return {
7929                     node: x,
7930                     remainder: Math.min(column - 1, accumualtedValue),
7931                     nodeStartOffset
7932                 };
7933             }
7934             else {
7935                 if (x.piece.length >= column - 1) {
7936                     let nodeStartOffset = this.offsetOfNode(x);
7937                     return {
7938                         node: x,
7939                         remainder: column - 1,
7940                         nodeStartOffset
7941                     };
7942                 }
7943                 else {
7944                     column -= x.piece.length;
7945                 }
7946             }
7947             x = x.next();
7948         }
7949         return null;
7950     }
7951     nodeCharCodeAt(node, offset) {
7952         if (node.piece.lineFeedCnt < 1) {
7953             return -1;
7954         }
7955         let buffer = this._buffers[node.piece.bufferIndex];
7956         let newOffset = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start) + offset;
7957         return buffer.buffer.charCodeAt(newOffset);
7958     }
7959     offsetOfNode(node) {
7960         if (!node) {
7961             return 0;
7962         }
7963         let pos = node.size_left;
7964         while (node !== this.root) {
7965             if (node.parent.right === node) {
7966                 pos += node.parent.size_left + node.parent.piece.length;
7967             }
7968             node = node.parent;
7969         }
7970         return pos;
7971     }
7972     // #endregion
7973     // #region CRLF
7974     shouldCheckCRLF() {
7975         return !(this._EOLNormalized && this._EOL === '\n');
7976     }
7977     startWithLF(val) {
7978         if (typeof val === 'string') {
7979             return val.charCodeAt(0) === 10;
7980         }
7981         if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
7982             return false;
7983         }
7984         let piece = val.piece;
7985         let lineStarts = this._buffers[piece.bufferIndex].lineStarts;
7986         let line = piece.start.line;
7987         let startOffset = lineStarts[line] + piece.start.column;
7988         if (line === lineStarts.length - 1) {
7989             // last line, so there is no line feed at the end of this line
7990             return false;
7991         }
7992         let nextLineOffset = lineStarts[line + 1];
7993         if (nextLineOffset > startOffset + 1) {
7994             return false;
7995         }
7996         return this._buffers[piece.bufferIndex].buffer.charCodeAt(startOffset) === 10;
7997     }
7998     endWithCR(val) {
7999         if (typeof val === 'string') {
8000             return val.charCodeAt(val.length - 1) === 13;
8001         }
8002         if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
8003             return false;
8004         }
8005         return this.nodeCharCodeAt(val, val.piece.length - 1) === 13;
8006     }
8007     validateCRLFWithPrevNode(nextNode) {
8008         if (this.shouldCheckCRLF() && this.startWithLF(nextNode)) {
8009             let node = nextNode.prev();
8010             if (this.endWithCR(node)) {
8011                 this.fixCRLF(node, nextNode);
8012             }
8013         }
8014     }
8015     validateCRLFWithNextNode(node) {
8016         if (this.shouldCheckCRLF() && this.endWithCR(node)) {
8017             let nextNode = node.next();
8018             if (this.startWithLF(nextNode)) {
8019                 this.fixCRLF(node, nextNode);
8020             }
8021         }
8022     }
8023     fixCRLF(prev, next) {
8024         let nodesToDel = [];
8025         // update node
8026         let lineStarts = this._buffers[prev.piece.bufferIndex].lineStarts;
8027         let newEnd;
8028         if (prev.piece.end.column === 0) {
8029             // it means, last line ends with \r, not \r\n
8030             newEnd = { line: prev.piece.end.line - 1, column: lineStarts[prev.piece.end.line] - lineStarts[prev.piece.end.line - 1] - 1 };
8031         }
8032         else {
8033             // \r\n
8034             newEnd = { line: prev.piece.end.line, column: prev.piece.end.column - 1 };
8035         }
8036         const prevNewLength = prev.piece.length - 1;
8037         const prevNewLFCnt = prev.piece.lineFeedCnt - 1;
8038         prev.piece = new Piece(prev.piece.bufferIndex, prev.piece.start, newEnd, prevNewLFCnt, prevNewLength);
8039         rbTreeBase_1.updateTreeMetadata(this, prev, -1, -1);
8040         if (prev.piece.length === 0) {
8041             nodesToDel.push(prev);
8042         }
8043         // update nextNode
8044         let newStart = { line: next.piece.start.line + 1, column: 0 };
8045         const newLength = next.piece.length - 1;
8046         const newLineFeedCnt = this.getLineFeedCnt(next.piece.bufferIndex, newStart, next.piece.end);
8047         next.piece = new Piece(next.piece.bufferIndex, newStart, next.piece.end, newLineFeedCnt, newLength);
8048         rbTreeBase_1.updateTreeMetadata(this, next, -1, -1);
8049         if (next.piece.length === 0) {
8050             nodesToDel.push(next);
8051         }
8052         // create new piece which contains \r\n
8053         let pieces = this.createNewPieces('\r\n');
8054         this.rbInsertRight(prev, pieces[0]);
8055         // delete empty nodes
8056         for (let i = 0; i < nodesToDel.length; i++) {
8057             rbTreeBase_1.rbDelete(this, nodesToDel[i]);
8058         }
8059     }
8060     adjustCarriageReturnFromNext(value, node) {
8061         if (this.shouldCheckCRLF() && this.endWithCR(value)) {
8062             let nextNode = node.next();
8063             if (this.startWithLF(nextNode)) {
8064                 // move `\n` forward
8065                 value += '\n';
8066                 if (nextNode.piece.length === 1) {
8067                     rbTreeBase_1.rbDelete(this, nextNode);
8068                 }
8069                 else {
8070                     const piece = nextNode.piece;
8071                     const newStart = { line: piece.start.line + 1, column: 0 };
8072                     const newLength = piece.length - 1;
8073                     const newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
8074                     nextNode.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
8075                     rbTreeBase_1.updateTreeMetadata(this, nextNode, -1, -1);
8076                 }
8077                 return true;
8078             }
8079         }
8080         return false;
8081     }
8082     // #endregion
8083     // #endregion
8084     // #region Tree operations
8085     iterate(node, callback) {
8086         if (node === rbTreeBase_1.SENTINEL) {
8087             return callback(rbTreeBase_1.SENTINEL);
8088         }
8089         let leftRet = this.iterate(node.left, callback);
8090         if (!leftRet) {
8091             return leftRet;
8092         }
8093         return callback(node) && this.iterate(node.right, callback);
8094     }
8095     getNodeContent(node) {
8096         if (node === rbTreeBase_1.SENTINEL) {
8097             return '';
8098         }
8099         let buffer = this._buffers[node.piece.bufferIndex];
8100         let currentContent;
8101         let piece = node.piece;
8102         let startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
8103         let endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
8104         currentContent = buffer.buffer.substring(startOffset, endOffset);
8105         return currentContent;
8106     }
8107     getPieceContent(piece) {
8108         let buffer = this._buffers[piece.bufferIndex];
8109         let startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
8110         let endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
8111         let currentContent = buffer.buffer.substring(startOffset, endOffset);
8112         return currentContent;
8113     }
8114     /**
8115      *      node              node
8116      *     /  \              /  \
8117      *    a   b    <----   a    b
8118      *                         /
8119      *                        z
8120      */
8121     rbInsertRight(node, p) {
8122         let z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
8123         z.left = rbTreeBase_1.SENTINEL;
8124         z.right = rbTreeBase_1.SENTINEL;
8125         z.parent = rbTreeBase_1.SENTINEL;
8126         z.size_left = 0;
8127         z.lf_left = 0;
8128         let x = this.root;
8129         if (x === rbTreeBase_1.SENTINEL) {
8130             this.root = z;
8131             z.color = 0 /* Black */;
8132         }
8133         else if (node.right === rbTreeBase_1.SENTINEL) {
8134             node.right = z;
8135             z.parent = node;
8136         }
8137         else {
8138             let nextNode = rbTreeBase_1.leftest(node.right);
8139             nextNode.left = z;
8140             z.parent = nextNode;
8141         }
8142         rbTreeBase_1.fixInsert(this, z);
8143         return z;
8144     }
8145     /**
8146      *      node              node
8147      *     /  \              /  \
8148      *    a   b     ---->   a    b
8149      *                       \
8150      *                        z
8151      */
8152     rbInsertLeft(node, p) {
8153         let z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
8154         z.left = rbTreeBase_1.SENTINEL;
8155         z.right = rbTreeBase_1.SENTINEL;
8156         z.parent = rbTreeBase_1.SENTINEL;
8157         z.size_left = 0;
8158         z.lf_left = 0;
8159         if (this.root === rbTreeBase_1.SENTINEL) {
8160             this.root = z;
8161             z.color = 0 /* Black */;
8162         }
8163         else if (node.left === rbTreeBase_1.SENTINEL) {
8164             node.left = z;
8165             z.parent = node;
8166         }
8167         else {
8168             let prevNode = rbTreeBase_1.righttest(node.left); // a
8169             prevNode.right = z;
8170             z.parent = prevNode;
8171         }
8172         rbTreeBase_1.fixInsert(this, z);
8173         return z;
8174     }
8175     getContentOfSubTree(node) {
8176         let str = '';
8177         this.iterate(node, node => {
8178             str += this.getNodeContent(node);
8179             return true;
8180         });
8181         return str;
8182     }
8183 }
8184 exports.PieceTreeBase = PieceTreeBase;
8185
8186
8187 /***/ }),
8188 /* 44 */
8189 /***/ (function(module, exports, __webpack_require__) {
8190
8191 "use strict";
8192
8193 /*---------------------------------------------------------------------------------------------
8194  *  Copyright (c) Microsoft Corporation. All rights reserved.
8195  *  Licensed under the MIT License. See License.txt in the project root for license information.
8196  *--------------------------------------------------------------------------------------------*/
8197 Object.defineProperty(exports, "__esModule", { value: true });
8198 /**
8199  * A position in the editor.
8200  */
8201 class Position {
8202     constructor(lineNumber, column) {
8203         this.lineNumber = lineNumber;
8204         this.column = column;
8205     }
8206     /**
8207      * Create a new postion from this position.
8208      *
8209      * @param newLineNumber new line number
8210      * @param newColumn new column
8211      */
8212     with(newLineNumber = this.lineNumber, newColumn = this.column) {
8213         if (newLineNumber === this.lineNumber && newColumn === this.column) {
8214             return this;
8215         }
8216         else {
8217             return new Position(newLineNumber, newColumn);
8218         }
8219     }
8220     /**
8221      * Derive a new position from this position.
8222      *
8223      * @param deltaLineNumber line number delta
8224      * @param deltaColumn column delta
8225      */
8226     delta(deltaLineNumber = 0, deltaColumn = 0) {
8227         return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
8228     }
8229     /**
8230      * Test if this position equals other position
8231      */
8232     equals(other) {
8233         return Position.equals(this, other);
8234     }
8235     /**
8236      * Test if position `a` equals position `b`
8237      */
8238     static equals(a, b) {
8239         if (!a && !b) {
8240             return true;
8241         }
8242         return (!!a &&
8243             !!b &&
8244             a.lineNumber === b.lineNumber &&
8245             a.column === b.column);
8246     }
8247     /**
8248      * Test if this position is before other position.
8249      * If the two positions are equal, the result will be false.
8250      */
8251     isBefore(other) {
8252         return Position.isBefore(this, other);
8253     }
8254     /**
8255      * Test if position `a` is before position `b`.
8256      * If the two positions are equal, the result will be false.
8257      */
8258     static isBefore(a, b) {
8259         if (a.lineNumber < b.lineNumber) {
8260             return true;
8261         }
8262         if (b.lineNumber < a.lineNumber) {
8263             return false;
8264         }
8265         return a.column < b.column;
8266     }
8267     /**
8268      * Test if this position is before other position.
8269      * If the two positions are equal, the result will be true.
8270      */
8271     isBeforeOrEqual(other) {
8272         return Position.isBeforeOrEqual(this, other);
8273     }
8274     /**
8275      * Test if position `a` is before position `b`.
8276      * If the two positions are equal, the result will be true.
8277      */
8278     static isBeforeOrEqual(a, b) {
8279         if (a.lineNumber < b.lineNumber) {
8280             return true;
8281         }
8282         if (b.lineNumber < a.lineNumber) {
8283             return false;
8284         }
8285         return a.column <= b.column;
8286     }
8287     /**
8288      * A function that compares positions, useful for sorting
8289      */
8290     static compare(a, b) {
8291         let aLineNumber = a.lineNumber | 0;
8292         let bLineNumber = b.lineNumber | 0;
8293         if (aLineNumber === bLineNumber) {
8294             let aColumn = a.column | 0;
8295             let bColumn = b.column | 0;
8296             return aColumn - bColumn;
8297         }
8298         return aLineNumber - bLineNumber;
8299     }
8300     /**
8301      * Clone this position.
8302      */
8303     clone() {
8304         return new Position(this.lineNumber, this.column);
8305     }
8306     /**
8307      * Convert to a human-readable representation.
8308      */
8309     toString() {
8310         return '(' + this.lineNumber + ',' + this.column + ')';
8311     }
8312     // ---
8313     /**
8314      * Create a `Position` from an `IPosition`.
8315      */
8316     static lift(pos) {
8317         return new Position(pos.lineNumber, pos.column);
8318     }
8319     /**
8320      * Test if `obj` is an `IPosition`.
8321      */
8322     static isIPosition(obj) {
8323         return (obj
8324             && (typeof obj.lineNumber === 'number')
8325             && (typeof obj.column === 'number'));
8326     }
8327 }
8328 exports.Position = Position;
8329
8330
8331 /***/ }),
8332 /* 45 */
8333 /***/ (function(module, exports, __webpack_require__) {
8334
8335 "use strict";
8336
8337 /*---------------------------------------------------------------------------------------------
8338  *  Copyright (c) Microsoft Corporation. All rights reserved.
8339  *  Licensed under the MIT License. See License.txt in the project root for license information.
8340  *--------------------------------------------------------------------------------------------*/
8341 Object.defineProperty(exports, "__esModule", { value: true });
8342 class TreeNode {
8343     constructor(piece, color) {
8344         this.piece = piece;
8345         this.color = color;
8346         this.size_left = 0;
8347         this.lf_left = 0;
8348         this.parent = this;
8349         this.left = this;
8350         this.right = this;
8351     }
8352     next() {
8353         if (this.right !== exports.SENTINEL) {
8354             return leftest(this.right);
8355         }
8356         let node = this;
8357         while (node.parent !== exports.SENTINEL) {
8358             if (node.parent.left === node) {
8359                 break;
8360             }
8361             node = node.parent;
8362         }
8363         if (node.parent === exports.SENTINEL) {
8364             return exports.SENTINEL;
8365         }
8366         else {
8367             return node.parent;
8368         }
8369     }
8370     prev() {
8371         if (this.left !== exports.SENTINEL) {
8372             return righttest(this.left);
8373         }
8374         let node = this;
8375         while (node.parent !== exports.SENTINEL) {
8376             if (node.parent.right === node) {
8377                 break;
8378             }
8379             node = node.parent;
8380         }
8381         if (node.parent === exports.SENTINEL) {
8382             return exports.SENTINEL;
8383         }
8384         else {
8385             return node.parent;
8386         }
8387     }
8388     detach() {
8389         this.parent = null;
8390         this.left = null;
8391         this.right = null;
8392     }
8393 }
8394 exports.TreeNode = TreeNode;
8395 exports.SENTINEL = new TreeNode(null, 0 /* Black */);
8396 exports.SENTINEL.parent = exports.SENTINEL;
8397 exports.SENTINEL.left = exports.SENTINEL;
8398 exports.SENTINEL.right = exports.SENTINEL;
8399 exports.SENTINEL.color = 0 /* Black */;
8400 function leftest(node) {
8401     while (node.left !== exports.SENTINEL) {
8402         node = node.left;
8403     }
8404     return node;
8405 }
8406 exports.leftest = leftest;
8407 function righttest(node) {
8408     while (node.right !== exports.SENTINEL) {
8409         node = node.right;
8410     }
8411     return node;
8412 }
8413 exports.righttest = righttest;
8414 function calculateSize(node) {
8415     if (node === exports.SENTINEL) {
8416         return 0;
8417     }
8418     return node.size_left + node.piece.length + calculateSize(node.right);
8419 }
8420 exports.calculateSize = calculateSize;
8421 function calculateLF(node) {
8422     if (node === exports.SENTINEL) {
8423         return 0;
8424     }
8425     return node.lf_left + node.piece.lineFeedCnt + calculateLF(node.right);
8426 }
8427 exports.calculateLF = calculateLF;
8428 function resetSentinel() {
8429     exports.SENTINEL.parent = exports.SENTINEL;
8430 }
8431 exports.resetSentinel = resetSentinel;
8432 function leftRotate(tree, x) {
8433     let y = x.right;
8434     // fix size_left
8435     y.size_left += x.size_left + (x.piece ? x.piece.length : 0);
8436     y.lf_left += x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
8437     x.right = y.left;
8438     if (y.left !== exports.SENTINEL) {
8439         y.left.parent = x;
8440     }
8441     y.parent = x.parent;
8442     if (x.parent === exports.SENTINEL) {
8443         tree.root = y;
8444     }
8445     else if (x.parent.left === x) {
8446         x.parent.left = y;
8447     }
8448     else {
8449         x.parent.right = y;
8450     }
8451     y.left = x;
8452     x.parent = y;
8453 }
8454 exports.leftRotate = leftRotate;
8455 function rightRotate(tree, y) {
8456     let x = y.left;
8457     y.left = x.right;
8458     if (x.right !== exports.SENTINEL) {
8459         x.right.parent = y;
8460     }
8461     x.parent = y.parent;
8462     // fix size_left
8463     y.size_left -= x.size_left + (x.piece ? x.piece.length : 0);
8464     y.lf_left -= x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
8465     if (y.parent === exports.SENTINEL) {
8466         tree.root = x;
8467     }
8468     else if (y === y.parent.right) {
8469         y.parent.right = x;
8470     }
8471     else {
8472         y.parent.left = x;
8473     }
8474     x.right = y;
8475     y.parent = x;
8476 }
8477 exports.rightRotate = rightRotate;
8478 function rbDelete(tree, z) {
8479     let x;
8480     let y;
8481     if (z.left === exports.SENTINEL) {
8482         y = z;
8483         x = y.right;
8484     }
8485     else if (z.right === exports.SENTINEL) {
8486         y = z;
8487         x = y.left;
8488     }
8489     else {
8490         y = leftest(z.right);
8491         x = y.right;
8492     }
8493     if (y === tree.root) {
8494         tree.root = x;
8495         // if x is null, we are removing the only node
8496         x.color = 0 /* Black */;
8497         z.detach();
8498         resetSentinel();
8499         tree.root.parent = exports.SENTINEL;
8500         return;
8501     }
8502     let yWasRed = (y.color === 1 /* Red */);
8503     if (y === y.parent.left) {
8504         y.parent.left = x;
8505     }
8506     else {
8507         y.parent.right = x;
8508     }
8509     if (y === z) {
8510         x.parent = y.parent;
8511         recomputeTreeMetadata(tree, x);
8512     }
8513     else {
8514         if (y.parent === z) {
8515             x.parent = y;
8516         }
8517         else {
8518             x.parent = y.parent;
8519         }
8520         // as we make changes to x's hierarchy, update size_left of subtree first
8521         recomputeTreeMetadata(tree, x);
8522         y.left = z.left;
8523         y.right = z.right;
8524         y.parent = z.parent;
8525         y.color = z.color;
8526         if (z === tree.root) {
8527             tree.root = y;
8528         }
8529         else {
8530             if (z === z.parent.left) {
8531                 z.parent.left = y;
8532             }
8533             else {
8534                 z.parent.right = y;
8535             }
8536         }
8537         if (y.left !== exports.SENTINEL) {
8538             y.left.parent = y;
8539         }
8540         if (y.right !== exports.SENTINEL) {
8541             y.right.parent = y;
8542         }
8543         // update metadata
8544         // we replace z with y, so in this sub tree, the length change is z.item.length
8545         y.size_left = z.size_left;
8546         y.lf_left = z.lf_left;
8547         recomputeTreeMetadata(tree, y);
8548     }
8549     z.detach();
8550     if (x.parent.left === x) {
8551         let newSizeLeft = calculateSize(x);
8552         let newLFLeft = calculateLF(x);
8553         if (newSizeLeft !== x.parent.size_left || newLFLeft !== x.parent.lf_left) {
8554             let delta = newSizeLeft - x.parent.size_left;
8555             let lf_delta = newLFLeft - x.parent.lf_left;
8556             x.parent.size_left = newSizeLeft;
8557             x.parent.lf_left = newLFLeft;
8558             updateTreeMetadata(tree, x.parent, delta, lf_delta);
8559         }
8560     }
8561     recomputeTreeMetadata(tree, x.parent);
8562     if (yWasRed) {
8563         resetSentinel();
8564         return;
8565     }
8566     // RB-DELETE-FIXUP
8567     let w;
8568     while (x !== tree.root && x.color === 0 /* Black */) {
8569         if (x === x.parent.left) {
8570             w = x.parent.right;
8571             if (w.color === 1 /* Red */) {
8572                 w.color = 0 /* Black */;
8573                 x.parent.color = 1 /* Red */;
8574                 leftRotate(tree, x.parent);
8575                 w = x.parent.right;
8576             }
8577             if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
8578                 w.color = 1 /* Red */;
8579                 x = x.parent;
8580             }
8581             else {
8582                 if (w.right.color === 0 /* Black */) {
8583                     w.left.color = 0 /* Black */;
8584                     w.color = 1 /* Red */;
8585                     rightRotate(tree, w);
8586                     w = x.parent.right;
8587                 }
8588                 w.color = x.parent.color;
8589                 x.parent.color = 0 /* Black */;
8590                 w.right.color = 0 /* Black */;
8591                 leftRotate(tree, x.parent);
8592                 x = tree.root;
8593             }
8594         }
8595         else {
8596             w = x.parent.left;
8597             if (w.color === 1 /* Red */) {
8598                 w.color = 0 /* Black */;
8599                 x.parent.color = 1 /* Red */;
8600                 rightRotate(tree, x.parent);
8601                 w = x.parent.left;
8602             }
8603             if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
8604                 w.color = 1 /* Red */;
8605                 x = x.parent;
8606             }
8607             else {
8608                 if (w.left.color === 0 /* Black */) {
8609                     w.right.color = 0 /* Black */;
8610                     w.color = 1 /* Red */;
8611                     leftRotate(tree, w);
8612                     w = x.parent.left;
8613                 }
8614                 w.color = x.parent.color;
8615                 x.parent.color = 0 /* Black */;
8616                 w.left.color = 0 /* Black */;
8617                 rightRotate(tree, x.parent);
8618                 x = tree.root;
8619             }
8620         }
8621     }
8622     x.color = 0 /* Black */;
8623     resetSentinel();
8624 }
8625 exports.rbDelete = rbDelete;
8626 function fixInsert(tree, x) {
8627     recomputeTreeMetadata(tree, x);
8628     while (x !== tree.root && x.parent.color === 1 /* Red */) {
8629         if (x.parent === x.parent.parent.left) {
8630             const y = x.parent.parent.right;
8631             if (y.color === 1 /* Red */) {
8632                 x.parent.color = 0 /* Black */;
8633                 y.color = 0 /* Black */;
8634                 x.parent.parent.color = 1 /* Red */;
8635                 x = x.parent.parent;
8636             }
8637             else {
8638                 if (x === x.parent.right) {
8639                     x = x.parent;
8640                     leftRotate(tree, x);
8641                 }
8642                 x.parent.color = 0 /* Black */;
8643                 x.parent.parent.color = 1 /* Red */;
8644                 rightRotate(tree, x.parent.parent);
8645             }
8646         }
8647         else {
8648             const y = x.parent.parent.left;
8649             if (y.color === 1 /* Red */) {
8650                 x.parent.color = 0 /* Black */;
8651                 y.color = 0 /* Black */;
8652                 x.parent.parent.color = 1 /* Red */;
8653                 x = x.parent.parent;
8654             }
8655             else {
8656                 if (x === x.parent.left) {
8657                     x = x.parent;
8658                     rightRotate(tree, x);
8659                 }
8660                 x.parent.color = 0 /* Black */;
8661                 x.parent.parent.color = 1 /* Red */;
8662                 leftRotate(tree, x.parent.parent);
8663             }
8664         }
8665     }
8666     tree.root.color = 0 /* Black */;
8667 }
8668 exports.fixInsert = fixInsert;
8669 function updateTreeMetadata(tree, x, delta, lineFeedCntDelta) {
8670     // node length change or line feed count change
8671     while (x !== tree.root && x !== exports.SENTINEL) {
8672         if (x.parent.left === x) {
8673             x.parent.size_left += delta;
8674             x.parent.lf_left += lineFeedCntDelta;
8675         }
8676         x = x.parent;
8677     }
8678 }
8679 exports.updateTreeMetadata = updateTreeMetadata;
8680 function recomputeTreeMetadata(tree, x) {
8681     let delta = 0;
8682     let lf_delta = 0;
8683     if (x === tree.root) {
8684         return;
8685     }
8686     if (delta === 0) {
8687         // go upwards till the node whose left subtree is changed.
8688         while (x !== tree.root && x === x.parent.right) {
8689             x = x.parent;
8690         }
8691         if (x === tree.root) {
8692             // well, it means we add a node to the end (inorder)
8693             return;
8694         }
8695         // x is the node whose right subtree is changed.
8696         x = x.parent;
8697         delta = calculateSize(x.left) - x.size_left;
8698         lf_delta = calculateLF(x.left) - x.lf_left;
8699         x.size_left += delta;
8700         x.lf_left += lf_delta;
8701     }
8702     // go upwards till root. O(logN)
8703     while (x !== tree.root && (delta !== 0 || lf_delta !== 0)) {
8704         if (x.parent.left === x) {
8705             x.parent.size_left += delta;
8706             x.parent.lf_left += lf_delta;
8707         }
8708         x = x.parent;
8709     }
8710 }
8711 exports.recomputeTreeMetadata = recomputeTreeMetadata;
8712
8713
8714 /***/ }),
8715 /* 46 */
8716 /***/ (function(module, exports, __webpack_require__) {
8717
8718 "use strict";
8719
8720 /*---------------------------------------------------------------------------------------------
8721  *  Copyright (c) Microsoft Corporation. All rights reserved.
8722  *  Licensed under the MIT License. See License.txt in the project root for license information.
8723  *--------------------------------------------------------------------------------------------*/
8724 Object.defineProperty(exports, "__esModule", { value: true });
8725 const pieceTreeBase_1 = __webpack_require__(43);
8726 exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
8727 function startsWithUTF8BOM(str) {
8728     return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
8729 }
8730 exports.startsWithUTF8BOM = startsWithUTF8BOM;
8731 class PieceTreeTextBufferFactory {
8732     constructor(_chunks, _bom, _cr, _lf, _crlf, _normalizeEOL) {
8733         this._chunks = _chunks;
8734         this._bom = _bom;
8735         this._cr = _cr;
8736         this._lf = _lf;
8737         this._crlf = _crlf;
8738         this._normalizeEOL = _normalizeEOL;
8739     }
8740     _getEOL(defaultEOL) {
8741         const totalEOLCount = this._cr + this._lf + this._crlf;
8742         const totalCRCount = this._cr + this._crlf;
8743         if (totalEOLCount === 0) {
8744             // This is an empty file or a file with precisely one line
8745             return (defaultEOL === 1 /* LF */ ? '\n' : '\r\n');
8746         }
8747         if (totalCRCount > totalEOLCount / 2) {
8748             // More than half of the file contains \r\n ending lines
8749             return '\r\n';
8750         }
8751         // At least one line more ends in \n
8752         return '\n';
8753     }
8754     create(defaultEOL) {
8755         const eol = this._getEOL(defaultEOL);
8756         let chunks = this._chunks;
8757         if (this._normalizeEOL &&
8758             ((eol === '\r\n' && (this._cr > 0 || this._lf > 0))
8759                 || (eol === '\n' && (this._cr > 0 || this._crlf > 0)))) {
8760             // Normalize pieces
8761             for (let i = 0, len = chunks.length; i < len; i++) {
8762                 let str = chunks[i].buffer.replace(/\r\n|\r|\n/g, eol);
8763                 let newLineStart = pieceTreeBase_1.createLineStartsFast(str);
8764                 chunks[i] = new pieceTreeBase_1.StringBuffer(str, newLineStart);
8765             }
8766         }
8767         return new pieceTreeBase_1.PieceTreeBase(chunks, eol, this._normalizeEOL);
8768     }
8769     getFirstLineText(lengthLimit) {
8770         return this._chunks[0].buffer.substr(0, 100).split(/\r\n|\r|\n/)[0];
8771     }
8772 }
8773 exports.PieceTreeTextBufferFactory = PieceTreeTextBufferFactory;
8774 class PieceTreeTextBufferBuilder {
8775     constructor() {
8776         this.chunks = [];
8777         this.BOM = '';
8778         this._hasPreviousChar = false;
8779         this._previousChar = 0;
8780         this._tmpLineStarts = [];
8781         this.cr = 0;
8782         this.lf = 0;
8783         this.crlf = 0;
8784     }
8785     acceptChunk(chunk) {
8786         if (chunk.length === 0) {
8787             return;
8788         }
8789         if (this.chunks.length === 0) {
8790             if (startsWithUTF8BOM(chunk)) {
8791                 this.BOM = exports.UTF8_BOM_CHARACTER;
8792                 chunk = chunk.substr(1);
8793             }
8794         }
8795         const lastChar = chunk.charCodeAt(chunk.length - 1);
8796         if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
8797             // last character is \r or a high surrogate => keep it back
8798             this._acceptChunk1(chunk.substr(0, chunk.length - 1), false);
8799             this._hasPreviousChar = true;
8800             this._previousChar = lastChar;
8801         }
8802         else {
8803             this._acceptChunk1(chunk, false);
8804             this._hasPreviousChar = false;
8805             this._previousChar = lastChar;
8806         }
8807     }
8808     _acceptChunk1(chunk, allowEmptyStrings) {
8809         if (!allowEmptyStrings && chunk.length === 0) {
8810             // Nothing to do
8811             return;
8812         }
8813         if (this._hasPreviousChar) {
8814             this._acceptChunk2(String.fromCharCode(this._previousChar) + chunk);
8815         }
8816         else {
8817             this._acceptChunk2(chunk);
8818         }
8819     }
8820     _acceptChunk2(chunk) {
8821         const lineStarts = pieceTreeBase_1.createLineStarts(this._tmpLineStarts, chunk);
8822         this.chunks.push(new pieceTreeBase_1.StringBuffer(chunk, lineStarts.lineStarts));
8823         this.cr += lineStarts.cr;
8824         this.lf += lineStarts.lf;
8825         this.crlf += lineStarts.crlf;
8826     }
8827     finish(normalizeEOL = true) {
8828         this._finish();
8829         return new PieceTreeTextBufferFactory(this.chunks, this.BOM, this.cr, this.lf, this.crlf, normalizeEOL);
8830     }
8831     _finish() {
8832         if (this.chunks.length === 0) {
8833             this._acceptChunk1('', true);
8834         }
8835         if (this._hasPreviousChar) {
8836             this._hasPreviousChar = false;
8837             // recreate last chunk
8838             let lastChunk = this.chunks[this.chunks.length - 1];
8839             lastChunk.buffer += String.fromCharCode(this._previousChar);
8840             let newLineStarts = pieceTreeBase_1.createLineStartsFast(lastChunk.buffer);
8841             lastChunk.lineStarts = newLineStarts;
8842             if (this._previousChar === 13 /* CarriageReturn */) {
8843                 this.cr++;
8844             }
8845         }
8846     }
8847 }
8848 exports.PieceTreeTextBufferBuilder = PieceTreeTextBufferBuilder;
8849
8850
8851 /***/ }),
8852 /* 47 */
8853 /***/ (function(module, exports, __webpack_require__) {
8854
8855 "use strict";
8856
8857 /*---------------------------------------------------------------------------------------------
8858  *  Copyright (c) Microsoft Corporation. All rights reserved.
8859  *  Licensed under the MIT License. See License.txt in the project root for license information.
8860  *--------------------------------------------------------------------------------------------*/
8861 Object.defineProperty(exports, "__esModule", { value: true });
8862 const position_1 = __webpack_require__(44);
8863 /**
8864  * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
8865  */
8866 class Range {
8867     constructor(startLineNumber, startColumn, endLineNumber, endColumn) {
8868         if ((startLineNumber > endLineNumber) || (startLineNumber === endLineNumber && startColumn > endColumn)) {
8869             this.startLineNumber = endLineNumber;
8870             this.startColumn = endColumn;
8871             this.endLineNumber = startLineNumber;
8872             this.endColumn = startColumn;
8873         }
8874         else {
8875             this.startLineNumber = startLineNumber;
8876             this.startColumn = startColumn;
8877             this.endLineNumber = endLineNumber;
8878             this.endColumn = endColumn;
8879         }
8880     }
8881     /**
8882      * Test if this range is empty.
8883      */
8884     isEmpty() {
8885         return Range.isEmpty(this);
8886     }
8887     /**
8888      * Test if `range` is empty.
8889      */
8890     static isEmpty(range) {
8891         return (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn);
8892     }
8893     /**
8894      * Test if position is in this range. If the position is at the edges, will return true.
8895      */
8896     containsPosition(position) {
8897         return Range.containsPosition(this, position);
8898     }
8899     /**
8900      * Test if `position` is in `range`. If the position is at the edges, will return true.
8901      */
8902     static containsPosition(range, position) {
8903         if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
8904             return false;
8905         }
8906         if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
8907             return false;
8908         }
8909         if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
8910             return false;
8911         }
8912         return true;
8913     }
8914     /**
8915      * Test if range is in this range. If the range is equal to this range, will return true.
8916      */
8917     containsRange(range) {
8918         return Range.containsRange(this, range);
8919     }
8920     /**
8921      * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
8922      */
8923     static containsRange(range, otherRange) {
8924         if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
8925             return false;
8926         }
8927         if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
8928             return false;
8929         }
8930         if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
8931             return false;
8932         }
8933         if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
8934             return false;
8935         }
8936         return true;
8937     }
8938     /**
8939      * A reunion of the two ranges.
8940      * The smallest position will be used as the start point, and the largest one as the end point.
8941      */
8942     plusRange(range) {
8943         return Range.plusRange(this, range);
8944     }
8945     /**
8946      * A reunion of the two ranges.
8947      * The smallest position will be used as the start point, and the largest one as the end point.
8948      */
8949     static plusRange(a, b) {
8950         let startLineNumber;
8951         let startColumn;
8952         let endLineNumber;
8953         let endColumn;
8954         if (b.startLineNumber < a.startLineNumber) {
8955             startLineNumber = b.startLineNumber;
8956             startColumn = b.startColumn;
8957         }
8958         else if (b.startLineNumber === a.startLineNumber) {
8959             startLineNumber = b.startLineNumber;
8960             startColumn = Math.min(b.startColumn, a.startColumn);
8961         }
8962         else {
8963             startLineNumber = a.startLineNumber;
8964             startColumn = a.startColumn;
8965         }
8966         if (b.endLineNumber > a.endLineNumber) {
8967             endLineNumber = b.endLineNumber;
8968             endColumn = b.endColumn;
8969         }
8970         else if (b.endLineNumber === a.endLineNumber) {
8971             endLineNumber = b.endLineNumber;
8972             endColumn = Math.max(b.endColumn, a.endColumn);
8973         }
8974         else {
8975             endLineNumber = a.endLineNumber;
8976             endColumn = a.endColumn;
8977         }
8978         return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
8979     }
8980     /**
8981      * A intersection of the two ranges.
8982      */
8983     intersectRanges(range) {
8984         return Range.intersectRanges(this, range);
8985     }
8986     /**
8987      * A intersection of the two ranges.
8988      */
8989     static intersectRanges(a, b) {
8990         let resultStartLineNumber = a.startLineNumber;
8991         let resultStartColumn = a.startColumn;
8992         let resultEndLineNumber = a.endLineNumber;
8993         let resultEndColumn = a.endColumn;
8994         let otherStartLineNumber = b.startLineNumber;
8995         let otherStartColumn = b.startColumn;
8996         let otherEndLineNumber = b.endLineNumber;
8997         let otherEndColumn = b.endColumn;
8998         if (resultStartLineNumber < otherStartLineNumber) {
8999             resultStartLineNumber = otherStartLineNumber;
9000             resultStartColumn = otherStartColumn;
9001         }
9002         else if (resultStartLineNumber === otherStartLineNumber) {
9003             resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
9004         }
9005         if (resultEndLineNumber > otherEndLineNumber) {
9006             resultEndLineNumber = otherEndLineNumber;
9007             resultEndColumn = otherEndColumn;
9008         }
9009         else if (resultEndLineNumber === otherEndLineNumber) {
9010             resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
9011         }
9012         // Check if selection is now empty
9013         if (resultStartLineNumber > resultEndLineNumber) {
9014             return null;
9015         }
9016         if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
9017             return null;
9018         }
9019         return new Range(resultStartLineNumber, resultStartColumn, resultEndLineNumber, resultEndColumn);
9020     }
9021     /**
9022      * Test if this range equals other.
9023      */
9024     equalsRange(other) {
9025         return Range.equalsRange(this, other);
9026     }
9027     /**
9028      * Test if range `a` equals `b`.
9029      */
9030     static equalsRange(a, b) {
9031         return (!!a &&
9032             !!b &&
9033             a.startLineNumber === b.startLineNumber &&
9034             a.startColumn === b.startColumn &&
9035             a.endLineNumber === b.endLineNumber &&
9036             a.endColumn === b.endColumn);
9037     }
9038     /**
9039      * Return the end position (which will be after or equal to the start position)
9040      */
9041     getEndPosition() {
9042         return new position_1.Position(this.endLineNumber, this.endColumn);
9043     }
9044     /**
9045      * Return the start position (which will be before or equal to the end position)
9046      */
9047     getStartPosition() {
9048         return new position_1.Position(this.startLineNumber, this.startColumn);
9049     }
9050     /**
9051      * Transform to a user presentable string representation.
9052      */
9053     toString() {
9054         return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
9055     }
9056     /**
9057      * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
9058      */
9059     setEndPosition(endLineNumber, endColumn) {
9060         return new Range(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
9061     }
9062     /**
9063      * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
9064      */
9065     setStartPosition(startLineNumber, startColumn) {
9066         return new Range(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
9067     }
9068     /**
9069      * Create a new empty range using this range's start position.
9070      */
9071     collapseToStart() {
9072         return Range.collapseToStart(this);
9073     }
9074     /**
9075      * Create a new empty range using this range's start position.
9076      */
9077     static collapseToStart(range) {
9078         return new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
9079     }
9080     // ---
9081     static fromPositions(start, end = start) {
9082         return new Range(start.lineNumber, start.column, end.lineNumber, end.column);
9083     }
9084     static lift(range) {
9085         if (!range) {
9086             return null;
9087         }
9088         return new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
9089     }
9090     /**
9091      * Test if `obj` is an `IRange`.
9092      */
9093     static isIRange(obj) {
9094         return (obj
9095             && (typeof obj.startLineNumber === 'number')
9096             && (typeof obj.startColumn === 'number')
9097             && (typeof obj.endLineNumber === 'number')
9098             && (typeof obj.endColumn === 'number'));
9099     }
9100     /**
9101      * Test if the two ranges are touching in any way.
9102      */
9103     static areIntersectingOrTouching(a, b) {
9104         // Check if `a` is before `b`
9105         if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn)) {
9106             return false;
9107         }
9108         // Check if `b` is before `a`
9109         if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn)) {
9110             return false;
9111         }
9112         // These ranges must intersect
9113         return true;
9114     }
9115     /**
9116      * Test if the two ranges are intersecting. If the ranges are touching it returns true.
9117      */
9118     static areIntersecting(a, b) {
9119         // Check if `a` is before `b`
9120         if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn)) {
9121             return false;
9122         }
9123         // Check if `b` is before `a`
9124         if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn)) {
9125             return false;
9126         }
9127         // These ranges must intersect
9128         return true;
9129     }
9130     /**
9131      * A function that compares ranges, useful for sorting ranges
9132      * It will first compare ranges on the startPosition and then on the endPosition
9133      */
9134     static compareRangesUsingStarts(a, b) {
9135         if (a && b) {
9136             const aStartLineNumber = a.startLineNumber | 0;
9137             const bStartLineNumber = b.startLineNumber | 0;
9138             if (aStartLineNumber === bStartLineNumber) {
9139                 const aStartColumn = a.startColumn | 0;
9140                 const bStartColumn = b.startColumn | 0;
9141                 if (aStartColumn === bStartColumn) {
9142                     const aEndLineNumber = a.endLineNumber | 0;
9143                     const bEndLineNumber = b.endLineNumber | 0;
9144                     if (aEndLineNumber === bEndLineNumber) {
9145                         const aEndColumn = a.endColumn | 0;
9146                         const bEndColumn = b.endColumn | 0;
9147                         return aEndColumn - bEndColumn;
9148                     }
9149                     return aEndLineNumber - bEndLineNumber;
9150                 }
9151                 return aStartColumn - bStartColumn;
9152             }
9153             return aStartLineNumber - bStartLineNumber;
9154         }
9155         const aExists = (a ? 1 : 0);
9156         const bExists = (b ? 1 : 0);
9157         return aExists - bExists;
9158     }
9159     /**
9160      * A function that compares ranges, useful for sorting ranges
9161      * It will first compare ranges on the endPosition and then on the startPosition
9162      */
9163     static compareRangesUsingEnds(a, b) {
9164         if (a.endLineNumber === b.endLineNumber) {
9165             if (a.endColumn === b.endColumn) {
9166                 if (a.startLineNumber === b.startLineNumber) {
9167                     return a.startColumn - b.startColumn;
9168                 }
9169                 return a.startLineNumber - b.startLineNumber;
9170             }
9171             return a.endColumn - b.endColumn;
9172         }
9173         return a.endLineNumber - b.endLineNumber;
9174     }
9175     /**
9176      * Test if the range spans multiple lines.
9177      */
9178     static spansMultipleLines(range) {
9179         return range.endLineNumber > range.startLineNumber;
9180     }
9181 }
9182 exports.Range = Range;
9183
9184
9185 /***/ }),
9186 /* 48 */
9187 /***/ (function(module, exports, __webpack_require__) {
9188
9189 "use strict";
9190 /* --------------------------------------------------------------------------------------------\r
9191  * Copyright (c) Microsoft Corporation. All rights reserved.\r
9192  * Licensed under the MIT License. See License.txt in the project root for license information.\r
9193  * ------------------------------------------------------------------------------------------ */\r
9194 \r
9195 Object.defineProperty(exports, "__esModule", { value: true });\r
9196 const vscode_languageserver_protocol_1 = __webpack_require__(3);\r
9197 const uuid_1 = __webpack_require__(38);\r
9198 class ProgressImpl {\r
9199     constructor(_connection, title, percentage, message, cancellable) {\r
9200         this._connection = _connection;\r
9201         this._id = uuid_1.generateUuid();\r
9202         let params = {\r
9203             id: this._id,\r
9204             title,\r
9205             cancellable\r
9206         };\r
9207         if (percentage !== undefined) {\r
9208             params.percentage = percentage;\r
9209         }\r
9210         if (message !== undefined) {\r
9211             params.message = message;\r
9212         }\r
9213         if (cancellable !== undefined) {\r
9214             params.cancellable = cancellable;\r
9215         }\r
9216         ProgressImpl.Instances.set(this._id, this);\r
9217         this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();\r
9218         this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressStartNotification.type, params);\r
9219     }\r
9220     get token() {\r
9221         return this._source.token;\r
9222     }\r
9223     report(arg0, arg1) {\r
9224         let percentage;\r
9225         let message;\r
9226         if (typeof arg0 === 'number') {\r
9227             percentage = arg0;\r
9228             if (arg1 !== undefined) {\r
9229                 message = arg1;\r
9230             }\r
9231         }\r
9232         else {\r
9233             message = arg0;\r
9234         }\r
9235         this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressReportNotification.type, { id: this._id, percentage, message });\r
9236     }\r
9237     done() {\r
9238         ProgressImpl.Instances.delete(this._id);\r
9239         this._source.dispose();\r
9240         this._connection.sendNotification(vscode_languageserver_protocol_1.Proposed.ProgressDoneNotification.type, { id: this._id });\r
9241     }\r
9242     cancel() {\r
9243         this._source.cancel();\r
9244     }\r
9245 }\r
9246 ProgressImpl.Instances = new Map();\r
9247 class NullProgress {\r
9248     constructor() {\r
9249         this._source = new vscode_languageserver_protocol_1.CancellationTokenSource();\r
9250     }\r
9251     get token() {\r
9252         return this._source.token;\r
9253     }\r
9254     report() {\r
9255     }\r
9256     done() {\r
9257     }\r
9258 }\r
9259 exports.ProgressFeature = (Base) => {\r
9260     return class extends Base {\r
9261         initialize(cap) {\r
9262             let capabilities = cap;\r
9263             if (capabilities.window && capabilities.window.progress) {\r
9264                 this._progressSupported = true;\r
9265                 this.connection.onNotification(vscode_languageserver_protocol_1.Proposed.ProgressCancelNotification.type, (params) => {\r
9266                     let progress = ProgressImpl.Instances.get(params.id);\r
9267                     if (progress !== undefined) {\r
9268                         progress.cancel();\r
9269                     }\r
9270                 });\r
9271             }\r
9272         }\r
9273         createProgress(title, percentage, message, cancellable) {\r
9274             if (this._progressSupported) {\r
9275                 return new ProgressImpl(this.connection, title, percentage, message, cancellable);\r
9276             }\r
9277             else {\r
9278                 return new NullProgress();\r
9279             }\r
9280         }\r
9281     };\r
9282 };\r
9283
9284
9285 /***/ }),
9286 /* 49 */
9287 /***/ (function(module, exports, __webpack_require__) {
9288
9289 "use strict";
9290 /*---------------------------------------------------------------------------------------------
9291  *  Copyright (c) Microsoft Corporation. All rights reserved.
9292  *  Licensed under the MIT License. See License.txt in the project root for license information.
9293  *--------------------------------------------------------------------------------------------*/
9294
9295 Object.defineProperty(exports, "__esModule", { value: true });
9296 var url_1 = __webpack_require__(40);
9297 var https = __webpack_require__(50);
9298 var http = __webpack_require__(51);
9299 var HttpProxyAgent = __webpack_require__(52);
9300 var HttpsProxyAgent = __webpack_require__(69);
9301 var zlib = __webpack_require__(75);
9302 var nls = __webpack_require__(76);
9303 nls.config(process.env['VSCODE_NLS_CONFIG']);
9304 var localize = nls.loadMessageBundle();
9305 var proxyUrl = null;
9306 var strictSSL = true;
9307 function configure(_proxyUrl, _strictSSL) {
9308     proxyUrl = _proxyUrl;
9309     strictSSL = _strictSSL;
9310 }
9311 exports.configure = configure;
9312 function xhr(options) {
9313     var agent = getProxyAgent(options.url, { proxyUrl: proxyUrl, strictSSL: strictSSL });
9314     options = assign({}, options);
9315     options = assign(options, { agent: agent, strictSSL: strictSSL });
9316     if (typeof options.followRedirects !== 'number') {
9317         options.followRedirects = 5;
9318     }
9319     return request(options).then(function (result) { return new Promise(function (c, e) {
9320         var res = result.res;
9321         var readable = res;
9322         var encoding = res.headers && res.headers['content-encoding'];
9323         var isCompleted = false;
9324         if (encoding === 'gzip') {
9325             var gunzip = zlib.createGunzip();
9326             res.pipe(gunzip);
9327             readable = gunzip;
9328         }
9329         else if (encoding === 'deflate') {
9330             var inflate = zlib.createInflate();
9331             res.pipe(inflate);
9332             readable = inflate;
9333         }
9334         var data = [];
9335         readable.on('data', function (c) { return data.push(c); });
9336         readable.on('end', function () {
9337             if (isCompleted) {
9338                 return;
9339             }
9340             isCompleted = true;
9341             if (options.followRedirects > 0 && (res.statusCode >= 300 && res.statusCode <= 303 || res.statusCode === 307)) {
9342                 var location = res.headers['location'];
9343                 if (location) {
9344                     var newOptions = {
9345                         type: options.type, url: location, user: options.user, password: options.password, responseType: options.responseType, headers: options.headers,
9346                         timeout: options.timeout, followRedirects: options.followRedirects - 1, data: options.data
9347                     };
9348                     xhr(newOptions).then(c, e);
9349                     return;
9350                 }
9351             }
9352             var response = {
9353                 responseText: data.join(''),
9354                 status: res.statusCode
9355             };
9356             if ((res.statusCode >= 200 && res.statusCode < 300) || res.statusCode === 1223) {
9357                 c(response);
9358             }
9359             else {
9360                 e(response);
9361             }
9362         });
9363         readable.on('error', function (err) {
9364             var response = {
9365                 responseText: localize('error', 'Unable to access {0}. Error: {1}', options.url, err.message),
9366                 status: 500
9367             };
9368             isCompleted = true;
9369             e(response);
9370         });
9371     }); }, function (err) {
9372         var message;
9373         if (agent) {
9374             message = localize('error.cannot.connect.proxy', 'Unable to connect to {0} through a proxy . Error: {1}', options.url, err.message);
9375         }
9376         else {
9377             message = localize('error.cannot.connect', 'Unable to connect to {0}. Error: {1}', options.url, err.message);
9378         }
9379         return Promise.reject({
9380             responseText: message,
9381             status: 404
9382         });
9383     });
9384 }
9385 exports.xhr = xhr;
9386 function assign(destination) {
9387     var sources = [];
9388     for (var _i = 1; _i < arguments.length; _i++) {
9389         sources[_i - 1] = arguments[_i];
9390     }
9391     sources.forEach(function (source) { return Object.keys(source).forEach(function (key) { return destination[key] = source[key]; }); });
9392     return destination;
9393 }
9394 function request(options) {
9395     var req;
9396     return new Promise(function (c, e) {
9397         var endpoint = url_1.parse(options.url);
9398         var opts = {
9399             hostname: endpoint.hostname,
9400             port: endpoint.port ? parseInt(endpoint.port) : (endpoint.protocol === 'https:' ? 443 : 80),
9401             path: endpoint.path,
9402             method: options.type || 'GET',
9403             headers: options.headers,
9404             agent: options.agent,
9405             rejectUnauthorized: (typeof options.strictSSL === 'boolean') ? options.strictSSL : true
9406         };
9407         if (options.user && options.password) {
9408             opts.auth = options.user + ':' + options.password;
9409         }
9410         var handler = function (res) {
9411             if (res.statusCode >= 300 && res.statusCode < 400 && options.followRedirects && options.followRedirects > 0 && res.headers['location']) {
9412                 c(request(assign({}, options, {
9413                     url: res.headers['location'],
9414                     followRedirects: options.followRedirects - 1
9415                 })));
9416             }
9417             else {
9418                 c({ req: req, res: res });
9419             }
9420         };
9421         if (endpoint.protocol === 'https:') {
9422             req = https.request(opts, handler);
9423         }
9424         else {
9425             req = http.request(opts, handler);
9426         }
9427         req.on('error', e);
9428         if (options.timeout) {
9429             req.setTimeout(options.timeout);
9430         }
9431         if (options.data) {
9432             req.write(options.data);
9433         }
9434         req.end();
9435     });
9436 }
9437 function getErrorStatusDescription(status) {
9438     if (status < 400) {
9439         return void 0;
9440     }
9441     switch (status) {
9442         case 400: return localize('status.400', 'Bad request. The request cannot be fulfilled due to bad syntax.');
9443         case 401: return localize('status.401', 'Unauthorized. The server is refusing to respond.');
9444         case 403: return localize('status.403', 'Forbidden. The server is refusing to respond.');
9445         case 404: return localize('status.404', 'Not Found. The requested location could not be found.');
9446         case 405: return localize('status.405', 'Method not allowed. A request was made using a request method not supported by that location.');
9447         case 406: return localize('status.406', 'Not Acceptable. The server can only generate a response that is not accepted by the client.');
9448         case 407: return localize('status.407', 'Proxy Authentication Required. The client must first authenticate itself with the proxy.');
9449         case 408: return localize('status.408', 'Request Timeout. The server timed out waiting for the request.');
9450         case 409: return localize('status.409', 'Conflict. The request could not be completed because of a conflict in the request.');
9451         case 410: return localize('status.410', 'Gone. The requested page is no longer available.');
9452         case 411: return localize('status.411', 'Length Required. The "Content-Length" is not defined.');
9453         case 412: return localize('status.412', 'Precondition Failed. The precondition given in the request evaluated to false by the server.');
9454         case 413: return localize('status.413', 'Request Entity Too Large. The server will not accept the request, because the request entity is too large.');
9455         case 414: return localize('status.414', 'Request-URI Too Long. The server will not accept the request, because the URL is too long.');
9456         case 415: return localize('status.415', 'Unsupported Media Type. The server will not accept the request, because the media type is not supported.');
9457         case 500: return localize('status.500', 'Internal Server Error.');
9458         case 501: return localize('status.501', 'Not Implemented. The server either does not recognize the request method, or it lacks the ability to fulfill the request.');
9459         case 503: return localize('status.503', 'Service Unavailable. The server is currently unavailable (overloaded or down).');
9460         default: return localize('status.416', 'HTTP status code {0}', status);
9461     }
9462 }
9463 exports.getErrorStatusDescription = getErrorStatusDescription;
9464 // proxy handling
9465 function getSystemProxyURI(requestURL) {
9466     if (requestURL.protocol === 'http:') {
9467         return process.env.HTTP_PROXY || process.env.http_proxy || null;
9468     }
9469     else if (requestURL.protocol === 'https:') {
9470         return process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || null;
9471     }
9472     return null;
9473 }
9474 function getProxyAgent(rawRequestURL, options) {
9475     if (options === void 0) { options = {}; }
9476     var requestURL = url_1.parse(rawRequestURL);
9477     var proxyURL = options.proxyUrl || getSystemProxyURI(requestURL);
9478     if (!proxyURL) {
9479         return null;
9480     }
9481     var proxyEndpoint = url_1.parse(proxyURL);
9482     if (!/^https?:$/.test(proxyEndpoint.protocol)) {
9483         return null;
9484     }
9485     var opts = {
9486         host: proxyEndpoint.hostname,
9487         port: Number(proxyEndpoint.port),
9488         auth: proxyEndpoint.auth,
9489         rejectUnauthorized: (typeof options.strictSSL === 'boolean') ? options.strictSSL : true
9490     };
9491     return requestURL.protocol === 'http:' ? new HttpProxyAgent(opts) : new HttpsProxyAgent(opts);
9492 }
9493 //# sourceMappingURL=main.js.map
9494
9495 /***/ }),
9496 /* 50 */
9497 /***/ (function(module, exports) {
9498
9499 module.exports = require("https");
9500
9501 /***/ }),
9502 /* 51 */
9503 /***/ (function(module, exports) {
9504
9505 module.exports = require("http");
9506
9507 /***/ }),
9508 /* 52 */
9509 /***/ (function(module, exports, __webpack_require__) {
9510
9511
9512 /**
9513  * Module dependencies.
9514  */
9515
9516 var net = __webpack_require__(15);
9517 var tls = __webpack_require__(53);
9518 var url = __webpack_require__(40);
9519 var Agent = __webpack_require__(54);
9520 var inherits = __webpack_require__(56).inherits;
9521 var debug = __webpack_require__(61)('http-proxy-agent');
9522
9523 /**
9524  * Module exports.
9525  */
9526
9527 module.exports = HttpProxyAgent;
9528
9529 /**
9530  * The `HttpProxyAgent` implements an HTTP Agent subclass that connects to the
9531  * specified "HTTP proxy server" in order to proxy HTTP requests.
9532  *
9533  * @api public
9534  */
9535
9536 function HttpProxyAgent (opts) {
9537   if (!(this instanceof HttpProxyAgent)) return new HttpProxyAgent(opts);
9538   if ('string' == typeof opts) opts = url.parse(opts);
9539   if (!opts) throw new Error('an HTTP(S) proxy server `host` and `port` must be specified!');
9540   debug('creating new HttpProxyAgent instance: %o', opts);
9541   Agent.call(this, opts);
9542
9543   var proxy = Object.assign({}, opts);
9544
9545   // if `true`, then connect to the proxy server over TLS. defaults to `false`.
9546   this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;
9547
9548   // prefer `hostname` over `host`, and set the `port` if needed
9549   proxy.host = proxy.hostname || proxy.host;
9550   proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);
9551
9552   if (proxy.host && proxy.path) {
9553     // if both a `host` and `path` are specified then it's most likely the
9554     // result of a `url.parse()` call... we need to remove the `path` portion so
9555     // that `net.connect()` doesn't attempt to open that as a unix socket file.
9556     delete proxy.path;
9557     delete proxy.pathname;
9558   }
9559
9560   this.proxy = proxy;
9561 }
9562 inherits(HttpProxyAgent, Agent);
9563
9564 /**
9565  * Called when the node-core HTTP client library is creating a new HTTP request.
9566  *
9567  * @api public
9568  */
9569
9570 HttpProxyAgent.prototype.callback = function connect (req, opts, fn) {
9571   var proxy = this.proxy;
9572
9573   // change the `http.ClientRequest` instance's "path" field
9574   // to the absolute path of the URL that will be requested
9575   var parsed = url.parse(req.path);
9576   if (null == parsed.protocol) parsed.protocol = 'http:';
9577   if (null == parsed.hostname) parsed.hostname = opts.hostname || opts.host;
9578   if (null == parsed.port) parsed.port = opts.port;
9579   if (parsed.port == 80) {
9580     // if port is 80, then we can remove the port so that the
9581     // ":80" portion is not on the produced URL
9582     delete parsed.port;
9583   }
9584   var absolute = url.format(parsed);
9585   req.path = absolute;
9586
9587   // inject the `Proxy-Authorization` header if necessary
9588   if (proxy.auth) {
9589     req.setHeader(
9590       'Proxy-Authorization',
9591       'Basic ' + Buffer.from(proxy.auth).toString('base64')
9592     );
9593   }
9594
9595   // create a socket connection to the proxy server
9596   var socket;
9597   if (this.secureProxy) {
9598     socket = tls.connect(proxy);
9599   } else {
9600     socket = net.connect(proxy);
9601   }
9602
9603   // at this point, the http ClientRequest's internal `_header` field might have
9604   // already been set. If this is the case then we'll need to re-generate the
9605   // string since we just changed the `req.path`
9606   if (req._header) {
9607     debug('regenerating stored HTTP header string for request');
9608     req._header = null;
9609     req._implicitHeader();
9610     if (req.output && req.output.length > 0) {
9611       debug('patching connection write() output buffer with updated header');
9612       // the _header has already been queued to be written to the socket
9613       var first = req.output[0];
9614       var endOfHeaders = first.indexOf('\r\n\r\n') + 4;
9615       req.output[0] = req._header + first.substring(endOfHeaders);
9616       debug('output buffer: %o', req.output);
9617     }
9618   }
9619
9620   fn(null, socket);
9621 };
9622
9623
9624 /***/ }),
9625 /* 53 */
9626 /***/ (function(module, exports) {
9627
9628 module.exports = require("tls");
9629
9630 /***/ }),
9631 /* 54 */
9632 /***/ (function(module, exports, __webpack_require__) {
9633
9634 "use strict";
9635
9636 __webpack_require__(55);
9637 const inherits = __webpack_require__(56).inherits;
9638 const promisify = __webpack_require__(57);
9639 const EventEmitter = __webpack_require__(60).EventEmitter;
9640
9641 module.exports = Agent;
9642
9643 function isAgent(v) {
9644   return v && typeof v.addRequest === 'function';
9645 }
9646
9647 /**
9648  * Base `http.Agent` implementation.
9649  * No pooling/keep-alive is implemented by default.
9650  *
9651  * @param {Function} callback
9652  * @api public
9653  */
9654 function Agent(callback, _opts) {
9655   if (!(this instanceof Agent)) {
9656     return new Agent(callback, _opts);
9657   }
9658
9659   EventEmitter.call(this);
9660
9661   // The callback gets promisified if it has 3 parameters
9662   // (i.e. it has a callback function) lazily
9663   this._promisifiedCallback = false;
9664
9665   let opts = _opts;
9666   if ('function' === typeof callback) {
9667     this.callback = callback;
9668   } else if (callback) {
9669     opts = callback;
9670   }
9671
9672   // timeout for the socket to be returned from the callback
9673   this.timeout = (opts && opts.timeout) || null;
9674
9675   this.options = opts;
9676 }
9677 inherits(Agent, EventEmitter);
9678
9679 /**
9680  * Override this function in your subclass!
9681  */
9682 Agent.prototype.callback = function callback(req, opts) {
9683   throw new Error(
9684     '"agent-base" has no default implementation, you must subclass and override `callback()`'
9685   );
9686 };
9687
9688 /**
9689  * Called by node-core's "_http_client.js" module when creating
9690  * a new HTTP request with this Agent instance.
9691  *
9692  * @api public
9693  */
9694 Agent.prototype.addRequest = function addRequest(req, _opts) {
9695   const ownOpts = Object.assign({}, _opts);
9696
9697   // Set default `host` for HTTP to localhost
9698   if (null == ownOpts.host) {
9699     ownOpts.host = 'localhost';
9700   }
9701
9702   // Set default `port` for HTTP if none was explicitly specified
9703   if (null == ownOpts.port) {
9704     ownOpts.port = ownOpts.secureEndpoint ? 443 : 80;
9705   }
9706
9707   const opts = Object.assign({}, this.options, ownOpts);
9708
9709   if (opts.host && opts.path) {
9710     // If both a `host` and `path` are specified then it's most likely the
9711     // result of a `url.parse()` call... we need to remove the `path` portion so
9712     // that `net.connect()` doesn't attempt to open that as a unix socket file.
9713     delete opts.path;
9714   }
9715
9716   delete opts.agent;
9717   delete opts.hostname;
9718   delete opts._defaultAgent;
9719   delete opts.defaultPort;
9720   delete opts.createConnection;
9721
9722   // Hint to use "Connection: close"
9723   // XXX: non-documented `http` module API :(
9724   req._last = true;
9725   req.shouldKeepAlive = false;
9726
9727   // Create the `stream.Duplex` instance
9728   let timeout;
9729   let timedOut = false;
9730   const timeoutMs = this.timeout;
9731   const freeSocket = this.freeSocket;
9732
9733   function onerror(err) {
9734     if (req._hadError) return;
9735     req.emit('error', err);
9736     // For Safety. Some additional errors might fire later on
9737     // and we need to make sure we don't double-fire the error event.
9738     req._hadError = true;
9739   }
9740
9741   function ontimeout() {
9742     timeout = null;
9743     timedOut = true;
9744     const err = new Error(
9745       'A "socket" was not created for HTTP request before ' + timeoutMs + 'ms'
9746     );
9747     err.code = 'ETIMEOUT';
9748     onerror(err);
9749   }
9750
9751   function callbackError(err) {
9752     if (timedOut) return;
9753     if (timeout != null) {
9754       clearTimeout(timeout);
9755       timeout = null;
9756     }
9757     onerror(err);
9758   }
9759
9760   function onsocket(socket) {
9761     if (timedOut) return;
9762     if (timeout != null) {
9763       clearTimeout(timeout);
9764       timeout = null;
9765     }
9766     if (isAgent(socket)) {
9767       // `socket` is actually an http.Agent instance, so relinquish
9768       // responsibility for this `req` to the Agent from here on
9769       socket.addRequest(req, opts);
9770     } else if (socket) {
9771       function onfree() {
9772         freeSocket(socket, opts);
9773       }
9774       socket.on('free', onfree);
9775       req.onSocket(socket);
9776     } else {
9777       const err = new Error(
9778         'no Duplex stream was returned to agent-base for `' + req.method + ' ' + req.path + '`'
9779       );
9780       onerror(err);
9781     }
9782   }
9783
9784   if (!this._promisifiedCallback && this.callback.length >= 3) {
9785     // Legacy callback function - convert to a Promise
9786     this.callback = promisify(this.callback, this);
9787     this._promisifiedCallback = true;
9788   }
9789
9790   if (timeoutMs > 0) {
9791     timeout = setTimeout(ontimeout, timeoutMs);
9792   }
9793
9794   try {
9795     Promise.resolve(this.callback(req, opts)).then(onsocket, callbackError);
9796   } catch (err) {
9797     Promise.reject(err).catch(callbackError);
9798   }
9799 };
9800
9801 Agent.prototype.freeSocket = function freeSocket(socket, opts) {
9802   // TODO reuse sockets
9803   socket.destroy();
9804 };
9805
9806
9807 /***/ }),
9808 /* 55 */
9809 /***/ (function(module, exports, __webpack_require__) {
9810
9811 "use strict";
9812
9813 const url = __webpack_require__(40);
9814 const https = __webpack_require__(50);
9815
9816 /**
9817  * This currently needs to be applied to all Node.js versions
9818  * in order to determine if the `req` is an HTTP or HTTPS request.
9819  *
9820  * There is currently no PR attempting to move this property upstream.
9821  */
9822 const patchMarker = "__agent_base_https_request_patched__";
9823 if (!https.request[patchMarker]) {
9824   https.request = (function(request) {
9825     return function(_options, cb) {
9826       let options;
9827       if (typeof _options === 'string') {
9828         options = url.parse(_options);
9829       } else {
9830         options = Object.assign({}, _options);
9831       }
9832       if (null == options.port) {
9833         options.port = 443;
9834       }
9835       options.secureEndpoint = true;
9836       return request.call(https, options, cb);
9837     };
9838   })(https.request);
9839   https.request[patchMarker] = true;
9840 }
9841
9842 /**
9843  * This is needed for Node.js >= 9.0.0 to make sure `https.get()` uses the
9844  * patched `https.request()`.
9845  *
9846  * Ref: https://github.com/nodejs/node/commit/5118f31
9847  */
9848 https.get = function (_url, _options, cb) {
9849     let options;
9850     if (typeof _url === 'string' && _options && typeof _options !== 'function') {
9851       options = Object.assign({}, url.parse(_url), _options);
9852     } else if (!_options && !cb) {
9853       options = _url;
9854     } else if (!cb) {
9855       options = _url;
9856       cb = _options;
9857     }
9858
9859   const req = https.request(options, cb);
9860   req.end();
9861   return req;
9862 };
9863
9864
9865 /***/ }),
9866 /* 56 */
9867 /***/ (function(module, exports) {
9868
9869 module.exports = require("util");
9870
9871 /***/ }),
9872 /* 57 */
9873 /***/ (function(module, exports, __webpack_require__) {
9874
9875 "use strict";
9876
9877
9878 /* global module, require */
9879 module.exports = function () {
9880
9881     "use strict";
9882
9883     // Get a promise object. This may be native, or it may be polyfilled
9884
9885     var ES6Promise = __webpack_require__(58);
9886
9887     /**
9888      * thatLooksLikeAPromiseToMe()
9889      *
9890      * Duck-types a promise.
9891      *
9892      * @param {object} o
9893      * @return {bool} True if this resembles a promise
9894      */
9895     function thatLooksLikeAPromiseToMe(o) {
9896         return o && typeof o.then === "function" && typeof o.catch === "function";
9897     }
9898
9899     /**
9900      * promisify()
9901      *
9902      * Transforms callback-based function -- func(arg1, arg2 .. argN, callback) -- into
9903      * an ES6-compatible Promise. Promisify provides a default callback of the form (error, result)
9904      * and rejects when `error` is truthy. You can also supply settings object as the second argument.
9905      *
9906      * @param {function} original - The function to promisify
9907      * @param {object} settings - Settings object
9908      * @param {object} settings.thisArg - A `this` context to use. If not set, assume `settings` _is_ `thisArg`
9909      * @param {bool} settings.multiArgs - Should multiple arguments be returned as an array?
9910      * @return {function} A promisified version of `original`
9911      */
9912     return function promisify(original, settings) {
9913
9914         return function () {
9915             for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
9916                 args[_key] = arguments[_key];
9917             }
9918
9919             var returnMultipleArguments = settings && settings.multiArgs;
9920
9921             var target = void 0;
9922             if (settings && settings.thisArg) {
9923                 target = settings.thisArg;
9924             } else if (settings) {
9925                 target = settings;
9926             }
9927
9928             // Return the promisified function
9929             return new ES6Promise(function (resolve, reject) {
9930
9931                 // Append the callback bound to the context
9932                 args.push(function callback(err) {
9933
9934                     if (err) {
9935                         return reject(err);
9936                     }
9937
9938                     for (var _len2 = arguments.length, values = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
9939                         values[_key2 - 1] = arguments[_key2];
9940                     }
9941
9942                     if (false === !!returnMultipleArguments) {
9943                         return resolve(values[0]);
9944                     }
9945
9946                     resolve(values);
9947                 });
9948
9949                 // Call the function
9950                 var response = original.apply(target, args);
9951
9952                 // If it looks like original already returns a promise,
9953                 // then just resolve with that promise. Hopefully, the callback function we added will just be ignored.
9954                 if (thatLooksLikeAPromiseToMe(response)) {
9955                     resolve(response);
9956                 }
9957             });
9958         };
9959     };
9960 }();
9961
9962 /***/ }),
9963 /* 58 */
9964 /***/ (function(module, exports, __webpack_require__) {
9965
9966 "use strict";
9967
9968
9969 /* global self, window, module, global, require */
9970 module.exports = function () {
9971
9972     "use strict";
9973
9974     var globalObject = void 0;
9975
9976     function isFunction(x) {
9977         return typeof x === "function";
9978     }
9979
9980     // Seek the global object
9981     if (global !== undefined) {
9982         globalObject = global;
9983     } else if (window !== undefined && window.document) {
9984         globalObject = window;
9985     } else {
9986         globalObject = self;
9987     }
9988
9989     // Test for any native promise implementation, and if that
9990     // implementation appears to conform to the specificaton.
9991     // This code mostly nicked from the es6-promise module polyfill
9992     // and then fooled with.
9993     var hasPromiseSupport = function () {
9994
9995         // No promise object at all, and it's a non-starter
9996         if (!globalObject.hasOwnProperty("Promise")) {
9997             return false;
9998         }
9999
10000         // There is a Promise object. Does it conform to the spec?
10001         var P = globalObject.Promise;
10002
10003         // Some of these methods are missing from
10004         // Firefox/Chrome experimental implementations
10005         if (!P.hasOwnProperty("resolve") || !P.hasOwnProperty("reject")) {
10006             return false;
10007         }
10008
10009         if (!P.hasOwnProperty("all") || !P.hasOwnProperty("race")) {
10010             return false;
10011         }
10012
10013         // Older version of the spec had a resolver object
10014         // as the arg rather than a function
10015         return function () {
10016
10017             var resolve = void 0;
10018
10019             var p = new globalObject.Promise(function (r) {
10020                 resolve = r;
10021             });
10022
10023             if (p) {
10024                 return isFunction(resolve);
10025             }
10026
10027             return false;
10028         }();
10029     }();
10030
10031     // Export the native Promise implementation if it
10032     // looks like it matches the spec
10033     if (hasPromiseSupport) {
10034         return globalObject.Promise;
10035     }
10036
10037     //  Otherwise, return the es6-promise polyfill by @jaffathecake.
10038     return __webpack_require__(59).Promise;
10039 }();
10040
10041 /***/ }),
10042 /* 59 */
10043 /***/ (function(module, exports, __webpack_require__) {
10044
10045 /*!
10046  * @overview es6-promise - a tiny implementation of Promises/A+.
10047  * @copyright Copyright (c) 2014 Yehuda Katz, Tom Dale, Stefan Penner and contributors (Conversion to ES6 API by Jake Archibald)
10048  * @license   Licensed under MIT license
10049  *            See https://raw.githubusercontent.com/stefanpenner/es6-promise/master/LICENSE
10050  * @version   v4.2.8+1e68dce6
10051  */
10052
10053 (function (global, factory) {
10054          true ? module.exports = factory() :
10055         undefined;
10056 }(this, (function () { 'use strict';
10057
10058 function objectOrFunction(x) {
10059   var type = typeof x;
10060   return x !== null && (type === 'object' || type === 'function');
10061 }
10062
10063 function isFunction(x) {
10064   return typeof x === 'function';
10065 }
10066
10067
10068
10069 var _isArray = void 0;
10070 if (Array.isArray) {
10071   _isArray = Array.isArray;
10072 } else {
10073   _isArray = function (x) {
10074     return Object.prototype.toString.call(x) === '[object Array]';
10075   };
10076 }
10077
10078 var isArray = _isArray;
10079
10080 var len = 0;
10081 var vertxNext = void 0;
10082 var customSchedulerFn = void 0;
10083
10084 var asap = function asap(callback, arg) {
10085   queue[len] = callback;
10086   queue[len + 1] = arg;
10087   len += 2;
10088   if (len === 2) {
10089     // If len is 2, that means that we need to schedule an async flush.
10090     // If additional callbacks are queued before the queue is flushed, they
10091     // will be processed by this flush that we are scheduling.
10092     if (customSchedulerFn) {
10093       customSchedulerFn(flush);
10094     } else {
10095       scheduleFlush();
10096     }
10097   }
10098 };
10099
10100 function setScheduler(scheduleFn) {
10101   customSchedulerFn = scheduleFn;
10102 }
10103
10104 function setAsap(asapFn) {
10105   asap = asapFn;
10106 }
10107
10108 var browserWindow = typeof window !== 'undefined' ? window : undefined;
10109 var browserGlobal = browserWindow || {};
10110 var BrowserMutationObserver = browserGlobal.MutationObserver || browserGlobal.WebKitMutationObserver;
10111 var isNode = typeof self === 'undefined' && typeof process !== 'undefined' && {}.toString.call(process) === '[object process]';
10112
10113 // test for web worker but not in IE10
10114 var isWorker = typeof Uint8ClampedArray !== 'undefined' && typeof importScripts !== 'undefined' && typeof MessageChannel !== 'undefined';
10115
10116 // node
10117 function useNextTick() {
10118   // node version 0.10.x displays a deprecation warning when nextTick is used recursively
10119   // see https://github.com/cujojs/when/issues/410 for details
10120   return function () {
10121     return process.nextTick(flush);
10122   };
10123 }
10124
10125 // vertx
10126 function useVertxTimer() {
10127   if (typeof vertxNext !== 'undefined') {
10128     return function () {
10129       vertxNext(flush);
10130     };
10131   }
10132
10133   return useSetTimeout();
10134 }
10135
10136 function useMutationObserver() {
10137   var iterations = 0;
10138   var observer = new BrowserMutationObserver(flush);
10139   var node = document.createTextNode('');
10140   observer.observe(node, { characterData: true });
10141
10142   return function () {
10143     node.data = iterations = ++iterations % 2;
10144   };
10145 }
10146
10147 // web worker
10148 function useMessageChannel() {
10149   var channel = new MessageChannel();
10150   channel.port1.onmessage = flush;
10151   return function () {
10152     return channel.port2.postMessage(0);
10153   };
10154 }
10155
10156 function useSetTimeout() {
10157   // Store setTimeout reference so es6-promise will be unaffected by
10158   // other code modifying setTimeout (like sinon.useFakeTimers())
10159   var globalSetTimeout = setTimeout;
10160   return function () {
10161     return globalSetTimeout(flush, 1);
10162   };
10163 }
10164
10165 var queue = new Array(1000);
10166 function flush() {
10167   for (var i = 0; i < len; i += 2) {
10168     var callback = queue[i];
10169     var arg = queue[i + 1];
10170
10171     callback(arg);
10172
10173     queue[i] = undefined;
10174     queue[i + 1] = undefined;
10175   }
10176
10177   len = 0;
10178 }
10179
10180 function attemptVertx() {
10181   try {
10182     var vertx = Function('return this')().require('vertx');
10183     vertxNext = vertx.runOnLoop || vertx.runOnContext;
10184     return useVertxTimer();
10185   } catch (e) {
10186     return useSetTimeout();
10187   }
10188 }
10189
10190 var scheduleFlush = void 0;
10191 // Decide what async method to use to triggering processing of queued callbacks:
10192 if (isNode) {
10193   scheduleFlush = useNextTick();
10194 } else if (BrowserMutationObserver) {
10195   scheduleFlush = useMutationObserver();
10196 } else if (isWorker) {
10197   scheduleFlush = useMessageChannel();
10198 } else if (browserWindow === undefined && "function" === 'function') {
10199   scheduleFlush = attemptVertx();
10200 } else {
10201   scheduleFlush = useSetTimeout();
10202 }
10203
10204 function then(onFulfillment, onRejection) {
10205   var parent = this;
10206
10207   var child = new this.constructor(noop);
10208
10209   if (child[PROMISE_ID] === undefined) {
10210     makePromise(child);
10211   }
10212
10213   var _state = parent._state;
10214
10215
10216   if (_state) {
10217     var callback = arguments[_state - 1];
10218     asap(function () {
10219       return invokeCallback(_state, child, callback, parent._result);
10220     });
10221   } else {
10222     subscribe(parent, child, onFulfillment, onRejection);
10223   }
10224
10225   return child;
10226 }
10227
10228 /**
10229   `Promise.resolve` returns a promise that will become resolved with the
10230   passed `value`. It is shorthand for the following:
10231
10232   ```javascript
10233   let promise = new Promise(function(resolve, reject){
10234     resolve(1);
10235   });
10236
10237   promise.then(function(value){
10238     // value === 1
10239   });
10240   ```
10241
10242   Instead of writing the above, your code now simply becomes the following:
10243
10244   ```javascript
10245   let promise = Promise.resolve(1);
10246
10247   promise.then(function(value){
10248     // value === 1
10249   });
10250   ```
10251
10252   @method resolve
10253   @static
10254   @param {Any} value value that the returned promise will be resolved with
10255   Useful for tooling.
10256   @return {Promise} a promise that will become fulfilled with the given
10257   `value`
10258 */
10259 function resolve$1(object) {
10260   /*jshint validthis:true */
10261   var Constructor = this;
10262
10263   if (object && typeof object === 'object' && object.constructor === Constructor) {
10264     return object;
10265   }
10266
10267   var promise = new Constructor(noop);
10268   resolve(promise, object);
10269   return promise;
10270 }
10271
10272 var PROMISE_ID = Math.random().toString(36).substring(2);
10273
10274 function noop() {}
10275
10276 var PENDING = void 0;
10277 var FULFILLED = 1;
10278 var REJECTED = 2;
10279
10280 function selfFulfillment() {
10281   return new TypeError("You cannot resolve a promise with itself");
10282 }
10283
10284 function cannotReturnOwn() {
10285   return new TypeError('A promises callback cannot return that same promise.');
10286 }
10287
10288 function tryThen(then$$1, value, fulfillmentHandler, rejectionHandler) {
10289   try {
10290     then$$1.call(value, fulfillmentHandler, rejectionHandler);
10291   } catch (e) {
10292     return e;
10293   }
10294 }
10295
10296 function handleForeignThenable(promise, thenable, then$$1) {
10297   asap(function (promise) {
10298     var sealed = false;
10299     var error = tryThen(then$$1, thenable, function (value) {
10300       if (sealed) {
10301         return;
10302       }
10303       sealed = true;
10304       if (thenable !== value) {
10305         resolve(promise, value);
10306       } else {
10307         fulfill(promise, value);
10308       }
10309     }, function (reason) {
10310       if (sealed) {
10311         return;
10312       }
10313       sealed = true;
10314
10315       reject(promise, reason);
10316     }, 'Settle: ' + (promise._label || ' unknown promise'));
10317
10318     if (!sealed && error) {
10319       sealed = true;
10320       reject(promise, error);
10321     }
10322   }, promise);
10323 }
10324
10325 function handleOwnThenable(promise, thenable) {
10326   if (thenable._state === FULFILLED) {
10327     fulfill(promise, thenable._result);
10328   } else if (thenable._state === REJECTED) {
10329     reject(promise, thenable._result);
10330   } else {
10331     subscribe(thenable, undefined, function (value) {
10332       return resolve(promise, value);
10333     }, function (reason) {
10334       return reject(promise, reason);
10335     });
10336   }
10337 }
10338
10339 function handleMaybeThenable(promise, maybeThenable, then$$1) {
10340   if (maybeThenable.constructor === promise.constructor && then$$1 === then && maybeThenable.constructor.resolve === resolve$1) {
10341     handleOwnThenable(promise, maybeThenable);
10342   } else {
10343     if (then$$1 === undefined) {
10344       fulfill(promise, maybeThenable);
10345     } else if (isFunction(then$$1)) {
10346       handleForeignThenable(promise, maybeThenable, then$$1);
10347     } else {
10348       fulfill(promise, maybeThenable);
10349     }
10350   }
10351 }
10352
10353 function resolve(promise, value) {
10354   if (promise === value) {
10355     reject(promise, selfFulfillment());
10356   } else if (objectOrFunction(value)) {
10357     var then$$1 = void 0;
10358     try {
10359       then$$1 = value.then;
10360     } catch (error) {
10361       reject(promise, error);
10362       return;
10363     }
10364     handleMaybeThenable(promise, value, then$$1);
10365   } else {
10366     fulfill(promise, value);
10367   }
10368 }
10369
10370 function publishRejection(promise) {
10371   if (promise._onerror) {
10372     promise._onerror(promise._result);
10373   }
10374
10375   publish(promise);
10376 }
10377
10378 function fulfill(promise, value) {
10379   if (promise._state !== PENDING) {
10380     return;
10381   }
10382
10383   promise._result = value;
10384   promise._state = FULFILLED;
10385
10386   if (promise._subscribers.length !== 0) {
10387     asap(publish, promise);
10388   }
10389 }
10390
10391 function reject(promise, reason) {
10392   if (promise._state !== PENDING) {
10393     return;
10394   }
10395   promise._state = REJECTED;
10396   promise._result = reason;
10397
10398   asap(publishRejection, promise);
10399 }
10400
10401 function subscribe(parent, child, onFulfillment, onRejection) {
10402   var _subscribers = parent._subscribers;
10403   var length = _subscribers.length;
10404
10405
10406   parent._onerror = null;
10407
10408   _subscribers[length] = child;
10409   _subscribers[length + FULFILLED] = onFulfillment;
10410   _subscribers[length + REJECTED] = onRejection;
10411
10412   if (length === 0 && parent._state) {
10413     asap(publish, parent);
10414   }
10415 }
10416
10417 function publish(promise) {
10418   var subscribers = promise._subscribers;
10419   var settled = promise._state;
10420
10421   if (subscribers.length === 0) {
10422     return;
10423   }
10424
10425   var child = void 0,
10426       callback = void 0,
10427       detail = promise._result;
10428
10429   for (var i = 0; i < subscribers.length; i += 3) {
10430     child = subscribers[i];
10431     callback = subscribers[i + settled];
10432
10433     if (child) {
10434       invokeCallback(settled, child, callback, detail);
10435     } else {
10436       callback(detail);
10437     }
10438   }
10439
10440   promise._subscribers.length = 0;
10441 }
10442
10443 function invokeCallback(settled, promise, callback, detail) {
10444   var hasCallback = isFunction(callback),
10445       value = void 0,
10446       error = void 0,
10447       succeeded = true;
10448
10449   if (hasCallback) {
10450     try {
10451       value = callback(detail);
10452     } catch (e) {
10453       succeeded = false;
10454       error = e;
10455     }
10456
10457     if (promise === value) {
10458       reject(promise, cannotReturnOwn());
10459       return;
10460     }
10461   } else {
10462     value = detail;
10463   }
10464
10465   if (promise._state !== PENDING) {
10466     // noop
10467   } else if (hasCallback && succeeded) {
10468     resolve(promise, value);
10469   } else if (succeeded === false) {
10470     reject(promise, error);
10471   } else if (settled === FULFILLED) {
10472     fulfill(promise, value);
10473   } else if (settled === REJECTED) {
10474     reject(promise, value);
10475   }
10476 }
10477
10478 function initializePromise(promise, resolver) {
10479   try {
10480     resolver(function resolvePromise(value) {
10481       resolve(promise, value);
10482     }, function rejectPromise(reason) {
10483       reject(promise, reason);
10484     });
10485   } catch (e) {
10486     reject(promise, e);
10487   }
10488 }
10489
10490 var id = 0;
10491 function nextId() {
10492   return id++;
10493 }
10494
10495 function makePromise(promise) {
10496   promise[PROMISE_ID] = id++;
10497   promise._state = undefined;
10498   promise._result = undefined;
10499   promise._subscribers = [];
10500 }
10501
10502 function validationError() {
10503   return new Error('Array Methods must be provided an Array');
10504 }
10505
10506 var Enumerator = function () {
10507   function Enumerator(Constructor, input) {
10508     this._instanceConstructor = Constructor;
10509     this.promise = new Constructor(noop);
10510
10511     if (!this.promise[PROMISE_ID]) {
10512       makePromise(this.promise);
10513     }
10514
10515     if (isArray(input)) {
10516       this.length = input.length;
10517       this._remaining = input.length;
10518
10519       this._result = new Array(this.length);
10520
10521       if (this.length === 0) {
10522         fulfill(this.promise, this._result);
10523       } else {
10524         this.length = this.length || 0;
10525         this._enumerate(input);
10526         if (this._remaining === 0) {
10527           fulfill(this.promise, this._result);
10528         }
10529       }
10530     } else {
10531       reject(this.promise, validationError());
10532     }
10533   }
10534
10535   Enumerator.prototype._enumerate = function _enumerate(input) {
10536     for (var i = 0; this._state === PENDING && i < input.length; i++) {
10537       this._eachEntry(input[i], i);
10538     }
10539   };
10540
10541   Enumerator.prototype._eachEntry = function _eachEntry(entry, i) {
10542     var c = this._instanceConstructor;
10543     var resolve$$1 = c.resolve;
10544
10545
10546     if (resolve$$1 === resolve$1) {
10547       var _then = void 0;
10548       var error = void 0;
10549       var didError = false;
10550       try {
10551         _then = entry.then;
10552       } catch (e) {
10553         didError = true;
10554         error = e;
10555       }
10556
10557       if (_then === then && entry._state !== PENDING) {
10558         this._settledAt(entry._state, i, entry._result);
10559       } else if (typeof _then !== 'function') {
10560         this._remaining--;
10561         this._result[i] = entry;
10562       } else if (c === Promise$1) {
10563         var promise = new c(noop);
10564         if (didError) {
10565           reject(promise, error);
10566         } else {
10567           handleMaybeThenable(promise, entry, _then);
10568         }
10569         this._willSettleAt(promise, i);
10570       } else {
10571         this._willSettleAt(new c(function (resolve$$1) {
10572           return resolve$$1(entry);
10573         }), i);
10574       }
10575     } else {
10576       this._willSettleAt(resolve$$1(entry), i);
10577     }
10578   };
10579
10580   Enumerator.prototype._settledAt = function _settledAt(state, i, value) {
10581     var promise = this.promise;
10582
10583
10584     if (promise._state === PENDING) {
10585       this._remaining--;
10586
10587       if (state === REJECTED) {
10588         reject(promise, value);
10589       } else {
10590         this._result[i] = value;
10591       }
10592     }
10593
10594     if (this._remaining === 0) {
10595       fulfill(promise, this._result);
10596     }
10597   };
10598
10599   Enumerator.prototype._willSettleAt = function _willSettleAt(promise, i) {
10600     var enumerator = this;
10601
10602     subscribe(promise, undefined, function (value) {
10603       return enumerator._settledAt(FULFILLED, i, value);
10604     }, function (reason) {
10605       return enumerator._settledAt(REJECTED, i, reason);
10606     });
10607   };
10608
10609   return Enumerator;
10610 }();
10611
10612 /**
10613   `Promise.all` accepts an array of promises, and returns a new promise which
10614   is fulfilled with an array of fulfillment values for the passed promises, or
10615   rejected with the reason of the first passed promise to be rejected. It casts all
10616   elements of the passed iterable to promises as it runs this algorithm.
10617
10618   Example:
10619
10620   ```javascript
10621   let promise1 = resolve(1);
10622   let promise2 = resolve(2);
10623   let promise3 = resolve(3);
10624   let promises = [ promise1, promise2, promise3 ];
10625
10626   Promise.all(promises).then(function(array){
10627     // The array here would be [ 1, 2, 3 ];
10628   });
10629   ```
10630
10631   If any of the `promises` given to `all` are rejected, the first promise
10632   that is rejected will be given as an argument to the returned promises's
10633   rejection handler. For example:
10634
10635   Example:
10636
10637   ```javascript
10638   let promise1 = resolve(1);
10639   let promise2 = reject(new Error("2"));
10640   let promise3 = reject(new Error("3"));
10641   let promises = [ promise1, promise2, promise3 ];
10642
10643   Promise.all(promises).then(function(array){
10644     // Code here never runs because there are rejected promises!
10645   }, function(error) {
10646     // error.message === "2"
10647   });
10648   ```
10649
10650   @method all
10651   @static
10652   @param {Array} entries array of promises
10653   @param {String} label optional string for labeling the promise.
10654   Useful for tooling.
10655   @return {Promise} promise that is fulfilled when all `promises` have been
10656   fulfilled, or rejected if any of them become rejected.
10657   @static
10658 */
10659 function all(entries) {
10660   return new Enumerator(this, entries).promise;
10661 }
10662
10663 /**
10664   `Promise.race` returns a new promise which is settled in the same way as the
10665   first passed promise to settle.
10666
10667   Example:
10668
10669   ```javascript
10670   let promise1 = new Promise(function(resolve, reject){
10671     setTimeout(function(){
10672       resolve('promise 1');
10673     }, 200);
10674   });
10675
10676   let promise2 = new Promise(function(resolve, reject){
10677     setTimeout(function(){
10678       resolve('promise 2');
10679     }, 100);
10680   });
10681
10682   Promise.race([promise1, promise2]).then(function(result){
10683     // result === 'promise 2' because it was resolved before promise1
10684     // was resolved.
10685   });
10686   ```
10687
10688   `Promise.race` is deterministic in that only the state of the first
10689   settled promise matters. For example, even if other promises given to the
10690   `promises` array argument are resolved, but the first settled promise has
10691   become rejected before the other promises became fulfilled, the returned
10692   promise will become rejected:
10693
10694   ```javascript
10695   let promise1 = new Promise(function(resolve, reject){
10696     setTimeout(function(){
10697       resolve('promise 1');
10698     }, 200);
10699   });
10700
10701   let promise2 = new Promise(function(resolve, reject){
10702     setTimeout(function(){
10703       reject(new Error('promise 2'));
10704     }, 100);
10705   });
10706
10707   Promise.race([promise1, promise2]).then(function(result){
10708     // Code here never runs
10709   }, function(reason){
10710     // reason.message === 'promise 2' because promise 2 became rejected before
10711     // promise 1 became fulfilled
10712   });
10713   ```
10714
10715   An example real-world use case is implementing timeouts:
10716
10717   ```javascript
10718   Promise.race([ajax('foo.json'), timeout(5000)])
10719   ```
10720
10721   @method race
10722   @static
10723   @param {Array} promises array of promises to observe
10724   Useful for tooling.
10725   @return {Promise} a promise which settles in the same way as the first passed
10726   promise to settle.
10727 */
10728 function race(entries) {
10729   /*jshint validthis:true */
10730   var Constructor = this;
10731
10732   if (!isArray(entries)) {
10733     return new Constructor(function (_, reject) {
10734       return reject(new TypeError('You must pass an array to race.'));
10735     });
10736   } else {
10737     return new Constructor(function (resolve, reject) {
10738       var length = entries.length;
10739       for (var i = 0; i < length; i++) {
10740         Constructor.resolve(entries[i]).then(resolve, reject);
10741       }
10742     });
10743   }
10744 }
10745
10746 /**
10747   `Promise.reject` returns a promise rejected with the passed `reason`.
10748   It is shorthand for the following:
10749
10750   ```javascript
10751   let promise = new Promise(function(resolve, reject){
10752     reject(new Error('WHOOPS'));
10753   });
10754
10755   promise.then(function(value){
10756     // Code here doesn't run because the promise is rejected!
10757   }, function(reason){
10758     // reason.message === 'WHOOPS'
10759   });
10760   ```
10761
10762   Instead of writing the above, your code now simply becomes the following:
10763
10764   ```javascript
10765   let promise = Promise.reject(new Error('WHOOPS'));
10766
10767   promise.then(function(value){
10768     // Code here doesn't run because the promise is rejected!
10769   }, function(reason){
10770     // reason.message === 'WHOOPS'
10771   });
10772   ```
10773
10774   @method reject
10775   @static
10776   @param {Any} reason value that the returned promise will be rejected with.
10777   Useful for tooling.
10778   @return {Promise} a promise rejected with the given `reason`.
10779 */
10780 function reject$1(reason) {
10781   /*jshint validthis:true */
10782   var Constructor = this;
10783   var promise = new Constructor(noop);
10784   reject(promise, reason);
10785   return promise;
10786 }
10787
10788 function needsResolver() {
10789   throw new TypeError('You must pass a resolver function as the first argument to the promise constructor');
10790 }
10791
10792 function needsNew() {
10793   throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
10794 }
10795
10796 /**
10797   Promise objects represent the eventual result of an asynchronous operation. The
10798   primary way of interacting with a promise is through its `then` method, which
10799   registers callbacks to receive either a promise's eventual value or the reason
10800   why the promise cannot be fulfilled.
10801
10802   Terminology
10803   -----------
10804
10805   - `promise` is an object or function with a `then` method whose behavior conforms to this specification.
10806   - `thenable` is an object or function that defines a `then` method.
10807   - `value` is any legal JavaScript value (including undefined, a thenable, or a promise).
10808   - `exception` is a value that is thrown using the throw statement.
10809   - `reason` is a value that indicates why a promise was rejected.
10810   - `settled` the final resting state of a promise, fulfilled or rejected.
10811
10812   A promise can be in one of three states: pending, fulfilled, or rejected.
10813
10814   Promises that are fulfilled have a fulfillment value and are in the fulfilled
10815   state.  Promises that are rejected have a rejection reason and are in the
10816   rejected state.  A fulfillment value is never a thenable.
10817
10818   Promises can also be said to *resolve* a value.  If this value is also a
10819   promise, then the original promise's settled state will match the value's
10820   settled state.  So a promise that *resolves* a promise that rejects will
10821   itself reject, and a promise that *resolves* a promise that fulfills will
10822   itself fulfill.
10823
10824
10825   Basic Usage:
10826   ------------
10827
10828   ```js
10829   let promise = new Promise(function(resolve, reject) {
10830     // on success
10831     resolve(value);
10832
10833     // on failure
10834     reject(reason);
10835   });
10836
10837   promise.then(function(value) {
10838     // on fulfillment
10839   }, function(reason) {
10840     // on rejection
10841   });
10842   ```
10843
10844   Advanced Usage:
10845   ---------------
10846
10847   Promises shine when abstracting away asynchronous interactions such as
10848   `XMLHttpRequest`s.
10849
10850   ```js
10851   function getJSON(url) {
10852     return new Promise(function(resolve, reject){
10853       let xhr = new XMLHttpRequest();
10854
10855       xhr.open('GET', url);
10856       xhr.onreadystatechange = handler;
10857       xhr.responseType = 'json';
10858       xhr.setRequestHeader('Accept', 'application/json');
10859       xhr.send();
10860
10861       function handler() {
10862         if (this.readyState === this.DONE) {
10863           if (this.status === 200) {
10864             resolve(this.response);
10865           } else {
10866             reject(new Error('getJSON: `' + url + '` failed with status: [' + this.status + ']'));
10867           }
10868         }
10869       };
10870     });
10871   }
10872
10873   getJSON('/posts.json').then(function(json) {
10874     // on fulfillment
10875   }, function(reason) {
10876     // on rejection
10877   });
10878   ```
10879
10880   Unlike callbacks, promises are great composable primitives.
10881
10882   ```js
10883   Promise.all([
10884     getJSON('/posts'),
10885     getJSON('/comments')
10886   ]).then(function(values){
10887     values[0] // => postsJSON
10888     values[1] // => commentsJSON
10889
10890     return values;
10891   });
10892   ```
10893
10894   @class Promise
10895   @param {Function} resolver
10896   Useful for tooling.
10897   @constructor
10898 */
10899
10900 var Promise$1 = function () {
10901   function Promise(resolver) {
10902     this[PROMISE_ID] = nextId();
10903     this._result = this._state = undefined;
10904     this._subscribers = [];
10905
10906     if (noop !== resolver) {
10907       typeof resolver !== 'function' && needsResolver();
10908       this instanceof Promise ? initializePromise(this, resolver) : needsNew();
10909     }
10910   }
10911
10912   /**
10913   The primary way of interacting with a promise is through its `then` method,
10914   which registers callbacks to receive either a promise's eventual value or the
10915   reason why the promise cannot be fulfilled.
10916    ```js
10917   findUser().then(function(user){
10918     // user is available
10919   }, function(reason){
10920     // user is unavailable, and you are given the reason why
10921   });
10922   ```
10923    Chaining
10924   --------
10925    The return value of `then` is itself a promise.  This second, 'downstream'
10926   promise is resolved with the return value of the first promise's fulfillment
10927   or rejection handler, or rejected if the handler throws an exception.
10928    ```js
10929   findUser().then(function (user) {
10930     return user.name;
10931   }, function (reason) {
10932     return 'default name';
10933   }).then(function (userName) {
10934     // If `findUser` fulfilled, `userName` will be the user's name, otherwise it
10935     // will be `'default name'`
10936   });
10937    findUser().then(function (user) {
10938     throw new Error('Found user, but still unhappy');
10939   }, function (reason) {
10940     throw new Error('`findUser` rejected and we're unhappy');
10941   }).then(function (value) {
10942     // never reached
10943   }, function (reason) {
10944     // if `findUser` fulfilled, `reason` will be 'Found user, but still unhappy'.
10945     // If `findUser` rejected, `reason` will be '`findUser` rejected and we're unhappy'.
10946   });
10947   ```
10948   If the downstream promise does not specify a rejection handler, rejection reasons will be propagated further downstream.
10949    ```js
10950   findUser().then(function (user) {
10951     throw new PedagogicalException('Upstream error');
10952   }).then(function (value) {
10953     // never reached
10954   }).then(function (value) {
10955     // never reached
10956   }, function (reason) {
10957     // The `PedgagocialException` is propagated all the way down to here
10958   });
10959   ```
10960    Assimilation
10961   ------------
10962    Sometimes the value you want to propagate to a downstream promise can only be
10963   retrieved asynchronously. This can be achieved by returning a promise in the
10964   fulfillment or rejection handler. The downstream promise will then be pending
10965   until the returned promise is settled. This is called *assimilation*.
10966    ```js
10967   findUser().then(function (user) {
10968     return findCommentsByAuthor(user);
10969   }).then(function (comments) {
10970     // The user's comments are now available
10971   });
10972   ```
10973    If the assimliated promise rejects, then the downstream promise will also reject.
10974    ```js
10975   findUser().then(function (user) {
10976     return findCommentsByAuthor(user);
10977   }).then(function (comments) {
10978     // If `findCommentsByAuthor` fulfills, we'll have the value here
10979   }, function (reason) {
10980     // If `findCommentsByAuthor` rejects, we'll have the reason here
10981   });
10982   ```
10983    Simple Example
10984   --------------
10985    Synchronous Example
10986    ```javascript
10987   let result;
10988    try {
10989     result = findResult();
10990     // success
10991   } catch(reason) {
10992     // failure
10993   }
10994   ```
10995    Errback Example
10996    ```js
10997   findResult(function(result, err){
10998     if (err) {
10999       // failure
11000     } else {
11001       // success
11002     }
11003   });
11004   ```
11005    Promise Example;
11006    ```javascript
11007   findResult().then(function(result){
11008     // success
11009   }, function(reason){
11010     // failure
11011   });
11012   ```
11013    Advanced Example
11014   --------------
11015    Synchronous Example
11016    ```javascript
11017   let author, books;
11018    try {
11019     author = findAuthor();
11020     books  = findBooksByAuthor(author);
11021     // success
11022   } catch(reason) {
11023     // failure
11024   }
11025   ```
11026    Errback Example
11027    ```js
11028    function foundBooks(books) {
11029    }
11030    function failure(reason) {
11031    }
11032    findAuthor(function(author, err){
11033     if (err) {
11034       failure(err);
11035       // failure
11036     } else {
11037       try {
11038         findBoooksByAuthor(author, function(books, err) {
11039           if (err) {
11040             failure(err);
11041           } else {
11042             try {
11043               foundBooks(books);
11044             } catch(reason) {
11045               failure(reason);
11046             }
11047           }
11048         });
11049       } catch(error) {
11050         failure(err);
11051       }
11052       // success
11053     }
11054   });
11055   ```
11056    Promise Example;
11057    ```javascript
11058   findAuthor().
11059     then(findBooksByAuthor).
11060     then(function(books){
11061       // found books
11062   }).catch(function(reason){
11063     // something went wrong
11064   });
11065   ```
11066    @method then
11067   @param {Function} onFulfilled
11068   @param {Function} onRejected
11069   Useful for tooling.
11070   @return {Promise}
11071   */
11072
11073   /**
11074   `catch` is simply sugar for `then(undefined, onRejection)` which makes it the same
11075   as the catch block of a try/catch statement.
11076   ```js
11077   function findAuthor(){
11078   throw new Error('couldn't find that author');
11079   }
11080   // synchronous
11081   try {
11082   findAuthor();
11083   } catch(reason) {
11084   // something went wrong
11085   }
11086   // async with promises
11087   findAuthor().catch(function(reason){
11088   // something went wrong
11089   });
11090   ```
11091   @method catch
11092   @param {Function} onRejection
11093   Useful for tooling.
11094   @return {Promise}
11095   */
11096
11097
11098   Promise.prototype.catch = function _catch(onRejection) {
11099     return this.then(null, onRejection);
11100   };
11101
11102   /**
11103     `finally` will be invoked regardless of the promise's fate just as native
11104     try/catch/finally behaves
11105   
11106     Synchronous example:
11107   
11108     ```js
11109     findAuthor() {
11110       if (Math.random() > 0.5) {
11111         throw new Error();
11112       }
11113       return new Author();
11114     }
11115   
11116     try {
11117       return findAuthor(); // succeed or fail
11118     } catch(error) {
11119       return findOtherAuther();
11120     } finally {
11121       // always runs
11122       // doesn't affect the return value
11123     }
11124     ```
11125   
11126     Asynchronous example:
11127   
11128     ```js
11129     findAuthor().catch(function(reason){
11130       return findOtherAuther();
11131     }).finally(function(){
11132       // author was either found, or not
11133     });
11134     ```
11135   
11136     @method finally
11137     @param {Function} callback
11138     @return {Promise}
11139   */
11140
11141
11142   Promise.prototype.finally = function _finally(callback) {
11143     var promise = this;
11144     var constructor = promise.constructor;
11145
11146     if (isFunction(callback)) {
11147       return promise.then(function (value) {
11148         return constructor.resolve(callback()).then(function () {
11149           return value;
11150         });
11151       }, function (reason) {
11152         return constructor.resolve(callback()).then(function () {
11153           throw reason;
11154         });
11155       });
11156     }
11157
11158     return promise.then(callback, callback);
11159   };
11160
11161   return Promise;
11162 }();
11163
11164 Promise$1.prototype.then = then;
11165 Promise$1.all = all;
11166 Promise$1.race = race;
11167 Promise$1.resolve = resolve$1;
11168 Promise$1.reject = reject$1;
11169 Promise$1._setScheduler = setScheduler;
11170 Promise$1._setAsap = setAsap;
11171 Promise$1._asap = asap;
11172
11173 /*global self*/
11174 function polyfill() {
11175   var local = void 0;
11176
11177   if (typeof global !== 'undefined') {
11178     local = global;
11179   } else if (typeof self !== 'undefined') {
11180     local = self;
11181   } else {
11182     try {
11183       local = Function('return this')();
11184     } catch (e) {
11185       throw new Error('polyfill failed because global object is unavailable in this environment');
11186     }
11187   }
11188
11189   var P = local.Promise;
11190
11191   if (P) {
11192     var promiseToString = null;
11193     try {
11194       promiseToString = Object.prototype.toString.call(P.resolve());
11195     } catch (e) {
11196       // silently ignored
11197     }
11198
11199     if (promiseToString === '[object Promise]' && !P.cast) {
11200       return;
11201     }
11202   }
11203
11204   local.Promise = Promise$1;
11205 }
11206
11207 // Strange compat..
11208 Promise$1.polyfill = polyfill;
11209 Promise$1.Promise = Promise$1;
11210
11211 return Promise$1;
11212
11213 })));
11214
11215
11216
11217 //# sourceMappingURL=es6-promise.map
11218
11219
11220 /***/ }),
11221 /* 60 */
11222 /***/ (function(module, exports) {
11223
11224 module.exports = require("events");
11225
11226 /***/ }),
11227 /* 61 */
11228 /***/ (function(module, exports, __webpack_require__) {
11229
11230 /**
11231  * Detect Electron renderer process, which is node, but we should
11232  * treat as a browser.
11233  */
11234
11235 if (typeof process === 'undefined' || process.type === 'renderer') {
11236   module.exports = __webpack_require__(62);
11237 } else {
11238   module.exports = __webpack_require__(65);
11239 }
11240
11241
11242 /***/ }),
11243 /* 62 */
11244 /***/ (function(module, exports, __webpack_require__) {
11245
11246 /**
11247  * This is the web browser implementation of `debug()`.
11248  *
11249  * Expose `debug()` as the module.
11250  */
11251
11252 exports = module.exports = __webpack_require__(63);
11253 exports.log = log;
11254 exports.formatArgs = formatArgs;
11255 exports.save = save;
11256 exports.load = load;
11257 exports.useColors = useColors;
11258 exports.storage = 'undefined' != typeof chrome
11259                && 'undefined' != typeof chrome.storage
11260                   ? chrome.storage.local
11261                   : localstorage();
11262
11263 /**
11264  * Colors.
11265  */
11266
11267 exports.colors = [
11268   '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC',
11269   '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF',
11270   '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC',
11271   '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF',
11272   '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC',
11273   '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033',
11274   '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366',
11275   '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933',
11276   '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC',
11277   '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF',
11278   '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'
11279 ];
11280
11281 /**
11282  * Currently only WebKit-based Web Inspectors, Firefox >= v31,
11283  * and the Firebug extension (any Firefox version) are known
11284  * to support "%c" CSS customizations.
11285  *
11286  * TODO: add a `localStorage` variable to explicitly enable/disable colors
11287  */
11288
11289 function useColors() {
11290   // NB: In an Electron preload script, document will be defined but not fully
11291   // initialized. Since we know we're in Chrome, we'll just detect this case
11292   // explicitly
11293   if (typeof window !== 'undefined' && window.process && window.process.type === 'renderer') {
11294     return true;
11295   }
11296
11297   // Internet Explorer and Edge do not support colors.
11298   if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
11299     return false;
11300   }
11301
11302   // is webkit? http://stackoverflow.com/a/16459606/376773
11303   // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
11304   return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
11305     // is firebug? http://stackoverflow.com/a/398120/376773
11306     (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
11307     // is firefox >= v31?
11308     // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
11309     (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
11310     // double check webkit in userAgent just in case we are in a worker
11311     (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
11312 }
11313
11314 /**
11315  * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
11316  */
11317
11318 exports.formatters.j = function(v) {
11319   try {
11320     return JSON.stringify(v);
11321   } catch (err) {
11322     return '[UnexpectedJSONParseError]: ' + err.message;
11323   }
11324 };
11325
11326
11327 /**
11328  * Colorize log arguments if enabled.
11329  *
11330  * @api public
11331  */
11332
11333 function formatArgs(args) {
11334   var useColors = this.useColors;
11335
11336   args[0] = (useColors ? '%c' : '')
11337     + this.namespace
11338     + (useColors ? ' %c' : ' ')
11339     + args[0]
11340     + (useColors ? '%c ' : ' ')
11341     + '+' + exports.humanize(this.diff);
11342
11343   if (!useColors) return;
11344
11345   var c = 'color: ' + this.color;
11346   args.splice(1, 0, c, 'color: inherit')
11347
11348   // the final "%c" is somewhat tricky, because there could be other
11349   // arguments passed either before or after the %c, so we need to
11350   // figure out the correct index to insert the CSS into
11351   var index = 0;
11352   var lastC = 0;
11353   args[0].replace(/%[a-zA-Z%]/g, function(match) {
11354     if ('%%' === match) return;
11355     index++;
11356     if ('%c' === match) {
11357       // we only are interested in the *last* %c
11358       // (the user may have provided their own)
11359       lastC = index;
11360     }
11361   });
11362
11363   args.splice(lastC, 0, c);
11364 }
11365
11366 /**
11367  * Invokes `console.log()` when available.
11368  * No-op when `console.log` is not a "function".
11369  *
11370  * @api public
11371  */
11372
11373 function log() {
11374   // this hackery is required for IE8/9, where
11375   // the `console.log` function doesn't have 'apply'
11376   return 'object' === typeof console
11377     && console.log
11378     && Function.prototype.apply.call(console.log, console, arguments);
11379 }
11380
11381 /**
11382  * Save `namespaces`.
11383  *
11384  * @param {String} namespaces
11385  * @api private
11386  */
11387
11388 function save(namespaces) {
11389   try {
11390     if (null == namespaces) {
11391       exports.storage.removeItem('debug');
11392     } else {
11393       exports.storage.debug = namespaces;
11394     }
11395   } catch(e) {}
11396 }
11397
11398 /**
11399  * Load `namespaces`.
11400  *
11401  * @return {String} returns the previously persisted debug modes
11402  * @api private
11403  */
11404
11405 function load() {
11406   var r;
11407   try {
11408     r = exports.storage.debug;
11409   } catch(e) {}
11410
11411   // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
11412   if (!r && typeof process !== 'undefined' && 'env' in process) {
11413     r = process.env.DEBUG;
11414   }
11415
11416   return r;
11417 }
11418
11419 /**
11420  * Enable namespaces listed in `localStorage.debug` initially.
11421  */
11422
11423 exports.enable(load());
11424
11425 /**
11426  * Localstorage attempts to return the localstorage.
11427  *
11428  * This is necessary because safari throws
11429  * when a user disables cookies/localstorage
11430  * and you attempt to access it.
11431  *
11432  * @return {LocalStorage}
11433  * @api private
11434  */
11435
11436 function localstorage() {
11437   try {
11438     return window.localStorage;
11439   } catch (e) {}
11440 }
11441
11442
11443 /***/ }),
11444 /* 63 */
11445 /***/ (function(module, exports, __webpack_require__) {
11446
11447
11448 /**
11449  * This is the common logic for both the Node.js and web browser
11450  * implementations of `debug()`.
11451  *
11452  * Expose `debug()` as the module.
11453  */
11454
11455 exports = module.exports = createDebug.debug = createDebug['default'] = createDebug;
11456 exports.coerce = coerce;
11457 exports.disable = disable;
11458 exports.enable = enable;
11459 exports.enabled = enabled;
11460 exports.humanize = __webpack_require__(64);
11461
11462 /**
11463  * Active `debug` instances.
11464  */
11465 exports.instances = [];
11466
11467 /**
11468  * The currently active debug mode names, and names to skip.
11469  */
11470
11471 exports.names = [];
11472 exports.skips = [];
11473
11474 /**
11475  * Map of special "%n" handling functions, for the debug "format" argument.
11476  *
11477  * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
11478  */
11479
11480 exports.formatters = {};
11481
11482 /**
11483  * Select a color.
11484  * @param {String} namespace
11485  * @return {Number}
11486  * @api private
11487  */
11488
11489 function selectColor(namespace) {
11490   var hash = 0, i;
11491
11492   for (i in namespace) {
11493     hash  = ((hash << 5) - hash) + namespace.charCodeAt(i);
11494     hash |= 0; // Convert to 32bit integer
11495   }
11496
11497   return exports.colors[Math.abs(hash) % exports.colors.length];
11498 }
11499
11500 /**
11501  * Create a debugger with the given `namespace`.
11502  *
11503  * @param {String} namespace
11504  * @return {Function}
11505  * @api public
11506  */
11507
11508 function createDebug(namespace) {
11509
11510   var prevTime;
11511
11512   function debug() {
11513     // disabled?
11514     if (!debug.enabled) return;
11515
11516     var self = debug;
11517
11518     // set `diff` timestamp
11519     var curr = +new Date();
11520     var ms = curr - (prevTime || curr);
11521     self.diff = ms;
11522     self.prev = prevTime;
11523     self.curr = curr;
11524     prevTime = curr;
11525
11526     // turn the `arguments` into a proper Array
11527     var args = new Array(arguments.length);
11528     for (var i = 0; i < args.length; i++) {
11529       args[i] = arguments[i];
11530     }
11531
11532     args[0] = exports.coerce(args[0]);
11533
11534     if ('string' !== typeof args[0]) {
11535       // anything else let's inspect with %O
11536       args.unshift('%O');
11537     }
11538
11539     // apply any `formatters` transformations
11540     var index = 0;
11541     args[0] = args[0].replace(/%([a-zA-Z%])/g, function(match, format) {
11542       // if we encounter an escaped % then don't increase the array index
11543       if (match === '%%') return match;
11544       index++;
11545       var formatter = exports.formatters[format];
11546       if ('function' === typeof formatter) {
11547         var val = args[index];
11548         match = formatter.call(self, val);
11549
11550         // now we need to remove `args[index]` since it's inlined in the `format`
11551         args.splice(index, 1);
11552         index--;
11553       }
11554       return match;
11555     });
11556
11557     // apply env-specific formatting (colors, etc.)
11558     exports.formatArgs.call(self, args);
11559
11560     var logFn = debug.log || exports.log || console.log.bind(console);
11561     logFn.apply(self, args);
11562   }
11563
11564   debug.namespace = namespace;
11565   debug.enabled = exports.enabled(namespace);
11566   debug.useColors = exports.useColors();
11567   debug.color = selectColor(namespace);
11568   debug.destroy = destroy;
11569
11570   // env-specific initialization logic for debug instances
11571   if ('function' === typeof exports.init) {
11572     exports.init(debug);
11573   }
11574
11575   exports.instances.push(debug);
11576
11577   return debug;
11578 }
11579
11580 function destroy () {
11581   var index = exports.instances.indexOf(this);
11582   if (index !== -1) {
11583     exports.instances.splice(index, 1);
11584     return true;
11585   } else {
11586     return false;
11587   }
11588 }
11589
11590 /**
11591  * Enables a debug mode by namespaces. This can include modes
11592  * separated by a colon and wildcards.
11593  *
11594  * @param {String} namespaces
11595  * @api public
11596  */
11597
11598 function enable(namespaces) {
11599   exports.save(namespaces);
11600
11601   exports.names = [];
11602   exports.skips = [];
11603
11604   var i;
11605   var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
11606   var len = split.length;
11607
11608   for (i = 0; i < len; i++) {
11609     if (!split[i]) continue; // ignore empty strings
11610     namespaces = split[i].replace(/\*/g, '.*?');
11611     if (namespaces[0] === '-') {
11612       exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
11613     } else {
11614       exports.names.push(new RegExp('^' + namespaces + '$'));
11615     }
11616   }
11617
11618   for (i = 0; i < exports.instances.length; i++) {
11619     var instance = exports.instances[i];
11620     instance.enabled = exports.enabled(instance.namespace);
11621   }
11622 }
11623
11624 /**
11625  * Disable debug output.
11626  *
11627  * @api public
11628  */
11629
11630 function disable() {
11631   exports.enable('');
11632 }
11633
11634 /**
11635  * Returns true if the given mode name is enabled, false otherwise.
11636  *
11637  * @param {String} name
11638  * @return {Boolean}
11639  * @api public
11640  */
11641
11642 function enabled(name) {
11643   if (name[name.length - 1] === '*') {
11644     return true;
11645   }
11646   var i, len;
11647   for (i = 0, len = exports.skips.length; i < len; i++) {
11648     if (exports.skips[i].test(name)) {
11649       return false;
11650     }
11651   }
11652   for (i = 0, len = exports.names.length; i < len; i++) {
11653     if (exports.names[i].test(name)) {
11654       return true;
11655     }
11656   }
11657   return false;
11658 }
11659
11660 /**
11661  * Coerce `val`.
11662  *
11663  * @param {Mixed} val
11664  * @return {Mixed}
11665  * @api private
11666  */
11667
11668 function coerce(val) {
11669   if (val instanceof Error) return val.stack || val.message;
11670   return val;
11671 }
11672
11673
11674 /***/ }),
11675 /* 64 */
11676 /***/ (function(module, exports) {
11677
11678 /**
11679  * Helpers.
11680  */
11681
11682 var s = 1000;
11683 var m = s * 60;
11684 var h = m * 60;
11685 var d = h * 24;
11686 var y = d * 365.25;
11687
11688 /**
11689  * Parse or format the given `val`.
11690  *
11691  * Options:
11692  *
11693  *  - `long` verbose formatting [false]
11694  *
11695  * @param {String|Number} val
11696  * @param {Object} [options]
11697  * @throws {Error} throw an error if val is not a non-empty string or a number
11698  * @return {String|Number}
11699  * @api public
11700  */
11701
11702 module.exports = function(val, options) {
11703   options = options || {};
11704   var type = typeof val;
11705   if (type === 'string' && val.length > 0) {
11706     return parse(val);
11707   } else if (type === 'number' && isNaN(val) === false) {
11708     return options.long ? fmtLong(val) : fmtShort(val);
11709   }
11710   throw new Error(
11711     'val is not a non-empty string or a valid number. val=' +
11712       JSON.stringify(val)
11713   );
11714 };
11715
11716 /**
11717  * Parse the given `str` and return milliseconds.
11718  *
11719  * @param {String} str
11720  * @return {Number}
11721  * @api private
11722  */
11723
11724 function parse(str) {
11725   str = String(str);
11726   if (str.length > 100) {
11727     return;
11728   }
11729   var match = /^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(
11730     str
11731   );
11732   if (!match) {
11733     return;
11734   }
11735   var n = parseFloat(match[1]);
11736   var type = (match[2] || 'ms').toLowerCase();
11737   switch (type) {
11738     case 'years':
11739     case 'year':
11740     case 'yrs':
11741     case 'yr':
11742     case 'y':
11743       return n * y;
11744     case 'days':
11745     case 'day':
11746     case 'd':
11747       return n * d;
11748     case 'hours':
11749     case 'hour':
11750     case 'hrs':
11751     case 'hr':
11752     case 'h':
11753       return n * h;
11754     case 'minutes':
11755     case 'minute':
11756     case 'mins':
11757     case 'min':
11758     case 'm':
11759       return n * m;
11760     case 'seconds':
11761     case 'second':
11762     case 'secs':
11763     case 'sec':
11764     case 's':
11765       return n * s;
11766     case 'milliseconds':
11767     case 'millisecond':
11768     case 'msecs':
11769     case 'msec':
11770     case 'ms':
11771       return n;
11772     default:
11773       return undefined;
11774   }
11775 }
11776
11777 /**
11778  * Short format for `ms`.
11779  *
11780  * @param {Number} ms
11781  * @return {String}
11782  * @api private
11783  */
11784
11785 function fmtShort(ms) {
11786   if (ms >= d) {
11787     return Math.round(ms / d) + 'd';
11788   }
11789   if (ms >= h) {
11790     return Math.round(ms / h) + 'h';
11791   }
11792   if (ms >= m) {
11793     return Math.round(ms / m) + 'm';
11794   }
11795   if (ms >= s) {
11796     return Math.round(ms / s) + 's';
11797   }
11798   return ms + 'ms';
11799 }
11800
11801 /**
11802  * Long format for `ms`.
11803  *
11804  * @param {Number} ms
11805  * @return {String}
11806  * @api private
11807  */
11808
11809 function fmtLong(ms) {
11810   return plural(ms, d, 'day') ||
11811     plural(ms, h, 'hour') ||
11812     plural(ms, m, 'minute') ||
11813     plural(ms, s, 'second') ||
11814     ms + ' ms';
11815 }
11816
11817 /**
11818  * Pluralization helper.
11819  */
11820
11821 function plural(ms, n, name) {
11822   if (ms < n) {
11823     return;
11824   }
11825   if (ms < n * 1.5) {
11826     return Math.floor(ms / n) + ' ' + name;
11827   }
11828   return Math.ceil(ms / n) + ' ' + name + 's';
11829 }
11830
11831
11832 /***/ }),
11833 /* 65 */
11834 /***/ (function(module, exports, __webpack_require__) {
11835
11836 /**
11837  * Module dependencies.
11838  */
11839
11840 var tty = __webpack_require__(66);
11841 var util = __webpack_require__(56);
11842
11843 /**
11844  * This is the Node.js implementation of `debug()`.
11845  *
11846  * Expose `debug()` as the module.
11847  */
11848
11849 exports = module.exports = __webpack_require__(63);
11850 exports.init = init;
11851 exports.log = log;
11852 exports.formatArgs = formatArgs;
11853 exports.save = save;
11854 exports.load = load;
11855 exports.useColors = useColors;
11856
11857 /**
11858  * Colors.
11859  */
11860
11861 exports.colors = [ 6, 2, 3, 4, 5, 1 ];
11862
11863 try {
11864   var supportsColor = __webpack_require__(67);
11865   if (supportsColor && supportsColor.level >= 2) {
11866     exports.colors = [
11867       20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68,
11868       69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134,
11869       135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171,
11870       172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204,
11871       205, 206, 207, 208, 209, 214, 215, 220, 221
11872     ];
11873   }
11874 } catch (err) {
11875   // swallow - we only care if `supports-color` is available; it doesn't have to be.
11876 }
11877
11878 /**
11879  * Build up the default `inspectOpts` object from the environment variables.
11880  *
11881  *   $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
11882  */
11883
11884 exports.inspectOpts = Object.keys(process.env).filter(function (key) {
11885   return /^debug_/i.test(key);
11886 }).reduce(function (obj, key) {
11887   // camel-case
11888   var prop = key
11889     .substring(6)
11890     .toLowerCase()
11891     .replace(/_([a-z])/g, function (_, k) { return k.toUpperCase() });
11892
11893   // coerce string value into JS value
11894   var val = process.env[key];
11895   if (/^(yes|on|true|enabled)$/i.test(val)) val = true;
11896   else if (/^(no|off|false|disabled)$/i.test(val)) val = false;
11897   else if (val === 'null') val = null;
11898   else val = Number(val);
11899
11900   obj[prop] = val;
11901   return obj;
11902 }, {});
11903
11904 /**
11905  * Is stdout a TTY? Colored output is enabled when `true`.
11906  */
11907
11908 function useColors() {
11909   return 'colors' in exports.inspectOpts
11910     ? Boolean(exports.inspectOpts.colors)
11911     : tty.isatty(process.stderr.fd);
11912 }
11913
11914 /**
11915  * Map %o to `util.inspect()`, all on a single line.
11916  */
11917
11918 exports.formatters.o = function(v) {
11919   this.inspectOpts.colors = this.useColors;
11920   return util.inspect(v, this.inspectOpts)
11921     .split('\n').map(function(str) {
11922       return str.trim()
11923     }).join(' ');
11924 };
11925
11926 /**
11927  * Map %o to `util.inspect()`, allowing multiple lines if needed.
11928  */
11929
11930 exports.formatters.O = function(v) {
11931   this.inspectOpts.colors = this.useColors;
11932   return util.inspect(v, this.inspectOpts);
11933 };
11934
11935 /**
11936  * Adds ANSI color escape codes if enabled.
11937  *
11938  * @api public
11939  */
11940
11941 function formatArgs(args) {
11942   var name = this.namespace;
11943   var useColors = this.useColors;
11944
11945   if (useColors) {
11946     var c = this.color;
11947     var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c);
11948     var prefix = '  ' + colorCode + ';1m' + name + ' ' + '\u001b[0m';
11949
11950     args[0] = prefix + args[0].split('\n').join('\n' + prefix);
11951     args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m');
11952   } else {
11953     args[0] = getDate() + name + ' ' + args[0];
11954   }
11955 }
11956
11957 function getDate() {
11958   if (exports.inspectOpts.hideDate) {
11959     return '';
11960   } else {
11961     return new Date().toISOString() + ' ';
11962   }
11963 }
11964
11965 /**
11966  * Invokes `util.format()` with the specified arguments and writes to stderr.
11967  */
11968
11969 function log() {
11970   return process.stderr.write(util.format.apply(util, arguments) + '\n');
11971 }
11972
11973 /**
11974  * Save `namespaces`.
11975  *
11976  * @param {String} namespaces
11977  * @api private
11978  */
11979
11980 function save(namespaces) {
11981   if (null == namespaces) {
11982     // If you set a process.env field to null or undefined, it gets cast to the
11983     // string 'null' or 'undefined'. Just delete instead.
11984     delete process.env.DEBUG;
11985   } else {
11986     process.env.DEBUG = namespaces;
11987   }
11988 }
11989
11990 /**
11991  * Load `namespaces`.
11992  *
11993  * @return {String} returns the previously persisted debug modes
11994  * @api private
11995  */
11996
11997 function load() {
11998   return process.env.DEBUG;
11999 }
12000
12001 /**
12002  * Init logic for `debug` instances.
12003  *
12004  * Create a new `inspectOpts` object in case `useColors` is set
12005  * differently for a particular `debug` instance.
12006  */
12007
12008 function init (debug) {
12009   debug.inspectOpts = {};
12010
12011   var keys = Object.keys(exports.inspectOpts);
12012   for (var i = 0; i < keys.length; i++) {
12013     debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
12014   }
12015 }
12016
12017 /**
12018  * Enable namespaces listed in `process.env.DEBUG` initially.
12019  */
12020
12021 exports.enable(load());
12022
12023
12024 /***/ }),
12025 /* 66 */
12026 /***/ (function(module, exports) {
12027
12028 module.exports = require("tty");
12029
12030 /***/ }),
12031 /* 67 */
12032 /***/ (function(module, exports, __webpack_require__) {
12033
12034 "use strict";
12035
12036 const os = __webpack_require__(13);
12037 const hasFlag = __webpack_require__(68);
12038
12039 const env = process.env;
12040
12041 let forceColor;
12042 if (hasFlag('no-color') ||
12043         hasFlag('no-colors') ||
12044         hasFlag('color=false')) {
12045         forceColor = false;
12046 } else if (hasFlag('color') ||
12047         hasFlag('colors') ||
12048         hasFlag('color=true') ||
12049         hasFlag('color=always')) {
12050         forceColor = true;
12051 }
12052 if ('FORCE_COLOR' in env) {
12053         forceColor = env.FORCE_COLOR.length === 0 || parseInt(env.FORCE_COLOR, 10) !== 0;
12054 }
12055
12056 function translateLevel(level) {
12057         if (level === 0) {
12058                 return false;
12059         }
12060
12061         return {
12062                 level,
12063                 hasBasic: true,
12064                 has256: level >= 2,
12065                 has16m: level >= 3
12066         };
12067 }
12068
12069 function supportsColor(stream) {
12070         if (forceColor === false) {
12071                 return 0;
12072         }
12073
12074         if (hasFlag('color=16m') ||
12075                 hasFlag('color=full') ||
12076                 hasFlag('color=truecolor')) {
12077                 return 3;
12078         }
12079
12080         if (hasFlag('color=256')) {
12081                 return 2;
12082         }
12083
12084         if (stream && !stream.isTTY && forceColor !== true) {
12085                 return 0;
12086         }
12087
12088         const min = forceColor ? 1 : 0;
12089
12090         if (process.platform === 'win32') {
12091                 // Node.js 7.5.0 is the first version of Node.js to include a patch to
12092                 // libuv that enables 256 color output on Windows. Anything earlier and it
12093                 // won't work. However, here we target Node.js 8 at minimum as it is an LTS
12094                 // release, and Node.js 7 is not. Windows 10 build 10586 is the first Windows
12095                 // release that supports 256 colors. Windows 10 build 14931 is the first release
12096                 // that supports 16m/TrueColor.
12097                 const osRelease = os.release().split('.');
12098                 if (
12099                         Number(process.versions.node.split('.')[0]) >= 8 &&
12100                         Number(osRelease[0]) >= 10 &&
12101                         Number(osRelease[2]) >= 10586
12102                 ) {
12103                         return Number(osRelease[2]) >= 14931 ? 3 : 2;
12104                 }
12105
12106                 return 1;
12107         }
12108
12109         if ('CI' in env) {
12110                 if (['TRAVIS', 'CIRCLECI', 'APPVEYOR', 'GITLAB_CI'].some(sign => sign in env) || env.CI_NAME === 'codeship') {
12111                         return 1;
12112                 }
12113
12114                 return min;
12115         }
12116
12117         if ('TEAMCITY_VERSION' in env) {
12118                 return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
12119         }
12120
12121         if (env.COLORTERM === 'truecolor') {
12122                 return 3;
12123         }
12124
12125         if ('TERM_PROGRAM' in env) {
12126                 const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
12127
12128                 switch (env.TERM_PROGRAM) {
12129                         case 'iTerm.app':
12130                                 return version >= 3 ? 3 : 2;
12131                         case 'Apple_Terminal':
12132                                 return 2;
12133                         // No default
12134                 }
12135         }
12136
12137         if (/-256(color)?$/i.test(env.TERM)) {
12138                 return 2;
12139         }
12140
12141         if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) {
12142                 return 1;
12143         }
12144
12145         if ('COLORTERM' in env) {
12146                 return 1;
12147         }
12148
12149         if (env.TERM === 'dumb') {
12150                 return min;
12151         }
12152
12153         return min;
12154 }
12155
12156 function getSupportLevel(stream) {
12157         const level = supportsColor(stream);
12158         return translateLevel(level);
12159 }
12160
12161 module.exports = {
12162         supportsColor: getSupportLevel,
12163         stdout: getSupportLevel(process.stdout),
12164         stderr: getSupportLevel(process.stderr)
12165 };
12166
12167
12168 /***/ }),
12169 /* 68 */
12170 /***/ (function(module, exports, __webpack_require__) {
12171
12172 "use strict";
12173
12174 module.exports = (flag, argv) => {
12175         argv = argv || process.argv;
12176         const prefix = flag.startsWith('-') ? '' : (flag.length === 1 ? '-' : '--');
12177         const pos = argv.indexOf(prefix + flag);
12178         const terminatorPos = argv.indexOf('--');
12179         return pos !== -1 && (terminatorPos === -1 ? true : pos < terminatorPos);
12180 };
12181
12182
12183 /***/ }),
12184 /* 69 */
12185 /***/ (function(module, exports, __webpack_require__) {
12186
12187 /**
12188  * Module dependencies.
12189  */
12190
12191 var net = __webpack_require__(15);
12192 var tls = __webpack_require__(53);
12193 var url = __webpack_require__(40);
12194 var Agent = __webpack_require__(54);
12195 var inherits = __webpack_require__(56).inherits;
12196 var debug = __webpack_require__(70)('https-proxy-agent');
12197
12198 /**
12199  * Module exports.
12200  */
12201
12202 module.exports = HttpsProxyAgent;
12203
12204 /**
12205  * The `HttpsProxyAgent` implements an HTTP Agent subclass that connects to the
12206  * specified "HTTP(s) proxy server" in order to proxy HTTPS requests.
12207  *
12208  * @api public
12209  */
12210
12211 function HttpsProxyAgent(opts) {
12212   if (!(this instanceof HttpsProxyAgent)) return new HttpsProxyAgent(opts);
12213   if ('string' == typeof opts) opts = url.parse(opts);
12214   if (!opts)
12215     throw new Error(
12216       'an HTTP(S) proxy server `host` and `port` must be specified!'
12217     );
12218   debug('creating new HttpsProxyAgent instance: %o', opts);
12219   Agent.call(this, opts);
12220
12221   var proxy = Object.assign({}, opts);
12222
12223   // if `true`, then connect to the proxy server over TLS. defaults to `false`.
12224   this.secureProxy = proxy.protocol ? /^https:?$/i.test(proxy.protocol) : false;
12225
12226   // prefer `hostname` over `host`, and set the `port` if needed
12227   proxy.host = proxy.hostname || proxy.host;
12228   proxy.port = +proxy.port || (this.secureProxy ? 443 : 80);
12229
12230   // ALPN is supported by Node.js >= v5.
12231   // attempt to negotiate http/1.1 for proxy servers that support http/2
12232   if (this.secureProxy && !('ALPNProtocols' in proxy)) {
12233     proxy.ALPNProtocols = ['http 1.1']
12234   }
12235
12236   if (proxy.host && proxy.path) {
12237     // if both a `host` and `path` are specified then it's most likely the
12238     // result of a `url.parse()` call... we need to remove the `path` portion so
12239     // that `net.connect()` doesn't attempt to open that as a unix socket file.
12240     delete proxy.path;
12241     delete proxy.pathname;
12242   }
12243
12244   this.proxy = proxy;
12245   this.defaultPort = 443;
12246 }
12247 inherits(HttpsProxyAgent, Agent);
12248
12249 /**
12250  * Called when the node-core HTTP client library is creating a new HTTP request.
12251  *
12252  * @api public
12253  */
12254
12255 HttpsProxyAgent.prototype.callback = function connect(req, opts, fn) {
12256   var proxy = this.proxy;
12257
12258   // create a socket connection to the proxy server
12259   var socket;
12260   if (this.secureProxy) {
12261     socket = tls.connect(proxy);
12262   } else {
12263     socket = net.connect(proxy);
12264   }
12265
12266   // we need to buffer any HTTP traffic that happens with the proxy before we get
12267   // the CONNECT response, so that if the response is anything other than an "200"
12268   // response code, then we can re-play the "data" events on the socket once the
12269   // HTTP parser is hooked up...
12270   var buffers = [];
12271   var buffersLength = 0;
12272
12273   function read() {
12274     var b = socket.read();
12275     if (b) ondata(b);
12276     else socket.once('readable', read);
12277   }
12278
12279   function cleanup() {
12280     socket.removeListener('data', ondata);
12281     socket.removeListener('end', onend);
12282     socket.removeListener('error', onerror);
12283     socket.removeListener('close', onclose);
12284     socket.removeListener('readable', read);
12285   }
12286
12287   function onclose(err) {
12288     debug('onclose had error %o', err);
12289   }
12290
12291   function onend() {
12292     debug('onend');
12293   }
12294
12295   function onerror(err) {
12296     cleanup();
12297     fn(err);
12298   }
12299
12300   function ondata(b) {
12301     buffers.push(b);
12302     buffersLength += b.length;
12303     var buffered = Buffer.concat(buffers, buffersLength);
12304     var str = buffered.toString('ascii');
12305
12306     if (!~str.indexOf('\r\n\r\n')) {
12307       // keep buffering
12308       debug('have not received end of HTTP headers yet...');
12309       if (socket.read) {
12310         read();
12311       } else {
12312         socket.once('data', ondata);
12313       }
12314       return;
12315     }
12316
12317     var firstLine = str.substring(0, str.indexOf('\r\n'));
12318     var statusCode = +firstLine.split(' ')[1];
12319     debug('got proxy server response: %o', firstLine);
12320
12321     if (200 == statusCode) {
12322       // 200 Connected status code!
12323       var sock = socket;
12324
12325       // nullify the buffered data since we won't be needing it
12326       buffers = buffered = null;
12327
12328       if (opts.secureEndpoint) {
12329         // since the proxy is connecting to an SSL server, we have
12330         // to upgrade this socket connection to an SSL connection
12331         debug(
12332           'upgrading proxy-connected socket to TLS connection: %o',
12333           opts.host
12334         );
12335         opts.socket = socket;
12336         opts.servername = opts.servername || opts.host;
12337         opts.host = null;
12338         opts.hostname = null;
12339         opts.port = null;
12340         sock = tls.connect(opts);
12341       }
12342
12343       cleanup();
12344       fn(null, sock);
12345     } else {
12346       // some other status code that's not 200... need to re-play the HTTP header
12347       // "data" events onto the socket once the HTTP machinery is attached so that
12348       // the user can parse and handle the error status code
12349       cleanup();
12350
12351       // save a reference to the concat'd Buffer for the `onsocket` callback
12352       buffers = buffered;
12353
12354       // need to wait for the "socket" event to re-play the "data" events
12355       req.once('socket', onsocket);
12356       fn(null, socket);
12357     }
12358   }
12359
12360   function onsocket(socket) {
12361     // replay the "buffers" Buffer onto the `socket`, since at this point
12362     // the HTTP module machinery has been hooked up for the user
12363     if ('function' == typeof socket.ondata) {
12364       // node <= v0.11.3, the `ondata` function is set on the socket
12365       socket.ondata(buffers, 0, buffers.length);
12366     } else if (socket.listeners('data').length > 0) {
12367       // node > v0.11.3, the "data" event is listened for directly
12368       socket.emit('data', buffers);
12369     } else {
12370       // never?
12371       throw new Error('should not happen...');
12372     }
12373
12374     // nullify the cached Buffer instance
12375     buffers = null;
12376   }
12377
12378   socket.on('error', onerror);
12379   socket.on('close', onclose);
12380   socket.on('end', onend);
12381
12382   if (socket.read) {
12383     read();
12384   } else {
12385     socket.once('data', ondata);
12386   }
12387
12388   var hostname = opts.host + ':' + opts.port;
12389   var msg = 'CONNECT ' + hostname + ' HTTP/1.1\r\n';
12390
12391   var headers = Object.assign({}, proxy.headers);
12392   if (proxy.auth) {
12393     headers['Proxy-Authorization'] =
12394       'Basic ' + Buffer.from(proxy.auth).toString('base64');
12395   }
12396
12397   // the Host header should only include the port
12398   // number when it is a non-standard port
12399   var host = opts.host;
12400   if (!isDefaultPort(opts.port, opts.secureEndpoint)) {
12401     host += ':' + opts.port;
12402   }
12403   headers['Host'] = host;
12404
12405   headers['Connection'] = 'close';
12406   Object.keys(headers).forEach(function(name) {
12407     msg += name + ': ' + headers[name] + '\r\n';
12408   });
12409
12410   socket.write(msg + '\r\n');
12411 };
12412
12413 function isDefaultPort(port, secure) {
12414   return Boolean((!secure && port === 80) || (secure && port === 443));
12415 }
12416
12417
12418 /***/ }),
12419 /* 70 */
12420 /***/ (function(module, exports, __webpack_require__) {
12421
12422 "use strict";
12423
12424
12425 /**
12426  * Detect Electron renderer / nwjs process, which is node, but we should
12427  * treat as a browser.
12428  */
12429 if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
12430   module.exports = __webpack_require__(71);
12431 } else {
12432   module.exports = __webpack_require__(74);
12433 }
12434
12435
12436
12437 /***/ }),
12438 /* 71 */
12439 /***/ (function(module, exports, __webpack_require__) {
12440
12441 "use strict";
12442
12443
12444 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
12445
12446 /* eslint-env browser */
12447
12448 /**
12449  * This is the web browser implementation of `debug()`.
12450  */
12451 exports.log = log;
12452 exports.formatArgs = formatArgs;
12453 exports.save = save;
12454 exports.load = load;
12455 exports.useColors = useColors;
12456 exports.storage = localstorage();
12457 /**
12458  * Colors.
12459  */
12460
12461 exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
12462 /**
12463  * Currently only WebKit-based Web Inspectors, Firefox >= v31,
12464  * and the Firebug extension (any Firefox version) are known
12465  * to support "%c" CSS customizations.
12466  *
12467  * TODO: add a `localStorage` variable to explicitly enable/disable colors
12468  */
12469 // eslint-disable-next-line complexity
12470
12471 function useColors() {
12472   // NB: In an Electron preload script, document will be defined but not fully
12473   // initialized. Since we know we're in Chrome, we'll just detect this case
12474   // explicitly
12475   if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
12476     return true;
12477   } // Internet Explorer and Edge do not support colors.
12478
12479
12480   if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
12481     return false;
12482   } // Is webkit? http://stackoverflow.com/a/16459606/376773
12483   // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
12484
12485
12486   return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
12487   typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
12488   // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
12489   typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
12490   typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
12491 }
12492 /**
12493  * Colorize log arguments if enabled.
12494  *
12495  * @api public
12496  */
12497
12498
12499 function formatArgs(args) {
12500   args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
12501
12502   if (!this.useColors) {
12503     return;
12504   }
12505
12506   var c = 'color: ' + this.color;
12507   args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
12508   // arguments passed either before or after the %c, so we need to
12509   // figure out the correct index to insert the CSS into
12510
12511   var index = 0;
12512   var lastC = 0;
12513   args[0].replace(/%[a-zA-Z%]/g, function (match) {
12514     if (match === '%%') {
12515       return;
12516     }
12517
12518     index++;
12519
12520     if (match === '%c') {
12521       // We only are interested in the *last* %c
12522       // (the user may have provided their own)
12523       lastC = index;
12524     }
12525   });
12526   args.splice(lastC, 0, c);
12527 }
12528 /**
12529  * Invokes `console.log()` when available.
12530  * No-op when `console.log` is not a "function".
12531  *
12532  * @api public
12533  */
12534
12535
12536 function log() {
12537   var _console;
12538
12539   // This hackery is required for IE8/9, where
12540   // the `console.log` function doesn't have 'apply'
12541   return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
12542 }
12543 /**
12544  * Save `namespaces`.
12545  *
12546  * @param {String} namespaces
12547  * @api private
12548  */
12549
12550
12551 function save(namespaces) {
12552   try {
12553     if (namespaces) {
12554       exports.storage.setItem('debug', namespaces);
12555     } else {
12556       exports.storage.removeItem('debug');
12557     }
12558   } catch (error) {// Swallow
12559     // XXX (@Qix-) should we be logging these?
12560   }
12561 }
12562 /**
12563  * Load `namespaces`.
12564  *
12565  * @return {String} returns the previously persisted debug modes
12566  * @api private
12567  */
12568
12569
12570 function load() {
12571   var r;
12572
12573   try {
12574     r = exports.storage.getItem('debug');
12575   } catch (error) {} // Swallow
12576   // XXX (@Qix-) should we be logging these?
12577   // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
12578
12579
12580   if (!r && typeof process !== 'undefined' && 'env' in process) {
12581     r = process.env.DEBUG;
12582   }
12583
12584   return r;
12585 }
12586 /**
12587  * Localstorage attempts to return the localstorage.
12588  *
12589  * This is necessary because safari throws
12590  * when a user disables cookies/localstorage
12591  * and you attempt to access it.
12592  *
12593  * @return {LocalStorage}
12594  * @api private
12595  */
12596
12597
12598 function localstorage() {
12599   try {
12600     // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
12601     // The Browser also has localStorage in the global context.
12602     return localStorage;
12603   } catch (error) {// Swallow
12604     // XXX (@Qix-) should we be logging these?
12605   }
12606 }
12607
12608 module.exports = __webpack_require__(72)(exports);
12609 var formatters = module.exports.formatters;
12610 /**
12611  * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
12612  */
12613
12614 formatters.j = function (v) {
12615   try {
12616     return JSON.stringify(v);
12617   } catch (error) {
12618     return '[UnexpectedJSONParseError]: ' + error.message;
12619   }
12620 };
12621
12622
12623
12624 /***/ }),
12625 /* 72 */
12626 /***/ (function(module, exports, __webpack_require__) {
12627
12628 "use strict";
12629
12630
12631 /**
12632  * This is the common logic for both the Node.js and web browser
12633  * implementations of `debug()`.
12634  */
12635 function setup(env) {
12636   createDebug.debug = createDebug;
12637   createDebug.default = createDebug;
12638   createDebug.coerce = coerce;
12639   createDebug.disable = disable;
12640   createDebug.enable = enable;
12641   createDebug.enabled = enabled;
12642   createDebug.humanize = __webpack_require__(73);
12643   Object.keys(env).forEach(function (key) {
12644     createDebug[key] = env[key];
12645   });
12646   /**
12647   * Active `debug` instances.
12648   */
12649
12650   createDebug.instances = [];
12651   /**
12652   * The currently active debug mode names, and names to skip.
12653   */
12654
12655   createDebug.names = [];
12656   createDebug.skips = [];
12657   /**
12658   * Map of special "%n" handling functions, for the debug "format" argument.
12659   *
12660   * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
12661   */
12662
12663   createDebug.formatters = {};
12664   /**
12665   * Selects a color for a debug namespace
12666   * @param {String} namespace The namespace string for the for the debug instance to be colored
12667   * @return {Number|String} An ANSI color code for the given namespace
12668   * @api private
12669   */
12670
12671   function selectColor(namespace) {
12672     var hash = 0;
12673
12674     for (var i = 0; i < namespace.length; i++) {
12675       hash = (hash << 5) - hash + namespace.charCodeAt(i);
12676       hash |= 0; // Convert to 32bit integer
12677     }
12678
12679     return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
12680   }
12681
12682   createDebug.selectColor = selectColor;
12683   /**
12684   * Create a debugger with the given `namespace`.
12685   *
12686   * @param {String} namespace
12687   * @return {Function}
12688   * @api public
12689   */
12690
12691   function createDebug(namespace) {
12692     var prevTime;
12693
12694     function debug() {
12695       // Disabled?
12696       if (!debug.enabled) {
12697         return;
12698       }
12699
12700       for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
12701         args[_key] = arguments[_key];
12702       }
12703
12704       var self = debug; // Set `diff` timestamp
12705
12706       var curr = Number(new Date());
12707       var ms = curr - (prevTime || curr);
12708       self.diff = ms;
12709       self.prev = prevTime;
12710       self.curr = curr;
12711       prevTime = curr;
12712       args[0] = createDebug.coerce(args[0]);
12713
12714       if (typeof args[0] !== 'string') {
12715         // Anything else let's inspect with %O
12716         args.unshift('%O');
12717       } // Apply any `formatters` transformations
12718
12719
12720       var index = 0;
12721       args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
12722         // If we encounter an escaped % then don't increase the array index
12723         if (match === '%%') {
12724           return match;
12725         }
12726
12727         index++;
12728         var formatter = createDebug.formatters[format];
12729
12730         if (typeof formatter === 'function') {
12731           var val = args[index];
12732           match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
12733
12734           args.splice(index, 1);
12735           index--;
12736         }
12737
12738         return match;
12739       }); // Apply env-specific formatting (colors, etc.)
12740
12741       createDebug.formatArgs.call(self, args);
12742       var logFn = self.log || createDebug.log;
12743       logFn.apply(self, args);
12744     }
12745
12746     debug.namespace = namespace;
12747     debug.enabled = createDebug.enabled(namespace);
12748     debug.useColors = createDebug.useColors();
12749     debug.color = selectColor(namespace);
12750     debug.destroy = destroy;
12751     debug.extend = extend; // Debug.formatArgs = formatArgs;
12752     // debug.rawLog = rawLog;
12753     // env-specific initialization logic for debug instances
12754
12755     if (typeof createDebug.init === 'function') {
12756       createDebug.init(debug);
12757     }
12758
12759     createDebug.instances.push(debug);
12760     return debug;
12761   }
12762
12763   function destroy() {
12764     var index = createDebug.instances.indexOf(this);
12765
12766     if (index !== -1) {
12767       createDebug.instances.splice(index, 1);
12768       return true;
12769     }
12770
12771     return false;
12772   }
12773
12774   function extend(namespace, delimiter) {
12775     return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
12776   }
12777   /**
12778   * Enables a debug mode by namespaces. This can include modes
12779   * separated by a colon and wildcards.
12780   *
12781   * @param {String} namespaces
12782   * @api public
12783   */
12784
12785
12786   function enable(namespaces) {
12787     createDebug.save(namespaces);
12788     createDebug.names = [];
12789     createDebug.skips = [];
12790     var i;
12791     var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
12792     var len = split.length;
12793
12794     for (i = 0; i < len; i++) {
12795       if (!split[i]) {
12796         // ignore empty strings
12797         continue;
12798       }
12799
12800       namespaces = split[i].replace(/\*/g, '.*?');
12801
12802       if (namespaces[0] === '-') {
12803         createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
12804       } else {
12805         createDebug.names.push(new RegExp('^' + namespaces + '$'));
12806       }
12807     }
12808
12809     for (i = 0; i < createDebug.instances.length; i++) {
12810       var instance = createDebug.instances[i];
12811       instance.enabled = createDebug.enabled(instance.namespace);
12812     }
12813   }
12814   /**
12815   * Disable debug output.
12816   *
12817   * @api public
12818   */
12819
12820
12821   function disable() {
12822     createDebug.enable('');
12823   }
12824   /**
12825   * Returns true if the given mode name is enabled, false otherwise.
12826   *
12827   * @param {String} name
12828   * @return {Boolean}
12829   * @api public
12830   */
12831
12832
12833   function enabled(name) {
12834     if (name[name.length - 1] === '*') {
12835       return true;
12836     }
12837
12838     var i;
12839     var len;
12840
12841     for (i = 0, len = createDebug.skips.length; i < len; i++) {
12842       if (createDebug.skips[i].test(name)) {
12843         return false;
12844       }
12845     }
12846
12847     for (i = 0, len = createDebug.names.length; i < len; i++) {
12848       if (createDebug.names[i].test(name)) {
12849         return true;
12850       }
12851     }
12852
12853     return false;
12854   }
12855   /**
12856   * Coerce `val`.
12857   *
12858   * @param {Mixed} val
12859   * @return {Mixed}
12860   * @api private
12861   */
12862
12863
12864   function coerce(val) {
12865     if (val instanceof Error) {
12866       return val.stack || val.message;
12867     }
12868
12869     return val;
12870   }
12871
12872   createDebug.enable(createDebug.load());
12873   return createDebug;
12874 }
12875
12876 module.exports = setup;
12877
12878
12879
12880 /***/ }),
12881 /* 73 */
12882 /***/ (function(module, exports) {
12883
12884 /**
12885  * Helpers.
12886  */
12887
12888 var s = 1000;
12889 var m = s * 60;
12890 var h = m * 60;
12891 var d = h * 24;
12892 var w = d * 7;
12893 var y = d * 365.25;
12894
12895 /**
12896  * Parse or format the given `val`.
12897  *
12898  * Options:
12899  *
12900  *  - `long` verbose formatting [false]
12901  *
12902  * @param {String|Number} val
12903  * @param {Object} [options]
12904  * @throws {Error} throw an error if val is not a non-empty string or a number
12905  * @return {String|Number}
12906  * @api public
12907  */
12908
12909 module.exports = function(val, options) {
12910   options = options || {};
12911   var type = typeof val;
12912   if (type === 'string' && val.length > 0) {
12913     return parse(val);
12914   } else if (type === 'number' && isFinite(val)) {
12915     return options.long ? fmtLong(val) : fmtShort(val);
12916   }
12917   throw new Error(
12918     'val is not a non-empty string or a valid number. val=' +
12919       JSON.stringify(val)
12920   );
12921 };
12922
12923 /**
12924  * Parse the given `str` and return milliseconds.
12925  *
12926  * @param {String} str
12927  * @return {Number}
12928  * @api private
12929  */
12930
12931 function parse(str) {
12932   str = String(str);
12933   if (str.length > 100) {
12934     return;
12935   }
12936   var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
12937     str
12938   );
12939   if (!match) {
12940     return;
12941   }
12942   var n = parseFloat(match[1]);
12943   var type = (match[2] || 'ms').toLowerCase();
12944   switch (type) {
12945     case 'years':
12946     case 'year':
12947     case 'yrs':
12948     case 'yr':
12949     case 'y':
12950       return n * y;
12951     case 'weeks':
12952     case 'week':
12953     case 'w':
12954       return n * w;
12955     case 'days':
12956     case 'day':
12957     case 'd':
12958       return n * d;
12959     case 'hours':
12960     case 'hour':
12961     case 'hrs':
12962     case 'hr':
12963     case 'h':
12964       return n * h;
12965     case 'minutes':
12966     case 'minute':
12967     case 'mins':
12968     case 'min':
12969     case 'm':
12970       return n * m;
12971     case 'seconds':
12972     case 'second':
12973     case 'secs':
12974     case 'sec':
12975     case 's':
12976       return n * s;
12977     case 'milliseconds':
12978     case 'millisecond':
12979     case 'msecs':
12980     case 'msec':
12981     case 'ms':
12982       return n;
12983     default:
12984       return undefined;
12985   }
12986 }
12987
12988 /**
12989  * Short format for `ms`.
12990  *
12991  * @param {Number} ms
12992  * @return {String}
12993  * @api private
12994  */
12995
12996 function fmtShort(ms) {
12997   var msAbs = Math.abs(ms);
12998   if (msAbs >= d) {
12999     return Math.round(ms / d) + 'd';
13000   }
13001   if (msAbs >= h) {
13002     return Math.round(ms / h) + 'h';
13003   }
13004   if (msAbs >= m) {
13005     return Math.round(ms / m) + 'm';
13006   }
13007   if (msAbs >= s) {
13008     return Math.round(ms / s) + 's';
13009   }
13010   return ms + 'ms';
13011 }
13012
13013 /**
13014  * Long format for `ms`.
13015  *
13016  * @param {Number} ms
13017  * @return {String}
13018  * @api private
13019  */
13020
13021 function fmtLong(ms) {
13022   var msAbs = Math.abs(ms);
13023   if (msAbs >= d) {
13024     return plural(ms, msAbs, d, 'day');
13025   }
13026   if (msAbs >= h) {
13027     return plural(ms, msAbs, h, 'hour');
13028   }
13029   if (msAbs >= m) {
13030     return plural(ms, msAbs, m, 'minute');
13031   }
13032   if (msAbs >= s) {
13033     return plural(ms, msAbs, s, 'second');
13034   }
13035   return ms + ' ms';
13036 }
13037
13038 /**
13039  * Pluralization helper.
13040  */
13041
13042 function plural(ms, msAbs, n, name) {
13043   var isPlural = msAbs >= n * 1.5;
13044   return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
13045 }
13046
13047
13048 /***/ }),
13049 /* 74 */
13050 /***/ (function(module, exports, __webpack_require__) {
13051
13052 "use strict";
13053
13054
13055 /**
13056  * Module dependencies.
13057  */
13058 var tty = __webpack_require__(66);
13059
13060 var util = __webpack_require__(56);
13061 /**
13062  * This is the Node.js implementation of `debug()`.
13063  */
13064
13065
13066 exports.init = init;
13067 exports.log = log;
13068 exports.formatArgs = formatArgs;
13069 exports.save = save;
13070 exports.load = load;
13071 exports.useColors = useColors;
13072 /**
13073  * Colors.
13074  */
13075
13076 exports.colors = [6, 2, 3, 4, 5, 1];
13077
13078 try {
13079   // Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
13080   // eslint-disable-next-line import/no-extraneous-dependencies
13081   var supportsColor = __webpack_require__(67);
13082
13083   if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
13084     exports.colors = [20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 214, 215, 220, 221];
13085   }
13086 } catch (error) {} // Swallow - we only care if `supports-color` is available; it doesn't have to be.
13087
13088 /**
13089  * Build up the default `inspectOpts` object from the environment variables.
13090  *
13091  *   $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
13092  */
13093
13094
13095 exports.inspectOpts = Object.keys(process.env).filter(function (key) {
13096   return /^debug_/i.test(key);
13097 }).reduce(function (obj, key) {
13098   // Camel-case
13099   var prop = key.substring(6).toLowerCase().replace(/_([a-z])/g, function (_, k) {
13100     return k.toUpperCase();
13101   }); // Coerce string value into JS value
13102
13103   var val = process.env[key];
13104
13105   if (/^(yes|on|true|enabled)$/i.test(val)) {
13106     val = true;
13107   } else if (/^(no|off|false|disabled)$/i.test(val)) {
13108     val = false;
13109   } else if (val === 'null') {
13110     val = null;
13111   } else {
13112     val = Number(val);
13113   }
13114
13115   obj[prop] = val;
13116   return obj;
13117 }, {});
13118 /**
13119  * Is stdout a TTY? Colored output is enabled when `true`.
13120  */
13121
13122 function useColors() {
13123   return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) : tty.isatty(process.stderr.fd);
13124 }
13125 /**
13126  * Adds ANSI color escape codes if enabled.
13127  *
13128  * @api public
13129  */
13130
13131
13132 function formatArgs(args) {
13133   var name = this.namespace,
13134       useColors = this.useColors;
13135
13136   if (useColors) {
13137     var c = this.color;
13138     var colorCode = "\x1B[3" + (c < 8 ? c : '8;5;' + c);
13139     var prefix = "  ".concat(colorCode, ";1m").concat(name, " \x1B[0m");
13140     args[0] = prefix + args[0].split('\n').join('\n' + prefix);
13141     args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + "\x1B[0m");
13142   } else {
13143     args[0] = getDate() + name + ' ' + args[0];
13144   }
13145 }
13146
13147 function getDate() {
13148   if (exports.inspectOpts.hideDate) {
13149     return '';
13150   }
13151
13152   return new Date().toISOString() + ' ';
13153 }
13154 /**
13155  * Invokes `util.format()` with the specified arguments and writes to stderr.
13156  */
13157
13158
13159 function log() {
13160   return process.stderr.write(util.format.apply(util, arguments) + '\n');
13161 }
13162 /**
13163  * Save `namespaces`.
13164  *
13165  * @param {String} namespaces
13166  * @api private
13167  */
13168
13169
13170 function save(namespaces) {
13171   if (namespaces) {
13172     process.env.DEBUG = namespaces;
13173   } else {
13174     // If you set a process.env field to null or undefined, it gets cast to the
13175     // string 'null' or 'undefined'. Just delete instead.
13176     delete process.env.DEBUG;
13177   }
13178 }
13179 /**
13180  * Load `namespaces`.
13181  *
13182  * @return {String} returns the previously persisted debug modes
13183  * @api private
13184  */
13185
13186
13187 function load() {
13188   return process.env.DEBUG;
13189 }
13190 /**
13191  * Init logic for `debug` instances.
13192  *
13193  * Create a new `inspectOpts` object in case `useColors` is set
13194  * differently for a particular `debug` instance.
13195  */
13196
13197
13198 function init(debug) {
13199   debug.inspectOpts = {};
13200   var keys = Object.keys(exports.inspectOpts);
13201
13202   for (var i = 0; i < keys.length; i++) {
13203     debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
13204   }
13205 }
13206
13207 module.exports = __webpack_require__(72)(exports);
13208 var formatters = module.exports.formatters;
13209 /**
13210  * Map %o to `util.inspect()`, all on a single line.
13211  */
13212
13213 formatters.o = function (v) {
13214   this.inspectOpts.colors = this.useColors;
13215   return util.inspect(v, this.inspectOpts).replace(/\s*\n\s*/g, ' ');
13216 };
13217 /**
13218  * Map %O to `util.inspect()`, allowing multiple lines if needed.
13219  */
13220
13221
13222 formatters.O = function (v) {
13223   this.inspectOpts.colors = this.useColors;
13224   return util.inspect(v, this.inspectOpts);
13225 };
13226
13227
13228
13229 /***/ }),
13230 /* 75 */
13231 /***/ (function(module, exports) {
13232
13233 module.exports = require("zlib");
13234
13235 /***/ }),
13236 /* 76 */
13237 /***/ (function(module, exports, __webpack_require__) {
13238
13239 "use strict";
13240 /* --------------------------------------------------------------------------------------------\r
13241  * Copyright (c) Microsoft Corporation. All rights reserved.\r
13242  * Licensed under the MIT License. See License.txt in the project root for license information.\r
13243  * ------------------------------------------------------------------------------------------ */\r
13244 \r
13245 Object.defineProperty(exports, "__esModule", { value: true });\r
13246 var path = __webpack_require__(1);\r
13247 var fs = __webpack_require__(2);\r
13248 var toString = Object.prototype.toString;\r
13249 function isDefined(value) {\r
13250     return typeof value !== 'undefined';\r
13251 }\r
13252 function isNumber(value) {\r
13253     return toString.call(value) === '[object Number]';\r
13254 }\r
13255 function isString(value) {\r
13256     return toString.call(value) === '[object String]';\r
13257 }\r
13258 function isBoolean(value) {\r
13259     return value === true || value === false;\r
13260 }\r
13261 function readJsonFileSync(filename) {\r
13262     return JSON.parse(fs.readFileSync(filename, 'utf8'));\r
13263 }\r
13264 var MessageFormat;\r
13265 (function (MessageFormat) {\r
13266     MessageFormat["file"] = "file";\r
13267     MessageFormat["bundle"] = "bundle";\r
13268     MessageFormat["both"] = "both";\r
13269 })(MessageFormat = exports.MessageFormat || (exports.MessageFormat = {}));\r
13270 var BundleFormat;\r
13271 (function (BundleFormat) {\r
13272     // the nls.bundle format\r
13273     BundleFormat["standalone"] = "standalone";\r
13274     BundleFormat["languagePack"] = "languagePack";\r
13275 })(BundleFormat = exports.BundleFormat || (exports.BundleFormat = {}));\r
13276 var LocalizeInfo;\r
13277 (function (LocalizeInfo) {\r
13278     function is(value) {\r
13279         var candidate = value;\r
13280         return candidate && isDefined(candidate.key) && isDefined(candidate.comment);\r
13281     }\r
13282     LocalizeInfo.is = is;\r
13283 })(LocalizeInfo || (LocalizeInfo = {}));\r
13284 var resolvedLanguage;\r
13285 var resolvedBundles;\r
13286 var options;\r
13287 var isPseudo;\r
13288 function initializeSettings() {\r
13289     options = { locale: undefined, language: undefined, languagePackSupport: false, cacheLanguageResolution: true, messageFormat: MessageFormat.bundle };\r
13290     if (isString(process.env.VSCODE_NLS_CONFIG)) {\r
13291         try {\r
13292             var vscodeOptions = JSON.parse(process.env.VSCODE_NLS_CONFIG);\r
13293             var language = void 0;\r
13294             var locale = void 0;\r
13295             if (vscodeOptions.availableLanguages) {\r
13296                 var value = vscodeOptions.availableLanguages['*'];\r
13297                 if (isString(value)) {\r
13298                     language = value;\r
13299                 }\r
13300             }\r
13301             if (isString(vscodeOptions.locale)) {\r
13302                 options.locale = vscodeOptions.locale.toLowerCase();\r
13303             }\r
13304             if (language === undefined) {\r
13305                 options.language = options.locale;\r
13306             }\r
13307             else if (language !== 'en') {\r
13308                 options.language = language;\r
13309             }\r
13310             if (isBoolean(vscodeOptions._languagePackSupport)) {\r
13311                 options.languagePackSupport = vscodeOptions._languagePackSupport;\r
13312             }\r
13313             if (isString(vscodeOptions._cacheRoot)) {\r
13314                 options.cacheRoot = vscodeOptions._cacheRoot;\r
13315             }\r
13316             if (isString(vscodeOptions._languagePackId)) {\r
13317                 options.languagePackId = vscodeOptions._languagePackId;\r
13318             }\r
13319             if (isString(vscodeOptions._translationsConfigFile)) {\r
13320                 options.translationsConfigFile = vscodeOptions._translationsConfigFile;\r
13321                 try {\r
13322                     options.translationsConfig = readJsonFileSync(options.translationsConfigFile);\r
13323                 }\r
13324                 catch (error) {\r
13325                     // We can't read the translation config file. Mark the cache as corrupted.\r
13326                     if (vscodeOptions._corruptedFile) {\r
13327                         fs.writeFile(vscodeOptions._corruptedFile, 'corrupted', 'utf8', function (err) {\r
13328                             console.error(err);\r
13329                         });\r
13330                     }\r
13331                 }\r
13332             }\r
13333         }\r
13334         catch (_a) {\r
13335             // Do nothing.\r
13336         }\r
13337     }\r
13338     isPseudo = options.locale === 'pseudo';\r
13339     resolvedLanguage = undefined;\r
13340     resolvedBundles = Object.create(null);\r
13341 }\r
13342 initializeSettings();\r
13343 function supportsLanguagePack() {\r
13344     return options.languagePackSupport === true && options.cacheRoot !== undefined && options.languagePackId !== undefined && options.translationsConfigFile !== undefined\r
13345         && options.translationsConfig !== undefined;\r
13346 }\r
13347 function format(message, args) {\r
13348     var result;\r
13349     if (isPseudo) {\r
13350         // FF3B and FF3D is the Unicode zenkaku representation for [ and ]\r
13351         message = '\uFF3B' + message.replace(/[aouei]/g, '$&$&') + '\uFF3D';\r
13352     }\r
13353     if (args.length === 0) {\r
13354         result = message;\r
13355     }\r
13356     else {\r
13357         result = message.replace(/\{(\d+)\}/g, function (match, rest) {\r
13358             var index = rest[0];\r
13359             var arg = args[index];\r
13360             var replacement = match;\r
13361             if (typeof arg === 'string') {\r
13362                 replacement = arg;\r
13363             }\r
13364             else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {\r
13365                 replacement = String(arg);\r
13366             }\r
13367             return replacement;\r
13368         });\r
13369     }\r
13370     return result;\r
13371 }\r
13372 function createScopedLocalizeFunction(messages) {\r
13373     return function (key, message) {\r
13374         var args = [];\r
13375         for (var _i = 2; _i < arguments.length; _i++) {\r
13376             args[_i - 2] = arguments[_i];\r
13377         }\r
13378         if (isNumber(key)) {\r
13379             if (key >= messages.length) {\r
13380                 console.error("Broken localize call found. Index out of bounds. Stacktrace is\n: " + new Error('').stack);\r
13381                 return;\r
13382             }\r
13383             return format(messages[key], args);\r
13384         }\r
13385         else {\r
13386             if (isString(message)) {\r
13387                 console.warn("Message " + message + " didn't get externalized correctly.");\r
13388                 return format(message, args);\r
13389             }\r
13390             else {\r
13391                 console.error("Broken localize call found. Stacktrace is\n: " + new Error('').stack);\r
13392             }\r
13393         }\r
13394     };\r
13395 }\r
13396 function localize(key, message) {\r
13397     var args = [];\r
13398     for (var _i = 2; _i < arguments.length; _i++) {\r
13399         args[_i - 2] = arguments[_i];\r
13400     }\r
13401     return format(message, args);\r
13402 }\r
13403 function resolveLanguage(file) {\r
13404     var resolvedLanguage;\r
13405     if (options.cacheLanguageResolution && resolvedLanguage) {\r
13406         resolvedLanguage = resolvedLanguage;\r
13407     }\r
13408     else {\r
13409         if (isPseudo || !options.language) {\r
13410             resolvedLanguage = '.nls.json';\r
13411         }\r
13412         else {\r
13413             var locale = options.language;\r
13414             while (locale) {\r
13415                 var candidate = '.nls.' + locale + '.json';\r
13416                 if (fs.existsSync(file + candidate)) {\r
13417                     resolvedLanguage = candidate;\r
13418                     break;\r
13419                 }\r
13420                 else {\r
13421                     var index = locale.lastIndexOf('-');\r
13422                     if (index > 0) {\r
13423                         locale = locale.substring(0, index);\r
13424                     }\r
13425                     else {\r
13426                         resolvedLanguage = '.nls.json';\r
13427                         locale = null;\r
13428                     }\r
13429                 }\r
13430             }\r
13431         }\r
13432         if (options.cacheLanguageResolution) {\r
13433             resolvedLanguage = resolvedLanguage;\r
13434         }\r
13435     }\r
13436     return file + resolvedLanguage;\r
13437 }\r
13438 function findInTheBoxBundle(root) {\r
13439     var language = options.language;\r
13440     while (language) {\r
13441         var candidate = path.join(root, "nls.bundle." + language + ".json");\r
13442         if (fs.existsSync(candidate)) {\r
13443             return candidate;\r
13444         }\r
13445         else {\r
13446             var index = language.lastIndexOf('-');\r
13447             if (index > 0) {\r
13448                 language = language.substring(0, index);\r
13449             }\r
13450             else {\r
13451                 language = undefined;\r
13452             }\r
13453         }\r
13454     }\r
13455     // Test if we can reslove the default bundle.\r
13456     if (language === undefined) {\r
13457         var candidate = path.join(root, 'nls.bundle.json');\r
13458         if (fs.existsSync(candidate)) {\r
13459             return candidate;\r
13460         }\r
13461     }\r
13462     return undefined;\r
13463 }\r
13464 function mkdir(directory) {\r
13465     try {\r
13466         fs.mkdirSync(directory);\r
13467     }\r
13468     catch (err) {\r
13469         if (err.code === 'EEXIST') {\r
13470             return;\r
13471         }\r
13472         else if (err.code === 'ENOENT') {\r
13473             var parent = path.dirname(directory);\r
13474             if (parent !== directory) {\r
13475                 mkdir(parent);\r
13476                 fs.mkdirSync(directory);\r
13477             }\r
13478         }\r
13479         else {\r
13480             throw err;\r
13481         }\r
13482     }\r
13483 }\r
13484 function createDefaultNlsBundle(folder) {\r
13485     var metaData = readJsonFileSync(path.join(folder, 'nls.metadata.json'));\r
13486     var result = Object.create(null);\r
13487     for (var module_1 in metaData) {\r
13488         var entry = metaData[module_1];\r
13489         result[module_1] = entry.messages;\r
13490     }\r
13491     return result;\r
13492 }\r
13493 function createNLSBundle(header, metaDataPath) {\r
13494     var languagePackLocation = options.translationsConfig[header.id];\r
13495     if (!languagePackLocation) {\r
13496         return undefined;\r
13497     }\r
13498     var languagePack = readJsonFileSync(languagePackLocation).contents;\r
13499     var metaData = readJsonFileSync(path.join(metaDataPath, 'nls.metadata.json'));\r
13500     var result = Object.create(null);\r
13501     for (var module_2 in metaData) {\r
13502         var entry = metaData[module_2];\r
13503         var translations = languagePack[header.outDir + "/" + module_2];\r
13504         if (translations) {\r
13505             var resultMessages = [];\r
13506             for (var i = 0; i < entry.keys.length; i++) {\r
13507                 var messageKey = entry.keys[i];\r
13508                 var key = isString(messageKey) ? messageKey : messageKey.key;\r
13509                 var translatedMessage = translations[key];\r
13510                 if (translatedMessage === undefined) {\r
13511                     translatedMessage = entry.messages[i];\r
13512                 }\r
13513                 resultMessages.push(translatedMessage);\r
13514             }\r
13515             result[module_2] = resultMessages;\r
13516         }\r
13517         else {\r
13518             result[module_2] = entry.messages;\r
13519         }\r
13520     }\r
13521     return result;\r
13522 }\r
13523 function touch(file) {\r
13524     var d = new Date();\r
13525     fs.utimes(file, d, d, function () {\r
13526         // Do nothing. Ignore\r
13527     });\r
13528 }\r
13529 function cacheBundle(key, bundle) {\r
13530     resolvedBundles[key] = bundle;\r
13531     return bundle;\r
13532 }\r
13533 function loadNlsBundleOrCreateFromI18n(header, bundlePath) {\r
13534     var result;\r
13535     var bundle = path.join(options.cacheRoot, header.id + "-" + header.hash + ".json");\r
13536     var useMemoryOnly = false;\r
13537     var writeBundle = false;\r
13538     try {\r
13539         result = JSON.parse(fs.readFileSync(bundle, { encoding: 'utf8', flag: 'r' }));\r
13540         touch(bundle);\r
13541         return result;\r
13542     }\r
13543     catch (err) {\r
13544         if (err.code === 'ENOENT') {\r
13545             writeBundle = true;\r
13546         }\r
13547         else if (err instanceof SyntaxError) {\r
13548             // We have a syntax error. So no valid JSON. Use\r
13549             console.log("Syntax error parsing message bundle: " + err.message + ".");\r
13550             fs.unlink(bundle, function (err) {\r
13551                 if (err) {\r
13552                     console.error("Deleting corrupted bundle " + bundle + " failed.");\r
13553                 }\r
13554             });\r
13555             useMemoryOnly = true;\r
13556         }\r
13557         else {\r
13558             throw err;\r
13559         }\r
13560     }\r
13561     result = createNLSBundle(header, bundlePath);\r
13562     if (!result || useMemoryOnly) {\r
13563         return result;\r
13564     }\r
13565     if (writeBundle) {\r
13566         try {\r
13567             fs.writeFileSync(bundle, JSON.stringify(result), { encoding: 'utf8', flag: 'wx' });\r
13568         }\r
13569         catch (err) {\r
13570             if (err.code === 'EEXIST') {\r
13571                 return result;\r
13572             }\r
13573             throw err;\r
13574         }\r
13575     }\r
13576     return result;\r
13577 }\r
13578 function loadDefaultNlsBundle(bundlePath) {\r
13579     try {\r
13580         return createDefaultNlsBundle(bundlePath);\r
13581     }\r
13582     catch (err) {\r
13583         console.log("Generating default bundle from meta data failed.", err);\r
13584         return undefined;\r
13585     }\r
13586 }\r
13587 function loadNlsBundle(header, bundlePath) {\r
13588     var result;\r
13589     // Core decided to use a language pack. Do the same in the extension\r
13590     if (supportsLanguagePack()) {\r
13591         try {\r
13592             result = loadNlsBundleOrCreateFromI18n(header, bundlePath);\r
13593         }\r
13594         catch (err) {\r
13595             console.log("Load or create bundle failed ", err);\r
13596         }\r
13597     }\r
13598     if (!result) {\r
13599         // No language pack found, but core is running in language pack mode\r
13600         // Don't try to use old in the box bundles since the might be stale\r
13601         // Fall right back to the default bundle.\r
13602         if (options.languagePackSupport) {\r
13603             return loadDefaultNlsBundle(bundlePath);\r
13604         }\r
13605         var candidate = findInTheBoxBundle(bundlePath);\r
13606         if (candidate) {\r
13607             try {\r
13608                 return readJsonFileSync(candidate);\r
13609             }\r
13610             catch (err) {\r
13611                 console.log("Loading in the box message bundle failed.", err);\r
13612             }\r
13613         }\r
13614         result = loadDefaultNlsBundle(bundlePath);\r
13615     }\r
13616     return result;\r
13617 }\r
13618 function tryFindMetaDataHeaderFile(file) {\r
13619     var result;\r
13620     var dirname = path.dirname(file);\r
13621     while (true) {\r
13622         result = path.join(dirname, 'nls.metadata.header.json');\r
13623         if (fs.existsSync(result)) {\r
13624             break;\r
13625         }\r
13626         var parent = path.dirname(dirname);\r
13627         if (parent === dirname) {\r
13628             result = undefined;\r
13629             break;\r
13630         }\r
13631         else {\r
13632             dirname = parent;\r
13633         }\r
13634     }\r
13635     return result;\r
13636 }\r
13637 function loadMessageBundle(file) {\r
13638     if (!file) {\r
13639         // No file. We are in dev mode. Return the default\r
13640         // localize function.\r
13641         return localize;\r
13642     }\r
13643     // Remove extension since we load json files.\r
13644     var ext = path.extname(file);\r
13645     if (ext) {\r
13646         file = file.substr(0, file.length - ext.length);\r
13647     }\r
13648     if (options.messageFormat === MessageFormat.both || options.messageFormat === MessageFormat.bundle) {\r
13649         var headerFile = tryFindMetaDataHeaderFile(file);\r
13650         if (headerFile) {\r
13651             var bundlePath = path.dirname(headerFile);\r
13652             var bundle = resolvedBundles[bundlePath];\r
13653             if (bundle === undefined) {\r
13654                 try {\r
13655                     var header = JSON.parse(fs.readFileSync(headerFile, 'utf8'));\r
13656                     try {\r
13657                         var nlsBundle = loadNlsBundle(header, bundlePath);\r
13658                         bundle = cacheBundle(bundlePath, nlsBundle ? { header: header, nlsBundle: nlsBundle } : null);\r
13659                     }\r
13660                     catch (err) {\r
13661                         console.error('Failed to load nls bundle', err);\r
13662                         bundle = cacheBundle(bundlePath, null);\r
13663                     }\r
13664                 }\r
13665                 catch (err) {\r
13666                     console.error('Failed to read header file', err);\r
13667                     bundle = cacheBundle(bundlePath, null);\r
13668                 }\r
13669             }\r
13670             if (bundle) {\r
13671                 var module_3 = file.substr(bundlePath.length + 1).replace(/\\/g, '/');\r
13672                 var messages = bundle.nlsBundle[module_3];\r
13673                 if (messages === undefined) {\r
13674                     console.error("Messages for file " + file + " not found. See console for details.");\r
13675                     return function () {\r
13676                         return 'Messages not found.';\r
13677                     };\r
13678                 }\r
13679                 return createScopedLocalizeFunction(messages);\r
13680             }\r
13681         }\r
13682     }\r
13683     if (options.messageFormat === MessageFormat.both || options.messageFormat === MessageFormat.file) {\r
13684         // Try to load a single file bundle\r
13685         try {\r
13686             var json = readJsonFileSync(resolveLanguage(file));\r
13687             if (Array.isArray(json)) {\r
13688                 return createScopedLocalizeFunction(json);\r
13689             }\r
13690             else {\r
13691                 if (isDefined(json.messages) && isDefined(json.keys)) {\r
13692                     return createScopedLocalizeFunction(json.messages);\r
13693                 }\r
13694                 else {\r
13695                     console.error("String bundle '" + file + "' uses an unsupported format.");\r
13696                     return function () {\r
13697                         return 'File bundle has unsupported format. See console for details';\r
13698                     };\r
13699                 }\r
13700             }\r
13701         }\r
13702         catch (err) {\r
13703             if (err.code !== 'ENOENT') {\r
13704                 console.error('Failed to load single file bundle', err);\r
13705             }\r
13706         }\r
13707     }\r
13708     console.error("Failed to load message bundle for file " + file);\r
13709     return function () {\r
13710         return 'Failed to load message bundle. See console for details.';\r
13711     };\r
13712 }\r
13713 exports.loadMessageBundle = loadMessageBundle;\r
13714 function config(opts) {\r
13715     if (opts) {\r
13716         if (isString(opts.locale)) {\r
13717             options.locale = opts.locale.toLowerCase();\r
13718             options.language = options.locale;\r
13719             resolvedLanguage = undefined;\r
13720             resolvedBundles = Object.create(null);\r
13721         }\r
13722         if (opts.messageFormat !== undefined) {\r
13723             options.messageFormat = opts.messageFormat;\r
13724         }\r
13725         if (opts.bundleFormat === BundleFormat.standalone && options.languagePackSupport === true) {\r
13726             options.languagePackSupport = false;\r
13727         }\r
13728     }\r
13729     isPseudo = options.locale === 'pseudo';\r
13730     return loadMessageBundle;\r
13731 }\r
13732 exports.config = config;\r
13733 //# sourceMappingURL=main.js.map
13734
13735 /***/ }),
13736 /* 77 */
13737 /***/ (function(module, __webpack_exports__, __webpack_require__) {
13738
13739 "use strict";
13740 __webpack_require__.r(__webpack_exports__);
13741 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setUriThrowOnMissingScheme", function() { return setUriThrowOnMissingScheme; });
13742 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "URI", function() { return URI; });
13743 /*---------------------------------------------------------------------------------------------
13744  *  Copyright (c) Microsoft Corporation. All rights reserved.
13745  *  Licensed under the MIT License. See License.txt in the project root for license information.
13746  *--------------------------------------------------------------------------------------------*/
13747
13748 var __extends = (undefined && undefined.__extends) || (function () {
13749     var extendStatics = Object.setPrototypeOf ||
13750         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
13751         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
13752     return function (d, b) {
13753         extendStatics(d, b);
13754         function __() { this.constructor = d; }
13755         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13756     };
13757 })();
13758 var isWindows;
13759 if (typeof process === 'object') {
13760     isWindows = process.platform === 'win32';
13761 }
13762 else if (typeof navigator === 'object') {
13763     var userAgent = navigator.userAgent;
13764     isWindows = userAgent.indexOf('Windows') >= 0;
13765 }
13766 //#endregion
13767 var _schemePattern = /^\w[\w\d+.-]*$/;
13768 var _singleSlashStart = /^\//;
13769 var _doubleSlashStart = /^\/\//;
13770 var _throwOnMissingSchema = true;
13771 /**
13772  * @internal
13773  */
13774 function setUriThrowOnMissingScheme(value) {
13775     var old = _throwOnMissingSchema;
13776     _throwOnMissingSchema = value;
13777     return old;
13778 }
13779 function _validateUri(ret, _strict) {
13780     // scheme, must be set
13781     if (!ret.scheme) {
13782         if (_strict || _throwOnMissingSchema) {
13783             throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
13784         }
13785         else {
13786             // console.warn(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
13787         }
13788     }
13789     // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
13790     // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
13791     if (ret.scheme && !_schemePattern.test(ret.scheme)) {
13792         throw new Error('[UriError]: Scheme contains illegal characters.');
13793     }
13794     // path, http://tools.ietf.org/html/rfc3986#section-3.3
13795     // If a URI contains an authority component, then the path component
13796     // must either be empty or begin with a slash ("/") character.  If a URI
13797     // does not contain an authority component, then the path cannot begin
13798     // with two slash characters ("//").
13799     if (ret.path) {
13800         if (ret.authority) {
13801             if (!_singleSlashStart.test(ret.path)) {
13802                 throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
13803             }
13804         }
13805         else {
13806             if (_doubleSlashStart.test(ret.path)) {
13807                 throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
13808             }
13809         }
13810     }
13811 }
13812 // for a while we allowed uris *without* schemes and this is the migration
13813 // for them, e.g. an uri without scheme and without strict-mode warns and falls
13814 // back to the file-scheme. that should cause the least carnage and still be a
13815 // clear warning
13816 function _schemeFix(scheme, _strict) {
13817     if (_strict || _throwOnMissingSchema) {
13818         return scheme || _empty;
13819     }
13820     if (!scheme) {
13821         // console.trace('BAD uri lacks scheme, falling back to file-scheme.');
13822         scheme = 'file';
13823     }
13824     return scheme;
13825 }
13826 // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
13827 function _referenceResolution(scheme, path) {
13828     // the slash-character is our 'default base' as we don't
13829     // support constructing URIs relative to other URIs. This
13830     // also means that we alter and potentially break paths.
13831     // see https://tools.ietf.org/html/rfc3986#section-5.1.4
13832     switch (scheme) {
13833         case 'https':
13834         case 'http':
13835         case 'file':
13836             if (!path) {
13837                 path = _slash;
13838             }
13839             else if (path[0] !== _slash) {
13840                 path = _slash + path;
13841             }
13842             break;
13843     }
13844     return path;
13845 }
13846 var _empty = '';
13847 var _slash = '/';
13848 var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
13849 function _isQueryStringScheme(scheme) {
13850     switch (scheme.toLowerCase()) {
13851         case 'http':
13852         case 'https':
13853         case 'ftp':
13854             return true;
13855     }
13856     return false;
13857 }
13858 /**
13859  * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
13860  * This class is a simple parser which creates the basic component parts
13861  * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
13862  * and encoding.
13863  *
13864  *       foo://example.com:8042/over/there?name=ferret#nose
13865  *       \_/   \______________/\_________/ \_________/ \__/
13866  *        |           |            |            |        |
13867  *     scheme     authority       path        query   fragment
13868  *        |   _____________________|__
13869  *       / \ /                        \
13870  *       urn:example:animal:ferret:nose
13871  */
13872 var URI = (function () {
13873     /**
13874      * @internal
13875      */
13876     function URI(schemeOrData, authority, path, query, fragment, _strict) {
13877         if (_strict === void 0) { _strict = false; }
13878         if (typeof schemeOrData === 'object') {
13879             this.scheme = schemeOrData.scheme || _empty;
13880             this.authority = schemeOrData.authority || _empty;
13881             this.path = schemeOrData.path || _empty;
13882             this.query = schemeOrData.query || _empty;
13883             this.fragment = schemeOrData.fragment || _empty;
13884             // no validation because it's this URI
13885             // that creates uri components.
13886             // _validateUri(this);
13887         }
13888         else {
13889             this.scheme = _schemeFix(schemeOrData, _strict);
13890             this.authority = authority || _empty;
13891             this.path = _referenceResolution(this.scheme, path || _empty);
13892             this.query = query || _empty;
13893             this.fragment = fragment || _empty;
13894             _validateUri(this, _strict);
13895         }
13896     }
13897     URI.isUri = function (thing) {
13898         if (thing instanceof URI) {
13899             return true;
13900         }
13901         if (!thing) {
13902             return false;
13903         }
13904         return typeof thing.authority === 'string'
13905             && typeof thing.fragment === 'string'
13906             && typeof thing.path === 'string'
13907             && typeof thing.query === 'string'
13908             && typeof thing.scheme === 'string'
13909             && typeof thing.fsPath === 'function'
13910             && typeof thing.with === 'function'
13911             && typeof thing.toString === 'function';
13912     };
13913     Object.defineProperty(URI.prototype, "fsPath", {
13914         // ---- filesystem path -----------------------
13915         /**
13916          * Returns a string representing the corresponding file system path of this URI.
13917          * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
13918          * platform specific path separator.
13919          *
13920          * * Will *not* validate the path for invalid characters and semantics.
13921          * * Will *not* look at the scheme of this URI.
13922          * * The result shall *not* be used for display purposes but for accessing a file on disk.
13923          *
13924          *
13925          * The *difference* to `URI#path` is the use of the platform specific separator and the handling
13926          * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
13927          *
13928          * ```ts
13929             const u = URI.parse('file://server/c$/folder/file.txt')
13930             u.authority === 'server'
13931             u.path === '/shares/c$/file.txt'
13932             u.fsPath === '\\server\c$\folder\file.txt'
13933         ```
13934          *
13935          * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
13936          * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
13937          * with URIs that represent files on disk (`file` scheme).
13938          */
13939         get: function () {
13940             // if (this.scheme !== 'file') {
13941             //  console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
13942             // }
13943             return _makeFsPath(this);
13944         },
13945         enumerable: true,
13946         configurable: true
13947     });
13948     // ---- modify to new -------------------------
13949     URI.prototype.with = function (change) {
13950         if (!change) {
13951             return this;
13952         }
13953         var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
13954         if (scheme === undefined) {
13955             scheme = this.scheme;
13956         }
13957         else if (scheme === null) {
13958             scheme = _empty;
13959         }
13960         if (authority === undefined) {
13961             authority = this.authority;
13962         }
13963         else if (authority === null) {
13964             authority = _empty;
13965         }
13966         if (path === undefined) {
13967             path = this.path;
13968         }
13969         else if (path === null) {
13970             path = _empty;
13971         }
13972         if (query === undefined) {
13973             query = this.query;
13974         }
13975         else if (query === null) {
13976             query = _empty;
13977         }
13978         if (fragment === undefined) {
13979             fragment = this.fragment;
13980         }
13981         else if (fragment === null) {
13982             fragment = _empty;
13983         }
13984         if (scheme === this.scheme
13985             && authority === this.authority
13986             && path === this.path
13987             && query === this.query
13988             && fragment === this.fragment) {
13989             return this;
13990         }
13991         return new _URI(scheme, authority, path, query, fragment);
13992     };
13993     // ---- parse & validate ------------------------
13994     /**
13995      * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
13996      * `file:///usr/home`, or `scheme:with/path`.
13997      *
13998      * @param value A string which represents an URI (see `URI#toString`).
13999      */
14000     URI.parse = function (value, _strict) {
14001         if (_strict === void 0) { _strict = false; }
14002         var match = _regexp.exec(value);
14003         if (!match) {
14004             return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
14005         }
14006         return new _URI(match[2] || _empty, decodeURIComponentFast(match[4] || _empty, false, false), decodeURIComponentFast(match[5] || _empty, true, false), decodeURIComponentFast(match[7] || _empty, false, _isQueryStringScheme(match[2])), decodeURIComponentFast(match[9] || _empty, false, false), _strict);
14007     };
14008     /**
14009      * Creates a new URI from a file system path, e.g. `c:\my\files`,
14010      * `/usr/home`, or `\\server\share\some\path`.
14011      *
14012      * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
14013      * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
14014      * `URI.parse('file://' + path)` because the path might contain characters that are
14015      * interpreted (# and ?). See the following sample:
14016      * ```ts
14017     const good = URI.file('/coding/c#/project1');
14018     good.scheme === 'file';
14019     good.path === '/coding/c#/project1';
14020     good.fragment === '';
14021     const bad = URI.parse('file://' + '/coding/c#/project1');
14022     bad.scheme === 'file';
14023     bad.path === '/coding/c'; // path is now broken
14024     bad.fragment === '/project1';
14025     ```
14026      *
14027      * @param path A file system path (see `URI#fsPath`)
14028      */
14029     URI.file = function (path) {
14030         var authority = _empty;
14031         // normalize to fwd-slashes on windows,
14032         // on other systems bwd-slashes are valid
14033         // filename character, eg /f\oo/ba\r.txt
14034         if (isWindows) {
14035             path = path.replace(/\\/g, _slash);
14036         }
14037         // check for authority as used in UNC shares
14038         // or use the path as given
14039         if (path[0] === _slash && path[1] === _slash) {
14040             var idx = path.indexOf(_slash, 2);
14041             if (idx === -1) {
14042                 authority = path.substring(2);
14043                 path = _slash;
14044             }
14045             else {
14046                 authority = path.substring(2, idx);
14047                 path = path.substring(idx) || _slash;
14048             }
14049         }
14050         return new _URI('file', authority, path, _empty, _empty);
14051     };
14052     URI.from = function (components) {
14053         return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
14054     };
14055     // ---- printing/externalize ---------------------------
14056     /**
14057      * Creates a string representation for this URI. It's guaranteed that calling
14058      * `URI.parse` with the result of this function creates an URI which is equal
14059      * to this URI.
14060      *
14061      * * The result shall *not* be used for display purposes but for externalization or transport.
14062      * * The result will be encoded using the percentage encoding and encoding happens mostly
14063      * ignore the scheme-specific encoding rules.
14064      *
14065      * @param skipEncoding Do not encode the result, default is `false`
14066      */
14067     URI.prototype.toString = function (skipEncoding) {
14068         if (skipEncoding === void 0) { skipEncoding = false; }
14069         return _asFormatted(this, skipEncoding);
14070     };
14071     URI.prototype.toJSON = function () {
14072         return this;
14073     };
14074     URI.revive = function (data) {
14075         if (!data) {
14076             return data;
14077         }
14078         else if (data instanceof URI) {
14079             return data;
14080         }
14081         else {
14082             var result = new _URI(data);
14083             result._formatted = data.external;
14084             result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
14085             return result;
14086         }
14087     };
14088     return URI;
14089 }());
14090
14091 var _pathSepMarker = isWindows ? 1 : undefined;
14092 // tslint:disable-next-line:class-name
14093 var _URI = (function (_super) {
14094     __extends(_URI, _super);
14095     function _URI() {
14096         var _this = _super !== null && _super.apply(this, arguments) || this;
14097         _this._formatted = null;
14098         _this._fsPath = null;
14099         return _this;
14100     }
14101     Object.defineProperty(_URI.prototype, "fsPath", {
14102         get: function () {
14103             if (!this._fsPath) {
14104                 this._fsPath = _makeFsPath(this);
14105             }
14106             return this._fsPath;
14107         },
14108         enumerable: true,
14109         configurable: true
14110     });
14111     _URI.prototype.toString = function (skipEncoding) {
14112         if (skipEncoding === void 0) { skipEncoding = false; }
14113         if (!skipEncoding) {
14114             if (!this._formatted) {
14115                 this._formatted = _asFormatted(this, false);
14116             }
14117             return this._formatted;
14118         }
14119         else {
14120             // we don't cache that
14121             return _asFormatted(this, true);
14122         }
14123     };
14124     _URI.prototype.toJSON = function () {
14125         var res = {
14126             $mid: 1
14127         };
14128         // cached state
14129         if (this._fsPath) {
14130             res.fsPath = this._fsPath;
14131             res._sep = _pathSepMarker;
14132         }
14133         if (this._formatted) {
14134             res.external = this._formatted;
14135         }
14136         // uri components
14137         if (this.path) {
14138             res.path = this.path;
14139         }
14140         if (this.scheme) {
14141             res.scheme = this.scheme;
14142         }
14143         if (this.authority) {
14144             res.authority = this.authority;
14145         }
14146         if (this.query) {
14147             res.query = this.query;
14148         }
14149         if (this.fragment) {
14150             res.fragment = this.fragment;
14151         }
14152         return res;
14153     };
14154     return _URI;
14155 }(URI));
14156 function isHex(value, pos) {
14157     if (pos >= value.length) {
14158         return false;
14159     }
14160     var code = value.charCodeAt(pos);
14161     return (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) // 0-9
14162         || (code >= 97 /* a */ && code <= 102 /* f */) //a-f
14163         || (code >= 65 /* A */ && code <= 70 /* F */); //A-F
14164 }
14165 function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
14166     var res;
14167     var nativeDecodePos = -1;
14168     for (var pos = 0; pos < uriComponent.length; pos++) {
14169         var code = uriComponent.charCodeAt(pos);
14170         // decoding needed
14171         if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
14172             var chA = uriComponent.charCodeAt(pos + 1);
14173             var chB = uriComponent.charCodeAt(pos + 2);
14174             // when in a path -> check and accept %2f and %2F (fwd slash)
14175             // when in a query string -> check and accept %3D, %26, and %3B (equals, ampersand, semi-colon)
14176             if ((isPath && chA === 50 /* Digit2 */ && (chB === 70 /* F */ || chB === 102 /* f */))
14177                 ||
14178                     (isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
14179                         ||
14180                             (chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
14181                     ))) {
14182                 if (nativeDecodePos !== -1) {
14183                     res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
14184                     nativeDecodePos = -1;
14185                 }
14186                 if (res !== undefined) {
14187                     res += uriComponent.substr(pos, 3);
14188                 }
14189                 pos += 2;
14190                 continue;
14191             }
14192             if (res === undefined) {
14193                 res = uriComponent.substring(0, pos);
14194             }
14195             if (nativeDecodePos === -1) {
14196                 nativeDecodePos = pos;
14197             }
14198             pos += 2;
14199         }
14200         else {
14201             if (nativeDecodePos !== -1) {
14202                 res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
14203                 nativeDecodePos = -1;
14204             }
14205             if (res !== undefined) {
14206                 res += String.fromCharCode(code);
14207             }
14208         }
14209     }
14210     if (nativeDecodePos !== -1) {
14211         res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
14212     }
14213     return res !== undefined ? res : uriComponent;
14214 }
14215 // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
14216 var encodeTable = (_a = {},
14217     _a[58 /* Colon */] = '%3A',
14218     _a[47 /* Slash */] = '%2F',
14219     _a[63 /* QuestionMark */] = '%3F',
14220     _a[35 /* Hash */] = '%23',
14221     _a[91 /* OpenSquareBracket */] = '%5B',
14222     _a[93 /* CloseSquareBracket */] = '%5D',
14223     _a[64 /* AtSign */] = '%40',
14224     _a[33 /* ExclamationMark */] = '%21',
14225     _a[36 /* DollarSign */] = '%24',
14226     _a[38 /* Ampersand */] = '%26',
14227     _a[39 /* SingleQuote */] = '%27',
14228     _a[40 /* OpenParen */] = '%28',
14229     _a[41 /* CloseParen */] = '%29',
14230     _a[42 /* Asterisk */] = '%2A',
14231     _a[43 /* Plus */] = '%2B',
14232     _a[44 /* Comma */] = '%2C',
14233     _a[59 /* Semicolon */] = '%3B',
14234     _a[61 /* Equals */] = '%3D',
14235     _a[32 /* Space */] = '%20',
14236     _a);
14237 function encodeURIComponentFast(uriComponent, isPath, isQueryString) {
14238     var res = undefined;
14239     var nativeEncodePos = -1;
14240     for (var pos = 0; pos < uriComponent.length; pos++) {
14241         var code = uriComponent.charCodeAt(pos);
14242         // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
14243         if ((code >= 97 /* a */ && code <= 122 /* z */)
14244             || (code >= 65 /* A */ && code <= 90 /* Z */)
14245             || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
14246             || code === 45 /* Dash */
14247             || code === 46 /* Period */
14248             || code === 95 /* Underline */
14249             || code === 126 /* Tilde */
14250             || (isPath && code === 47 /* Slash */) // path => allow slash AS-IS
14251             || (isQueryString && (code === 61 /* Equals */ || code === 38 /* Ampersand */ || code === 59 /* Semicolon */)) // query string => allow &=;
14252         ) {
14253             // check if we are delaying native encode
14254             if (nativeEncodePos !== -1) {
14255                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
14256                 nativeEncodePos = -1;
14257             }
14258             // check if we write into a new string (by default we try to return the param)
14259             if (res !== undefined) {
14260                 res += uriComponent.charAt(pos);
14261             }
14262         }
14263         else if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
14264             // at percentage encoded value
14265             // check if we are delaying native encode
14266             if (nativeEncodePos !== -1) {
14267                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
14268                 nativeEncodePos = -1;
14269             }
14270             // check if we write into a new string (by default we try to return the param)
14271             if (res !== undefined) {
14272                 res += uriComponent.substr(pos, 3);
14273             }
14274             pos += 2;
14275         }
14276         else {
14277             // encoding needed, we need to allocate a new string
14278             if (res === undefined) {
14279                 res = uriComponent.substr(0, pos);
14280             }
14281             // check with default table first
14282             var escaped = encodeTable[code];
14283             if (escaped !== undefined) {
14284                 // check if we are delaying native encode
14285                 if (nativeEncodePos !== -1) {
14286                     res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
14287                     nativeEncodePos = -1;
14288                 }
14289                 // append escaped variant to result
14290                 res += escaped;
14291             }
14292             else if (nativeEncodePos === -1) {
14293                 // use native encode only when needed
14294                 nativeEncodePos = pos;
14295             }
14296         }
14297     }
14298     if (nativeEncodePos !== -1) {
14299         res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
14300     }
14301     return res !== undefined ? res : uriComponent;
14302 }
14303 function encodeURIComponentMinimal(path) {
14304     var res = undefined;
14305     for (var pos = 0; pos < path.length; pos++) {
14306         var code = path.charCodeAt(pos);
14307         if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
14308             if (res === undefined) {
14309                 res = path.substr(0, pos);
14310             }
14311             res += encodeTable[code];
14312         }
14313         else {
14314             if (res !== undefined) {
14315                 res += path[pos];
14316             }
14317         }
14318     }
14319     return res !== undefined ? res : path;
14320 }
14321 /**
14322  * Compute `fsPath` for the given uri
14323  */
14324 function _makeFsPath(uri) {
14325     var value;
14326     if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
14327         // unc path: file://shares/c$/far/boo
14328         value = "//" + uri.authority + uri.path;
14329     }
14330     else if (uri.path.charCodeAt(0) === 47 /* Slash */
14331         && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
14332         && uri.path.charCodeAt(2) === 58 /* Colon */) {
14333         // windows drive letter: file:///c:/far/boo
14334         value = uri.path[1].toLowerCase() + uri.path.substr(2);
14335     }
14336     else {
14337         // other path
14338         value = uri.path;
14339     }
14340     if (isWindows) {
14341         value = value.replace(/\//g, '\\');
14342     }
14343     return value;
14344 }
14345 /**
14346  * Create the external version of a uri
14347  */
14348 function _asFormatted(uri, skipEncoding) {
14349     var encoder = !skipEncoding
14350         ? encodeURIComponentFast
14351         : encodeURIComponentMinimal;
14352     var res = '';
14353     var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
14354     if (scheme) {
14355         res += scheme;
14356         res += ':';
14357     }
14358     if (authority || scheme === 'file') {
14359         res += _slash;
14360         res += _slash;
14361     }
14362     if (authority) {
14363         var idx = authority.indexOf('@');
14364         if (idx !== -1) {
14365             // <user>@<auth>
14366             var userinfo = authority.substr(0, idx);
14367             authority = authority.substr(idx + 1);
14368             idx = userinfo.indexOf(':');
14369             if (idx === -1) {
14370                 res += encoder(userinfo, false, false);
14371             }
14372             else {
14373                 // <user>:<pass>@<auth>
14374                 res += encoder(userinfo.substr(0, idx), false, false);
14375                 res += ':';
14376                 res += encoder(userinfo.substr(idx + 1), false, false);
14377             }
14378             res += '@';
14379         }
14380         authority = authority.toLowerCase();
14381         idx = authority.indexOf(':');
14382         if (idx === -1) {
14383             res += encoder(authority, false, false);
14384         }
14385         else {
14386             // <auth>:<port>
14387             res += encoder(authority.substr(0, idx), false, false);
14388             res += authority.substr(idx);
14389         }
14390     }
14391     if (path) {
14392         // lower-case windows drive letters in /C:/fff or C:/fff
14393         if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
14394             var code = path.charCodeAt(1);
14395             if (code >= 65 /* A */ && code <= 90 /* Z */) {
14396                 path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
14397             }
14398         }
14399         else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
14400             var code = path.charCodeAt(0);
14401             if (code >= 65 /* A */ && code <= 90 /* Z */) {
14402                 path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
14403             }
14404         }
14405         // encode the rest of the path
14406         res += encoder(path, true, false);
14407     }
14408     if (query) {
14409         res += '?';
14410         res += encoder(query, false, _isQueryStringScheme(scheme));
14411     }
14412     if (fragment) {
14413         res += '#';
14414         res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
14415     }
14416     return res;
14417 }
14418 var _a;
14419
14420
14421 /***/ }),
14422 /* 78 */
14423 /***/ (function(module, exports, __webpack_require__) {
14424
14425 "use strict";
14426
14427 /*---------------------------------------------------------------------------------------------
14428  *  Copyright (c) Microsoft Corporation. All rights reserved.
14429  *  Licensed under the MIT License. See License.txt in the project root for license information.
14430  *--------------------------------------------------------------------------------------------*/
14431 Object.defineProperty(exports, "__esModule", { value: true });
14432 const vscode_languageserver_1 = __webpack_require__(34);
14433 function formatError(message, err) {
14434     if (err instanceof Error) {
14435         let error = err;
14436         return `${message}: ${error.message}\n${error.stack}`;
14437     }
14438     else if (typeof err === 'string') {
14439         return `${message}: ${err}`;
14440     }
14441     else if (err) {
14442         return `${message}: ${err.toString()}`;
14443     }
14444     return message;
14445 }
14446 exports.formatError = formatError;
14447 function runSafeAsync(func, errorVal, errorMessage, token) {
14448     return new Promise((resolve) => {
14449         setImmediate(() => {
14450             if (token.isCancellationRequested) {
14451                 resolve(cancelValue());
14452             }
14453             return func().then(result => {
14454                 if (token.isCancellationRequested) {
14455                     resolve(cancelValue());
14456                     return;
14457                 }
14458                 else {
14459                     resolve(result);
14460                 }
14461             }, e => {
14462                 console.error(formatError(errorMessage, e));
14463                 resolve(errorVal);
14464             });
14465         });
14466     });
14467 }
14468 exports.runSafeAsync = runSafeAsync;
14469 function runSafe(func, errorVal, errorMessage, token) {
14470     return new Promise((resolve) => {
14471         setImmediate(() => {
14472             if (token.isCancellationRequested) {
14473                 resolve(cancelValue());
14474             }
14475             else {
14476                 try {
14477                     let result = func();
14478                     if (token.isCancellationRequested) {
14479                         resolve(cancelValue());
14480                         return;
14481                     }
14482                     else {
14483                         resolve(result);
14484                     }
14485                 }
14486                 catch (e) {
14487                     console.error(formatError(errorMessage, e));
14488                     resolve(errorVal);
14489                 }
14490             }
14491         });
14492     });
14493 }
14494 exports.runSafe = runSafe;
14495 function cancelValue() {
14496     console.log('cancelled');
14497     return new vscode_languageserver_1.ResponseError(vscode_languageserver_1.ErrorCodes.RequestCancelled, 'Request cancelled');
14498 }
14499
14500
14501 /***/ }),
14502 /* 79 */
14503 /***/ (function(module, __webpack_exports__, __webpack_require__) {
14504
14505 "use strict";
14506 __webpack_require__.r(__webpack_exports__);
14507 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLanguageService", function() { return getLanguageService; });
14508 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80);
14509 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["TextDocument"]; });
14510
14511 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Position"]; });
14512
14513 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["CompletionItem"]; });
14514
14515 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["CompletionList"]; });
14516
14517 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Hover"]; });
14518
14519 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Range"]; });
14520
14521 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["SymbolInformation"]; });
14522
14523 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Diagnostic"]; });
14524
14525 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["TextEdit"]; });
14526
14527 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["FormattingOptions"]; });
14528
14529 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["MarkedString"]; });
14530
14531 /* harmony import */ var _services_jsonCompletion__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(81);
14532 /* harmony import */ var _services_jsonHover__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(92);
14533 /* harmony import */ var _services_jsonValidation__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(93);
14534 /* harmony import */ var _services_jsonDocumentSymbols__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(96);
14535 /* harmony import */ var _parser_jsonParser__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(82);
14536 /* harmony import */ var _services_configuration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(98);
14537 /* harmony import */ var _services_jsonSchemaService__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(94);
14538 /* harmony import */ var _services_jsonFolding__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(99);
14539 /* harmony import */ var _services_jsonSelectionRanges__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(100);
14540 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(83);
14541 /* harmony import */ var _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(89);
14542 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["Color"]; });
14543
14544 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["ColorInformation"]; });
14545
14546 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["ColorPresentation"]; });
14547
14548 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["FoldingRange"]; });
14549
14550 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["FoldingRangeKind"]; });
14551
14552 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["SelectionRange"]; });
14553
14554 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ErrorCode", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["ErrorCode"]; });
14555
14556 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClientCapabilities", function() { return _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_11__["ClientCapabilities"]; });
14557
14558 /*---------------------------------------------------------------------------------------------
14559  *  Copyright (c) Microsoft Corporation. All rights reserved.
14560  *  Licensed under the MIT License. See License.txt in the project root for license information.
14561  *--------------------------------------------------------------------------------------------*/
14562
14563
14564
14565
14566
14567
14568
14569
14570
14571
14572
14573
14574
14575 function getLanguageService(params) {
14576     var promise = params.promiseConstructor || Promise;
14577     var jsonSchemaService = new _services_jsonSchemaService__WEBPACK_IMPORTED_MODULE_7__["JSONSchemaService"](params.schemaRequestService, params.workspaceContext, promise);
14578     jsonSchemaService.setSchemaContributions(_services_configuration__WEBPACK_IMPORTED_MODULE_6__["schemaContributions"]);
14579     var jsonCompletion = new _services_jsonCompletion__WEBPACK_IMPORTED_MODULE_1__["JSONCompletion"](jsonSchemaService, params.contributions, promise, params.clientCapabilities);
14580     var jsonHover = new _services_jsonHover__WEBPACK_IMPORTED_MODULE_2__["JSONHover"](jsonSchemaService, params.contributions, promise);
14581     var jsonDocumentSymbols = new _services_jsonDocumentSymbols__WEBPACK_IMPORTED_MODULE_4__["JSONDocumentSymbols"](jsonSchemaService);
14582     var jsonValidation = new _services_jsonValidation__WEBPACK_IMPORTED_MODULE_3__["JSONValidation"](jsonSchemaService, promise);
14583     return {
14584         configure: function (settings) {
14585             jsonSchemaService.clearExternalSchemas();
14586             if (settings.schemas) {
14587                 settings.schemas.forEach(function (settings) {
14588                     jsonSchemaService.registerExternalSchema(settings.uri, settings.fileMatch, settings.schema);
14589                 });
14590             }
14591             jsonValidation.configure(settings);
14592         },
14593         resetSchema: function (uri) { return jsonSchemaService.onResourceChange(uri); },
14594         doValidation: jsonValidation.doValidation.bind(jsonValidation),
14595         parseJSONDocument: function (document) { return Object(_parser_jsonParser__WEBPACK_IMPORTED_MODULE_5__["parse"])(document, { collectComments: true }); },
14596         newJSONDocument: function (root, diagnostics) { return Object(_parser_jsonParser__WEBPACK_IMPORTED_MODULE_5__["newJSONDocument"])(root, diagnostics); },
14597         doResolve: jsonCompletion.doResolve.bind(jsonCompletion),
14598         doComplete: jsonCompletion.doComplete.bind(jsonCompletion),
14599         findDocumentSymbols: jsonDocumentSymbols.findDocumentSymbols.bind(jsonDocumentSymbols),
14600         findDocumentSymbols2: jsonDocumentSymbols.findDocumentSymbols2.bind(jsonDocumentSymbols),
14601         findColorSymbols: function (d, s) { return jsonDocumentSymbols.findDocumentColors(d, s).then(function (s) { return s.map(function (s) { return s.range; }); }); },
14602         findDocumentColors: jsonDocumentSymbols.findDocumentColors.bind(jsonDocumentSymbols),
14603         getColorPresentations: jsonDocumentSymbols.getColorPresentations.bind(jsonDocumentSymbols),
14604         doHover: jsonHover.doHover.bind(jsonHover),
14605         getFoldingRanges: _services_jsonFolding__WEBPACK_IMPORTED_MODULE_8__["getFoldingRanges"],
14606         getSelectionRanges: _services_jsonSelectionRanges__WEBPACK_IMPORTED_MODULE_9__["getSelectionRanges"],
14607         format: function (d, r, o) {
14608             var range = void 0;
14609             if (r) {
14610                 var offset = d.offsetAt(r.start);
14611                 var length = d.offsetAt(r.end) - offset;
14612                 range = { offset: offset, length: length };
14613             }
14614             var options = { tabSize: o ? o.tabSize : 4, insertSpaces: o ? o.insertSpaces : true, eol: '\n' };
14615             return Object(jsonc_parser__WEBPACK_IMPORTED_MODULE_10__["format"])(d.getText(), range, options).map(function (e) {
14616                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["TextEdit"].replace(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Range"].create(d.positionAt(e.offset), d.positionAt(e.offset + e.length)), e.content);
14617             });
14618         }
14619     };
14620 }
14621
14622
14623 /***/ }),
14624 /* 80 */
14625 /***/ (function(module, __webpack_exports__, __webpack_require__) {
14626
14627 "use strict";
14628 __webpack_require__.r(__webpack_exports__);
14629 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Position", function() { return Position; });
14630 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return Range; });
14631 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Location", function() { return Location; });
14632 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LocationLink", function() { return LocationLink; });
14633 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return Color; });
14634 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return ColorInformation; });
14635 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return ColorPresentation; });
14636 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return FoldingRangeKind; });
14637 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return FoldingRange; });
14638 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticRelatedInformation", function() { return DiagnosticRelatedInformation; });
14639 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticSeverity", function() { return DiagnosticSeverity; });
14640 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiagnosticTag", function() { return DiagnosticTag; });
14641 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Diagnostic", function() { return Diagnostic; });
14642 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Command", function() { return Command; });
14643 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return TextEdit; });
14644 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentEdit", function() { return TextDocumentEdit; });
14645 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CreateFile", function() { return CreateFile; });
14646 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenameFile", function() { return RenameFile; });
14647 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeleteFile", function() { return DeleteFile; });
14648 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceEdit", function() { return WorkspaceEdit; });
14649 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkspaceChange", function() { return WorkspaceChange; });
14650 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentIdentifier", function() { return TextDocumentIdentifier; });
14651 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VersionedTextDocumentIdentifier", function() { return VersionedTextDocumentIdentifier; });
14652 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentItem", function() { return TextDocumentItem; });
14653 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupKind", function() { return MarkupKind; });
14654 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkupContent", function() { return MarkupContent; });
14655 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItemKind", function() { return CompletionItemKind; });
14656 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InsertTextFormat", function() { return InsertTextFormat; });
14657 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionItem", function() { return CompletionItem; });
14658 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompletionList", function() { return CompletionList; });
14659 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MarkedString", function() { return MarkedString; });
14660 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hover", function() { return Hover; });
14661 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParameterInformation", function() { return ParameterInformation; });
14662 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SignatureInformation", function() { return SignatureInformation; });
14663 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlightKind", function() { return DocumentHighlightKind; });
14664 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentHighlight", function() { return DocumentHighlight; });
14665 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolKind", function() { return SymbolKind; });
14666 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolInformation", function() { return SymbolInformation; });
14667 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentSymbol", function() { return DocumentSymbol; });
14668 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionKind", function() { return CodeActionKind; });
14669 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeActionContext", function() { return CodeActionContext; });
14670 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeAction", function() { return CodeAction; });
14671 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CodeLens", function() { return CodeLens; });
14672 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FormattingOptions", function() { return FormattingOptions; });
14673 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DocumentLink", function() { return DocumentLink; });
14674 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return SelectionRange; });
14675 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EOL", function() { return EOL; });
14676 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocument", function() { return TextDocument; });
14677 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextDocumentSaveReason", function() { return TextDocumentSaveReason; });
14678 /* --------------------------------------------------------------------------------------------
14679  * Copyright (c) Microsoft Corporation. All rights reserved.
14680  * Licensed under the MIT License. See License.txt in the project root for license information.
14681  * ------------------------------------------------------------------------------------------ */
14682
14683 /**
14684  * The Position namespace provides helper functions to work with
14685  * [Position](#Position) literals.
14686  */
14687 var Position;
14688 (function (Position) {
14689     /**
14690      * Creates a new Position literal from the given line and character.
14691      * @param line The position's line.
14692      * @param character The position's character.
14693      */
14694     function create(line, character) {
14695         return { line: line, character: character };
14696     }
14697     Position.create = create;
14698     /**
14699      * Checks whether the given liternal conforms to the [Position](#Position) interface.
14700      */
14701     function is(value) {
14702         var candidate = value;
14703         return Is.objectLiteral(candidate) && Is.number(candidate.line) && Is.number(candidate.character);
14704     }
14705     Position.is = is;
14706 })(Position || (Position = {}));
14707 /**
14708  * The Range namespace provides helper functions to work with
14709  * [Range](#Range) literals.
14710  */
14711 var Range;
14712 (function (Range) {
14713     function create(one, two, three, four) {
14714         if (Is.number(one) && Is.number(two) && Is.number(three) && Is.number(four)) {
14715             return { start: Position.create(one, two), end: Position.create(three, four) };
14716         }
14717         else if (Position.is(one) && Position.is(two)) {
14718             return { start: one, end: two };
14719         }
14720         else {
14721             throw new Error("Range#create called with invalid arguments[" + one + ", " + two + ", " + three + ", " + four + "]");
14722         }
14723     }
14724     Range.create = create;
14725     /**
14726      * Checks whether the given literal conforms to the [Range](#Range) interface.
14727      */
14728     function is(value) {
14729         var candidate = value;
14730         return Is.objectLiteral(candidate) && Position.is(candidate.start) && Position.is(candidate.end);
14731     }
14732     Range.is = is;
14733 })(Range || (Range = {}));
14734 /**
14735  * The Location namespace provides helper functions to work with
14736  * [Location](#Location) literals.
14737  */
14738 var Location;
14739 (function (Location) {
14740     /**
14741      * Creates a Location literal.
14742      * @param uri The location's uri.
14743      * @param range The location's range.
14744      */
14745     function create(uri, range) {
14746         return { uri: uri, range: range };
14747     }
14748     Location.create = create;
14749     /**
14750      * Checks whether the given literal conforms to the [Location](#Location) interface.
14751      */
14752     function is(value) {
14753         var candidate = value;
14754         return Is.defined(candidate) && Range.is(candidate.range) && (Is.string(candidate.uri) || Is.undefined(candidate.uri));
14755     }
14756     Location.is = is;
14757 })(Location || (Location = {}));
14758 /**
14759  * The LocationLink namespace provides helper functions to work with
14760  * [LocationLink](#LocationLink) literals.
14761  */
14762 var LocationLink;
14763 (function (LocationLink) {
14764     /**
14765      * Creates a LocationLink literal.
14766      * @param targetUri The definition's uri.
14767      * @param targetRange The full range of the definition.
14768      * @param targetSelectionRange The span of the symbol definition at the target.
14769      * @param originSelectionRange The span of the symbol being defined in the originating source file.
14770      */
14771     function create(targetUri, targetRange, targetSelectionRange, originSelectionRange) {
14772         return { targetUri: targetUri, targetRange: targetRange, targetSelectionRange: targetSelectionRange, originSelectionRange: originSelectionRange };
14773     }
14774     LocationLink.create = create;
14775     /**
14776      * Checks whether the given literal conforms to the [LocationLink](#LocationLink) interface.
14777      */
14778     function is(value) {
14779         var candidate = value;
14780         return Is.defined(candidate) && Range.is(candidate.targetRange) && Is.string(candidate.targetUri)
14781             && (Range.is(candidate.targetSelectionRange) || Is.undefined(candidate.targetSelectionRange))
14782             && (Range.is(candidate.originSelectionRange) || Is.undefined(candidate.originSelectionRange));
14783     }
14784     LocationLink.is = is;
14785 })(LocationLink || (LocationLink = {}));
14786 /**
14787  * The Color namespace provides helper functions to work with
14788  * [Color](#Color) literals.
14789  */
14790 var Color;
14791 (function (Color) {
14792     /**
14793      * Creates a new Color literal.
14794      */
14795     function create(red, green, blue, alpha) {
14796         return {
14797             red: red,
14798             green: green,
14799             blue: blue,
14800             alpha: alpha,
14801         };
14802     }
14803     Color.create = create;
14804     /**
14805      * Checks whether the given literal conforms to the [Color](#Color) interface.
14806      */
14807     function is(value) {
14808         var candidate = value;
14809         return Is.number(candidate.red)
14810             && Is.number(candidate.green)
14811             && Is.number(candidate.blue)
14812             && Is.number(candidate.alpha);
14813     }
14814     Color.is = is;
14815 })(Color || (Color = {}));
14816 /**
14817  * The ColorInformation namespace provides helper functions to work with
14818  * [ColorInformation](#ColorInformation) literals.
14819  */
14820 var ColorInformation;
14821 (function (ColorInformation) {
14822     /**
14823      * Creates a new ColorInformation literal.
14824      */
14825     function create(range, color) {
14826         return {
14827             range: range,
14828             color: color,
14829         };
14830     }
14831     ColorInformation.create = create;
14832     /**
14833      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
14834      */
14835     function is(value) {
14836         var candidate = value;
14837         return Range.is(candidate.range) && Color.is(candidate.color);
14838     }
14839     ColorInformation.is = is;
14840 })(ColorInformation || (ColorInformation = {}));
14841 /**
14842  * The Color namespace provides helper functions to work with
14843  * [ColorPresentation](#ColorPresentation) literals.
14844  */
14845 var ColorPresentation;
14846 (function (ColorPresentation) {
14847     /**
14848      * Creates a new ColorInformation literal.
14849      */
14850     function create(label, textEdit, additionalTextEdits) {
14851         return {
14852             label: label,
14853             textEdit: textEdit,
14854             additionalTextEdits: additionalTextEdits,
14855         };
14856     }
14857     ColorPresentation.create = create;
14858     /**
14859      * Checks whether the given literal conforms to the [ColorInformation](#ColorInformation) interface.
14860      */
14861     function is(value) {
14862         var candidate = value;
14863         return Is.string(candidate.label)
14864             && (Is.undefined(candidate.textEdit) || TextEdit.is(candidate))
14865             && (Is.undefined(candidate.additionalTextEdits) || Is.typedArray(candidate.additionalTextEdits, TextEdit.is));
14866     }
14867     ColorPresentation.is = is;
14868 })(ColorPresentation || (ColorPresentation = {}));
14869 /**
14870  * Enum of known range kinds
14871  */
14872 var FoldingRangeKind;
14873 (function (FoldingRangeKind) {
14874     /**
14875      * Folding range for a comment
14876      */
14877     FoldingRangeKind["Comment"] = "comment";
14878     /**
14879      * Folding range for a imports or includes
14880      */
14881     FoldingRangeKind["Imports"] = "imports";
14882     /**
14883      * Folding range for a region (e.g. `#region`)
14884      */
14885     FoldingRangeKind["Region"] = "region";
14886 })(FoldingRangeKind || (FoldingRangeKind = {}));
14887 /**
14888  * The folding range namespace provides helper functions to work with
14889  * [FoldingRange](#FoldingRange) literals.
14890  */
14891 var FoldingRange;
14892 (function (FoldingRange) {
14893     /**
14894      * Creates a new FoldingRange literal.
14895      */
14896     function create(startLine, endLine, startCharacter, endCharacter, kind) {
14897         var result = {
14898             startLine: startLine,
14899             endLine: endLine
14900         };
14901         if (Is.defined(startCharacter)) {
14902             result.startCharacter = startCharacter;
14903         }
14904         if (Is.defined(endCharacter)) {
14905             result.endCharacter = endCharacter;
14906         }
14907         if (Is.defined(kind)) {
14908             result.kind = kind;
14909         }
14910         return result;
14911     }
14912     FoldingRange.create = create;
14913     /**
14914      * Checks whether the given literal conforms to the [FoldingRange](#FoldingRange) interface.
14915      */
14916     function is(value) {
14917         var candidate = value;
14918         return Is.number(candidate.startLine) && Is.number(candidate.startLine)
14919             && (Is.undefined(candidate.startCharacter) || Is.number(candidate.startCharacter))
14920             && (Is.undefined(candidate.endCharacter) || Is.number(candidate.endCharacter))
14921             && (Is.undefined(candidate.kind) || Is.string(candidate.kind));
14922     }
14923     FoldingRange.is = is;
14924 })(FoldingRange || (FoldingRange = {}));
14925 /**
14926  * The DiagnosticRelatedInformation namespace provides helper functions to work with
14927  * [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) literals.
14928  */
14929 var DiagnosticRelatedInformation;
14930 (function (DiagnosticRelatedInformation) {
14931     /**
14932      * Creates a new DiagnosticRelatedInformation literal.
14933      */
14934     function create(location, message) {
14935         return {
14936             location: location,
14937             message: message
14938         };
14939     }
14940     DiagnosticRelatedInformation.create = create;
14941     /**
14942      * Checks whether the given literal conforms to the [DiagnosticRelatedInformation](#DiagnosticRelatedInformation) interface.
14943      */
14944     function is(value) {
14945         var candidate = value;
14946         return Is.defined(candidate) && Location.is(candidate.location) && Is.string(candidate.message);
14947     }
14948     DiagnosticRelatedInformation.is = is;
14949 })(DiagnosticRelatedInformation || (DiagnosticRelatedInformation = {}));
14950 /**
14951  * The diagnostic's severity.
14952  */
14953 var DiagnosticSeverity;
14954 (function (DiagnosticSeverity) {
14955     /**
14956      * Reports an error.
14957      */
14958     DiagnosticSeverity.Error = 1;
14959     /**
14960      * Reports a warning.
14961      */
14962     DiagnosticSeverity.Warning = 2;
14963     /**
14964      * Reports an information.
14965      */
14966     DiagnosticSeverity.Information = 3;
14967     /**
14968      * Reports a hint.
14969      */
14970     DiagnosticSeverity.Hint = 4;
14971 })(DiagnosticSeverity || (DiagnosticSeverity = {}));
14972 var DiagnosticTag;
14973 (function (DiagnosticTag) {
14974     /**
14975      * Unused or unnecessary code.
14976      *
14977      * Clients are allowed to render diagnostics with this tag faded out instead of having
14978      * an error squiggle.
14979      */
14980     DiagnosticTag.Unnecessary = 1;
14981 })(DiagnosticTag || (DiagnosticTag = {}));
14982 /**
14983  * The Diagnostic namespace provides helper functions to work with
14984  * [Diagnostic](#Diagnostic) literals.
14985  */
14986 var Diagnostic;
14987 (function (Diagnostic) {
14988     /**
14989      * Creates a new Diagnostic literal.
14990      */
14991     function create(range, message, severity, code, source, relatedInformation) {
14992         var result = { range: range, message: message };
14993         if (Is.defined(severity)) {
14994             result.severity = severity;
14995         }
14996         if (Is.defined(code)) {
14997             result.code = code;
14998         }
14999         if (Is.defined(source)) {
15000             result.source = source;
15001         }
15002         if (Is.defined(relatedInformation)) {
15003             result.relatedInformation = relatedInformation;
15004         }
15005         return result;
15006     }
15007     Diagnostic.create = create;
15008     /**
15009      * Checks whether the given literal conforms to the [Diagnostic](#Diagnostic) interface.
15010      */
15011     function is(value) {
15012         var candidate = value;
15013         return Is.defined(candidate)
15014             && Range.is(candidate.range)
15015             && Is.string(candidate.message)
15016             && (Is.number(candidate.severity) || Is.undefined(candidate.severity))
15017             && (Is.number(candidate.code) || Is.string(candidate.code) || Is.undefined(candidate.code))
15018             && (Is.string(candidate.source) || Is.undefined(candidate.source))
15019             && (Is.undefined(candidate.relatedInformation) || Is.typedArray(candidate.relatedInformation, DiagnosticRelatedInformation.is));
15020     }
15021     Diagnostic.is = is;
15022 })(Diagnostic || (Diagnostic = {}));
15023 /**
15024  * The Command namespace provides helper functions to work with
15025  * [Command](#Command) literals.
15026  */
15027 var Command;
15028 (function (Command) {
15029     /**
15030      * Creates a new Command literal.
15031      */
15032     function create(title, command) {
15033         var args = [];
15034         for (var _i = 2; _i < arguments.length; _i++) {
15035             args[_i - 2] = arguments[_i];
15036         }
15037         var result = { title: title, command: command };
15038         if (Is.defined(args) && args.length > 0) {
15039             result.arguments = args;
15040         }
15041         return result;
15042     }
15043     Command.create = create;
15044     /**
15045      * Checks whether the given literal conforms to the [Command](#Command) interface.
15046      */
15047     function is(value) {
15048         var candidate = value;
15049         return Is.defined(candidate) && Is.string(candidate.title) && Is.string(candidate.command);
15050     }
15051     Command.is = is;
15052 })(Command || (Command = {}));
15053 /**
15054  * The TextEdit namespace provides helper function to create replace,
15055  * insert and delete edits more easily.
15056  */
15057 var TextEdit;
15058 (function (TextEdit) {
15059     /**
15060      * Creates a replace text edit.
15061      * @param range The range of text to be replaced.
15062      * @param newText The new text.
15063      */
15064     function replace(range, newText) {
15065         return { range: range, newText: newText };
15066     }
15067     TextEdit.replace = replace;
15068     /**
15069      * Creates a insert text edit.
15070      * @param position The position to insert the text at.
15071      * @param newText The text to be inserted.
15072      */
15073     function insert(position, newText) {
15074         return { range: { start: position, end: position }, newText: newText };
15075     }
15076     TextEdit.insert = insert;
15077     /**
15078      * Creates a delete text edit.
15079      * @param range The range of text to be deleted.
15080      */
15081     function del(range) {
15082         return { range: range, newText: '' };
15083     }
15084     TextEdit.del = del;
15085     function is(value) {
15086         var candidate = value;
15087         return Is.objectLiteral(candidate)
15088             && Is.string(candidate.newText)
15089             && Range.is(candidate.range);
15090     }
15091     TextEdit.is = is;
15092 })(TextEdit || (TextEdit = {}));
15093 /**
15094  * The TextDocumentEdit namespace provides helper function to create
15095  * an edit that manipulates a text document.
15096  */
15097 var TextDocumentEdit;
15098 (function (TextDocumentEdit) {
15099     /**
15100      * Creates a new `TextDocumentEdit`
15101      */
15102     function create(textDocument, edits) {
15103         return { textDocument: textDocument, edits: edits };
15104     }
15105     TextDocumentEdit.create = create;
15106     function is(value) {
15107         var candidate = value;
15108         return Is.defined(candidate)
15109             && VersionedTextDocumentIdentifier.is(candidate.textDocument)
15110             && Array.isArray(candidate.edits);
15111     }
15112     TextDocumentEdit.is = is;
15113 })(TextDocumentEdit || (TextDocumentEdit = {}));
15114 var CreateFile;
15115 (function (CreateFile) {
15116     function create(uri, options) {
15117         var result = {
15118             kind: 'create',
15119             uri: uri
15120         };
15121         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
15122             result.options = options;
15123         }
15124         return result;
15125     }
15126     CreateFile.create = create;
15127     function is(value) {
15128         var candidate = value;
15129         return candidate && candidate.kind === 'create' && Is.string(candidate.uri) &&
15130             (candidate.options === void 0 ||
15131                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
15132     }
15133     CreateFile.is = is;
15134 })(CreateFile || (CreateFile = {}));
15135 var RenameFile;
15136 (function (RenameFile) {
15137     function create(oldUri, newUri, options) {
15138         var result = {
15139             kind: 'rename',
15140             oldUri: oldUri,
15141             newUri: newUri
15142         };
15143         if (options !== void 0 && (options.overwrite !== void 0 || options.ignoreIfExists !== void 0)) {
15144             result.options = options;
15145         }
15146         return result;
15147     }
15148     RenameFile.create = create;
15149     function is(value) {
15150         var candidate = value;
15151         return candidate && candidate.kind === 'rename' && Is.string(candidate.oldUri) && Is.string(candidate.newUri) &&
15152             (candidate.options === void 0 ||
15153                 ((candidate.options.overwrite === void 0 || Is.boolean(candidate.options.overwrite)) && (candidate.options.ignoreIfExists === void 0 || Is.boolean(candidate.options.ignoreIfExists))));
15154     }
15155     RenameFile.is = is;
15156 })(RenameFile || (RenameFile = {}));
15157 var DeleteFile;
15158 (function (DeleteFile) {
15159     function create(uri, options) {
15160         var result = {
15161             kind: 'delete',
15162             uri: uri
15163         };
15164         if (options !== void 0 && (options.recursive !== void 0 || options.ignoreIfNotExists !== void 0)) {
15165             result.options = options;
15166         }
15167         return result;
15168     }
15169     DeleteFile.create = create;
15170     function is(value) {
15171         var candidate = value;
15172         return candidate && candidate.kind === 'delete' && Is.string(candidate.uri) &&
15173             (candidate.options === void 0 ||
15174                 ((candidate.options.recursive === void 0 || Is.boolean(candidate.options.recursive)) && (candidate.options.ignoreIfNotExists === void 0 || Is.boolean(candidate.options.ignoreIfNotExists))));
15175     }
15176     DeleteFile.is = is;
15177 })(DeleteFile || (DeleteFile = {}));
15178 var WorkspaceEdit;
15179 (function (WorkspaceEdit) {
15180     function is(value) {
15181         var candidate = value;
15182         return candidate &&
15183             (candidate.changes !== void 0 || candidate.documentChanges !== void 0) &&
15184             (candidate.documentChanges === void 0 || candidate.documentChanges.every(function (change) {
15185                 if (Is.string(change.kind)) {
15186                     return CreateFile.is(change) || RenameFile.is(change) || DeleteFile.is(change);
15187                 }
15188                 else {
15189                     return TextDocumentEdit.is(change);
15190                 }
15191             }));
15192     }
15193     WorkspaceEdit.is = is;
15194 })(WorkspaceEdit || (WorkspaceEdit = {}));
15195 var TextEditChangeImpl = /** @class */ (function () {
15196     function TextEditChangeImpl(edits) {
15197         this.edits = edits;
15198     }
15199     TextEditChangeImpl.prototype.insert = function (position, newText) {
15200         this.edits.push(TextEdit.insert(position, newText));
15201     };
15202     TextEditChangeImpl.prototype.replace = function (range, newText) {
15203         this.edits.push(TextEdit.replace(range, newText));
15204     };
15205     TextEditChangeImpl.prototype.delete = function (range) {
15206         this.edits.push(TextEdit.del(range));
15207     };
15208     TextEditChangeImpl.prototype.add = function (edit) {
15209         this.edits.push(edit);
15210     };
15211     TextEditChangeImpl.prototype.all = function () {
15212         return this.edits;
15213     };
15214     TextEditChangeImpl.prototype.clear = function () {
15215         this.edits.splice(0, this.edits.length);
15216     };
15217     return TextEditChangeImpl;
15218 }());
15219 /**
15220  * A workspace change helps constructing changes to a workspace.
15221  */
15222 var WorkspaceChange = /** @class */ (function () {
15223     function WorkspaceChange(workspaceEdit) {
15224         var _this = this;
15225         this._textEditChanges = Object.create(null);
15226         if (workspaceEdit) {
15227             this._workspaceEdit = workspaceEdit;
15228             if (workspaceEdit.documentChanges) {
15229                 workspaceEdit.documentChanges.forEach(function (change) {
15230                     if (TextDocumentEdit.is(change)) {
15231                         var textEditChange = new TextEditChangeImpl(change.edits);
15232                         _this._textEditChanges[change.textDocument.uri] = textEditChange;
15233                     }
15234                 });
15235             }
15236             else if (workspaceEdit.changes) {
15237                 Object.keys(workspaceEdit.changes).forEach(function (key) {
15238                     var textEditChange = new TextEditChangeImpl(workspaceEdit.changes[key]);
15239                     _this._textEditChanges[key] = textEditChange;
15240                 });
15241             }
15242         }
15243     }
15244     Object.defineProperty(WorkspaceChange.prototype, "edit", {
15245         /**
15246          * Returns the underlying [WorkspaceEdit](#WorkspaceEdit) literal
15247          * use to be returned from a workspace edit operation like rename.
15248          */
15249         get: function () {
15250             return this._workspaceEdit;
15251         },
15252         enumerable: true,
15253         configurable: true
15254     });
15255     WorkspaceChange.prototype.getTextEditChange = function (key) {
15256         if (VersionedTextDocumentIdentifier.is(key)) {
15257             if (!this._workspaceEdit) {
15258                 this._workspaceEdit = {
15259                     documentChanges: []
15260                 };
15261             }
15262             if (!this._workspaceEdit.documentChanges) {
15263                 throw new Error('Workspace edit is not configured for document changes.');
15264             }
15265             var textDocument = key;
15266             var result = this._textEditChanges[textDocument.uri];
15267             if (!result) {
15268                 var edits = [];
15269                 var textDocumentEdit = {
15270                     textDocument: textDocument,
15271                     edits: edits
15272                 };
15273                 this._workspaceEdit.documentChanges.push(textDocumentEdit);
15274                 result = new TextEditChangeImpl(edits);
15275                 this._textEditChanges[textDocument.uri] = result;
15276             }
15277             return result;
15278         }
15279         else {
15280             if (!this._workspaceEdit) {
15281                 this._workspaceEdit = {
15282                     changes: Object.create(null)
15283                 };
15284             }
15285             if (!this._workspaceEdit.changes) {
15286                 throw new Error('Workspace edit is not configured for normal text edit changes.');
15287             }
15288             var result = this._textEditChanges[key];
15289             if (!result) {
15290                 var edits = [];
15291                 this._workspaceEdit.changes[key] = edits;
15292                 result = new TextEditChangeImpl(edits);
15293                 this._textEditChanges[key] = result;
15294             }
15295             return result;
15296         }
15297     };
15298     WorkspaceChange.prototype.createFile = function (uri, options) {
15299         this.checkDocumentChanges();
15300         this._workspaceEdit.documentChanges.push(CreateFile.create(uri, options));
15301     };
15302     WorkspaceChange.prototype.renameFile = function (oldUri, newUri, options) {
15303         this.checkDocumentChanges();
15304         this._workspaceEdit.documentChanges.push(RenameFile.create(oldUri, newUri, options));
15305     };
15306     WorkspaceChange.prototype.deleteFile = function (uri, options) {
15307         this.checkDocumentChanges();
15308         this._workspaceEdit.documentChanges.push(DeleteFile.create(uri, options));
15309     };
15310     WorkspaceChange.prototype.checkDocumentChanges = function () {
15311         if (!this._workspaceEdit || !this._workspaceEdit.documentChanges) {
15312             throw new Error('Workspace edit is not configured for document changes.');
15313         }
15314     };
15315     return WorkspaceChange;
15316 }());
15317
15318 /**
15319  * The TextDocumentIdentifier namespace provides helper functions to work with
15320  * [TextDocumentIdentifier](#TextDocumentIdentifier) literals.
15321  */
15322 var TextDocumentIdentifier;
15323 (function (TextDocumentIdentifier) {
15324     /**
15325      * Creates a new TextDocumentIdentifier literal.
15326      * @param uri The document's uri.
15327      */
15328     function create(uri) {
15329         return { uri: uri };
15330     }
15331     TextDocumentIdentifier.create = create;
15332     /**
15333      * Checks whether the given literal conforms to the [TextDocumentIdentifier](#TextDocumentIdentifier) interface.
15334      */
15335     function is(value) {
15336         var candidate = value;
15337         return Is.defined(candidate) && Is.string(candidate.uri);
15338     }
15339     TextDocumentIdentifier.is = is;
15340 })(TextDocumentIdentifier || (TextDocumentIdentifier = {}));
15341 /**
15342  * The VersionedTextDocumentIdentifier namespace provides helper functions to work with
15343  * [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) literals.
15344  */
15345 var VersionedTextDocumentIdentifier;
15346 (function (VersionedTextDocumentIdentifier) {
15347     /**
15348      * Creates a new VersionedTextDocumentIdentifier literal.
15349      * @param uri The document's uri.
15350      * @param uri The document's text.
15351      */
15352     function create(uri, version) {
15353         return { uri: uri, version: version };
15354     }
15355     VersionedTextDocumentIdentifier.create = create;
15356     /**
15357      * Checks whether the given literal conforms to the [VersionedTextDocumentIdentifier](#VersionedTextDocumentIdentifier) interface.
15358      */
15359     function is(value) {
15360         var candidate = value;
15361         return Is.defined(candidate) && Is.string(candidate.uri) && (candidate.version === null || Is.number(candidate.version));
15362     }
15363     VersionedTextDocumentIdentifier.is = is;
15364 })(VersionedTextDocumentIdentifier || (VersionedTextDocumentIdentifier = {}));
15365 /**
15366  * The TextDocumentItem namespace provides helper functions to work with
15367  * [TextDocumentItem](#TextDocumentItem) literals.
15368  */
15369 var TextDocumentItem;
15370 (function (TextDocumentItem) {
15371     /**
15372      * Creates a new TextDocumentItem literal.
15373      * @param uri The document's uri.
15374      * @param languageId The document's language identifier.
15375      * @param version The document's version number.
15376      * @param text The document's text.
15377      */
15378     function create(uri, languageId, version, text) {
15379         return { uri: uri, languageId: languageId, version: version, text: text };
15380     }
15381     TextDocumentItem.create = create;
15382     /**
15383      * Checks whether the given literal conforms to the [TextDocumentItem](#TextDocumentItem) interface.
15384      */
15385     function is(value) {
15386         var candidate = value;
15387         return Is.defined(candidate) && Is.string(candidate.uri) && Is.string(candidate.languageId) && Is.number(candidate.version) && Is.string(candidate.text);
15388     }
15389     TextDocumentItem.is = is;
15390 })(TextDocumentItem || (TextDocumentItem = {}));
15391 /**
15392  * Describes the content type that a client supports in various
15393  * result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
15394  *
15395  * Please note that `MarkupKinds` must not start with a `$`. This kinds
15396  * are reserved for internal usage.
15397  */
15398 var MarkupKind;
15399 (function (MarkupKind) {
15400     /**
15401      * Plain text is supported as a content format
15402      */
15403     MarkupKind.PlainText = 'plaintext';
15404     /**
15405      * Markdown is supported as a content format
15406      */
15407     MarkupKind.Markdown = 'markdown';
15408 })(MarkupKind || (MarkupKind = {}));
15409 (function (MarkupKind) {
15410     /**
15411      * Checks whether the given value is a value of the [MarkupKind](#MarkupKind) type.
15412      */
15413     function is(value) {
15414         var candidate = value;
15415         return candidate === MarkupKind.PlainText || candidate === MarkupKind.Markdown;
15416     }
15417     MarkupKind.is = is;
15418 })(MarkupKind || (MarkupKind = {}));
15419 var MarkupContent;
15420 (function (MarkupContent) {
15421     /**
15422      * Checks whether the given value conforms to the [MarkupContent](#MarkupContent) interface.
15423      */
15424     function is(value) {
15425         var candidate = value;
15426         return Is.objectLiteral(value) && MarkupKind.is(candidate.kind) && Is.string(candidate.value);
15427     }
15428     MarkupContent.is = is;
15429 })(MarkupContent || (MarkupContent = {}));
15430 /**
15431  * The kind of a completion entry.
15432  */
15433 var CompletionItemKind;
15434 (function (CompletionItemKind) {
15435     CompletionItemKind.Text = 1;
15436     CompletionItemKind.Method = 2;
15437     CompletionItemKind.Function = 3;
15438     CompletionItemKind.Constructor = 4;
15439     CompletionItemKind.Field = 5;
15440     CompletionItemKind.Variable = 6;
15441     CompletionItemKind.Class = 7;
15442     CompletionItemKind.Interface = 8;
15443     CompletionItemKind.Module = 9;
15444     CompletionItemKind.Property = 10;
15445     CompletionItemKind.Unit = 11;
15446     CompletionItemKind.Value = 12;
15447     CompletionItemKind.Enum = 13;
15448     CompletionItemKind.Keyword = 14;
15449     CompletionItemKind.Snippet = 15;
15450     CompletionItemKind.Color = 16;
15451     CompletionItemKind.File = 17;
15452     CompletionItemKind.Reference = 18;
15453     CompletionItemKind.Folder = 19;
15454     CompletionItemKind.EnumMember = 20;
15455     CompletionItemKind.Constant = 21;
15456     CompletionItemKind.Struct = 22;
15457     CompletionItemKind.Event = 23;
15458     CompletionItemKind.Operator = 24;
15459     CompletionItemKind.TypeParameter = 25;
15460 })(CompletionItemKind || (CompletionItemKind = {}));
15461 /**
15462  * Defines whether the insert text in a completion item should be interpreted as
15463  * plain text or a snippet.
15464  */
15465 var InsertTextFormat;
15466 (function (InsertTextFormat) {
15467     /**
15468      * The primary text to be inserted is treated as a plain string.
15469      */
15470     InsertTextFormat.PlainText = 1;
15471     /**
15472      * The primary text to be inserted is treated as a snippet.
15473      *
15474      * A snippet can define tab stops and placeholders with `$1`, `$2`
15475      * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
15476      * the end of the snippet. Placeholders with equal identifiers are linked,
15477      * that is typing in one will update others too.
15478      *
15479      * See also: https://github.com/Microsoft/vscode/blob/master/src/vs/editor/contrib/snippet/common/snippet.md
15480      */
15481     InsertTextFormat.Snippet = 2;
15482 })(InsertTextFormat || (InsertTextFormat = {}));
15483 /**
15484  * The CompletionItem namespace provides functions to deal with
15485  * completion items.
15486  */
15487 var CompletionItem;
15488 (function (CompletionItem) {
15489     /**
15490      * Create a completion item and seed it with a label.
15491      * @param label The completion item's label
15492      */
15493     function create(label) {
15494         return { label: label };
15495     }
15496     CompletionItem.create = create;
15497 })(CompletionItem || (CompletionItem = {}));
15498 /**
15499  * The CompletionList namespace provides functions to deal with
15500  * completion lists.
15501  */
15502 var CompletionList;
15503 (function (CompletionList) {
15504     /**
15505      * Creates a new completion list.
15506      *
15507      * @param items The completion items.
15508      * @param isIncomplete The list is not complete.
15509      */
15510     function create(items, isIncomplete) {
15511         return { items: items ? items : [], isIncomplete: !!isIncomplete };
15512     }
15513     CompletionList.create = create;
15514 })(CompletionList || (CompletionList = {}));
15515 var MarkedString;
15516 (function (MarkedString) {
15517     /**
15518      * Creates a marked string from plain text.
15519      *
15520      * @param plainText The plain text.
15521      */
15522     function fromPlainText(plainText) {
15523         return plainText.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
15524     }
15525     MarkedString.fromPlainText = fromPlainText;
15526     /**
15527      * Checks whether the given value conforms to the [MarkedString](#MarkedString) type.
15528      */
15529     function is(value) {
15530         var candidate = value;
15531         return Is.string(candidate) || (Is.objectLiteral(candidate) && Is.string(candidate.language) && Is.string(candidate.value));
15532     }
15533     MarkedString.is = is;
15534 })(MarkedString || (MarkedString = {}));
15535 var Hover;
15536 (function (Hover) {
15537     /**
15538      * Checks whether the given value conforms to the [Hover](#Hover) interface.
15539      */
15540     function is(value) {
15541         var candidate = value;
15542         return !!candidate && Is.objectLiteral(candidate) && (MarkupContent.is(candidate.contents) ||
15543             MarkedString.is(candidate.contents) ||
15544             Is.typedArray(candidate.contents, MarkedString.is)) && (value.range === void 0 || Range.is(value.range));
15545     }
15546     Hover.is = is;
15547 })(Hover || (Hover = {}));
15548 /**
15549  * The ParameterInformation namespace provides helper functions to work with
15550  * [ParameterInformation](#ParameterInformation) literals.
15551  */
15552 var ParameterInformation;
15553 (function (ParameterInformation) {
15554     /**
15555      * Creates a new parameter information literal.
15556      *
15557      * @param label A label string.
15558      * @param documentation A doc string.
15559      */
15560     function create(label, documentation) {
15561         return documentation ? { label: label, documentation: documentation } : { label: label };
15562     }
15563     ParameterInformation.create = create;
15564     ;
15565 })(ParameterInformation || (ParameterInformation = {}));
15566 /**
15567  * The SignatureInformation namespace provides helper functions to work with
15568  * [SignatureInformation](#SignatureInformation) literals.
15569  */
15570 var SignatureInformation;
15571 (function (SignatureInformation) {
15572     function create(label, documentation) {
15573         var parameters = [];
15574         for (var _i = 2; _i < arguments.length; _i++) {
15575             parameters[_i - 2] = arguments[_i];
15576         }
15577         var result = { label: label };
15578         if (Is.defined(documentation)) {
15579             result.documentation = documentation;
15580         }
15581         if (Is.defined(parameters)) {
15582             result.parameters = parameters;
15583         }
15584         else {
15585             result.parameters = [];
15586         }
15587         return result;
15588     }
15589     SignatureInformation.create = create;
15590 })(SignatureInformation || (SignatureInformation = {}));
15591 /**
15592  * A document highlight kind.
15593  */
15594 var DocumentHighlightKind;
15595 (function (DocumentHighlightKind) {
15596     /**
15597      * A textual occurrence.
15598      */
15599     DocumentHighlightKind.Text = 1;
15600     /**
15601      * Read-access of a symbol, like reading a variable.
15602      */
15603     DocumentHighlightKind.Read = 2;
15604     /**
15605      * Write-access of a symbol, like writing to a variable.
15606      */
15607     DocumentHighlightKind.Write = 3;
15608 })(DocumentHighlightKind || (DocumentHighlightKind = {}));
15609 /**
15610  * DocumentHighlight namespace to provide helper functions to work with
15611  * [DocumentHighlight](#DocumentHighlight) literals.
15612  */
15613 var DocumentHighlight;
15614 (function (DocumentHighlight) {
15615     /**
15616      * Create a DocumentHighlight object.
15617      * @param range The range the highlight applies to.
15618      */
15619     function create(range, kind) {
15620         var result = { range: range };
15621         if (Is.number(kind)) {
15622             result.kind = kind;
15623         }
15624         return result;
15625     }
15626     DocumentHighlight.create = create;
15627 })(DocumentHighlight || (DocumentHighlight = {}));
15628 /**
15629  * A symbol kind.
15630  */
15631 var SymbolKind;
15632 (function (SymbolKind) {
15633     SymbolKind.File = 1;
15634     SymbolKind.Module = 2;
15635     SymbolKind.Namespace = 3;
15636     SymbolKind.Package = 4;
15637     SymbolKind.Class = 5;
15638     SymbolKind.Method = 6;
15639     SymbolKind.Property = 7;
15640     SymbolKind.Field = 8;
15641     SymbolKind.Constructor = 9;
15642     SymbolKind.Enum = 10;
15643     SymbolKind.Interface = 11;
15644     SymbolKind.Function = 12;
15645     SymbolKind.Variable = 13;
15646     SymbolKind.Constant = 14;
15647     SymbolKind.String = 15;
15648     SymbolKind.Number = 16;
15649     SymbolKind.Boolean = 17;
15650     SymbolKind.Array = 18;
15651     SymbolKind.Object = 19;
15652     SymbolKind.Key = 20;
15653     SymbolKind.Null = 21;
15654     SymbolKind.EnumMember = 22;
15655     SymbolKind.Struct = 23;
15656     SymbolKind.Event = 24;
15657     SymbolKind.Operator = 25;
15658     SymbolKind.TypeParameter = 26;
15659 })(SymbolKind || (SymbolKind = {}));
15660 var SymbolInformation;
15661 (function (SymbolInformation) {
15662     /**
15663      * Creates a new symbol information literal.
15664      *
15665      * @param name The name of the symbol.
15666      * @param kind The kind of the symbol.
15667      * @param range The range of the location of the symbol.
15668      * @param uri The resource of the location of symbol, defaults to the current document.
15669      * @param containerName The name of the symbol containing the symbol.
15670      */
15671     function create(name, kind, range, uri, containerName) {
15672         var result = {
15673             name: name,
15674             kind: kind,
15675             location: { uri: uri, range: range }
15676         };
15677         if (containerName) {
15678             result.containerName = containerName;
15679         }
15680         return result;
15681     }
15682     SymbolInformation.create = create;
15683 })(SymbolInformation || (SymbolInformation = {}));
15684 /**
15685  * Represents programming constructs like variables, classes, interfaces etc.
15686  * that appear in a document. Document symbols can be hierarchical and they
15687  * have two ranges: one that encloses its definition and one that points to
15688  * its most interesting range, e.g. the range of an identifier.
15689  */
15690 var DocumentSymbol = /** @class */ (function () {
15691     function DocumentSymbol() {
15692     }
15693     return DocumentSymbol;
15694 }());
15695
15696 (function (DocumentSymbol) {
15697     /**
15698      * Creates a new symbol information literal.
15699      *
15700      * @param name The name of the symbol.
15701      * @param detail The detail of the symbol.
15702      * @param kind The kind of the symbol.
15703      * @param range The range of the symbol.
15704      * @param selectionRange The selectionRange of the symbol.
15705      * @param children Children of the symbol.
15706      */
15707     function create(name, detail, kind, range, selectionRange, children) {
15708         var result = {
15709             name: name,
15710             detail: detail,
15711             kind: kind,
15712             range: range,
15713             selectionRange: selectionRange
15714         };
15715         if (children !== void 0) {
15716             result.children = children;
15717         }
15718         return result;
15719     }
15720     DocumentSymbol.create = create;
15721     /**
15722      * Checks whether the given literal conforms to the [DocumentSymbol](#DocumentSymbol) interface.
15723      */
15724     function is(value) {
15725         var candidate = value;
15726         return candidate &&
15727             Is.string(candidate.name) && Is.number(candidate.kind) &&
15728             Range.is(candidate.range) && Range.is(candidate.selectionRange) &&
15729             (candidate.detail === void 0 || Is.string(candidate.detail)) &&
15730             (candidate.deprecated === void 0 || Is.boolean(candidate.deprecated)) &&
15731             (candidate.children === void 0 || Array.isArray(candidate.children));
15732     }
15733     DocumentSymbol.is = is;
15734 })(DocumentSymbol || (DocumentSymbol = {}));
15735 /**
15736  * A set of predefined code action kinds
15737  */
15738 var CodeActionKind;
15739 (function (CodeActionKind) {
15740     /**
15741      * Base kind for quickfix actions: 'quickfix'
15742      */
15743     CodeActionKind.QuickFix = 'quickfix';
15744     /**
15745      * Base kind for refactoring actions: 'refactor'
15746      */
15747     CodeActionKind.Refactor = 'refactor';
15748     /**
15749      * Base kind for refactoring extraction actions: 'refactor.extract'
15750      *
15751      * Example extract actions:
15752      *
15753      * - Extract method
15754      * - Extract function
15755      * - Extract variable
15756      * - Extract interface from class
15757      * - ...
15758      */
15759     CodeActionKind.RefactorExtract = 'refactor.extract';
15760     /**
15761      * Base kind for refactoring inline actions: 'refactor.inline'
15762      *
15763      * Example inline actions:
15764      *
15765      * - Inline function
15766      * - Inline variable
15767      * - Inline constant
15768      * - ...
15769      */
15770     CodeActionKind.RefactorInline = 'refactor.inline';
15771     /**
15772      * Base kind for refactoring rewrite actions: 'refactor.rewrite'
15773      *
15774      * Example rewrite actions:
15775      *
15776      * - Convert JavaScript function to class
15777      * - Add or remove parameter
15778      * - Encapsulate field
15779      * - Make method static
15780      * - Move method to base class
15781      * - ...
15782      */
15783     CodeActionKind.RefactorRewrite = 'refactor.rewrite';
15784     /**
15785      * Base kind for source actions: `source`
15786      *
15787      * Source code actions apply to the entire file.
15788      */
15789     CodeActionKind.Source = 'source';
15790     /**
15791      * Base kind for an organize imports source action: `source.organizeImports`
15792      */
15793     CodeActionKind.SourceOrganizeImports = 'source.organizeImports';
15794 })(CodeActionKind || (CodeActionKind = {}));
15795 /**
15796  * The CodeActionContext namespace provides helper functions to work with
15797  * [CodeActionContext](#CodeActionContext) literals.
15798  */
15799 var CodeActionContext;
15800 (function (CodeActionContext) {
15801     /**
15802      * Creates a new CodeActionContext literal.
15803      */
15804     function create(diagnostics, only) {
15805         var result = { diagnostics: diagnostics };
15806         if (only !== void 0 && only !== null) {
15807             result.only = only;
15808         }
15809         return result;
15810     }
15811     CodeActionContext.create = create;
15812     /**
15813      * Checks whether the given literal conforms to the [CodeActionContext](#CodeActionContext) interface.
15814      */
15815     function is(value) {
15816         var candidate = value;
15817         return Is.defined(candidate) && Is.typedArray(candidate.diagnostics, Diagnostic.is) && (candidate.only === void 0 || Is.typedArray(candidate.only, Is.string));
15818     }
15819     CodeActionContext.is = is;
15820 })(CodeActionContext || (CodeActionContext = {}));
15821 var CodeAction;
15822 (function (CodeAction) {
15823     function create(title, commandOrEdit, kind) {
15824         var result = { title: title };
15825         if (Command.is(commandOrEdit)) {
15826             result.command = commandOrEdit;
15827         }
15828         else {
15829             result.edit = commandOrEdit;
15830         }
15831         if (kind !== void null) {
15832             result.kind = kind;
15833         }
15834         return result;
15835     }
15836     CodeAction.create = create;
15837     function is(value) {
15838         var candidate = value;
15839         return candidate && Is.string(candidate.title) &&
15840             (candidate.diagnostics === void 0 || Is.typedArray(candidate.diagnostics, Diagnostic.is)) &&
15841             (candidate.kind === void 0 || Is.string(candidate.kind)) &&
15842             (candidate.edit !== void 0 || candidate.command !== void 0) &&
15843             (candidate.command === void 0 || Command.is(candidate.command)) &&
15844             (candidate.edit === void 0 || WorkspaceEdit.is(candidate.edit));
15845     }
15846     CodeAction.is = is;
15847 })(CodeAction || (CodeAction = {}));
15848 /**
15849  * The CodeLens namespace provides helper functions to work with
15850  * [CodeLens](#CodeLens) literals.
15851  */
15852 var CodeLens;
15853 (function (CodeLens) {
15854     /**
15855      * Creates a new CodeLens literal.
15856      */
15857     function create(range, data) {
15858         var result = { range: range };
15859         if (Is.defined(data))
15860             result.data = data;
15861         return result;
15862     }
15863     CodeLens.create = create;
15864     /**
15865      * Checks whether the given literal conforms to the [CodeLens](#CodeLens) interface.
15866      */
15867     function is(value) {
15868         var candidate = value;
15869         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.command) || Command.is(candidate.command));
15870     }
15871     CodeLens.is = is;
15872 })(CodeLens || (CodeLens = {}));
15873 /**
15874  * The FormattingOptions namespace provides helper functions to work with
15875  * [FormattingOptions](#FormattingOptions) literals.
15876  */
15877 var FormattingOptions;
15878 (function (FormattingOptions) {
15879     /**
15880      * Creates a new FormattingOptions literal.
15881      */
15882     function create(tabSize, insertSpaces) {
15883         return { tabSize: tabSize, insertSpaces: insertSpaces };
15884     }
15885     FormattingOptions.create = create;
15886     /**
15887      * Checks whether the given literal conforms to the [FormattingOptions](#FormattingOptions) interface.
15888      */
15889     function is(value) {
15890         var candidate = value;
15891         return Is.defined(candidate) && Is.number(candidate.tabSize) && Is.boolean(candidate.insertSpaces);
15892     }
15893     FormattingOptions.is = is;
15894 })(FormattingOptions || (FormattingOptions = {}));
15895 /**
15896  * A document link is a range in a text document that links to an internal or external resource, like another
15897  * text document or a web site.
15898  */
15899 var DocumentLink = /** @class */ (function () {
15900     function DocumentLink() {
15901     }
15902     return DocumentLink;
15903 }());
15904
15905 /**
15906  * The DocumentLink namespace provides helper functions to work with
15907  * [DocumentLink](#DocumentLink) literals.
15908  */
15909 (function (DocumentLink) {
15910     /**
15911      * Creates a new DocumentLink literal.
15912      */
15913     function create(range, target, data) {
15914         return { range: range, target: target, data: data };
15915     }
15916     DocumentLink.create = create;
15917     /**
15918      * Checks whether the given literal conforms to the [DocumentLink](#DocumentLink) interface.
15919      */
15920     function is(value) {
15921         var candidate = value;
15922         return Is.defined(candidate) && Range.is(candidate.range) && (Is.undefined(candidate.target) || Is.string(candidate.target));
15923     }
15924     DocumentLink.is = is;
15925 })(DocumentLink || (DocumentLink = {}));
15926 /**
15927  * The SelectionRange namespace provides helper function to work with
15928  * SelectionRange literals.
15929  */
15930 var SelectionRange;
15931 (function (SelectionRange) {
15932     /**
15933      * Creates a new SelectionRange
15934      * @param range the range.
15935      * @param parent an optional parent.
15936      */
15937     function create(range, parent) {
15938         return { range: range, parent: parent };
15939     }
15940     SelectionRange.create = create;
15941     function is(value) {
15942         var candidate = value;
15943         return candidate !== undefined && Range.is(candidate.range) && (candidate.parent === undefined || SelectionRange.is(candidate.parent));
15944     }
15945     SelectionRange.is = is;
15946 })(SelectionRange || (SelectionRange = {}));
15947 var EOL = ['\n', '\r\n', '\r'];
15948 var TextDocument;
15949 (function (TextDocument) {
15950     /**
15951      * Creates a new ITextDocument literal from the given uri and content.
15952      * @param uri The document's uri.
15953      * @param languageId  The document's language Id.
15954      * @param content The document's content.
15955      */
15956     function create(uri, languageId, version, content) {
15957         return new FullTextDocument(uri, languageId, version, content);
15958     }
15959     TextDocument.create = create;
15960     /**
15961      * Checks whether the given literal conforms to the [ITextDocument](#ITextDocument) interface.
15962      */
15963     function is(value) {
15964         var candidate = value;
15965         return Is.defined(candidate) && Is.string(candidate.uri) && (Is.undefined(candidate.languageId) || Is.string(candidate.languageId)) && Is.number(candidate.lineCount)
15966             && Is.func(candidate.getText) && Is.func(candidate.positionAt) && Is.func(candidate.offsetAt) ? true : false;
15967     }
15968     TextDocument.is = is;
15969     function applyEdits(document, edits) {
15970         var text = document.getText();
15971         var sortedEdits = mergeSort(edits, function (a, b) {
15972             var diff = a.range.start.line - b.range.start.line;
15973             if (diff === 0) {
15974                 return a.range.start.character - b.range.start.character;
15975             }
15976             return diff;
15977         });
15978         var lastModifiedOffset = text.length;
15979         for (var i = sortedEdits.length - 1; i >= 0; i--) {
15980             var e = sortedEdits[i];
15981             var startOffset = document.offsetAt(e.range.start);
15982             var endOffset = document.offsetAt(e.range.end);
15983             if (endOffset <= lastModifiedOffset) {
15984                 text = text.substring(0, startOffset) + e.newText + text.substring(endOffset, text.length);
15985             }
15986             else {
15987                 throw new Error('Overlapping edit');
15988             }
15989             lastModifiedOffset = startOffset;
15990         }
15991         return text;
15992     }
15993     TextDocument.applyEdits = applyEdits;
15994     function mergeSort(data, compare) {
15995         if (data.length <= 1) {
15996             // sorted
15997             return data;
15998         }
15999         var p = (data.length / 2) | 0;
16000         var left = data.slice(0, p);
16001         var right = data.slice(p);
16002         mergeSort(left, compare);
16003         mergeSort(right, compare);
16004         var leftIdx = 0;
16005         var rightIdx = 0;
16006         var i = 0;
16007         while (leftIdx < left.length && rightIdx < right.length) {
16008             var ret = compare(left[leftIdx], right[rightIdx]);
16009             if (ret <= 0) {
16010                 // smaller_equal -> take left to preserve order
16011                 data[i++] = left[leftIdx++];
16012             }
16013             else {
16014                 // greater -> take right
16015                 data[i++] = right[rightIdx++];
16016             }
16017         }
16018         while (leftIdx < left.length) {
16019             data[i++] = left[leftIdx++];
16020         }
16021         while (rightIdx < right.length) {
16022             data[i++] = right[rightIdx++];
16023         }
16024         return data;
16025     }
16026 })(TextDocument || (TextDocument = {}));
16027 /**
16028  * Represents reasons why a text document is saved.
16029  */
16030 var TextDocumentSaveReason;
16031 (function (TextDocumentSaveReason) {
16032     /**
16033      * Manually triggered, e.g. by the user pressing save, by starting debugging,
16034      * or by an API call.
16035      */
16036     TextDocumentSaveReason.Manual = 1;
16037     /**
16038      * Automatic after a delay.
16039      */
16040     TextDocumentSaveReason.AfterDelay = 2;
16041     /**
16042      * When the editor lost focus.
16043      */
16044     TextDocumentSaveReason.FocusOut = 3;
16045 })(TextDocumentSaveReason || (TextDocumentSaveReason = {}));
16046 var FullTextDocument = /** @class */ (function () {
16047     function FullTextDocument(uri, languageId, version, content) {
16048         this._uri = uri;
16049         this._languageId = languageId;
16050         this._version = version;
16051         this._content = content;
16052         this._lineOffsets = null;
16053     }
16054     Object.defineProperty(FullTextDocument.prototype, "uri", {
16055         get: function () {
16056             return this._uri;
16057         },
16058         enumerable: true,
16059         configurable: true
16060     });
16061     Object.defineProperty(FullTextDocument.prototype, "languageId", {
16062         get: function () {
16063             return this._languageId;
16064         },
16065         enumerable: true,
16066         configurable: true
16067     });
16068     Object.defineProperty(FullTextDocument.prototype, "version", {
16069         get: function () {
16070             return this._version;
16071         },
16072         enumerable: true,
16073         configurable: true
16074     });
16075     FullTextDocument.prototype.getText = function (range) {
16076         if (range) {
16077             var start = this.offsetAt(range.start);
16078             var end = this.offsetAt(range.end);
16079             return this._content.substring(start, end);
16080         }
16081         return this._content;
16082     };
16083     FullTextDocument.prototype.update = function (event, version) {
16084         this._content = event.text;
16085         this._version = version;
16086         this._lineOffsets = null;
16087     };
16088     FullTextDocument.prototype.getLineOffsets = function () {
16089         if (this._lineOffsets === null) {
16090             var lineOffsets = [];
16091             var text = this._content;
16092             var isLineStart = true;
16093             for (var i = 0; i < text.length; i++) {
16094                 if (isLineStart) {
16095                     lineOffsets.push(i);
16096                     isLineStart = false;
16097                 }
16098                 var ch = text.charAt(i);
16099                 isLineStart = (ch === '\r' || ch === '\n');
16100                 if (ch === '\r' && i + 1 < text.length && text.charAt(i + 1) === '\n') {
16101                     i++;
16102                 }
16103             }
16104             if (isLineStart && text.length > 0) {
16105                 lineOffsets.push(text.length);
16106             }
16107             this._lineOffsets = lineOffsets;
16108         }
16109         return this._lineOffsets;
16110     };
16111     FullTextDocument.prototype.positionAt = function (offset) {
16112         offset = Math.max(Math.min(offset, this._content.length), 0);
16113         var lineOffsets = this.getLineOffsets();
16114         var low = 0, high = lineOffsets.length;
16115         if (high === 0) {
16116             return Position.create(0, offset);
16117         }
16118         while (low < high) {
16119             var mid = Math.floor((low + high) / 2);
16120             if (lineOffsets[mid] > offset) {
16121                 high = mid;
16122             }
16123             else {
16124                 low = mid + 1;
16125             }
16126         }
16127         // low is the least x for which the line offset is larger than the current offset
16128         // or array.length if no line offset is larger than the current offset
16129         var line = low - 1;
16130         return Position.create(line, offset - lineOffsets[line]);
16131     };
16132     FullTextDocument.prototype.offsetAt = function (position) {
16133         var lineOffsets = this.getLineOffsets();
16134         if (position.line >= lineOffsets.length) {
16135             return this._content.length;
16136         }
16137         else if (position.line < 0) {
16138             return 0;
16139         }
16140         var lineOffset = lineOffsets[position.line];
16141         var nextLineOffset = (position.line + 1 < lineOffsets.length) ? lineOffsets[position.line + 1] : this._content.length;
16142         return Math.max(Math.min(lineOffset + position.character, nextLineOffset), lineOffset);
16143     };
16144     Object.defineProperty(FullTextDocument.prototype, "lineCount", {
16145         get: function () {
16146             return this.getLineOffsets().length;
16147         },
16148         enumerable: true,
16149         configurable: true
16150     });
16151     return FullTextDocument;
16152 }());
16153 var Is;
16154 (function (Is) {
16155     var toString = Object.prototype.toString;
16156     function defined(value) {
16157         return typeof value !== 'undefined';
16158     }
16159     Is.defined = defined;
16160     function undefined(value) {
16161         return typeof value === 'undefined';
16162     }
16163     Is.undefined = undefined;
16164     function boolean(value) {
16165         return value === true || value === false;
16166     }
16167     Is.boolean = boolean;
16168     function string(value) {
16169         return toString.call(value) === '[object String]';
16170     }
16171     Is.string = string;
16172     function number(value) {
16173         return toString.call(value) === '[object Number]';
16174     }
16175     Is.number = number;
16176     function func(value) {
16177         return toString.call(value) === '[object Function]';
16178     }
16179     Is.func = func;
16180     function objectLiteral(value) {
16181         // Strictly speaking class instances pass this check as well. Since the LSP
16182         // doesn't use classes we ignore this for now. If we do we need to add something
16183         // like this: `Object.getPrototypeOf(Object.getPrototypeOf(x)) === null`
16184         return value !== null && typeof value === 'object';
16185     }
16186     Is.objectLiteral = objectLiteral;
16187     function typedArray(value, check) {
16188         return Array.isArray(value) && value.every(check);
16189     }
16190     Is.typedArray = typedArray;
16191 })(Is || (Is = {}));
16192
16193
16194 /***/ }),
16195 /* 81 */
16196 /***/ (function(module, __webpack_exports__, __webpack_require__) {
16197
16198 "use strict";
16199 __webpack_require__.r(__webpack_exports__);
16200 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONCompletion", function() { return JSONCompletion; });
16201 /* harmony import */ var _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82);
16202 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(83);
16203 /* harmony import */ var _utils_json__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(90);
16204 /* harmony import */ var _utils_strings__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(91);
16205 /* harmony import */ var _utils_objects__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(88);
16206 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(80);
16207 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(76);
16208 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(vscode_nls__WEBPACK_IMPORTED_MODULE_6__);
16209 /*---------------------------------------------------------------------------------------------
16210  *  Copyright (c) Microsoft Corporation. All rights reserved.
16211  *  Licensed under the MIT License. See License.txt in the project root for license information.
16212  *--------------------------------------------------------------------------------------------*/
16213
16214
16215
16216
16217
16218
16219
16220 var localize = vscode_nls__WEBPACK_IMPORTED_MODULE_6__["loadMessageBundle"]();
16221 var JSONCompletion = /** @class */ (function () {
16222     function JSONCompletion(schemaService, contributions, promiseConstructor, clientCapabilities) {
16223         if (contributions === void 0) { contributions = []; }
16224         if (promiseConstructor === void 0) { promiseConstructor = Promise; }
16225         if (clientCapabilities === void 0) { clientCapabilities = {}; }
16226         this.schemaService = schemaService;
16227         this.contributions = contributions;
16228         this.promiseConstructor = promiseConstructor;
16229         this.clientCapabilities = clientCapabilities;
16230         this.templateVarIdCounter = 0;
16231     }
16232     JSONCompletion.prototype.doResolve = function (item) {
16233         for (var i = this.contributions.length - 1; i >= 0; i--) {
16234             if (this.contributions[i].resolveCompletion) {
16235                 var resolver = this.contributions[i].resolveCompletion(item);
16236                 if (resolver) {
16237                     return resolver;
16238                 }
16239             }
16240         }
16241         return this.promiseConstructor.resolve(item);
16242     };
16243     JSONCompletion.prototype.doComplete = function (document, position, doc) {
16244         var _this = this;
16245         var result = {
16246             items: [],
16247             isIncomplete: false
16248         };
16249         var offset = document.offsetAt(position);
16250         var node = doc.getNodeFromOffset(offset, true);
16251         if (this.isInComment(document, node ? node.offset : 0, offset)) {
16252             return Promise.resolve(result);
16253         }
16254         var currentWord = this.getCurrentWord(document, offset);
16255         var overwriteRange = null;
16256         if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
16257             overwriteRange = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["Range"].create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
16258         }
16259         else {
16260             var overwriteStart = offset - currentWord.length;
16261             if (overwriteStart > 0 && document.getText()[overwriteStart - 1] === '"') {
16262                 overwriteStart--;
16263             }
16264             overwriteRange = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["Range"].create(document.positionAt(overwriteStart), position);
16265         }
16266         var proposed = {};
16267         var collector = {
16268             add: function (suggestion) {
16269                 var existing = proposed[suggestion.label];
16270                 if (!existing) {
16271                     proposed[suggestion.label] = suggestion;
16272                     if (overwriteRange) {
16273                         suggestion.textEdit = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["TextEdit"].replace(overwriteRange, suggestion.insertText);
16274                     }
16275                     result.items.push(suggestion);
16276                 }
16277                 else if (!existing.documentation) {
16278                     existing.documentation = suggestion.documentation;
16279                 }
16280             },
16281             setAsIncomplete: function () {
16282                 result.isIncomplete = true;
16283             },
16284             error: function (message) {
16285                 console.error(message);
16286             },
16287             log: function (message) {
16288                 console.log(message);
16289             },
16290             getNumberOfProposals: function () {
16291                 return result.items.length;
16292             }
16293         };
16294         return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
16295             var collectionPromises = [];
16296             var addValue = true;
16297             var currentKey = '';
16298             var currentProperty = null;
16299             if (node) {
16300                 if (node.type === 'string') {
16301                     var parent = node.parent;
16302                     if (parent && parent.type === 'property' && parent.keyNode === node) {
16303                         addValue = !parent.valueNode;
16304                         currentProperty = parent;
16305                         currentKey = document.getText().substr(node.offset + 1, node.length - 2);
16306                         if (parent) {
16307                             node = parent.parent;
16308                         }
16309                     }
16310                 }
16311             }
16312             // proposals for properties
16313             if (node && node.type === 'object') {
16314                 // don't suggest keys when the cursor is just before the opening curly brace
16315                 if (node.offset === offset) {
16316                     return result;
16317                 }
16318                 // don't suggest properties that are already present
16319                 var properties = node.properties;
16320                 properties.forEach(function (p) {
16321                     if (!currentProperty || currentProperty !== p) {
16322                         proposed[p.keyNode.value] = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItem"].create('__');
16323                     }
16324                 });
16325                 var separatorAfter_1 = '';
16326                 if (addValue) {
16327                     separatorAfter_1 = _this.evaluateSeparatorAfter(document, document.offsetAt(overwriteRange.end));
16328                 }
16329                 if (schema) {
16330                     // property proposals with schema
16331                     _this.getPropertyCompletions(schema, doc, node, addValue, separatorAfter_1, collector);
16332                 }
16333                 else {
16334                     // property proposals without schema
16335                     _this.getSchemaLessPropertyCompletions(doc, node, currentKey, collector);
16336                 }
16337                 var location_1 = _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodePath"](node);
16338                 _this.contributions.forEach(function (contribution) {
16339                     var collectPromise = contribution.collectPropertyCompletions(document.uri, location_1, currentWord, addValue, separatorAfter_1 === '', collector);
16340                     if (collectPromise) {
16341                         collectionPromises.push(collectPromise);
16342                     }
16343                 });
16344                 if ((!schema && currentWord.length > 0 && document.getText().charAt(offset - currentWord.length - 1) !== '"')) {
16345                     collector.add({
16346                         kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Property,
16347                         label: _this.getLabelForValue(currentWord),
16348                         insertText: _this.getInsertTextForProperty(currentWord, null, false, separatorAfter_1),
16349                         insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet, documentation: '',
16350                     });
16351                     collector.setAsIncomplete();
16352                 }
16353             }
16354             // proposals for values
16355             var types = {};
16356             if (schema) {
16357                 // value proposals with schema
16358                 _this.getValueCompletions(schema, doc, node, offset, document, collector, types);
16359             }
16360             else {
16361                 // value proposals without schema
16362                 _this.getSchemaLessValueCompletions(doc, node, offset, document, collector);
16363             }
16364             if (_this.contributions.length > 0) {
16365                 _this.getContributedValueCompletions(doc, node, offset, document, collector, collectionPromises);
16366             }
16367             return _this.promiseConstructor.all(collectionPromises).then(function () {
16368                 if (collector.getNumberOfProposals() === 0) {
16369                     var offsetForSeparator = offset;
16370                     if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
16371                         offsetForSeparator = node.offset + node.length;
16372                     }
16373                     var separatorAfter = _this.evaluateSeparatorAfter(document, offsetForSeparator);
16374                     _this.addFillerValueCompletions(types, separatorAfter, collector);
16375                 }
16376                 return result;
16377             });
16378         });
16379     };
16380     JSONCompletion.prototype.getPropertyCompletions = function (schema, doc, node, addValue, separatorAfter, collector) {
16381         var _this = this;
16382         var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
16383         matchingSchemas.forEach(function (s) {
16384             if (s.node === node && !s.inverted) {
16385                 var schemaProperties_1 = s.schema.properties;
16386                 if (schemaProperties_1) {
16387                     Object.keys(schemaProperties_1).forEach(function (key) {
16388                         var propertySchema = schemaProperties_1[key];
16389                         if (typeof propertySchema === 'object' && !propertySchema.deprecationMessage && !propertySchema.doNotSuggest) {
16390                             var proposal = {
16391                                 kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Property,
16392                                 label: _this.sanitizeLabel(key),
16393                                 insertText: _this.getInsertTextForProperty(key, propertySchema, addValue, separatorAfter),
16394                                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16395                                 filterText: _this.getFilterTextForValue(key),
16396                                 documentation: _this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '',
16397                             };
16398                             if (Object(_utils_strings__WEBPACK_IMPORTED_MODULE_3__["endsWith"])(proposal.insertText, "$1" + separatorAfter)) {
16399                                 proposal.command = {
16400                                     title: 'Suggest',
16401                                     command: 'editor.action.triggerSuggest'
16402                                 };
16403                             }
16404                             collector.add(proposal);
16405                         }
16406                     });
16407                 }
16408             }
16409         });
16410     };
16411     JSONCompletion.prototype.getSchemaLessPropertyCompletions = function (doc, node, currentKey, collector) {
16412         var _this = this;
16413         var collectCompletionsForSimilarObject = function (obj) {
16414             obj.properties.forEach(function (p) {
16415                 var key = p.keyNode.value;
16416                 collector.add({
16417                     kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Property,
16418                     label: _this.sanitizeLabel(key),
16419                     insertText: _this.getInsertTextForValue(key, ''),
16420                     insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16421                     filterText: _this.getFilterTextForValue(key),
16422                     documentation: ''
16423                 });
16424             });
16425         };
16426         if (node.parent) {
16427             if (node.parent.type === 'property') {
16428                 // if the object is a property value, check the tree for other objects that hang under a property of the same name
16429                 var parentKey_1 = node.parent.keyNode.value;
16430                 doc.visit(function (n) {
16431                     if (n.type === 'property' && n !== node.parent && n.keyNode.value === parentKey_1 && n.valueNode && n.valueNode.type === 'object') {
16432                         collectCompletionsForSimilarObject(n.valueNode);
16433                     }
16434                     return true;
16435                 });
16436             }
16437             else if (node.parent.type === 'array') {
16438                 // if the object is in an array, use all other array elements as similar objects
16439                 node.parent.items.forEach(function (n) {
16440                     if (n.type === 'object' && n !== node) {
16441                         collectCompletionsForSimilarObject(n);
16442                     }
16443                 });
16444             }
16445         }
16446         else if (node.type === 'object') {
16447             collector.add({
16448                 kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Property,
16449                 label: '$schema',
16450                 insertText: this.getInsertTextForProperty('$schema', null, true, ''),
16451                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet, documentation: '',
16452                 filterText: this.getFilterTextForValue("$schema")
16453             });
16454         }
16455     };
16456     JSONCompletion.prototype.getSchemaLessValueCompletions = function (doc, node, offset, document, collector) {
16457         var _this = this;
16458         var offsetForSeparator = offset;
16459         if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
16460             offsetForSeparator = node.offset + node.length;
16461             node = node.parent;
16462         }
16463         if (!node) {
16464             collector.add({
16465                 kind: this.getSuggestionKind('object'),
16466                 label: 'Empty object',
16467                 insertText: this.getInsertTextForValue({}, ''),
16468                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16469                 documentation: ''
16470             });
16471             collector.add({
16472                 kind: this.getSuggestionKind('array'),
16473                 label: 'Empty array',
16474                 insertText: this.getInsertTextForValue([], ''),
16475                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16476                 documentation: ''
16477             });
16478             return;
16479         }
16480         var separatorAfter = this.evaluateSeparatorAfter(document, offsetForSeparator);
16481         var collectSuggestionsForValues = function (value) {
16482             if (!_parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["contains"](value.parent, offset, true)) {
16483                 collector.add({
16484                     kind: _this.getSuggestionKind(value.type),
16485                     label: _this.getLabelTextForMatchingNode(value, document),
16486                     insertText: _this.getInsertTextForMatchingNode(value, document, separatorAfter),
16487                     insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet, documentation: ''
16488                 });
16489             }
16490             if (value.type === 'boolean') {
16491                 _this.addBooleanValueCompletion(!value.value, separatorAfter, collector);
16492             }
16493         };
16494         if (node.type === 'property') {
16495             if (offset > node.colonOffset) {
16496                 var valueNode = node.valueNode;
16497                 if (valueNode && (offset > (valueNode.offset + valueNode.length) || valueNode.type === 'object' || valueNode.type === 'array')) {
16498                     return;
16499                 }
16500                 // suggest values at the same key
16501                 var parentKey_2 = node.keyNode.value;
16502                 doc.visit(function (n) {
16503                     if (n.type === 'property' && n.keyNode.value === parentKey_2 && n.valueNode) {
16504                         collectSuggestionsForValues(n.valueNode);
16505                     }
16506                     return true;
16507                 });
16508                 if (parentKey_2 === '$schema' && node.parent && !node.parent.parent) {
16509                     this.addDollarSchemaCompletions(separatorAfter, collector);
16510                 }
16511             }
16512         }
16513         if (node.type === 'array') {
16514             if (node.parent && node.parent.type === 'property') {
16515                 // suggest items of an array at the same key
16516                 var parentKey_3 = node.parent.keyNode.value;
16517                 doc.visit(function (n) {
16518                     if (n.type === 'property' && n.keyNode.value === parentKey_3 && n.valueNode && n.valueNode.type === 'array') {
16519                         n.valueNode.items.forEach(collectSuggestionsForValues);
16520                     }
16521                     return true;
16522                 });
16523             }
16524             else {
16525                 // suggest items in the same array
16526                 node.items.forEach(collectSuggestionsForValues);
16527             }
16528         }
16529     };
16530     JSONCompletion.prototype.getValueCompletions = function (schema, doc, node, offset, document, collector, types) {
16531         var _this = this;
16532         var offsetForSeparator = offset;
16533         var parentKey = null;
16534         var valueNode = null;
16535         if (node && (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null')) {
16536             offsetForSeparator = node.offset + node.length;
16537             valueNode = node;
16538             node = node.parent;
16539         }
16540         if (!node) {
16541             this.addSchemaValueCompletions(schema.schema, '', collector, types);
16542             return;
16543         }
16544         if ((node.type === 'property') && offset > node.colonOffset) {
16545             var valueNode_1 = node.valueNode;
16546             if (valueNode_1 && offset > (valueNode_1.offset + valueNode_1.length)) {
16547                 return; // we are past the value node
16548             }
16549             parentKey = node.keyNode.value;
16550             node = node.parent;
16551         }
16552         if (node && (parentKey !== null || node.type === 'array')) {
16553             var separatorAfter_2 = this.evaluateSeparatorAfter(document, offsetForSeparator);
16554             var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset, valueNode);
16555             matchingSchemas.forEach(function (s) {
16556                 if (s.node === node && !s.inverted && s.schema) {
16557                     if (node.type === 'array' && s.schema.items) {
16558                         if (Array.isArray(s.schema.items)) {
16559                             var index = _this.findItemAtOffset(node, document, offset);
16560                             if (index < s.schema.items.length) {
16561                                 _this.addSchemaValueCompletions(s.schema.items[index], separatorAfter_2, collector, types);
16562                             }
16563                         }
16564                         else {
16565                             _this.addSchemaValueCompletions(s.schema.items, separatorAfter_2, collector, types);
16566                         }
16567                     }
16568                     if (s.schema.properties) {
16569                         var propertySchema = s.schema.properties[parentKey];
16570                         if (propertySchema) {
16571                             _this.addSchemaValueCompletions(propertySchema, separatorAfter_2, collector, types);
16572                         }
16573                     }
16574                 }
16575             });
16576             if (parentKey === '$schema' && !node.parent) {
16577                 this.addDollarSchemaCompletions(separatorAfter_2, collector);
16578             }
16579             if (types['boolean']) {
16580                 this.addBooleanValueCompletion(true, separatorAfter_2, collector);
16581                 this.addBooleanValueCompletion(false, separatorAfter_2, collector);
16582             }
16583             if (types['null']) {
16584                 this.addNullValueCompletion(separatorAfter_2, collector);
16585             }
16586         }
16587     };
16588     JSONCompletion.prototype.getContributedValueCompletions = function (doc, node, offset, document, collector, collectionPromises) {
16589         if (!node) {
16590             this.contributions.forEach(function (contribution) {
16591                 var collectPromise = contribution.collectDefaultCompletions(document.uri, collector);
16592                 if (collectPromise) {
16593                     collectionPromises.push(collectPromise);
16594                 }
16595             });
16596         }
16597         else {
16598             if (node.type === 'string' || node.type === 'number' || node.type === 'boolean' || node.type === 'null') {
16599                 node = node.parent;
16600             }
16601             if ((node.type === 'property') && offset > node.colonOffset) {
16602                 var parentKey_4 = node.keyNode.value;
16603                 var valueNode = node.valueNode;
16604                 if (!valueNode || offset <= (valueNode.offset + valueNode.length)) {
16605                     var location_2 = _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodePath"](node.parent);
16606                     this.contributions.forEach(function (contribution) {
16607                         var collectPromise = contribution.collectValueCompletions(document.uri, location_2, parentKey_4, collector);
16608                         if (collectPromise) {
16609                             collectionPromises.push(collectPromise);
16610                         }
16611                     });
16612                 }
16613             }
16614         }
16615     };
16616     JSONCompletion.prototype.addSchemaValueCompletions = function (schema, separatorAfter, collector, types) {
16617         var _this = this;
16618         if (typeof schema === 'object') {
16619             this.addEnumValueCompletions(schema, separatorAfter, collector);
16620             this.addDefaultValueCompletions(schema, separatorAfter, collector);
16621             this.collectTypes(schema, types);
16622             if (Array.isArray(schema.allOf)) {
16623                 schema.allOf.forEach(function (s) { return _this.addSchemaValueCompletions(s, separatorAfter, collector, types); });
16624             }
16625             if (Array.isArray(schema.anyOf)) {
16626                 schema.anyOf.forEach(function (s) { return _this.addSchemaValueCompletions(s, separatorAfter, collector, types); });
16627             }
16628             if (Array.isArray(schema.oneOf)) {
16629                 schema.oneOf.forEach(function (s) { return _this.addSchemaValueCompletions(s, separatorAfter, collector, types); });
16630             }
16631         }
16632     };
16633     JSONCompletion.prototype.addDefaultValueCompletions = function (schema, separatorAfter, collector, arrayDepth) {
16634         var _this = this;
16635         if (arrayDepth === void 0) { arrayDepth = 0; }
16636         var hasProposals = false;
16637         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(schema.default)) {
16638             var type = schema.type;
16639             var value = schema.default;
16640             for (var i = arrayDepth; i > 0; i--) {
16641                 value = [value];
16642                 type = 'array';
16643             }
16644             collector.add({
16645                 kind: this.getSuggestionKind(type),
16646                 label: this.getLabelForValue(value),
16647                 insertText: this.getInsertTextForValue(value, separatorAfter),
16648                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16649                 detail: localize('json.suggest.default', 'Default value')
16650             });
16651             hasProposals = true;
16652         }
16653         if (Array.isArray(schema.examples)) {
16654             schema.examples.forEach(function (example) {
16655                 var type = schema.type;
16656                 var value = example;
16657                 for (var i = arrayDepth; i > 0; i--) {
16658                     value = [value];
16659                     type = 'array';
16660                 }
16661                 collector.add({
16662                     kind: _this.getSuggestionKind(type),
16663                     label: _this.getLabelForValue(value),
16664                     insertText: _this.getInsertTextForValue(value, separatorAfter),
16665                     insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet
16666                 });
16667                 hasProposals = true;
16668             });
16669         }
16670         if (Array.isArray(schema.defaultSnippets)) {
16671             schema.defaultSnippets.forEach(function (s) {
16672                 var type = schema.type;
16673                 var value = s.body;
16674                 var label = s.label;
16675                 var insertText;
16676                 var filterText;
16677                 if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(value)) {
16678                     var type_1 = schema.type;
16679                     for (var i = arrayDepth; i > 0; i--) {
16680                         value = [value];
16681                         type_1 = 'array';
16682                     }
16683                     insertText = _this.getInsertTextForSnippetValue(value, separatorAfter);
16684                     filterText = _this.getFilterTextForSnippetValue(value);
16685                     label = label || _this.getLabelForSnippetValue(value);
16686                 }
16687                 else if (typeof s.bodyText === 'string') {
16688                     var prefix = '', suffix = '', indent = '';
16689                     for (var i = arrayDepth; i > 0; i--) {
16690                         prefix = prefix + indent + '[\n';
16691                         suffix = suffix + '\n' + indent + ']';
16692                         indent += '\t';
16693                         type = 'array';
16694                     }
16695                     insertText = prefix + indent + s.bodyText.split('\n').join('\n' + indent) + suffix + separatorAfter;
16696                     label = label || _this.sanitizeLabel(insertText),
16697                         filterText = insertText.replace(/[\n]/g, ''); // remove new lines
16698                 }
16699                 collector.add({
16700                     kind: _this.getSuggestionKind(type),
16701                     label: label,
16702                     documentation: _this.fromMarkup(s.markdownDescription) || s.description,
16703                     insertText: insertText,
16704                     insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16705                     filterText: filterText
16706                 });
16707                 hasProposals = true;
16708             });
16709         }
16710         if (!hasProposals && typeof schema.items === 'object' && !Array.isArray(schema.items)) {
16711             this.addDefaultValueCompletions(schema.items, separatorAfter, collector, arrayDepth + 1);
16712         }
16713     };
16714     JSONCompletion.prototype.addEnumValueCompletions = function (schema, separatorAfter, collector) {
16715         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(schema.const)) {
16716             collector.add({
16717                 kind: this.getSuggestionKind(schema.type),
16718                 label: this.getLabelForValue(schema.const),
16719                 insertText: this.getInsertTextForValue(schema.const, separatorAfter),
16720                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16721                 documentation: this.fromMarkup(schema.markdownDescription) || schema.description
16722             });
16723         }
16724         if (Array.isArray(schema.enum)) {
16725             for (var i = 0, length = schema.enum.length; i < length; i++) {
16726                 var enm = schema.enum[i];
16727                 var documentation = this.fromMarkup(schema.markdownDescription) || schema.description;
16728                 if (schema.markdownEnumDescriptions && i < schema.markdownEnumDescriptions.length && this.doesSupportMarkdown()) {
16729                     documentation = this.fromMarkup(schema.markdownEnumDescriptions[i]);
16730                 }
16731                 else if (schema.enumDescriptions && i < schema.enumDescriptions.length) {
16732                     documentation = schema.enumDescriptions[i];
16733                 }
16734                 collector.add({
16735                     kind: this.getSuggestionKind(schema.type),
16736                     label: this.getLabelForValue(enm),
16737                     insertText: this.getInsertTextForValue(enm, separatorAfter),
16738                     insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16739                     documentation: documentation
16740                 });
16741             }
16742         }
16743     };
16744     JSONCompletion.prototype.collectTypes = function (schema, types) {
16745         if (Array.isArray(schema.enum) || Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(schema.const)) {
16746             return;
16747         }
16748         var type = schema.type;
16749         if (Array.isArray(type)) {
16750             type.forEach(function (t) { return types[t] = true; });
16751         }
16752         else {
16753             types[type] = true;
16754         }
16755     };
16756     JSONCompletion.prototype.addFillerValueCompletions = function (types, separatorAfter, collector) {
16757         if (types['object']) {
16758             collector.add({
16759                 kind: this.getSuggestionKind('object'),
16760                 label: '{}',
16761                 insertText: this.getInsertTextForGuessedValue({}, separatorAfter),
16762                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16763                 detail: localize('defaults.object', 'New object'),
16764                 documentation: ''
16765             });
16766         }
16767         if (types['array']) {
16768             collector.add({
16769                 kind: this.getSuggestionKind('array'),
16770                 label: '[]',
16771                 insertText: this.getInsertTextForGuessedValue([], separatorAfter),
16772                 insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16773                 detail: localize('defaults.array', 'New array'),
16774                 documentation: ''
16775             });
16776         }
16777     };
16778     JSONCompletion.prototype.addBooleanValueCompletion = function (value, separatorAfter, collector) {
16779         collector.add({
16780             kind: this.getSuggestionKind('boolean'),
16781             label: value ? 'true' : 'false',
16782             insertText: this.getInsertTextForValue(value, separatorAfter),
16783             insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16784             documentation: ''
16785         });
16786     };
16787     JSONCompletion.prototype.addNullValueCompletion = function (separatorAfter, collector) {
16788         collector.add({
16789             kind: this.getSuggestionKind('null'),
16790             label: 'null',
16791             insertText: 'null' + separatorAfter,
16792             insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet,
16793             documentation: ''
16794         });
16795     };
16796     JSONCompletion.prototype.addDollarSchemaCompletions = function (separatorAfter, collector) {
16797         var _this = this;
16798         var schemaIds = this.schemaService.getRegisteredSchemaIds(function (schema) { return schema === 'http' || schema === 'https'; });
16799         schemaIds.forEach(function (schemaId) { return collector.add({
16800             kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Module,
16801             label: _this.getLabelForValue(schemaId),
16802             filterText: _this.getFilterTextForValue(schemaId),
16803             insertText: _this.getInsertTextForValue(schemaId, separatorAfter),
16804             insertTextFormat: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["InsertTextFormat"].Snippet, documentation: ''
16805         }); });
16806     };
16807     JSONCompletion.prototype.sanitizeLabel = function (label) {
16808         label = label.replace(/[\n]/g, '↵');
16809         if (label.length > 57) {
16810             label = label.substr(0, 57).trim() + '...';
16811         }
16812         return label;
16813     };
16814     JSONCompletion.prototype.getLabelForValue = function (value) {
16815         return this.sanitizeLabel(JSON.stringify(value));
16816     };
16817     JSONCompletion.prototype.getFilterTextForValue = function (value) {
16818         return JSON.stringify(value);
16819     };
16820     JSONCompletion.prototype.getFilterTextForSnippetValue = function (value) {
16821         return JSON.stringify(value).replace(/\$\{\d+:([^}]+)\}|\$\d+/g, '$1');
16822     };
16823     JSONCompletion.prototype.getLabelForSnippetValue = function (value) {
16824         var label = JSON.stringify(value);
16825         label = label.replace(/\$\{\d+:([^}]+)\}|\$\d+/g, '$1');
16826         return this.sanitizeLabel(label);
16827     };
16828     JSONCompletion.prototype.getInsertTextForPlainText = function (text) {
16829         return text.replace(/[\\\$\}]/g, '\\$&'); // escape $, \ and } 
16830     };
16831     JSONCompletion.prototype.getInsertTextForValue = function (value, separatorAfter) {
16832         var text = JSON.stringify(value, null, '\t');
16833         if (text === '{}') {
16834             return '{$1}' + separatorAfter;
16835         }
16836         else if (text === '[]') {
16837             return '[$1]' + separatorAfter;
16838         }
16839         return this.getInsertTextForPlainText(text + separatorAfter);
16840     };
16841     JSONCompletion.prototype.getInsertTextForSnippetValue = function (value, separatorAfter) {
16842         var replacer = function (value) {
16843             if (typeof value === 'string') {
16844                 if (value[0] === '^') {
16845                     return value.substr(1);
16846                 }
16847             }
16848             return JSON.stringify(value);
16849         };
16850         return Object(_utils_json__WEBPACK_IMPORTED_MODULE_2__["stringifyObject"])(value, '', replacer) + separatorAfter;
16851     };
16852     JSONCompletion.prototype.getInsertTextForGuessedValue = function (value, separatorAfter) {
16853         switch (typeof value) {
16854             case 'object':
16855                 if (value === null) {
16856                     return '${1:null}' + separatorAfter;
16857                 }
16858                 return this.getInsertTextForValue(value, separatorAfter);
16859             case 'string':
16860                 var snippetValue = JSON.stringify(value);
16861                 snippetValue = snippetValue.substr(1, snippetValue.length - 2); // remove quotes
16862                 snippetValue = this.getInsertTextForPlainText(snippetValue); // escape \ and }
16863                 return '"${1:' + snippetValue + '}"' + separatorAfter;
16864             case 'number':
16865             case 'boolean':
16866                 return '${1:' + JSON.stringify(value) + '}' + separatorAfter;
16867         }
16868         return this.getInsertTextForValue(value, separatorAfter);
16869     };
16870     JSONCompletion.prototype.getSuggestionKind = function (type) {
16871         if (Array.isArray(type)) {
16872             var array = type;
16873             type = array.length > 0 ? array[0] : null;
16874         }
16875         if (!type) {
16876             return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Value;
16877         }
16878         switch (type) {
16879             case 'string': return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Value;
16880             case 'object': return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Module;
16881             case 'property': return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Property;
16882             default: return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["CompletionItemKind"].Value;
16883         }
16884     };
16885     JSONCompletion.prototype.getLabelTextForMatchingNode = function (node, document) {
16886         switch (node.type) {
16887             case 'array':
16888                 return '[]';
16889             case 'object':
16890                 return '{}';
16891             default:
16892                 var content = document.getText().substr(node.offset, node.length);
16893                 return content;
16894         }
16895     };
16896     JSONCompletion.prototype.getInsertTextForMatchingNode = function (node, document, separatorAfter) {
16897         switch (node.type) {
16898             case 'array':
16899                 return this.getInsertTextForValue([], separatorAfter);
16900             case 'object':
16901                 return this.getInsertTextForValue({}, separatorAfter);
16902             default:
16903                 var content = document.getText().substr(node.offset, node.length) + separatorAfter;
16904                 return this.getInsertTextForPlainText(content);
16905         }
16906     };
16907     JSONCompletion.prototype.getInsertTextForProperty = function (key, propertySchema, addValue, separatorAfter) {
16908         var propertyText = this.getInsertTextForValue(key, '');
16909         if (!addValue) {
16910             return propertyText;
16911         }
16912         var resultText = propertyText + ': ';
16913         var value;
16914         var nValueProposals = 0;
16915         if (propertySchema) {
16916             if (Array.isArray(propertySchema.defaultSnippets)) {
16917                 if (propertySchema.defaultSnippets.length === 1) {
16918                     var body = propertySchema.defaultSnippets[0].body;
16919                     if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(body)) {
16920                         value = this.getInsertTextForSnippetValue(body, '');
16921                     }
16922                 }
16923                 nValueProposals += propertySchema.defaultSnippets.length;
16924             }
16925             if (propertySchema.enum) {
16926                 if (!value && propertySchema.enum.length === 1) {
16927                     value = this.getInsertTextForGuessedValue(propertySchema.enum[0], '');
16928                 }
16929                 nValueProposals += propertySchema.enum.length;
16930             }
16931             if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(propertySchema.default)) {
16932                 if (!value) {
16933                     value = this.getInsertTextForGuessedValue(propertySchema.default, '');
16934                 }
16935                 nValueProposals++;
16936             }
16937             if (nValueProposals === 0) {
16938                 var type = Array.isArray(propertySchema.type) ? propertySchema.type[0] : propertySchema.type;
16939                 if (!type) {
16940                     if (propertySchema.properties) {
16941                         type = 'object';
16942                     }
16943                     else if (propertySchema.items) {
16944                         type = 'array';
16945                     }
16946                 }
16947                 switch (type) {
16948                     case 'boolean':
16949                         value = '$1';
16950                         break;
16951                     case 'string':
16952                         value = '"$1"';
16953                         break;
16954                     case 'object':
16955                         value = '{$1}';
16956                         break;
16957                     case 'array':
16958                         value = '[$1]';
16959                         break;
16960                     case 'number':
16961                     case 'integer':
16962                         value = '${1:0}';
16963                         break;
16964                     case 'null':
16965                         value = '${1:null}';
16966                         break;
16967                     default:
16968                         return propertyText;
16969                 }
16970             }
16971         }
16972         if (!value || nValueProposals > 1) {
16973             value = '$1';
16974         }
16975         return resultText + value + separatorAfter;
16976     };
16977     JSONCompletion.prototype.getCurrentWord = function (document, offset) {
16978         var i = offset - 1;
16979         var text = document.getText();
16980         while (i >= 0 && ' \t\n\r\v":{[,]}'.indexOf(text.charAt(i)) === -1) {
16981             i--;
16982         }
16983         return text.substring(i + 1, offset);
16984     };
16985     JSONCompletion.prototype.evaluateSeparatorAfter = function (document, offset) {
16986         var scanner = jsonc_parser__WEBPACK_IMPORTED_MODULE_1__["createScanner"](document.getText(), true);
16987         scanner.setPosition(offset);
16988         var token = scanner.scan();
16989         switch (token) {
16990             case 5 /* CommaToken */:
16991             case 2 /* CloseBraceToken */:
16992             case 4 /* CloseBracketToken */:
16993             case 17 /* EOF */:
16994                 return '';
16995             default:
16996                 return ',';
16997         }
16998     };
16999     JSONCompletion.prototype.findItemAtOffset = function (node, document, offset) {
17000         var scanner = jsonc_parser__WEBPACK_IMPORTED_MODULE_1__["createScanner"](document.getText(), true);
17001         var children = node.items;
17002         for (var i = children.length - 1; i >= 0; i--) {
17003             var child = children[i];
17004             if (offset > child.offset + child.length) {
17005                 scanner.setPosition(child.offset + child.length);
17006                 var token = scanner.scan();
17007                 if (token === 5 /* CommaToken */ && offset >= scanner.getTokenOffset() + scanner.getTokenLength()) {
17008                     return i + 1;
17009                 }
17010                 return i;
17011             }
17012             else if (offset >= child.offset) {
17013                 return i;
17014             }
17015         }
17016         return 0;
17017     };
17018     JSONCompletion.prototype.isInComment = function (document, start, offset) {
17019         var scanner = jsonc_parser__WEBPACK_IMPORTED_MODULE_1__["createScanner"](document.getText(), false);
17020         scanner.setPosition(start);
17021         var token = scanner.scan();
17022         while (token !== 17 /* EOF */ && (scanner.getTokenOffset() + scanner.getTokenLength() < offset)) {
17023             token = scanner.scan();
17024         }
17025         return (token === 12 /* LineCommentTrivia */ || token === 13 /* BlockCommentTrivia */) && scanner.getTokenOffset() <= offset;
17026     };
17027     JSONCompletion.prototype.fromMarkup = function (markupString) {
17028         if (markupString && this.doesSupportMarkdown()) {
17029             return {
17030                 kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["MarkupKind"].Markdown,
17031                 value: markupString
17032             };
17033         }
17034         return undefined;
17035     };
17036     JSONCompletion.prototype.doesSupportMarkdown = function () {
17037         if (!Object(_utils_objects__WEBPACK_IMPORTED_MODULE_4__["isDefined"])(this.supportsMarkdown)) {
17038             var completion = this.clientCapabilities.textDocument && this.clientCapabilities.textDocument.completion;
17039             this.supportsMarkdown = completion && completion.completionItem && Array.isArray(completion.completionItem.documentationFormat) && completion.completionItem.documentationFormat.indexOf(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_5__["MarkupKind"].Markdown) !== -1;
17040         }
17041         return this.supportsMarkdown;
17042     };
17043     return JSONCompletion;
17044 }());
17045
17046
17047
17048 /***/ }),
17049 /* 82 */
17050 /***/ (function(module, __webpack_exports__, __webpack_require__) {
17051
17052 "use strict";
17053 __webpack_require__.r(__webpack_exports__);
17054 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ASTNodeImpl", function() { return ASTNodeImpl; });
17055 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullASTNodeImpl", function() { return NullASTNodeImpl; });
17056 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BooleanASTNodeImpl", function() { return BooleanASTNodeImpl; });
17057 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayASTNodeImpl", function() { return ArrayASTNodeImpl; });
17058 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NumberASTNodeImpl", function() { return NumberASTNodeImpl; });
17059 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringASTNodeImpl", function() { return StringASTNodeImpl; });
17060 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PropertyASTNodeImpl", function() { return PropertyASTNodeImpl; });
17061 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ObjectASTNodeImpl", function() { return ObjectASTNodeImpl; });
17062 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "asSchema", function() { return asSchema; });
17063 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnumMatch", function() { return EnumMatch; });
17064 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValidationResult", function() { return ValidationResult; });
17065 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "newJSONDocument", function() { return newJSONDocument; });
17066 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodeValue", function() { return getNodeValue; });
17067 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodePath", function() { return getNodePath; });
17068 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return contains; });
17069 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONDocument", function() { return JSONDocument; });
17070 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return parse; });
17071 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83);
17072 /* harmony import */ var _utils_objects__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(88);
17073 /* harmony import */ var _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89);
17074 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(76);
17075 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(vscode_nls__WEBPACK_IMPORTED_MODULE_3__);
17076 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(80);
17077 /*---------------------------------------------------------------------------------------------
17078  *  Copyright (c) Microsoft Corporation. All rights reserved.
17079  *  Licensed under the MIT License. See License.txt in the project root for license information.
17080  *--------------------------------------------------------------------------------------------*/
17081 var __extends = (undefined && undefined.__extends) || (function () {
17082     var extendStatics = function (d, b) {
17083         extendStatics = Object.setPrototypeOf ||
17084             ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
17085             function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
17086         return extendStatics(d, b);
17087     };
17088     return function (d, b) {
17089         extendStatics(d, b);
17090         function __() { this.constructor = d; }
17091         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
17092     };
17093 })();
17094
17095
17096
17097
17098
17099 var localize = vscode_nls__WEBPACK_IMPORTED_MODULE_3__["loadMessageBundle"]();
17100 var colorHexPattern = /^#([0-9A-Fa-f]{3,4}|([0-9A-Fa-f]{2}){3,4})$/;
17101 var emailPattern = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
17102 var ASTNodeImpl = /** @class */ (function () {
17103     function ASTNodeImpl(parent, offset, length) {
17104         this.offset = offset;
17105         this.length = length;
17106         this.parent = parent;
17107     }
17108     Object.defineProperty(ASTNodeImpl.prototype, "children", {
17109         get: function () {
17110             return [];
17111         },
17112         enumerable: true,
17113         configurable: true
17114     });
17115     ASTNodeImpl.prototype.toString = function () {
17116         return 'type: ' + this.type + ' (' + this.offset + '/' + this.length + ')' + (this.parent ? ' parent: {' + this.parent.toString() + '}' : '');
17117     };
17118     return ASTNodeImpl;
17119 }());
17120
17121 var NullASTNodeImpl = /** @class */ (function (_super) {
17122     __extends(NullASTNodeImpl, _super);
17123     function NullASTNodeImpl(parent, offset) {
17124         var _this = _super.call(this, parent, offset) || this;
17125         _this.type = 'null';
17126         _this.value = null;
17127         return _this;
17128     }
17129     return NullASTNodeImpl;
17130 }(ASTNodeImpl));
17131
17132 var BooleanASTNodeImpl = /** @class */ (function (_super) {
17133     __extends(BooleanASTNodeImpl, _super);
17134     function BooleanASTNodeImpl(parent, boolValue, offset) {
17135         var _this = _super.call(this, parent, offset) || this;
17136         _this.type = 'boolean';
17137         _this.value = boolValue;
17138         return _this;
17139     }
17140     return BooleanASTNodeImpl;
17141 }(ASTNodeImpl));
17142
17143 var ArrayASTNodeImpl = /** @class */ (function (_super) {
17144     __extends(ArrayASTNodeImpl, _super);
17145     function ArrayASTNodeImpl(parent, offset) {
17146         var _this = _super.call(this, parent, offset) || this;
17147         _this.type = 'array';
17148         _this.items = [];
17149         return _this;
17150     }
17151     Object.defineProperty(ArrayASTNodeImpl.prototype, "children", {
17152         get: function () {
17153             return this.items;
17154         },
17155         enumerable: true,
17156         configurable: true
17157     });
17158     return ArrayASTNodeImpl;
17159 }(ASTNodeImpl));
17160
17161 var NumberASTNodeImpl = /** @class */ (function (_super) {
17162     __extends(NumberASTNodeImpl, _super);
17163     function NumberASTNodeImpl(parent, offset) {
17164         var _this = _super.call(this, parent, offset) || this;
17165         _this.type = 'number';
17166         _this.isInteger = true;
17167         _this.value = Number.NaN;
17168         return _this;
17169     }
17170     return NumberASTNodeImpl;
17171 }(ASTNodeImpl));
17172
17173 var StringASTNodeImpl = /** @class */ (function (_super) {
17174     __extends(StringASTNodeImpl, _super);
17175     function StringASTNodeImpl(parent, offset, length) {
17176         var _this = _super.call(this, parent, offset, length) || this;
17177         _this.type = 'string';
17178         _this.value = '';
17179         return _this;
17180     }
17181     return StringASTNodeImpl;
17182 }(ASTNodeImpl));
17183
17184 var PropertyASTNodeImpl = /** @class */ (function (_super) {
17185     __extends(PropertyASTNodeImpl, _super);
17186     function PropertyASTNodeImpl(parent, offset) {
17187         var _this = _super.call(this, parent, offset) || this;
17188         _this.type = 'property';
17189         _this.colonOffset = -1;
17190         return _this;
17191     }
17192     Object.defineProperty(PropertyASTNodeImpl.prototype, "children", {
17193         get: function () {
17194             return this.valueNode ? [this.keyNode, this.valueNode] : [this.keyNode];
17195         },
17196         enumerable: true,
17197         configurable: true
17198     });
17199     return PropertyASTNodeImpl;
17200 }(ASTNodeImpl));
17201
17202 var ObjectASTNodeImpl = /** @class */ (function (_super) {
17203     __extends(ObjectASTNodeImpl, _super);
17204     function ObjectASTNodeImpl(parent, offset) {
17205         var _this = _super.call(this, parent, offset) || this;
17206         _this.type = 'object';
17207         _this.properties = [];
17208         return _this;
17209     }
17210     Object.defineProperty(ObjectASTNodeImpl.prototype, "children", {
17211         get: function () {
17212             return this.properties;
17213         },
17214         enumerable: true,
17215         configurable: true
17216     });
17217     return ObjectASTNodeImpl;
17218 }(ASTNodeImpl));
17219
17220 function asSchema(schema) {
17221     if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isBoolean"])(schema)) {
17222         return schema ? {} : { "not": {} };
17223     }
17224     return schema;
17225 }
17226 var EnumMatch;
17227 (function (EnumMatch) {
17228     EnumMatch[EnumMatch["Key"] = 0] = "Key";
17229     EnumMatch[EnumMatch["Enum"] = 1] = "Enum";
17230 })(EnumMatch || (EnumMatch = {}));
17231 var SchemaCollector = /** @class */ (function () {
17232     function SchemaCollector(focusOffset, exclude) {
17233         if (focusOffset === void 0) { focusOffset = -1; }
17234         if (exclude === void 0) { exclude = null; }
17235         this.focusOffset = focusOffset;
17236         this.exclude = exclude;
17237         this.schemas = [];
17238     }
17239     SchemaCollector.prototype.add = function (schema) {
17240         this.schemas.push(schema);
17241     };
17242     SchemaCollector.prototype.merge = function (other) {
17243         var _a;
17244         (_a = this.schemas).push.apply(_a, other.schemas);
17245     };
17246     SchemaCollector.prototype.include = function (node) {
17247         return (this.focusOffset === -1 || contains(node, this.focusOffset)) && (node !== this.exclude);
17248     };
17249     SchemaCollector.prototype.newSub = function () {
17250         return new SchemaCollector(-1, this.exclude);
17251     };
17252     return SchemaCollector;
17253 }());
17254 var NoOpSchemaCollector = /** @class */ (function () {
17255     function NoOpSchemaCollector() {
17256     }
17257     Object.defineProperty(NoOpSchemaCollector.prototype, "schemas", {
17258         get: function () { return []; },
17259         enumerable: true,
17260         configurable: true
17261     });
17262     NoOpSchemaCollector.prototype.add = function (schema) { };
17263     NoOpSchemaCollector.prototype.merge = function (other) { };
17264     NoOpSchemaCollector.prototype.include = function (node) { return true; };
17265     NoOpSchemaCollector.prototype.newSub = function () { return this; };
17266     NoOpSchemaCollector.instance = new NoOpSchemaCollector();
17267     return NoOpSchemaCollector;
17268 }());
17269 var ValidationResult = /** @class */ (function () {
17270     function ValidationResult() {
17271         this.problems = [];
17272         this.propertiesMatches = 0;
17273         this.propertiesValueMatches = 0;
17274         this.primaryValueMatches = 0;
17275         this.enumValueMatch = false;
17276         this.enumValues = null;
17277     }
17278     ValidationResult.prototype.hasProblems = function () {
17279         return !!this.problems.length;
17280     };
17281     ValidationResult.prototype.mergeAll = function (validationResults) {
17282         for (var _i = 0, validationResults_1 = validationResults; _i < validationResults_1.length; _i++) {
17283             var validationResult = validationResults_1[_i];
17284             this.merge(validationResult);
17285         }
17286     };
17287     ValidationResult.prototype.merge = function (validationResult) {
17288         this.problems = this.problems.concat(validationResult.problems);
17289     };
17290     ValidationResult.prototype.mergeEnumValues = function (validationResult) {
17291         if (!this.enumValueMatch && !validationResult.enumValueMatch && this.enumValues && validationResult.enumValues) {
17292             this.enumValues = this.enumValues.concat(validationResult.enumValues);
17293             for (var _i = 0, _a = this.problems; _i < _a.length; _i++) {
17294                 var error = _a[_i];
17295                 if (error.code === _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].EnumValueMismatch) {
17296                     error.message = localize('enumWarning', 'Value is not accepted. Valid values: {0}.', this.enumValues.map(function (v) { return JSON.stringify(v); }).join(', '));
17297                 }
17298             }
17299         }
17300     };
17301     ValidationResult.prototype.mergePropertyMatch = function (propertyValidationResult) {
17302         this.merge(propertyValidationResult);
17303         this.propertiesMatches++;
17304         if (propertyValidationResult.enumValueMatch || !propertyValidationResult.hasProblems() && propertyValidationResult.propertiesMatches) {
17305             this.propertiesValueMatches++;
17306         }
17307         if (propertyValidationResult.enumValueMatch && propertyValidationResult.enumValues && propertyValidationResult.enumValues.length === 1) {
17308             this.primaryValueMatches++;
17309         }
17310     };
17311     ValidationResult.prototype.compare = function (other) {
17312         var hasProblems = this.hasProblems();
17313         if (hasProblems !== other.hasProblems()) {
17314             return hasProblems ? -1 : 1;
17315         }
17316         if (this.enumValueMatch !== other.enumValueMatch) {
17317             return other.enumValueMatch ? -1 : 1;
17318         }
17319         if (this.primaryValueMatches !== other.primaryValueMatches) {
17320             return this.primaryValueMatches - other.primaryValueMatches;
17321         }
17322         if (this.propertiesValueMatches !== other.propertiesValueMatches) {
17323             return this.propertiesValueMatches - other.propertiesValueMatches;
17324         }
17325         return this.propertiesMatches - other.propertiesMatches;
17326     };
17327     return ValidationResult;
17328 }());
17329
17330 function newJSONDocument(root, diagnostics) {
17331     if (diagnostics === void 0) { diagnostics = []; }
17332     return new JSONDocument(root, diagnostics, []);
17333 }
17334 function getNodeValue(node) {
17335     return jsonc_parser__WEBPACK_IMPORTED_MODULE_0__["getNodeValue"](node);
17336 }
17337 function getNodePath(node) {
17338     return jsonc_parser__WEBPACK_IMPORTED_MODULE_0__["getNodePath"](node);
17339 }
17340 function contains(node, offset, includeRightBound) {
17341     if (includeRightBound === void 0) { includeRightBound = false; }
17342     return offset >= node.offset && offset < (node.offset + node.length) || includeRightBound && offset === (node.offset + node.length);
17343 }
17344 var JSONDocument = /** @class */ (function () {
17345     function JSONDocument(root, syntaxErrors, comments) {
17346         if (syntaxErrors === void 0) { syntaxErrors = []; }
17347         if (comments === void 0) { comments = []; }
17348         this.root = root;
17349         this.syntaxErrors = syntaxErrors;
17350         this.comments = comments;
17351     }
17352     JSONDocument.prototype.getNodeFromOffset = function (offset, includeRightBound) {
17353         if (includeRightBound === void 0) { includeRightBound = false; }
17354         if (this.root) {
17355             return jsonc_parser__WEBPACK_IMPORTED_MODULE_0__["findNodeAtOffset"](this.root, offset, includeRightBound);
17356         }
17357         return void 0;
17358     };
17359     JSONDocument.prototype.visit = function (visitor) {
17360         if (this.root) {
17361             var doVisit_1 = function (node) {
17362                 var ctn = visitor(node);
17363                 var children = node.children;
17364                 if (Array.isArray(children)) {
17365                     for (var i = 0; i < children.length && ctn; i++) {
17366                         ctn = doVisit_1(children[i]);
17367                     }
17368                 }
17369                 return ctn;
17370             };
17371             doVisit_1(this.root);
17372         }
17373     };
17374     JSONDocument.prototype.validate = function (textDocument, schema) {
17375         if (this.root && schema) {
17376             var validationResult = new ValidationResult();
17377             validate(this.root, schema, validationResult, NoOpSchemaCollector.instance);
17378             return validationResult.problems.map(function (p) {
17379                 var range = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["Range"].create(textDocument.positionAt(p.location.offset), textDocument.positionAt(p.location.offset + p.location.length));
17380                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["Diagnostic"].create(range, p.message, p.severity, p.code);
17381             });
17382         }
17383         return null;
17384     };
17385     JSONDocument.prototype.getMatchingSchemas = function (schema, focusOffset, exclude) {
17386         if (focusOffset === void 0) { focusOffset = -1; }
17387         if (exclude === void 0) { exclude = null; }
17388         var matchingSchemas = new SchemaCollector(focusOffset, exclude);
17389         if (this.root && schema) {
17390             validate(this.root, schema, new ValidationResult(), matchingSchemas);
17391         }
17392         return matchingSchemas.schemas;
17393     };
17394     return JSONDocument;
17395 }());
17396
17397 function validate(node, schema, validationResult, matchingSchemas) {
17398     if (!node || !matchingSchemas.include(node)) {
17399         return;
17400     }
17401     switch (node.type) {
17402         case 'object':
17403             _validateObjectNode(node, schema, validationResult, matchingSchemas);
17404             break;
17405         case 'array':
17406             _validateArrayNode(node, schema, validationResult, matchingSchemas);
17407             break;
17408         case 'string':
17409             _validateStringNode(node, schema, validationResult, matchingSchemas);
17410             break;
17411         case 'number':
17412             _validateNumberNode(node, schema, validationResult, matchingSchemas);
17413             break;
17414         case 'property':
17415             return validate(node.valueNode, schema, validationResult, matchingSchemas);
17416     }
17417     _validateNode();
17418     matchingSchemas.add({ node: node, schema: schema });
17419     function _validateNode() {
17420         function matchesType(type) {
17421             return node.type === type || (type === 'integer' && node.type === 'number' && node.isInteger);
17422         }
17423         if (Array.isArray(schema.type)) {
17424             if (!schema.type.some(matchesType)) {
17425                 validationResult.problems.push({
17426                     location: { offset: node.offset, length: node.length },
17427                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17428                     message: schema.errorMessage || localize('typeArrayMismatchWarning', 'Incorrect type. Expected one of {0}.', schema.type.join(', '))
17429                 });
17430             }
17431         }
17432         else if (schema.type) {
17433             if (!matchesType(schema.type)) {
17434                 validationResult.problems.push({
17435                     location: { offset: node.offset, length: node.length },
17436                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17437                     message: schema.errorMessage || localize('typeMismatchWarning', 'Incorrect type. Expected "{0}".', schema.type)
17438                 });
17439             }
17440         }
17441         if (Array.isArray(schema.allOf)) {
17442             for (var _i = 0, _a = schema.allOf; _i < _a.length; _i++) {
17443                 var subSchemaRef = _a[_i];
17444                 validate(node, asSchema(subSchemaRef), validationResult, matchingSchemas);
17445             }
17446         }
17447         var notSchema = asSchema(schema.not);
17448         if (notSchema) {
17449             var subValidationResult = new ValidationResult();
17450             var subMatchingSchemas = matchingSchemas.newSub();
17451             validate(node, notSchema, subValidationResult, subMatchingSchemas);
17452             if (!subValidationResult.hasProblems()) {
17453                 validationResult.problems.push({
17454                     location: { offset: node.offset, length: node.length },
17455                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17456                     message: localize('notSchemaWarning', "Matches a schema that is not allowed.")
17457                 });
17458             }
17459             for (var _b = 0, _c = subMatchingSchemas.schemas; _b < _c.length; _b++) {
17460                 var ms = _c[_b];
17461                 ms.inverted = !ms.inverted;
17462                 matchingSchemas.add(ms);
17463             }
17464         }
17465         var testAlternatives = function (alternatives, maxOneMatch) {
17466             var matches = [];
17467             // remember the best match that is used for error messages
17468             var bestMatch = null;
17469             for (var _i = 0, alternatives_1 = alternatives; _i < alternatives_1.length; _i++) {
17470                 var subSchemaRef = alternatives_1[_i];
17471                 var subSchema = asSchema(subSchemaRef);
17472                 var subValidationResult = new ValidationResult();
17473                 var subMatchingSchemas = matchingSchemas.newSub();
17474                 validate(node, subSchema, subValidationResult, subMatchingSchemas);
17475                 if (!subValidationResult.hasProblems()) {
17476                     matches.push(subSchema);
17477                 }
17478                 if (!bestMatch) {
17479                     bestMatch = { schema: subSchema, validationResult: subValidationResult, matchingSchemas: subMatchingSchemas };
17480                 }
17481                 else {
17482                     if (!maxOneMatch && !subValidationResult.hasProblems() && !bestMatch.validationResult.hasProblems()) {
17483                         // no errors, both are equally good matches
17484                         bestMatch.matchingSchemas.merge(subMatchingSchemas);
17485                         bestMatch.validationResult.propertiesMatches += subValidationResult.propertiesMatches;
17486                         bestMatch.validationResult.propertiesValueMatches += subValidationResult.propertiesValueMatches;
17487                     }
17488                     else {
17489                         var compareResult = subValidationResult.compare(bestMatch.validationResult);
17490                         if (compareResult > 0) {
17491                             // our node is the best matching so far
17492                             bestMatch = { schema: subSchema, validationResult: subValidationResult, matchingSchemas: subMatchingSchemas };
17493                         }
17494                         else if (compareResult === 0) {
17495                             // there's already a best matching but we are as good
17496                             bestMatch.matchingSchemas.merge(subMatchingSchemas);
17497                             bestMatch.validationResult.mergeEnumValues(subValidationResult);
17498                         }
17499                     }
17500                 }
17501             }
17502             if (matches.length > 1 && maxOneMatch) {
17503                 validationResult.problems.push({
17504                     location: { offset: node.offset, length: 1 },
17505                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17506                     message: localize('oneOfWarning', "Matches multiple schemas when only one must validate.")
17507                 });
17508             }
17509             if (bestMatch !== null) {
17510                 validationResult.merge(bestMatch.validationResult);
17511                 validationResult.propertiesMatches += bestMatch.validationResult.propertiesMatches;
17512                 validationResult.propertiesValueMatches += bestMatch.validationResult.propertiesValueMatches;
17513                 matchingSchemas.merge(bestMatch.matchingSchemas);
17514             }
17515             return matches.length;
17516         };
17517         if (Array.isArray(schema.anyOf)) {
17518             testAlternatives(schema.anyOf, false);
17519         }
17520         if (Array.isArray(schema.oneOf)) {
17521             testAlternatives(schema.oneOf, true);
17522         }
17523         var testBranch = function (schema) {
17524             var subValidationResult = new ValidationResult();
17525             var subMatchingSchemas = matchingSchemas.newSub();
17526             validate(node, asSchema(schema), subValidationResult, subMatchingSchemas);
17527             validationResult.merge(subValidationResult);
17528             validationResult.propertiesMatches += subValidationResult.propertiesMatches;
17529             validationResult.propertiesValueMatches += subValidationResult.propertiesValueMatches;
17530             matchingSchemas.merge(subMatchingSchemas);
17531         };
17532         var testCondition = function (ifSchema, thenSchema, elseSchema) {
17533             var subSchema = asSchema(ifSchema);
17534             var subValidationResult = new ValidationResult();
17535             var subMatchingSchemas = matchingSchemas.newSub();
17536             validate(node, subSchema, subValidationResult, subMatchingSchemas);
17537             matchingSchemas.merge(subMatchingSchemas);
17538             if (!subValidationResult.hasProblems()) {
17539                 if (thenSchema) {
17540                     testBranch(thenSchema);
17541                 }
17542             }
17543             else if (elseSchema) {
17544                 testBranch(elseSchema);
17545             }
17546         };
17547         var ifSchema = asSchema(schema.if);
17548         if (ifSchema) {
17549             testCondition(ifSchema, asSchema(schema.then), asSchema(schema.else));
17550         }
17551         if (Array.isArray(schema.enum)) {
17552             var val = getNodeValue(node);
17553             var enumValueMatch = false;
17554             for (var _d = 0, _e = schema.enum; _d < _e.length; _d++) {
17555                 var e = _e[_d];
17556                 if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["equals"])(val, e)) {
17557                     enumValueMatch = true;
17558                     break;
17559                 }
17560             }
17561             validationResult.enumValues = schema.enum;
17562             validationResult.enumValueMatch = enumValueMatch;
17563             if (!enumValueMatch) {
17564                 validationResult.problems.push({
17565                     location: { offset: node.offset, length: node.length },
17566                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17567                     code: _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].EnumValueMismatch,
17568                     message: schema.errorMessage || localize('enumWarning', 'Value is not accepted. Valid values: {0}.', schema.enum.map(function (v) { return JSON.stringify(v); }).join(', '))
17569                 });
17570             }
17571         }
17572         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isDefined"])(schema.const)) {
17573             var val = getNodeValue(node);
17574             if (!Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["equals"])(val, schema.const)) {
17575                 validationResult.problems.push({
17576                     location: { offset: node.offset, length: node.length },
17577                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17578                     code: _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].EnumValueMismatch,
17579                     message: schema.errorMessage || localize('constWarning', 'Value must be {0}.', JSON.stringify(schema.const))
17580                 });
17581                 validationResult.enumValueMatch = false;
17582             }
17583             else {
17584                 validationResult.enumValueMatch = true;
17585             }
17586             validationResult.enumValues = [schema.const];
17587         }
17588         if (schema.deprecationMessage && node.parent) {
17589             validationResult.problems.push({
17590                 location: { offset: node.parent.offset, length: node.parent.length },
17591                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17592                 message: schema.deprecationMessage
17593             });
17594         }
17595     }
17596     function _validateNumberNode(node, schema, validationResult, matchingSchemas) {
17597         var val = node.value;
17598         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.multipleOf)) {
17599             if (val % schema.multipleOf !== 0) {
17600                 validationResult.problems.push({
17601                     location: { offset: node.offset, length: node.length },
17602                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17603                     message: localize('multipleOfWarning', 'Value is not divisible by {0}.', schema.multipleOf)
17604                 });
17605             }
17606         }
17607         function getExclusiveLimit(limit, exclusive) {
17608             if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(exclusive)) {
17609                 return exclusive;
17610             }
17611             if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isBoolean"])(exclusive) && exclusive) {
17612                 return limit;
17613             }
17614             return void 0;
17615         }
17616         function getLimit(limit, exclusive) {
17617             if (!Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isBoolean"])(exclusive) || !exclusive) {
17618                 return limit;
17619             }
17620             return void 0;
17621         }
17622         var exclusiveMinimum = getExclusiveLimit(schema.minimum, schema.exclusiveMinimum);
17623         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(exclusiveMinimum) && val <= exclusiveMinimum) {
17624             validationResult.problems.push({
17625                 location: { offset: node.offset, length: node.length },
17626                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17627                 message: localize('exclusiveMinimumWarning', 'Value is below the exclusive minimum of {0}.', exclusiveMinimum)
17628             });
17629         }
17630         var exclusiveMaximum = getExclusiveLimit(schema.maximum, schema.exclusiveMaximum);
17631         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(exclusiveMaximum) && val >= exclusiveMaximum) {
17632             validationResult.problems.push({
17633                 location: { offset: node.offset, length: node.length },
17634                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17635                 message: localize('exclusiveMaximumWarning', 'Value is above the exclusive maximum of {0}.', exclusiveMaximum)
17636             });
17637         }
17638         var minimum = getLimit(schema.minimum, schema.exclusiveMinimum);
17639         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(minimum) && val < minimum) {
17640             validationResult.problems.push({
17641                 location: { offset: node.offset, length: node.length },
17642                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17643                 message: localize('minimumWarning', 'Value is below the minimum of {0}.', minimum)
17644             });
17645         }
17646         var maximum = getLimit(schema.maximum, schema.exclusiveMaximum);
17647         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(maximum) && val > maximum) {
17648             validationResult.problems.push({
17649                 location: { offset: node.offset, length: node.length },
17650                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17651                 message: localize('maximumWarning', 'Value is above the maximum of {0}.', maximum)
17652             });
17653         }
17654     }
17655     function _validateStringNode(node, schema, validationResult, matchingSchemas) {
17656         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.minLength) && node.value.length < schema.minLength) {
17657             validationResult.problems.push({
17658                 location: { offset: node.offset, length: node.length },
17659                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17660                 message: localize('minLengthWarning', 'String is shorter than the minimum length of {0}.', schema.minLength)
17661             });
17662         }
17663         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.maxLength) && node.value.length > schema.maxLength) {
17664             validationResult.problems.push({
17665                 location: { offset: node.offset, length: node.length },
17666                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17667                 message: localize('maxLengthWarning', 'String is longer than the maximum length of {0}.', schema.maxLength)
17668             });
17669         }
17670         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isString"])(schema.pattern)) {
17671             var regex = new RegExp(schema.pattern);
17672             if (!regex.test(node.value)) {
17673                 validationResult.problems.push({
17674                     location: { offset: node.offset, length: node.length },
17675                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17676                     message: schema.patternErrorMessage || schema.errorMessage || localize('patternWarning', 'String does not match the pattern of "{0}".', schema.pattern)
17677                 });
17678             }
17679         }
17680         if (schema.format) {
17681             switch (schema.format) {
17682                 case 'uri':
17683                 case 'uri-reference':
17684                     {
17685                         var errorMessage = void 0;
17686                         if (!node.value) {
17687                             errorMessage = localize('uriEmpty', 'URI expected.');
17688                         }
17689                         else {
17690                             var match = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/.exec(node.value);
17691                             if (!match) {
17692                                 errorMessage = localize('uriMissing', 'URI is expected.');
17693                             }
17694                             else if (!match[2] && schema.format === 'uri') {
17695                                 errorMessage = localize('uriSchemeMissing', 'URI with a scheme is expected.');
17696                             }
17697                         }
17698                         if (errorMessage) {
17699                             validationResult.problems.push({
17700                                 location: { offset: node.offset, length: node.length },
17701                                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17702                                 message: schema.patternErrorMessage || schema.errorMessage || localize('uriFormatWarning', 'String is not a URI: {0}', errorMessage)
17703                             });
17704                         }
17705                     }
17706                     break;
17707                 case 'email':
17708                     {
17709                         if (!node.value.match(emailPattern)) {
17710                             validationResult.problems.push({
17711                                 location: { offset: node.offset, length: node.length },
17712                                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17713                                 message: schema.patternErrorMessage || schema.errorMessage || localize('emailFormatWarning', 'String is not an e-mail address.')
17714                             });
17715                         }
17716                     }
17717                     break;
17718                 case 'color-hex':
17719                     {
17720                         if (!node.value.match(colorHexPattern)) {
17721                             validationResult.problems.push({
17722                                 location: { offset: node.offset, length: node.length },
17723                                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17724                                 message: schema.patternErrorMessage || schema.errorMessage || localize('colorHexFormatWarning', 'Invalid color format. Use #RGB, #RGBA, #RRGGBB or #RRGGBBAA.')
17725                             });
17726                         }
17727                     }
17728                     break;
17729                 default:
17730             }
17731         }
17732     }
17733     function _validateArrayNode(node, schema, validationResult, matchingSchemas) {
17734         if (Array.isArray(schema.items)) {
17735             var subSchemas = schema.items;
17736             for (var index = 0; index < subSchemas.length; index++) {
17737                 var subSchemaRef = subSchemas[index];
17738                 var subSchema = asSchema(subSchemaRef);
17739                 var itemValidationResult = new ValidationResult();
17740                 var item = node.items[index];
17741                 if (item) {
17742                     validate(item, subSchema, itemValidationResult, matchingSchemas);
17743                     validationResult.mergePropertyMatch(itemValidationResult);
17744                 }
17745                 else if (node.items.length >= subSchemas.length) {
17746                     validationResult.propertiesValueMatches++;
17747                 }
17748             }
17749             if (node.items.length > subSchemas.length) {
17750                 if (typeof schema.additionalItems === 'object') {
17751                     for (var i = subSchemas.length; i < node.items.length; i++) {
17752                         var itemValidationResult = new ValidationResult();
17753                         validate(node.items[i], schema.additionalItems, itemValidationResult, matchingSchemas);
17754                         validationResult.mergePropertyMatch(itemValidationResult);
17755                     }
17756                 }
17757                 else if (schema.additionalItems === false) {
17758                     validationResult.problems.push({
17759                         location: { offset: node.offset, length: node.length },
17760                         severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17761                         message: localize('additionalItemsWarning', 'Array has too many items according to schema. Expected {0} or fewer.', subSchemas.length)
17762                     });
17763                 }
17764             }
17765         }
17766         else {
17767             var itemSchema = asSchema(schema.items);
17768             if (itemSchema) {
17769                 for (var _i = 0, _a = node.items; _i < _a.length; _i++) {
17770                     var item = _a[_i];
17771                     var itemValidationResult = new ValidationResult();
17772                     validate(item, itemSchema, itemValidationResult, matchingSchemas);
17773                     validationResult.mergePropertyMatch(itemValidationResult);
17774                 }
17775             }
17776         }
17777         var containsSchema = asSchema(schema.contains);
17778         if (containsSchema) {
17779             var doesContain = node.items.some(function (item) {
17780                 var itemValidationResult = new ValidationResult();
17781                 validate(item, containsSchema, itemValidationResult, NoOpSchemaCollector.instance);
17782                 return !itemValidationResult.hasProblems();
17783             });
17784             if (!doesContain) {
17785                 validationResult.problems.push({
17786                     location: { offset: node.offset, length: node.length },
17787                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17788                     message: schema.errorMessage || localize('requiredItemMissingWarning', 'Array does not contain required item.')
17789                 });
17790             }
17791         }
17792         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.minItems) && node.items.length < schema.minItems) {
17793             validationResult.problems.push({
17794                 location: { offset: node.offset, length: node.length },
17795                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17796                 message: localize('minItemsWarning', 'Array has too few items. Expected {0} or more.', schema.minItems)
17797             });
17798         }
17799         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.maxItems) && node.items.length > schema.maxItems) {
17800             validationResult.problems.push({
17801                 location: { offset: node.offset, length: node.length },
17802                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17803                 message: localize('maxItemsWarning', 'Array has too many items. Expected {0} or fewer.', schema.maxItems)
17804             });
17805         }
17806         if (schema.uniqueItems === true) {
17807             var values_1 = getNodeValue(node);
17808             var duplicates = values_1.some(function (value, index) {
17809                 return index !== values_1.lastIndexOf(value);
17810             });
17811             if (duplicates) {
17812                 validationResult.problems.push({
17813                     location: { offset: node.offset, length: node.length },
17814                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17815                     message: localize('uniqueItemsWarning', 'Array has duplicate items.')
17816                 });
17817             }
17818         }
17819     }
17820     function _validateObjectNode(node, schema, validationResult, matchingSchemas) {
17821         var seenKeys = Object.create(null);
17822         var unprocessedProperties = [];
17823         for (var _i = 0, _a = node.properties; _i < _a.length; _i++) {
17824             var propertyNode = _a[_i];
17825             var key = propertyNode.keyNode.value;
17826             seenKeys[key] = propertyNode.valueNode;
17827             unprocessedProperties.push(key);
17828         }
17829         if (Array.isArray(schema.required)) {
17830             for (var _b = 0, _c = schema.required; _b < _c.length; _b++) {
17831                 var propertyName = _c[_b];
17832                 if (!seenKeys[propertyName]) {
17833                     var keyNode = node.parent && node.parent.type === 'property' && node.parent.keyNode;
17834                     var location = keyNode ? { offset: keyNode.offset, length: keyNode.length } : { offset: node.offset, length: 1 };
17835                     validationResult.problems.push({
17836                         location: location,
17837                         severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17838                         message: localize('MissingRequiredPropWarning', 'Missing property "{0}".', propertyName)
17839                     });
17840                 }
17841             }
17842         }
17843         var propertyProcessed = function (prop) {
17844             var index = unprocessedProperties.indexOf(prop);
17845             while (index >= 0) {
17846                 unprocessedProperties.splice(index, 1);
17847                 index = unprocessedProperties.indexOf(prop);
17848             }
17849         };
17850         if (schema.properties) {
17851             for (var _d = 0, _e = Object.keys(schema.properties); _d < _e.length; _d++) {
17852                 var propertyName = _e[_d];
17853                 propertyProcessed(propertyName);
17854                 var propertySchema = schema.properties[propertyName];
17855                 var child = seenKeys[propertyName];
17856                 if (child) {
17857                     if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isBoolean"])(propertySchema)) {
17858                         if (!propertySchema) {
17859                             var propertyNode = child.parent;
17860                             validationResult.problems.push({
17861                                 location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
17862                                 severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17863                                 message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName)
17864                             });
17865                         }
17866                         else {
17867                             validationResult.propertiesMatches++;
17868                             validationResult.propertiesValueMatches++;
17869                         }
17870                     }
17871                     else {
17872                         var propertyValidationResult = new ValidationResult();
17873                         validate(child, propertySchema, propertyValidationResult, matchingSchemas);
17874                         validationResult.mergePropertyMatch(propertyValidationResult);
17875                     }
17876                 }
17877             }
17878         }
17879         if (schema.patternProperties) {
17880             for (var _f = 0, _g = Object.keys(schema.patternProperties); _f < _g.length; _f++) {
17881                 var propertyPattern = _g[_f];
17882                 var regex = new RegExp(propertyPattern);
17883                 for (var _h = 0, _j = unprocessedProperties.slice(0); _h < _j.length; _h++) {
17884                     var propertyName = _j[_h];
17885                     if (regex.test(propertyName)) {
17886                         propertyProcessed(propertyName);
17887                         var child = seenKeys[propertyName];
17888                         if (child) {
17889                             var propertySchema = schema.patternProperties[propertyPattern];
17890                             if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isBoolean"])(propertySchema)) {
17891                                 if (!propertySchema) {
17892                                     var propertyNode = child.parent;
17893                                     validationResult.problems.push({
17894                                         location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
17895                                         severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17896                                         message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName)
17897                                     });
17898                                 }
17899                                 else {
17900                                     validationResult.propertiesMatches++;
17901                                     validationResult.propertiesValueMatches++;
17902                                 }
17903                             }
17904                             else {
17905                                 var propertyValidationResult = new ValidationResult();
17906                                 validate(child, propertySchema, propertyValidationResult, matchingSchemas);
17907                                 validationResult.mergePropertyMatch(propertyValidationResult);
17908                             }
17909                         }
17910                     }
17911                 }
17912             }
17913         }
17914         if (typeof schema.additionalProperties === 'object') {
17915             for (var _k = 0, unprocessedProperties_1 = unprocessedProperties; _k < unprocessedProperties_1.length; _k++) {
17916                 var propertyName = unprocessedProperties_1[_k];
17917                 var child = seenKeys[propertyName];
17918                 if (child) {
17919                     var propertyValidationResult = new ValidationResult();
17920                     validate(child, schema.additionalProperties, propertyValidationResult, matchingSchemas);
17921                     validationResult.mergePropertyMatch(propertyValidationResult);
17922                 }
17923             }
17924         }
17925         else if (schema.additionalProperties === false) {
17926             if (unprocessedProperties.length > 0) {
17927                 for (var _l = 0, unprocessedProperties_2 = unprocessedProperties; _l < unprocessedProperties_2.length; _l++) {
17928                     var propertyName = unprocessedProperties_2[_l];
17929                     var child = seenKeys[propertyName];
17930                     if (child) {
17931                         var propertyNode = child.parent;
17932                         validationResult.problems.push({
17933                             location: { offset: propertyNode.keyNode.offset, length: propertyNode.keyNode.length },
17934                             severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17935                             message: schema.errorMessage || localize('DisallowedExtraPropWarning', 'Property {0} is not allowed.', propertyName)
17936                         });
17937                     }
17938                 }
17939             }
17940         }
17941         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.maxProperties)) {
17942             if (node.properties.length > schema.maxProperties) {
17943                 validationResult.problems.push({
17944                     location: { offset: node.offset, length: node.length },
17945                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17946                     message: localize('MaxPropWarning', 'Object has more properties than limit of {0}.', schema.maxProperties)
17947                 });
17948             }
17949         }
17950         if (Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(schema.minProperties)) {
17951             if (node.properties.length < schema.minProperties) {
17952                 validationResult.problems.push({
17953                     location: { offset: node.offset, length: node.length },
17954                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17955                     message: localize('MinPropWarning', 'Object has fewer properties than the required number of {0}', schema.minProperties)
17956                 });
17957             }
17958         }
17959         if (schema.dependencies) {
17960             for (var _m = 0, _o = Object.keys(schema.dependencies); _m < _o.length; _m++) {
17961                 var key = _o[_m];
17962                 var prop = seenKeys[key];
17963                 if (prop) {
17964                     var propertyDep = schema.dependencies[key];
17965                     if (Array.isArray(propertyDep)) {
17966                         for (var _p = 0, propertyDep_1 = propertyDep; _p < propertyDep_1.length; _p++) {
17967                             var requiredProp = propertyDep_1[_p];
17968                             if (!seenKeys[requiredProp]) {
17969                                 validationResult.problems.push({
17970                                     location: { offset: node.offset, length: node.length },
17971                                     severity: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning,
17972                                     message: localize('RequiredDependentPropWarning', 'Object is missing property {0} required by property {1}.', requiredProp, key)
17973                                 });
17974                             }
17975                             else {
17976                                 validationResult.propertiesValueMatches++;
17977                             }
17978                         }
17979                     }
17980                     else {
17981                         var propertySchema = asSchema(propertyDep);
17982                         if (propertySchema) {
17983                             var propertyValidationResult = new ValidationResult();
17984                             validate(node, propertySchema, propertyValidationResult, matchingSchemas);
17985                             validationResult.mergePropertyMatch(propertyValidationResult);
17986                         }
17987                     }
17988                 }
17989             }
17990         }
17991         var propertyNames = asSchema(schema.propertyNames);
17992         if (propertyNames) {
17993             for (var _q = 0, _r = node.properties; _q < _r.length; _q++) {
17994                 var f = _r[_q];
17995                 var key = f.keyNode;
17996                 if (key) {
17997                     validate(key, propertyNames, validationResult, NoOpSchemaCollector.instance);
17998                 }
17999             }
18000         }
18001     }
18002 }
18003 function parse(textDocument, config) {
18004     var problems = [];
18005     var lastProblemOffset = -1;
18006     var text = textDocument.getText();
18007     var scanner = jsonc_parser__WEBPACK_IMPORTED_MODULE_0__["createScanner"](text, false);
18008     var commentRanges = config && config.collectComments ? [] : void 0;
18009     function _scanNext() {
18010         while (true) {
18011             var token_1 = scanner.scan();
18012             _checkScanError();
18013             switch (token_1) {
18014                 case 12 /* LineCommentTrivia */:
18015                 case 13 /* BlockCommentTrivia */:
18016                     if (Array.isArray(commentRanges)) {
18017                         commentRanges.push(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["Range"].create(textDocument.positionAt(scanner.getTokenOffset()), textDocument.positionAt(scanner.getTokenOffset() + scanner.getTokenLength())));
18018                     }
18019                     break;
18020                 case 15 /* Trivia */:
18021                 case 14 /* LineBreakTrivia */:
18022                     break;
18023                 default:
18024                     return token_1;
18025             }
18026         }
18027     }
18028     function _accept(token) {
18029         if (scanner.getToken() === token) {
18030             _scanNext();
18031             return true;
18032         }
18033         return false;
18034     }
18035     function _errorAtRange(message, code, startOffset, endOffset, severity) {
18036         if (severity === void 0) { severity = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Error; }
18037         if (problems.length === 0 || startOffset !== lastProblemOffset) {
18038             var range = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["Range"].create(textDocument.positionAt(startOffset), textDocument.positionAt(endOffset));
18039             problems.push(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["Diagnostic"].create(range, message, severity, code, textDocument.languageId));
18040             lastProblemOffset = startOffset;
18041         }
18042     }
18043     function _error(message, code, node, skipUntilAfter, skipUntil) {
18044         if (node === void 0) { node = null; }
18045         if (skipUntilAfter === void 0) { skipUntilAfter = []; }
18046         if (skipUntil === void 0) { skipUntil = []; }
18047         var start = scanner.getTokenOffset();
18048         var end = scanner.getTokenOffset() + scanner.getTokenLength();
18049         if (start === end && start > 0) {
18050             start--;
18051             while (start > 0 && /\s/.test(text.charAt(start))) {
18052                 start--;
18053             }
18054             end = start + 1;
18055         }
18056         _errorAtRange(message, code, start, end);
18057         if (node) {
18058             _finalize(node, false);
18059         }
18060         if (skipUntilAfter.length + skipUntil.length > 0) {
18061             var token_2 = scanner.getToken();
18062             while (token_2 !== 17 /* EOF */) {
18063                 if (skipUntilAfter.indexOf(token_2) !== -1) {
18064                     _scanNext();
18065                     break;
18066                 }
18067                 else if (skipUntil.indexOf(token_2) !== -1) {
18068                     break;
18069                 }
18070                 token_2 = _scanNext();
18071             }
18072         }
18073         return node;
18074     }
18075     function _checkScanError() {
18076         switch (scanner.getTokenError()) {
18077             case 4 /* InvalidUnicode */:
18078                 _error(localize('InvalidUnicode', 'Invalid unicode sequence in string.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].InvalidUnicode);
18079                 return true;
18080             case 5 /* InvalidEscapeCharacter */:
18081                 _error(localize('InvalidEscapeCharacter', 'Invalid escape character in string.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].InvalidEscapeCharacter);
18082                 return true;
18083             case 3 /* UnexpectedEndOfNumber */:
18084                 _error(localize('UnexpectedEndOfNumber', 'Unexpected end of number.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].UnexpectedEndOfNumber);
18085                 return true;
18086             case 1 /* UnexpectedEndOfComment */:
18087                 _error(localize('UnexpectedEndOfComment', 'Unexpected end of comment.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].UnexpectedEndOfComment);
18088                 return true;
18089             case 2 /* UnexpectedEndOfString */:
18090                 _error(localize('UnexpectedEndOfString', 'Unexpected end of string.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].UnexpectedEndOfString);
18091                 return true;
18092             case 6 /* InvalidCharacter */:
18093                 _error(localize('InvalidCharacter', 'Invalid characters in string. Control characters must be escaped.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].InvalidCharacter);
18094                 return true;
18095         }
18096         return false;
18097     }
18098     function _finalize(node, scanNext) {
18099         node.length = scanner.getTokenOffset() + scanner.getTokenLength() - node.offset;
18100         if (scanNext) {
18101             _scanNext();
18102         }
18103         return node;
18104     }
18105     function _parseArray(parent) {
18106         if (scanner.getToken() !== 3 /* OpenBracketToken */) {
18107             return null;
18108         }
18109         var node = new ArrayASTNodeImpl(parent, scanner.getTokenOffset());
18110         _scanNext(); // consume OpenBracketToken
18111         var count = 0;
18112         var needsComma = false;
18113         while (scanner.getToken() !== 4 /* CloseBracketToken */ && scanner.getToken() !== 17 /* EOF */) {
18114             if (scanner.getToken() === 5 /* CommaToken */) {
18115                 if (!needsComma) {
18116                     _error(localize('ValueExpected', 'Value expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].ValueExpected);
18117                 }
18118                 var commaOffset = scanner.getTokenOffset();
18119                 _scanNext(); // consume comma
18120                 if (scanner.getToken() === 4 /* CloseBracketToken */) {
18121                     if (needsComma) {
18122                         _errorAtRange(localize('TrailingComma', 'Trailing comma'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].TrailingComma, commaOffset, commaOffset + 1);
18123                     }
18124                     continue;
18125                 }
18126             }
18127             else if (needsComma) {
18128                 _error(localize('ExpectedComma', 'Expected comma'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].CommaExpected);
18129             }
18130             var item = _parseValue(node, count++);
18131             if (!item) {
18132                 _error(localize('PropertyExpected', 'Value expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].ValueExpected, null, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]);
18133             }
18134             else {
18135                 node.items.push(item);
18136             }
18137             needsComma = true;
18138         }
18139         if (scanner.getToken() !== 4 /* CloseBracketToken */) {
18140             return _error(localize('ExpectedCloseBracket', 'Expected comma or closing bracket'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].CommaOrCloseBacketExpected, node);
18141         }
18142         return _finalize(node, true);
18143     }
18144     function _parseProperty(parent, keysSeen) {
18145         var node = new PropertyASTNodeImpl(parent, scanner.getTokenOffset());
18146         var key = _parseString(node);
18147         if (!key) {
18148             if (scanner.getToken() === 16 /* Unknown */) {
18149                 // give a more helpful error message
18150                 _error(localize('DoubleQuotesExpected', 'Property keys must be doublequoted'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].Undefined);
18151                 var keyNode = new StringASTNodeImpl(node, scanner.getTokenOffset(), scanner.getTokenLength());
18152                 keyNode.value = scanner.getTokenValue();
18153                 key = keyNode;
18154                 _scanNext(); // consume Unknown
18155             }
18156             else {
18157                 return null;
18158             }
18159         }
18160         node.keyNode = key;
18161         var seen = keysSeen[key.value];
18162         if (seen) {
18163             _errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].DuplicateKey, node.keyNode.offset, node.keyNode.offset + node.keyNode.length, vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning);
18164             if (typeof seen === 'object') {
18165                 _errorAtRange(localize('DuplicateKeyWarning', "Duplicate object key"), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].DuplicateKey, seen.keyNode.offset, seen.keyNode.offset + seen.keyNode.length, vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_4__["DiagnosticSeverity"].Warning);
18166             }
18167             keysSeen[key.value] = true; // if the same key is duplicate again, avoid duplicate error reporting
18168         }
18169         else {
18170             keysSeen[key.value] = node;
18171         }
18172         if (scanner.getToken() === 6 /* ColonToken */) {
18173             node.colonOffset = scanner.getTokenOffset();
18174             _scanNext(); // consume ColonToken
18175         }
18176         else {
18177             _error(localize('ColonExpected', 'Colon expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].ColonExpected);
18178             if (scanner.getToken() === 10 /* StringLiteral */ && textDocument.positionAt(key.offset + key.length).line < textDocument.positionAt(scanner.getTokenOffset()).line) {
18179                 node.length = key.length;
18180                 return node;
18181             }
18182         }
18183         var value = _parseValue(node, key.value);
18184         if (!value) {
18185             return _error(localize('ValueExpected', 'Value expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].ValueExpected, node, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
18186         }
18187         node.valueNode = value;
18188         node.length = value.offset + value.length - node.offset;
18189         return node;
18190     }
18191     function _parseObject(parent) {
18192         if (scanner.getToken() !== 1 /* OpenBraceToken */) {
18193             return null;
18194         }
18195         var node = new ObjectASTNodeImpl(parent, scanner.getTokenOffset());
18196         var keysSeen = Object.create(null);
18197         _scanNext(); // consume OpenBraceToken
18198         var needsComma = false;
18199         while (scanner.getToken() !== 2 /* CloseBraceToken */ && scanner.getToken() !== 17 /* EOF */) {
18200             if (scanner.getToken() === 5 /* CommaToken */) {
18201                 if (!needsComma) {
18202                     _error(localize('PropertyExpected', 'Property expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].PropertyExpected);
18203                 }
18204                 var commaOffset = scanner.getTokenOffset();
18205                 _scanNext(); // consume comma
18206                 if (scanner.getToken() === 2 /* CloseBraceToken */) {
18207                     if (needsComma) {
18208                         _errorAtRange(localize('TrailingComma', 'Trailing comma'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].TrailingComma, commaOffset, commaOffset + 1);
18209                     }
18210                     continue;
18211                 }
18212             }
18213             else if (needsComma) {
18214                 _error(localize('ExpectedComma', 'Expected comma'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].CommaExpected);
18215             }
18216             var property = _parseProperty(node, keysSeen);
18217             if (!property) {
18218                 _error(localize('PropertyExpected', 'Property expected'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].PropertyExpected, null, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
18219             }
18220             else {
18221                 node.properties.push(property);
18222             }
18223             needsComma = true;
18224         }
18225         if (scanner.getToken() !== 2 /* CloseBraceToken */) {
18226             return _error(localize('ExpectedCloseBrace', 'Expected comma or closing brace'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].CommaOrCloseBraceExpected, node);
18227         }
18228         return _finalize(node, true);
18229     }
18230     function _parseString(parent) {
18231         if (scanner.getToken() !== 10 /* StringLiteral */) {
18232             return null;
18233         }
18234         var node = new StringASTNodeImpl(parent, scanner.getTokenOffset());
18235         node.value = scanner.getTokenValue();
18236         return _finalize(node, true);
18237     }
18238     function _parseNumber(parent) {
18239         if (scanner.getToken() !== 11 /* NumericLiteral */) {
18240             return null;
18241         }
18242         var node = new NumberASTNodeImpl(parent, scanner.getTokenOffset());
18243         if (scanner.getTokenError() === 0 /* None */) {
18244             var tokenValue = scanner.getTokenValue();
18245             try {
18246                 var numberValue = JSON.parse(tokenValue);
18247                 if (!Object(_utils_objects__WEBPACK_IMPORTED_MODULE_1__["isNumber"])(numberValue)) {
18248                     return _error(localize('InvalidNumberFormat', 'Invalid number format.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].Undefined, node);
18249                 }
18250                 node.value = numberValue;
18251             }
18252             catch (e) {
18253                 return _error(localize('InvalidNumberFormat', 'Invalid number format.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].Undefined, node);
18254             }
18255             node.isInteger = tokenValue.indexOf('.') === -1;
18256         }
18257         return _finalize(node, true);
18258     }
18259     function _parseLiteral(parent) {
18260         var node;
18261         switch (scanner.getToken()) {
18262             case 7 /* NullKeyword */:
18263                 return _finalize(new NullASTNodeImpl(parent, scanner.getTokenOffset()), true);
18264             case 8 /* TrueKeyword */:
18265                 return _finalize(new BooleanASTNodeImpl(parent, true, scanner.getTokenOffset()), true);
18266             case 9 /* FalseKeyword */:
18267                 return _finalize(new BooleanASTNodeImpl(parent, false, scanner.getTokenOffset()), true);
18268             default:
18269                 return null;
18270         }
18271     }
18272     function _parseValue(parent, name) {
18273         return _parseArray(parent) || _parseObject(parent) || _parseString(parent) || _parseNumber(parent) || _parseLiteral(parent);
18274     }
18275     var _root = null;
18276     var token = _scanNext();
18277     if (token !== 17 /* EOF */) {
18278         _root = _parseValue(null, null);
18279         if (!_root) {
18280             _error(localize('Invalid symbol', 'Expected a JSON object, array or literal.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].Undefined);
18281         }
18282         else if (scanner.getToken() !== 17 /* EOF */) {
18283             _error(localize('End of file expected', 'End of file expected.'), _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].Undefined);
18284         }
18285     }
18286     return new JSONDocument(_root, problems, commentRanges);
18287 }
18288
18289
18290 /***/ }),
18291 /* 83 */
18292 /***/ (function(module, __webpack_exports__, __webpack_require__) {
18293
18294 "use strict";
18295 __webpack_require__.r(__webpack_exports__);
18296 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createScanner", function() { return createScanner; });
18297 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocation", function() { return getLocation; });
18298 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return parse; });
18299 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseTree", function() { return parseTree; });
18300 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNodeAtLocation", function() { return findNodeAtLocation; });
18301 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNodeAtOffset", function() { return findNodeAtOffset; });
18302 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodePath", function() { return getNodePath; });
18303 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodeValue", function() { return getNodeValue; });
18304 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "visit", function() { return visit; });
18305 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripComments", function() { return stripComments; });
18306 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "printParseErrorCode", function() { return printParseErrorCode; });
18307 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "format", function() { return format; });
18308 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "modify", function() { return modify; });
18309 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyEdits", function() { return applyEdits; });
18310 /* harmony import */ var _impl_format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(84);
18311 /* harmony import */ var _impl_edit__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(86);
18312 /* harmony import */ var _impl_scanner__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(85);
18313 /* harmony import */ var _impl_parser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(87);
18314 /*---------------------------------------------------------------------------------------------
18315  *  Copyright (c) Microsoft Corporation. All rights reserved.
18316  *  Licensed under the MIT License. See License.txt in the project root for license information.
18317  *--------------------------------------------------------------------------------------------*/
18318
18319
18320
18321
18322
18323 /**
18324  * Creates a JSON scanner on the given text.
18325  * If ignoreTrivia is set, whitespaces or comments are ignored.
18326  */
18327 var createScanner = _impl_scanner__WEBPACK_IMPORTED_MODULE_2__["createScanner"];
18328 /**
18329  * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
18330  */
18331 var getLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["getLocation"];
18332 /**
18333  * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
18334  * Therefore, always check the errors list to find out if the input was valid.
18335  */
18336 var parse = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["parse"];
18337 /**
18338  * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
18339  */
18340 var parseTree = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["parseTree"];
18341 /**
18342  * Finds the node at the given path in a JSON DOM.
18343  */
18344 var findNodeAtLocation = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["findNodeAtLocation"];
18345 /**
18346  * Finds the innermost node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
18347  */
18348 var findNodeAtOffset = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["findNodeAtOffset"];
18349 /**
18350  * Gets the JSON path of the given JSON DOM node
18351  */
18352 var getNodePath = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["getNodePath"];
18353 /**
18354  * Evaluates the JavaScript object of the given JSON DOM node
18355  */
18356 var getNodeValue = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["getNodeValue"];
18357 /**
18358  * Parses the given text and invokes the visitor functions for each object, array and literal reached.
18359  */
18360 var visit = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["visit"];
18361 /**
18362  * Takes JSON with JavaScript-style comments and remove
18363  * them. Optionally replaces every none-newline character
18364  * of comments with a replaceCharacter
18365  */
18366 var stripComments = _impl_parser__WEBPACK_IMPORTED_MODULE_3__["stripComments"];
18367 function printParseErrorCode(code) {
18368     switch (code) {
18369         case 1 /* InvalidSymbol */: return 'InvalidSymbol';
18370         case 2 /* InvalidNumberFormat */: return 'InvalidNumberFormat';
18371         case 3 /* PropertyNameExpected */: return 'PropertyNameExpected';
18372         case 4 /* ValueExpected */: return 'ValueExpected';
18373         case 5 /* ColonExpected */: return 'ColonExpected';
18374         case 6 /* CommaExpected */: return 'CommaExpected';
18375         case 7 /* CloseBraceExpected */: return 'CloseBraceExpected';
18376         case 8 /* CloseBracketExpected */: return 'CloseBracketExpected';
18377         case 9 /* EndOfFileExpected */: return 'EndOfFileExpected';
18378         case 10 /* InvalidCommentToken */: return 'InvalidCommentToken';
18379         case 11 /* UnexpectedEndOfComment */: return 'UnexpectedEndOfComment';
18380         case 12 /* UnexpectedEndOfString */: return 'UnexpectedEndOfString';
18381         case 13 /* UnexpectedEndOfNumber */: return 'UnexpectedEndOfNumber';
18382         case 14 /* InvalidUnicode */: return 'InvalidUnicode';
18383         case 15 /* InvalidEscapeCharacter */: return 'InvalidEscapeCharacter';
18384         case 16 /* InvalidCharacter */: return 'InvalidCharacter';
18385     }
18386     return '<unknown ParseErrorCode>';
18387 }
18388 /**
18389  * Computes the edits needed to format a JSON document.
18390  *
18391  * @param documentText The input text
18392  * @param range The range to format or `undefined` to format the full content
18393  * @param options The formatting options
18394  * @returns A list of edit operations describing the formatting changes to the original document. Edits can be either inserts, replacements or
18395  * removals of text segments. All offsets refer to the original state of the document. No two edits must change or remove the same range of
18396  * text in the original document. However, multiple edits can have
18397  * the same offset, for example multiple inserts, or an insert followed by a remove or replace. The order in the array defines which edit is applied first.
18398  * To apply edits to an input, you can use `applyEdits`.
18399  */
18400 function format(documentText, range, options) {
18401     return _impl_format__WEBPACK_IMPORTED_MODULE_0__["format"](documentText, range, options);
18402 }
18403 /**
18404  * Computes the edits needed to modify a value in the JSON document.
18405  *
18406  * @param documentText The input text
18407  * @param path The path of the value to change. The path represents either to the document root, a property or an array item.
18408  * If the path points to an non-existing property or item, it will be created.
18409  * @param value The new value for the specified property or item. If the value is undefined,
18410  * the property or item will be removed.
18411  * @param options Options
18412  * @returns A list of edit operations describing the formatting changes to the original document. Edits can be either inserts, replacements or
18413  * removals of text segments. All offsets refer to the original state of the document. No two edits must change or remove the same range of
18414  * text in the original document. However, multiple edits can have
18415  * the same offset, for example multiple inserts, or an insert followed by a remove or replace. The order in the array defines which edit is applied first.
18416  * To apply edits to an input, you can use `applyEdits`.
18417  */
18418 function modify(text, path, value, options) {
18419     return _impl_edit__WEBPACK_IMPORTED_MODULE_1__["setProperty"](text, path, value, options.formattingOptions, options.getInsertionIndex);
18420 }
18421 /**
18422  * Applies edits to a input string.
18423  */
18424 function applyEdits(text, edits) {
18425     for (var i = edits.length - 1; i >= 0; i--) {
18426         text = _impl_edit__WEBPACK_IMPORTED_MODULE_1__["applyEdit"](text, edits[i]);
18427     }
18428     return text;
18429 }
18430 //# sourceMappingURL=main.js.map
18431
18432 /***/ }),
18433 /* 84 */
18434 /***/ (function(module, __webpack_exports__, __webpack_require__) {
18435
18436 "use strict";
18437 __webpack_require__.r(__webpack_exports__);
18438 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "format", function() { return format; });
18439 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isEOL", function() { return isEOL; });
18440 /* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(85);
18441 /*---------------------------------------------------------------------------------------------
18442  *  Copyright (c) Microsoft Corporation. All rights reserved.
18443  *  Licensed under the MIT License. See License.txt in the project root for license information.
18444  *--------------------------------------------------------------------------------------------*/
18445
18446
18447 function format(documentText, range, options) {
18448     var initialIndentLevel;
18449     var formatText;
18450     var formatTextStart;
18451     var rangeStart;
18452     var rangeEnd;
18453     if (range) {
18454         rangeStart = range.offset;
18455         rangeEnd = rangeStart + range.length;
18456         formatTextStart = rangeStart;
18457         while (formatTextStart > 0 && !isEOL(documentText, formatTextStart - 1)) {
18458             formatTextStart--;
18459         }
18460         var endOffset = rangeEnd;
18461         while (endOffset < documentText.length && !isEOL(documentText, endOffset)) {
18462             endOffset++;
18463         }
18464         formatText = documentText.substring(formatTextStart, endOffset);
18465         initialIndentLevel = computeIndentLevel(formatText, options);
18466     }
18467     else {
18468         formatText = documentText;
18469         initialIndentLevel = 0;
18470         formatTextStart = 0;
18471         rangeStart = 0;
18472         rangeEnd = documentText.length;
18473     }
18474     var eol = getEOL(options, documentText);
18475     var lineBreak = false;
18476     var indentLevel = 0;
18477     var indentValue;
18478     if (options.insertSpaces) {
18479         indentValue = repeat(' ', options.tabSize || 4);
18480     }
18481     else {
18482         indentValue = '\t';
18483     }
18484     var scanner = Object(_scanner__WEBPACK_IMPORTED_MODULE_0__["createScanner"])(formatText, false);
18485     var hasError = false;
18486     function newLineAndIndent() {
18487         return eol + repeat(indentValue, initialIndentLevel + indentLevel);
18488     }
18489     function scanNext() {
18490         var token = scanner.scan();
18491         lineBreak = false;
18492         while (token === 15 /* Trivia */ || token === 14 /* LineBreakTrivia */) {
18493             lineBreak = lineBreak || (token === 14 /* LineBreakTrivia */);
18494             token = scanner.scan();
18495         }
18496         hasError = token === 16 /* Unknown */ || scanner.getTokenError() !== 0 /* None */;
18497         return token;
18498     }
18499     var editOperations = [];
18500     function addEdit(text, startOffset, endOffset) {
18501         if (!hasError && startOffset < rangeEnd && endOffset > rangeStart && documentText.substring(startOffset, endOffset) !== text) {
18502             editOperations.push({ offset: startOffset, length: endOffset - startOffset, content: text });
18503         }
18504     }
18505     var firstToken = scanNext();
18506     if (firstToken !== 17 /* EOF */) {
18507         var firstTokenStart = scanner.getTokenOffset() + formatTextStart;
18508         var initialIndent = repeat(indentValue, initialIndentLevel);
18509         addEdit(initialIndent, formatTextStart, firstTokenStart);
18510     }
18511     while (firstToken !== 17 /* EOF */) {
18512         var firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
18513         var secondToken = scanNext();
18514         var replaceContent = '';
18515         while (!lineBreak && (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */)) {
18516             // comments on the same line: keep them on the same line, but ignore them otherwise
18517             var commentTokenStart = scanner.getTokenOffset() + formatTextStart;
18518             addEdit(' ', firstTokenEnd, commentTokenStart);
18519             firstTokenEnd = scanner.getTokenOffset() + scanner.getTokenLength() + formatTextStart;
18520             replaceContent = secondToken === 12 /* LineCommentTrivia */ ? newLineAndIndent() : '';
18521             secondToken = scanNext();
18522         }
18523         if (secondToken === 2 /* CloseBraceToken */) {
18524             if (firstToken !== 1 /* OpenBraceToken */) {
18525                 indentLevel--;
18526                 replaceContent = newLineAndIndent();
18527             }
18528         }
18529         else if (secondToken === 4 /* CloseBracketToken */) {
18530             if (firstToken !== 3 /* OpenBracketToken */) {
18531                 indentLevel--;
18532                 replaceContent = newLineAndIndent();
18533             }
18534         }
18535         else {
18536             switch (firstToken) {
18537                 case 3 /* OpenBracketToken */:
18538                 case 1 /* OpenBraceToken */:
18539                     indentLevel++;
18540                     replaceContent = newLineAndIndent();
18541                     break;
18542                 case 5 /* CommaToken */:
18543                 case 12 /* LineCommentTrivia */:
18544                     replaceContent = newLineAndIndent();
18545                     break;
18546                 case 13 /* BlockCommentTrivia */:
18547                     if (lineBreak) {
18548                         replaceContent = newLineAndIndent();
18549                     }
18550                     else {
18551                         // symbol following comment on the same line: keep on same line, separate with ' '
18552                         replaceContent = ' ';
18553                     }
18554                     break;
18555                 case 6 /* ColonToken */:
18556                     replaceContent = ' ';
18557                     break;
18558                 case 10 /* StringLiteral */:
18559                     if (secondToken === 6 /* ColonToken */) {
18560                         replaceContent = '';
18561                         break;
18562                     }
18563                 // fall through
18564                 case 7 /* NullKeyword */:
18565                 case 8 /* TrueKeyword */:
18566                 case 9 /* FalseKeyword */:
18567                 case 11 /* NumericLiteral */:
18568                 case 2 /* CloseBraceToken */:
18569                 case 4 /* CloseBracketToken */:
18570                     if (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */) {
18571                         replaceContent = ' ';
18572                     }
18573                     else if (secondToken !== 5 /* CommaToken */ && secondToken !== 17 /* EOF */) {
18574                         hasError = true;
18575                     }
18576                     break;
18577                 case 16 /* Unknown */:
18578                     hasError = true;
18579                     break;
18580             }
18581             if (lineBreak && (secondToken === 12 /* LineCommentTrivia */ || secondToken === 13 /* BlockCommentTrivia */)) {
18582                 replaceContent = newLineAndIndent();
18583             }
18584         }
18585         var secondTokenStart = scanner.getTokenOffset() + formatTextStart;
18586         addEdit(replaceContent, firstTokenEnd, secondTokenStart);
18587         firstToken = secondToken;
18588     }
18589     return editOperations;
18590 }
18591 function repeat(s, count) {
18592     var result = '';
18593     for (var i = 0; i < count; i++) {
18594         result += s;
18595     }
18596     return result;
18597 }
18598 function computeIndentLevel(content, options) {
18599     var i = 0;
18600     var nChars = 0;
18601     var tabSize = options.tabSize || 4;
18602     while (i < content.length) {
18603         var ch = content.charAt(i);
18604         if (ch === ' ') {
18605             nChars++;
18606         }
18607         else if (ch === '\t') {
18608             nChars += tabSize;
18609         }
18610         else {
18611             break;
18612         }
18613         i++;
18614     }
18615     return Math.floor(nChars / tabSize);
18616 }
18617 function getEOL(options, text) {
18618     for (var i = 0; i < text.length; i++) {
18619         var ch = text.charAt(i);
18620         if (ch === '\r') {
18621             if (i + 1 < text.length && text.charAt(i + 1) === '\n') {
18622                 return '\r\n';
18623             }
18624             return '\r';
18625         }
18626         else if (ch === '\n') {
18627             return '\n';
18628         }
18629     }
18630     return (options && options.eol) || '\n';
18631 }
18632 function isEOL(text, offset) {
18633     return '\r\n'.indexOf(text.charAt(offset)) !== -1;
18634 }
18635 //# sourceMappingURL=format.js.map
18636
18637 /***/ }),
18638 /* 85 */
18639 /***/ (function(module, __webpack_exports__, __webpack_require__) {
18640
18641 "use strict";
18642 __webpack_require__.r(__webpack_exports__);
18643 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createScanner", function() { return createScanner; });
18644 /*---------------------------------------------------------------------------------------------
18645  *  Copyright (c) Microsoft Corporation. All rights reserved.
18646  *  Licensed under the MIT License. See License.txt in the project root for license information.
18647  *--------------------------------------------------------------------------------------------*/
18648
18649 /**
18650  * Creates a JSON scanner on the given text.
18651  * If ignoreTrivia is set, whitespaces or comments are ignored.
18652  */
18653 function createScanner(text, ignoreTrivia) {
18654     if (ignoreTrivia === void 0) { ignoreTrivia = false; }
18655     var pos = 0, len = text.length, value = '', tokenOffset = 0, token = 16 /* Unknown */, lineNumber = 0, lineStartOffset = 0, tokenLineStartOffset = 0, prevTokenLineStartOffset = 0, scanError = 0 /* None */;
18656     function scanHexDigits(count, exact) {
18657         var digits = 0;
18658         var value = 0;
18659         while (digits < count || !exact) {
18660             var ch = text.charCodeAt(pos);
18661             if (ch >= 48 /* _0 */ && ch <= 57 /* _9 */) {
18662                 value = value * 16 + ch - 48 /* _0 */;
18663             }
18664             else if (ch >= 65 /* A */ && ch <= 70 /* F */) {
18665                 value = value * 16 + ch - 65 /* A */ + 10;
18666             }
18667             else if (ch >= 97 /* a */ && ch <= 102 /* f */) {
18668                 value = value * 16 + ch - 97 /* a */ + 10;
18669             }
18670             else {
18671                 break;
18672             }
18673             pos++;
18674             digits++;
18675         }
18676         if (digits < count) {
18677             value = -1;
18678         }
18679         return value;
18680     }
18681     function setPosition(newPosition) {
18682         pos = newPosition;
18683         value = '';
18684         tokenOffset = 0;
18685         token = 16 /* Unknown */;
18686         scanError = 0 /* None */;
18687     }
18688     function scanNumber() {
18689         var start = pos;
18690         if (text.charCodeAt(pos) === 48 /* _0 */) {
18691             pos++;
18692         }
18693         else {
18694             pos++;
18695             while (pos < text.length && isDigit(text.charCodeAt(pos))) {
18696                 pos++;
18697             }
18698         }
18699         if (pos < text.length && text.charCodeAt(pos) === 46 /* dot */) {
18700             pos++;
18701             if (pos < text.length && isDigit(text.charCodeAt(pos))) {
18702                 pos++;
18703                 while (pos < text.length && isDigit(text.charCodeAt(pos))) {
18704                     pos++;
18705                 }
18706             }
18707             else {
18708                 scanError = 3 /* UnexpectedEndOfNumber */;
18709                 return text.substring(start, pos);
18710             }
18711         }
18712         var end = pos;
18713         if (pos < text.length && (text.charCodeAt(pos) === 69 /* E */ || text.charCodeAt(pos) === 101 /* e */)) {
18714             pos++;
18715             if (pos < text.length && text.charCodeAt(pos) === 43 /* plus */ || text.charCodeAt(pos) === 45 /* minus */) {
18716                 pos++;
18717             }
18718             if (pos < text.length && isDigit(text.charCodeAt(pos))) {
18719                 pos++;
18720                 while (pos < text.length && isDigit(text.charCodeAt(pos))) {
18721                     pos++;
18722                 }
18723                 end = pos;
18724             }
18725             else {
18726                 scanError = 3 /* UnexpectedEndOfNumber */;
18727             }
18728         }
18729         return text.substring(start, end);
18730     }
18731     function scanString() {
18732         var result = '', start = pos;
18733         while (true) {
18734             if (pos >= len) {
18735                 result += text.substring(start, pos);
18736                 scanError = 2 /* UnexpectedEndOfString */;
18737                 break;
18738             }
18739             var ch = text.charCodeAt(pos);
18740             if (ch === 34 /* doubleQuote */) {
18741                 result += text.substring(start, pos);
18742                 pos++;
18743                 break;
18744             }
18745             if (ch === 92 /* backslash */) {
18746                 result += text.substring(start, pos);
18747                 pos++;
18748                 if (pos >= len) {
18749                     scanError = 2 /* UnexpectedEndOfString */;
18750                     break;
18751                 }
18752                 ch = text.charCodeAt(pos++);
18753                 switch (ch) {
18754                     case 34 /* doubleQuote */:
18755                         result += '\"';
18756                         break;
18757                     case 92 /* backslash */:
18758                         result += '\\';
18759                         break;
18760                     case 47 /* slash */:
18761                         result += '/';
18762                         break;
18763                     case 98 /* b */:
18764                         result += '\b';
18765                         break;
18766                     case 102 /* f */:
18767                         result += '\f';
18768                         break;
18769                     case 110 /* n */:
18770                         result += '\n';
18771                         break;
18772                     case 114 /* r */:
18773                         result += '\r';
18774                         break;
18775                     case 116 /* t */:
18776                         result += '\t';
18777                         break;
18778                     case 117 /* u */:
18779                         var ch_1 = scanHexDigits(4, true);
18780                         if (ch_1 >= 0) {
18781                             result += String.fromCharCode(ch_1);
18782                         }
18783                         else {
18784                             scanError = 4 /* InvalidUnicode */;
18785                         }
18786                         break;
18787                     default:
18788                         scanError = 5 /* InvalidEscapeCharacter */;
18789                 }
18790                 start = pos;
18791                 continue;
18792             }
18793             if (ch >= 0 && ch <= 0x1f) {
18794                 if (isLineBreak(ch)) {
18795                     result += text.substring(start, pos);
18796                     scanError = 2 /* UnexpectedEndOfString */;
18797                     break;
18798                 }
18799                 else {
18800                     scanError = 6 /* InvalidCharacter */;
18801                     // mark as error but continue with string
18802                 }
18803             }
18804             pos++;
18805         }
18806         return result;
18807     }
18808     function scanNext() {
18809         value = '';
18810         scanError = 0 /* None */;
18811         tokenOffset = pos;
18812         lineStartOffset = lineNumber;
18813         prevTokenLineStartOffset = tokenLineStartOffset;
18814         if (pos >= len) {
18815             // at the end
18816             tokenOffset = len;
18817             return token = 17 /* EOF */;
18818         }
18819         var code = text.charCodeAt(pos);
18820         // trivia: whitespace
18821         if (isWhiteSpace(code)) {
18822             do {
18823                 pos++;
18824                 value += String.fromCharCode(code);
18825                 code = text.charCodeAt(pos);
18826             } while (isWhiteSpace(code));
18827             return token = 15 /* Trivia */;
18828         }
18829         // trivia: newlines
18830         if (isLineBreak(code)) {
18831             pos++;
18832             value += String.fromCharCode(code);
18833             if (code === 13 /* carriageReturn */ && text.charCodeAt(pos) === 10 /* lineFeed */) {
18834                 pos++;
18835                 value += '\n';
18836             }
18837             lineNumber++;
18838             tokenLineStartOffset = pos;
18839             return token = 14 /* LineBreakTrivia */;
18840         }
18841         switch (code) {
18842             // tokens: []{}:,
18843             case 123 /* openBrace */:
18844                 pos++;
18845                 return token = 1 /* OpenBraceToken */;
18846             case 125 /* closeBrace */:
18847                 pos++;
18848                 return token = 2 /* CloseBraceToken */;
18849             case 91 /* openBracket */:
18850                 pos++;
18851                 return token = 3 /* OpenBracketToken */;
18852             case 93 /* closeBracket */:
18853                 pos++;
18854                 return token = 4 /* CloseBracketToken */;
18855             case 58 /* colon */:
18856                 pos++;
18857                 return token = 6 /* ColonToken */;
18858             case 44 /* comma */:
18859                 pos++;
18860                 return token = 5 /* CommaToken */;
18861             // strings
18862             case 34 /* doubleQuote */:
18863                 pos++;
18864                 value = scanString();
18865                 return token = 10 /* StringLiteral */;
18866             // comments
18867             case 47 /* slash */:
18868                 var start = pos - 1;
18869                 // Single-line comment
18870                 if (text.charCodeAt(pos + 1) === 47 /* slash */) {
18871                     pos += 2;
18872                     while (pos < len) {
18873                         if (isLineBreak(text.charCodeAt(pos))) {
18874                             break;
18875                         }
18876                         pos++;
18877                     }
18878                     value = text.substring(start, pos);
18879                     return token = 12 /* LineCommentTrivia */;
18880                 }
18881                 // Multi-line comment
18882                 if (text.charCodeAt(pos + 1) === 42 /* asterisk */) {
18883                     pos += 2;
18884                     var safeLength = len - 1; // For lookahead.
18885                     var commentClosed = false;
18886                     while (pos < safeLength) {
18887                         var ch = text.charCodeAt(pos);
18888                         if (ch === 42 /* asterisk */ && text.charCodeAt(pos + 1) === 47 /* slash */) {
18889                             pos += 2;
18890                             commentClosed = true;
18891                             break;
18892                         }
18893                         pos++;
18894                         if (isLineBreak(ch)) {
18895                             if (ch === 13 /* carriageReturn */ && text.charCodeAt(pos) === 10 /* lineFeed */) {
18896                                 pos++;
18897                             }
18898                             lineNumber++;
18899                             tokenLineStartOffset = pos;
18900                         }
18901                     }
18902                     if (!commentClosed) {
18903                         pos++;
18904                         scanError = 1 /* UnexpectedEndOfComment */;
18905                     }
18906                     value = text.substring(start, pos);
18907                     return token = 13 /* BlockCommentTrivia */;
18908                 }
18909                 // just a single slash
18910                 value += String.fromCharCode(code);
18911                 pos++;
18912                 return token = 16 /* Unknown */;
18913             // numbers
18914             case 45 /* minus */:
18915                 value += String.fromCharCode(code);
18916                 pos++;
18917                 if (pos === len || !isDigit(text.charCodeAt(pos))) {
18918                     return token = 16 /* Unknown */;
18919                 }
18920             // found a minus, followed by a number so
18921             // we fall through to proceed with scanning
18922             // numbers
18923             case 48 /* _0 */:
18924             case 49 /* _1 */:
18925             case 50 /* _2 */:
18926             case 51 /* _3 */:
18927             case 52 /* _4 */:
18928             case 53 /* _5 */:
18929             case 54 /* _6 */:
18930             case 55 /* _7 */:
18931             case 56 /* _8 */:
18932             case 57 /* _9 */:
18933                 value += scanNumber();
18934                 return token = 11 /* NumericLiteral */;
18935             // literals and unknown symbols
18936             default:
18937                 // is a literal? Read the full word.
18938                 while (pos < len && isUnknownContentCharacter(code)) {
18939                     pos++;
18940                     code = text.charCodeAt(pos);
18941                 }
18942                 if (tokenOffset !== pos) {
18943                     value = text.substring(tokenOffset, pos);
18944                     // keywords: true, false, null
18945                     switch (value) {
18946                         case 'true': return token = 8 /* TrueKeyword */;
18947                         case 'false': return token = 9 /* FalseKeyword */;
18948                         case 'null': return token = 7 /* NullKeyword */;
18949                     }
18950                     return token = 16 /* Unknown */;
18951                 }
18952                 // some
18953                 value += String.fromCharCode(code);
18954                 pos++;
18955                 return token = 16 /* Unknown */;
18956         }
18957     }
18958     function isUnknownContentCharacter(code) {
18959         if (isWhiteSpace(code) || isLineBreak(code)) {
18960             return false;
18961         }
18962         switch (code) {
18963             case 125 /* closeBrace */:
18964             case 93 /* closeBracket */:
18965             case 123 /* openBrace */:
18966             case 91 /* openBracket */:
18967             case 34 /* doubleQuote */:
18968             case 58 /* colon */:
18969             case 44 /* comma */:
18970             case 47 /* slash */:
18971                 return false;
18972         }
18973         return true;
18974     }
18975     function scanNextNonTrivia() {
18976         var result;
18977         do {
18978             result = scanNext();
18979         } while (result >= 12 /* LineCommentTrivia */ && result <= 15 /* Trivia */);
18980         return result;
18981     }
18982     return {
18983         setPosition: setPosition,
18984         getPosition: function () { return pos; },
18985         scan: ignoreTrivia ? scanNextNonTrivia : scanNext,
18986         getToken: function () { return token; },
18987         getTokenValue: function () { return value; },
18988         getTokenOffset: function () { return tokenOffset; },
18989         getTokenLength: function () { return pos - tokenOffset; },
18990         getTokenStartLine: function () { return lineStartOffset; },
18991         getTokenStartCharacter: function () { return tokenOffset - prevTokenLineStartOffset; },
18992         getTokenError: function () { return scanError; },
18993     };
18994 }
18995 function isWhiteSpace(ch) {
18996     return ch === 32 /* space */ || ch === 9 /* tab */ || ch === 11 /* verticalTab */ || ch === 12 /* formFeed */ ||
18997         ch === 160 /* nonBreakingSpace */ || ch === 5760 /* ogham */ || ch >= 8192 /* enQuad */ && ch <= 8203 /* zeroWidthSpace */ ||
18998         ch === 8239 /* narrowNoBreakSpace */ || ch === 8287 /* mathematicalSpace */ || ch === 12288 /* ideographicSpace */ || ch === 65279 /* byteOrderMark */;
18999 }
19000 function isLineBreak(ch) {
19001     return ch === 10 /* lineFeed */ || ch === 13 /* carriageReturn */ || ch === 8232 /* lineSeparator */ || ch === 8233 /* paragraphSeparator */;
19002 }
19003 function isDigit(ch) {
19004     return ch >= 48 /* _0 */ && ch <= 57 /* _9 */;
19005 }
19006 //# sourceMappingURL=scanner.js.map
19007
19008 /***/ }),
19009 /* 86 */
19010 /***/ (function(module, __webpack_exports__, __webpack_require__) {
19011
19012 "use strict";
19013 __webpack_require__.r(__webpack_exports__);
19014 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeProperty", function() { return removeProperty; });
19015 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setProperty", function() { return setProperty; });
19016 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "applyEdit", function() { return applyEdit; });
19017 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isWS", function() { return isWS; });
19018 /* harmony import */ var _format__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(84);
19019 /* harmony import */ var _parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(87);
19020 /*---------------------------------------------------------------------------------------------
19021  *  Copyright (c) Microsoft Corporation. All rights reserved.
19022  *  Licensed under the MIT License. See License.txt in the project root for license information.
19023  *--------------------------------------------------------------------------------------------*/
19024
19025
19026
19027 function removeProperty(text, path, formattingOptions) {
19028     return setProperty(text, path, void 0, formattingOptions);
19029 }
19030 function setProperty(text, originalPath, value, formattingOptions, getInsertionIndex) {
19031     var _a;
19032     var path = originalPath.slice();
19033     var errors = [];
19034     var root = Object(_parser__WEBPACK_IMPORTED_MODULE_1__["parseTree"])(text, errors);
19035     var parent = void 0;
19036     var lastSegment = void 0;
19037     while (path.length > 0) {
19038         lastSegment = path.pop();
19039         parent = Object(_parser__WEBPACK_IMPORTED_MODULE_1__["findNodeAtLocation"])(root, path);
19040         if (parent === void 0 && value !== void 0) {
19041             if (typeof lastSegment === 'string') {
19042                 value = (_a = {}, _a[lastSegment] = value, _a);
19043             }
19044             else {
19045                 value = [value];
19046             }
19047         }
19048         else {
19049             break;
19050         }
19051     }
19052     if (!parent) {
19053         // empty document
19054         if (value === void 0) { // delete
19055             throw new Error('Can not delete in empty document');
19056         }
19057         return withFormatting(text, { offset: root ? root.offset : 0, length: root ? root.length : 0, content: JSON.stringify(value) }, formattingOptions);
19058     }
19059     else if (parent.type === 'object' && typeof lastSegment === 'string' && Array.isArray(parent.children)) {
19060         var existing = Object(_parser__WEBPACK_IMPORTED_MODULE_1__["findNodeAtLocation"])(parent, [lastSegment]);
19061         if (existing !== void 0) {
19062             if (value === void 0) { // delete
19063                 if (!existing.parent) {
19064                     throw new Error('Malformed AST');
19065                 }
19066                 var propertyIndex = parent.children.indexOf(existing.parent);
19067                 var removeBegin = void 0;
19068                 var removeEnd = existing.parent.offset + existing.parent.length;
19069                 if (propertyIndex > 0) {
19070                     // remove the comma of the previous node
19071                     var previous = parent.children[propertyIndex - 1];
19072                     removeBegin = previous.offset + previous.length;
19073                 }
19074                 else {
19075                     removeBegin = parent.offset + 1;
19076                     if (parent.children.length > 1) {
19077                         // remove the comma of the next node
19078                         var next = parent.children[1];
19079                         removeEnd = next.offset;
19080                     }
19081                 }
19082                 return withFormatting(text, { offset: removeBegin, length: removeEnd - removeBegin, content: '' }, formattingOptions);
19083             }
19084             else {
19085                 // set value of existing property
19086                 return withFormatting(text, { offset: existing.offset, length: existing.length, content: JSON.stringify(value) }, formattingOptions);
19087             }
19088         }
19089         else {
19090             if (value === void 0) { // delete
19091                 return []; // property does not exist, nothing to do
19092             }
19093             var newProperty = JSON.stringify(lastSegment) + ": " + JSON.stringify(value);
19094             var index = getInsertionIndex ? getInsertionIndex(parent.children.map(function (p) { return p.children[0].value; })) : parent.children.length;
19095             var edit = void 0;
19096             if (index > 0) {
19097                 var previous = parent.children[index - 1];
19098                 edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
19099             }
19100             else if (parent.children.length === 0) {
19101                 edit = { offset: parent.offset + 1, length: 0, content: newProperty };
19102             }
19103             else {
19104                 edit = { offset: parent.offset + 1, length: 0, content: newProperty + ',' };
19105             }
19106             return withFormatting(text, edit, formattingOptions);
19107         }
19108     }
19109     else if (parent.type === 'array' && typeof lastSegment === 'number' && Array.isArray(parent.children)) {
19110         var insertIndex = lastSegment;
19111         if (insertIndex === -1) {
19112             // Insert
19113             var newProperty = "" + JSON.stringify(value);
19114             var edit = void 0;
19115             if (parent.children.length === 0) {
19116                 edit = { offset: parent.offset + 1, length: 0, content: newProperty };
19117             }
19118             else {
19119                 var previous = parent.children[parent.children.length - 1];
19120                 edit = { offset: previous.offset + previous.length, length: 0, content: ',' + newProperty };
19121             }
19122             return withFormatting(text, edit, formattingOptions);
19123         }
19124         else {
19125             if (value === void 0 && parent.children.length >= 0) {
19126                 //Removal
19127                 var removalIndex = lastSegment;
19128                 var toRemove = parent.children[removalIndex];
19129                 var edit = void 0;
19130                 if (parent.children.length === 1) {
19131                     // only item
19132                     edit = { offset: parent.offset + 1, length: parent.length - 2, content: '' };
19133                 }
19134                 else if (parent.children.length - 1 === removalIndex) {
19135                     // last item
19136                     var previous = parent.children[removalIndex - 1];
19137                     var offset = previous.offset + previous.length;
19138                     var parentEndOffset = parent.offset + parent.length;
19139                     edit = { offset: offset, length: parentEndOffset - 2 - offset, content: '' };
19140                 }
19141                 else {
19142                     edit = { offset: toRemove.offset, length: parent.children[removalIndex + 1].offset - toRemove.offset, content: '' };
19143                 }
19144                 return withFormatting(text, edit, formattingOptions);
19145             }
19146             else {
19147                 throw new Error('Array modification not supported yet');
19148             }
19149         }
19150     }
19151     else {
19152         throw new Error("Can not add " + (typeof lastSegment !== 'number' ? 'index' : 'property') + " to parent of type " + parent.type);
19153     }
19154 }
19155 function withFormatting(text, edit, formattingOptions) {
19156     // apply the edit
19157     var newText = applyEdit(text, edit);
19158     // format the new text
19159     var begin = edit.offset;
19160     var end = edit.offset + edit.content.length;
19161     if (edit.length === 0 || edit.content.length === 0) { // insert or remove
19162         while (begin > 0 && !Object(_format__WEBPACK_IMPORTED_MODULE_0__["isEOL"])(newText, begin - 1)) {
19163             begin--;
19164         }
19165         while (end < newText.length && !Object(_format__WEBPACK_IMPORTED_MODULE_0__["isEOL"])(newText, end)) {
19166             end++;
19167         }
19168     }
19169     var edits = Object(_format__WEBPACK_IMPORTED_MODULE_0__["format"])(newText, { offset: begin, length: end - begin }, formattingOptions);
19170     // apply the formatting edits and track the begin and end offsets of the changes
19171     for (var i = edits.length - 1; i >= 0; i--) {
19172         var edit_1 = edits[i];
19173         newText = applyEdit(newText, edit_1);
19174         begin = Math.min(begin, edit_1.offset);
19175         end = Math.max(end, edit_1.offset + edit_1.length);
19176         end += edit_1.content.length - edit_1.length;
19177     }
19178     // create a single edit with all changes
19179     var editLength = text.length - (newText.length - end) - begin;
19180     return [{ offset: begin, length: editLength, content: newText.substring(begin, end) }];
19181 }
19182 function applyEdit(text, edit) {
19183     return text.substring(0, edit.offset) + edit.content + text.substring(edit.offset + edit.length);
19184 }
19185 function isWS(text, offset) {
19186     return '\r\n \t'.indexOf(text.charAt(offset)) !== -1;
19187 }
19188 //# sourceMappingURL=edit.js.map
19189
19190 /***/ }),
19191 /* 87 */
19192 /***/ (function(module, __webpack_exports__, __webpack_require__) {
19193
19194 "use strict";
19195 __webpack_require__.r(__webpack_exports__);
19196 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getLocation", function() { return getLocation; });
19197 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parse", function() { return parse; });
19198 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseTree", function() { return parseTree; });
19199 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNodeAtLocation", function() { return findNodeAtLocation; });
19200 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodePath", function() { return getNodePath; });
19201 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNodeValue", function() { return getNodeValue; });
19202 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "contains", function() { return contains; });
19203 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findNodeAtOffset", function() { return findNodeAtOffset; });
19204 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "visit", function() { return visit; });
19205 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stripComments", function() { return stripComments; });
19206 /* harmony import */ var _scanner__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(85);
19207 /*---------------------------------------------------------------------------------------------
19208  *  Copyright (c) Microsoft Corporation. All rights reserved.
19209  *  Licensed under the MIT License. See License.txt in the project root for license information.
19210  *--------------------------------------------------------------------------------------------*/
19211
19212
19213 var ParseOptions;
19214 (function (ParseOptions) {
19215     ParseOptions.DEFAULT = {
19216         allowTrailingComma: false
19217     };
19218 })(ParseOptions || (ParseOptions = {}));
19219 /**
19220  * For a given offset, evaluate the location in the JSON document. Each segment in the location path is either a property name or an array index.
19221  */
19222 function getLocation(text, position) {
19223     var segments = []; // strings or numbers
19224     var earlyReturnException = new Object();
19225     var previousNode = void 0;
19226     var previousNodeInst = {
19227         value: {},
19228         offset: 0,
19229         length: 0,
19230         type: 'object',
19231         parent: void 0
19232     };
19233     var isAtPropertyKey = false;
19234     function setPreviousNode(value, offset, length, type) {
19235         previousNodeInst.value = value;
19236         previousNodeInst.offset = offset;
19237         previousNodeInst.length = length;
19238         previousNodeInst.type = type;
19239         previousNodeInst.colonOffset = void 0;
19240         previousNode = previousNodeInst;
19241     }
19242     try {
19243         visit(text, {
19244             onObjectBegin: function (offset, length) {
19245                 if (position <= offset) {
19246                     throw earlyReturnException;
19247                 }
19248                 previousNode = void 0;
19249                 isAtPropertyKey = position > offset;
19250                 segments.push(''); // push a placeholder (will be replaced)
19251             },
19252             onObjectProperty: function (name, offset, length) {
19253                 if (position < offset) {
19254                     throw earlyReturnException;
19255                 }
19256                 setPreviousNode(name, offset, length, 'property');
19257                 segments[segments.length - 1] = name;
19258                 if (position <= offset + length) {
19259                     throw earlyReturnException;
19260                 }
19261             },
19262             onObjectEnd: function (offset, length) {
19263                 if (position <= offset) {
19264                     throw earlyReturnException;
19265                 }
19266                 previousNode = void 0;
19267                 segments.pop();
19268             },
19269             onArrayBegin: function (offset, length) {
19270                 if (position <= offset) {
19271                     throw earlyReturnException;
19272                 }
19273                 previousNode = void 0;
19274                 segments.push(0);
19275             },
19276             onArrayEnd: function (offset, length) {
19277                 if (position <= offset) {
19278                     throw earlyReturnException;
19279                 }
19280                 previousNode = void 0;
19281                 segments.pop();
19282             },
19283             onLiteralValue: function (value, offset, length) {
19284                 if (position < offset) {
19285                     throw earlyReturnException;
19286                 }
19287                 setPreviousNode(value, offset, length, getLiteralNodeType(value));
19288                 if (position <= offset + length) {
19289                     throw earlyReturnException;
19290                 }
19291             },
19292             onSeparator: function (sep, offset, length) {
19293                 if (position <= offset) {
19294                     throw earlyReturnException;
19295                 }
19296                 if (sep === ':' && previousNode && previousNode.type === 'property') {
19297                     previousNode.colonOffset = offset;
19298                     isAtPropertyKey = false;
19299                     previousNode = void 0;
19300                 }
19301                 else if (sep === ',') {
19302                     var last = segments[segments.length - 1];
19303                     if (typeof last === 'number') {
19304                         segments[segments.length - 1] = last + 1;
19305                     }
19306                     else {
19307                         isAtPropertyKey = true;
19308                         segments[segments.length - 1] = '';
19309                     }
19310                     previousNode = void 0;
19311                 }
19312             }
19313         });
19314     }
19315     catch (e) {
19316         if (e !== earlyReturnException) {
19317             throw e;
19318         }
19319     }
19320     return {
19321         path: segments,
19322         previousNode: previousNode,
19323         isAtPropertyKey: isAtPropertyKey,
19324         matches: function (pattern) {
19325             var k = 0;
19326             for (var i = 0; k < pattern.length && i < segments.length; i++) {
19327                 if (pattern[k] === segments[i] || pattern[k] === '*') {
19328                     k++;
19329                 }
19330                 else if (pattern[k] !== '**') {
19331                     return false;
19332                 }
19333             }
19334             return k === pattern.length;
19335         }
19336     };
19337 }
19338 /**
19339  * Parses the given text and returns the object the JSON content represents. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
19340  * Therefore always check the errors list to find out if the input was valid.
19341  */
19342 function parse(text, errors, options) {
19343     if (errors === void 0) { errors = []; }
19344     if (options === void 0) { options = ParseOptions.DEFAULT; }
19345     var currentProperty = null;
19346     var currentParent = [];
19347     var previousParents = [];
19348     function onValue(value) {
19349         if (Array.isArray(currentParent)) {
19350             currentParent.push(value);
19351         }
19352         else if (currentProperty) {
19353             currentParent[currentProperty] = value;
19354         }
19355     }
19356     var visitor = {
19357         onObjectBegin: function () {
19358             var object = {};
19359             onValue(object);
19360             previousParents.push(currentParent);
19361             currentParent = object;
19362             currentProperty = null;
19363         },
19364         onObjectProperty: function (name) {
19365             currentProperty = name;
19366         },
19367         onObjectEnd: function () {
19368             currentParent = previousParents.pop();
19369         },
19370         onArrayBegin: function () {
19371             var array = [];
19372             onValue(array);
19373             previousParents.push(currentParent);
19374             currentParent = array;
19375             currentProperty = null;
19376         },
19377         onArrayEnd: function () {
19378             currentParent = previousParents.pop();
19379         },
19380         onLiteralValue: onValue,
19381         onError: function (error, offset, length) {
19382             errors.push({ error: error, offset: offset, length: length });
19383         }
19384     };
19385     visit(text, visitor, options);
19386     return currentParent[0];
19387 }
19388 /**
19389  * Parses the given text and returns a tree representation the JSON content. On invalid input, the parser tries to be as fault tolerant as possible, but still return a result.
19390  */
19391 function parseTree(text, errors, options) {
19392     if (errors === void 0) { errors = []; }
19393     if (options === void 0) { options = ParseOptions.DEFAULT; }
19394     var currentParent = { type: 'array', offset: -1, length: -1, children: [], parent: void 0 }; // artificial root
19395     function ensurePropertyComplete(endOffset) {
19396         if (currentParent.type === 'property') {
19397             currentParent.length = endOffset - currentParent.offset;
19398             currentParent = currentParent.parent;
19399         }
19400     }
19401     function onValue(valueNode) {
19402         currentParent.children.push(valueNode);
19403         return valueNode;
19404     }
19405     var visitor = {
19406         onObjectBegin: function (offset) {
19407             currentParent = onValue({ type: 'object', offset: offset, length: -1, parent: currentParent, children: [] });
19408         },
19409         onObjectProperty: function (name, offset, length) {
19410             currentParent = onValue({ type: 'property', offset: offset, length: -1, parent: currentParent, children: [] });
19411             currentParent.children.push({ type: 'string', value: name, offset: offset, length: length, parent: currentParent });
19412         },
19413         onObjectEnd: function (offset, length) {
19414             currentParent.length = offset + length - currentParent.offset;
19415             currentParent = currentParent.parent;
19416             ensurePropertyComplete(offset + length);
19417         },
19418         onArrayBegin: function (offset, length) {
19419             currentParent = onValue({ type: 'array', offset: offset, length: -1, parent: currentParent, children: [] });
19420         },
19421         onArrayEnd: function (offset, length) {
19422             currentParent.length = offset + length - currentParent.offset;
19423             currentParent = currentParent.parent;
19424             ensurePropertyComplete(offset + length);
19425         },
19426         onLiteralValue: function (value, offset, length) {
19427             onValue({ type: getLiteralNodeType(value), offset: offset, length: length, parent: currentParent, value: value });
19428             ensurePropertyComplete(offset + length);
19429         },
19430         onSeparator: function (sep, offset, length) {
19431             if (currentParent.type === 'property') {
19432                 if (sep === ':') {
19433                     currentParent.colonOffset = offset;
19434                 }
19435                 else if (sep === ',') {
19436                     ensurePropertyComplete(offset);
19437                 }
19438             }
19439         },
19440         onError: function (error, offset, length) {
19441             errors.push({ error: error, offset: offset, length: length });
19442         }
19443     };
19444     visit(text, visitor, options);
19445     var result = currentParent.children[0];
19446     if (result) {
19447         delete result.parent;
19448     }
19449     return result;
19450 }
19451 /**
19452  * Finds the node at the given path in a JSON DOM.
19453  */
19454 function findNodeAtLocation(root, path) {
19455     if (!root) {
19456         return void 0;
19457     }
19458     var node = root;
19459     for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
19460         var segment = path_1[_i];
19461         if (typeof segment === 'string') {
19462             if (node.type !== 'object' || !Array.isArray(node.children)) {
19463                 return void 0;
19464             }
19465             var found = false;
19466             for (var _a = 0, _b = node.children; _a < _b.length; _a++) {
19467                 var propertyNode = _b[_a];
19468                 if (Array.isArray(propertyNode.children) && propertyNode.children[0].value === segment) {
19469                     node = propertyNode.children[1];
19470                     found = true;
19471                     break;
19472                 }
19473             }
19474             if (!found) {
19475                 return void 0;
19476             }
19477         }
19478         else {
19479             var index = segment;
19480             if (node.type !== 'array' || index < 0 || !Array.isArray(node.children) || index >= node.children.length) {
19481                 return void 0;
19482             }
19483             node = node.children[index];
19484         }
19485     }
19486     return node;
19487 }
19488 /**
19489  * Gets the JSON path of the given JSON DOM node
19490  */
19491 function getNodePath(node) {
19492     if (!node.parent || !node.parent.children) {
19493         return [];
19494     }
19495     var path = getNodePath(node.parent);
19496     if (node.parent.type === 'property') {
19497         var key = node.parent.children[0].value;
19498         path.push(key);
19499     }
19500     else if (node.parent.type === 'array') {
19501         var index = node.parent.children.indexOf(node);
19502         if (index !== -1) {
19503             path.push(index);
19504         }
19505     }
19506     return path;
19507 }
19508 /**
19509  * Evaluates the JavaScript object of the given JSON DOM node
19510  */
19511 function getNodeValue(node) {
19512     switch (node.type) {
19513         case 'array':
19514             return node.children.map(getNodeValue);
19515         case 'object':
19516             var obj = Object.create(null);
19517             for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
19518                 var prop = _a[_i];
19519                 var valueNode = prop.children[1];
19520                 if (valueNode) {
19521                     obj[prop.children[0].value] = getNodeValue(valueNode);
19522                 }
19523             }
19524             return obj;
19525         case 'null':
19526         case 'string':
19527         case 'number':
19528         case 'boolean':
19529             return node.value;
19530         default:
19531             return void 0;
19532     }
19533 }
19534 function contains(node, offset, includeRightBound) {
19535     if (includeRightBound === void 0) { includeRightBound = false; }
19536     return (offset >= node.offset && offset < (node.offset + node.length)) || includeRightBound && (offset === (node.offset + node.length));
19537 }
19538 /**
19539  * Finds the most inner node at the given offset. If includeRightBound is set, also finds nodes that end at the given offset.
19540  */
19541 function findNodeAtOffset(node, offset, includeRightBound) {
19542     if (includeRightBound === void 0) { includeRightBound = false; }
19543     if (contains(node, offset, includeRightBound)) {
19544         var children = node.children;
19545         if (Array.isArray(children)) {
19546             for (var i = 0; i < children.length && children[i].offset <= offset; i++) {
19547                 var item = findNodeAtOffset(children[i], offset, includeRightBound);
19548                 if (item) {
19549                     return item;
19550                 }
19551             }
19552         }
19553         return node;
19554     }
19555     return void 0;
19556 }
19557 /**
19558  * Parses the given text and invokes the visitor functions for each object, array and literal reached.
19559  */
19560 function visit(text, visitor, options) {
19561     if (options === void 0) { options = ParseOptions.DEFAULT; }
19562     var _scanner = Object(_scanner__WEBPACK_IMPORTED_MODULE_0__["createScanner"])(text, false);
19563     function toNoArgVisit(visitFunction) {
19564         return visitFunction ? function () { return visitFunction(_scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); } : function () { return true; };
19565     }
19566     function toOneArgVisit(visitFunction) {
19567         return visitFunction ? function (arg) { return visitFunction(arg, _scanner.getTokenOffset(), _scanner.getTokenLength(), _scanner.getTokenStartLine(), _scanner.getTokenStartCharacter()); } : function () { return true; };
19568     }
19569     var onObjectBegin = toNoArgVisit(visitor.onObjectBegin), onObjectProperty = toOneArgVisit(visitor.onObjectProperty), onObjectEnd = toNoArgVisit(visitor.onObjectEnd), onArrayBegin = toNoArgVisit(visitor.onArrayBegin), onArrayEnd = toNoArgVisit(visitor.onArrayEnd), onLiteralValue = toOneArgVisit(visitor.onLiteralValue), onSeparator = toOneArgVisit(visitor.onSeparator), onComment = toNoArgVisit(visitor.onComment), onError = toOneArgVisit(visitor.onError);
19570     var disallowComments = options && options.disallowComments;
19571     var allowTrailingComma = options && options.allowTrailingComma;
19572     function scanNext() {
19573         while (true) {
19574             var token = _scanner.scan();
19575             switch (_scanner.getTokenError()) {
19576                 case 4 /* InvalidUnicode */:
19577                     handleError(14 /* InvalidUnicode */);
19578                     break;
19579                 case 5 /* InvalidEscapeCharacter */:
19580                     handleError(15 /* InvalidEscapeCharacter */);
19581                     break;
19582                 case 3 /* UnexpectedEndOfNumber */:
19583                     handleError(13 /* UnexpectedEndOfNumber */);
19584                     break;
19585                 case 1 /* UnexpectedEndOfComment */:
19586                     if (!disallowComments) {
19587                         handleError(11 /* UnexpectedEndOfComment */);
19588                     }
19589                     break;
19590                 case 2 /* UnexpectedEndOfString */:
19591                     handleError(12 /* UnexpectedEndOfString */);
19592                     break;
19593                 case 6 /* InvalidCharacter */:
19594                     handleError(16 /* InvalidCharacter */);
19595                     break;
19596             }
19597             switch (token) {
19598                 case 12 /* LineCommentTrivia */:
19599                 case 13 /* BlockCommentTrivia */:
19600                     if (disallowComments) {
19601                         handleError(10 /* InvalidCommentToken */);
19602                     }
19603                     else {
19604                         onComment();
19605                     }
19606                     break;
19607                 case 16 /* Unknown */:
19608                     handleError(1 /* InvalidSymbol */);
19609                     break;
19610                 case 15 /* Trivia */:
19611                 case 14 /* LineBreakTrivia */:
19612                     break;
19613                 default:
19614                     return token;
19615             }
19616         }
19617     }
19618     function handleError(error, skipUntilAfter, skipUntil) {
19619         if (skipUntilAfter === void 0) { skipUntilAfter = []; }
19620         if (skipUntil === void 0) { skipUntil = []; }
19621         onError(error);
19622         if (skipUntilAfter.length + skipUntil.length > 0) {
19623             var token = _scanner.getToken();
19624             while (token !== 17 /* EOF */) {
19625                 if (skipUntilAfter.indexOf(token) !== -1) {
19626                     scanNext();
19627                     break;
19628                 }
19629                 else if (skipUntil.indexOf(token) !== -1) {
19630                     break;
19631                 }
19632                 token = scanNext();
19633             }
19634         }
19635     }
19636     function parseString(isValue) {
19637         var value = _scanner.getTokenValue();
19638         if (isValue) {
19639             onLiteralValue(value);
19640         }
19641         else {
19642             onObjectProperty(value);
19643         }
19644         scanNext();
19645         return true;
19646     }
19647     function parseLiteral() {
19648         switch (_scanner.getToken()) {
19649             case 11 /* NumericLiteral */:
19650                 var value = 0;
19651                 try {
19652                     value = JSON.parse(_scanner.getTokenValue());
19653                     if (typeof value !== 'number') {
19654                         handleError(2 /* InvalidNumberFormat */);
19655                         value = 0;
19656                     }
19657                 }
19658                 catch (e) {
19659                     handleError(2 /* InvalidNumberFormat */);
19660                 }
19661                 onLiteralValue(value);
19662                 break;
19663             case 7 /* NullKeyword */:
19664                 onLiteralValue(null);
19665                 break;
19666             case 8 /* TrueKeyword */:
19667                 onLiteralValue(true);
19668                 break;
19669             case 9 /* FalseKeyword */:
19670                 onLiteralValue(false);
19671                 break;
19672             default:
19673                 return false;
19674         }
19675         scanNext();
19676         return true;
19677     }
19678     function parseProperty() {
19679         if (_scanner.getToken() !== 10 /* StringLiteral */) {
19680             handleError(3 /* PropertyNameExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
19681             return false;
19682         }
19683         parseString(false);
19684         if (_scanner.getToken() === 6 /* ColonToken */) {
19685             onSeparator(':');
19686             scanNext(); // consume colon
19687             if (!parseValue()) {
19688                 handleError(4 /* ValueExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
19689             }
19690         }
19691         else {
19692             handleError(5 /* ColonExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
19693         }
19694         return true;
19695     }
19696     function parseObject() {
19697         onObjectBegin();
19698         scanNext(); // consume open brace
19699         var needsComma = false;
19700         while (_scanner.getToken() !== 2 /* CloseBraceToken */ && _scanner.getToken() !== 17 /* EOF */) {
19701             if (_scanner.getToken() === 5 /* CommaToken */) {
19702                 if (!needsComma) {
19703                     handleError(4 /* ValueExpected */, [], []);
19704                 }
19705                 onSeparator(',');
19706                 scanNext(); // consume comma
19707                 if (_scanner.getToken() === 2 /* CloseBraceToken */ && allowTrailingComma) {
19708                     break;
19709                 }
19710             }
19711             else if (needsComma) {
19712                 handleError(6 /* CommaExpected */, [], []);
19713             }
19714             if (!parseProperty()) {
19715                 handleError(4 /* ValueExpected */, [], [2 /* CloseBraceToken */, 5 /* CommaToken */]);
19716             }
19717             needsComma = true;
19718         }
19719         onObjectEnd();
19720         if (_scanner.getToken() !== 2 /* CloseBraceToken */) {
19721             handleError(7 /* CloseBraceExpected */, [2 /* CloseBraceToken */], []);
19722         }
19723         else {
19724             scanNext(); // consume close brace
19725         }
19726         return true;
19727     }
19728     function parseArray() {
19729         onArrayBegin();
19730         scanNext(); // consume open bracket
19731         var needsComma = false;
19732         while (_scanner.getToken() !== 4 /* CloseBracketToken */ && _scanner.getToken() !== 17 /* EOF */) {
19733             if (_scanner.getToken() === 5 /* CommaToken */) {
19734                 if (!needsComma) {
19735                     handleError(4 /* ValueExpected */, [], []);
19736                 }
19737                 onSeparator(',');
19738                 scanNext(); // consume comma
19739                 if (_scanner.getToken() === 4 /* CloseBracketToken */ && allowTrailingComma) {
19740                     break;
19741                 }
19742             }
19743             else if (needsComma) {
19744                 handleError(6 /* CommaExpected */, [], []);
19745             }
19746             if (!parseValue()) {
19747                 handleError(4 /* ValueExpected */, [], [4 /* CloseBracketToken */, 5 /* CommaToken */]);
19748             }
19749             needsComma = true;
19750         }
19751         onArrayEnd();
19752         if (_scanner.getToken() !== 4 /* CloseBracketToken */) {
19753             handleError(8 /* CloseBracketExpected */, [4 /* CloseBracketToken */], []);
19754         }
19755         else {
19756             scanNext(); // consume close bracket
19757         }
19758         return true;
19759     }
19760     function parseValue() {
19761         switch (_scanner.getToken()) {
19762             case 3 /* OpenBracketToken */:
19763                 return parseArray();
19764             case 1 /* OpenBraceToken */:
19765                 return parseObject();
19766             case 10 /* StringLiteral */:
19767                 return parseString(true);
19768             default:
19769                 return parseLiteral();
19770         }
19771     }
19772     scanNext();
19773     if (_scanner.getToken() === 17 /* EOF */) {
19774         return true;
19775     }
19776     if (!parseValue()) {
19777         handleError(4 /* ValueExpected */, [], []);
19778         return false;
19779     }
19780     if (_scanner.getToken() !== 17 /* EOF */) {
19781         handleError(9 /* EndOfFileExpected */, [], []);
19782     }
19783     return true;
19784 }
19785 /**
19786  * Takes JSON with JavaScript-style comments and remove
19787  * them. Optionally replaces every none-newline character
19788  * of comments with a replaceCharacter
19789  */
19790 function stripComments(text, replaceCh) {
19791     var _scanner = Object(_scanner__WEBPACK_IMPORTED_MODULE_0__["createScanner"])(text), parts = [], kind, offset = 0, pos;
19792     do {
19793         pos = _scanner.getPosition();
19794         kind = _scanner.scan();
19795         switch (kind) {
19796             case 12 /* LineCommentTrivia */:
19797             case 13 /* BlockCommentTrivia */:
19798             case 17 /* EOF */:
19799                 if (offset !== pos) {
19800                     parts.push(text.substring(offset, pos));
19801                 }
19802                 if (replaceCh !== void 0) {
19803                     parts.push(_scanner.getTokenValue().replace(/[^\r\n]/g, replaceCh));
19804                 }
19805                 offset = _scanner.getPosition();
19806                 break;
19807         }
19808     } while (kind !== 17 /* EOF */);
19809     return parts.join('');
19810 }
19811 function getLiteralNodeType(value) {
19812     switch (typeof value) {
19813         case 'boolean': return 'boolean';
19814         case 'number': return 'number';
19815         case 'string': return 'string';
19816         default: return 'null';
19817     }
19818 }
19819 //# sourceMappingURL=parser.js.map
19820
19821 /***/ }),
19822 /* 88 */
19823 /***/ (function(module, __webpack_exports__, __webpack_require__) {
19824
19825 "use strict";
19826 __webpack_require__.r(__webpack_exports__);
19827 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "equals", function() { return equals; });
19828 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isNumber", function() { return isNumber; });
19829 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isDefined", function() { return isDefined; });
19830 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isBoolean", function() { return isBoolean; });
19831 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return isString; });
19832 /*---------------------------------------------------------------------------------------------
19833 *  Copyright (c) Microsoft Corporation. All rights reserved.
19834 *  Licensed under the MIT License. See License.txt in the project root for license information.
19835 *--------------------------------------------------------------------------------------------*/
19836 function equals(one, other) {
19837     if (one === other) {
19838         return true;
19839     }
19840     if (one === null || one === undefined || other === null || other === undefined) {
19841         return false;
19842     }
19843     if (typeof one !== typeof other) {
19844         return false;
19845     }
19846     if (typeof one !== 'object') {
19847         return false;
19848     }
19849     if ((Array.isArray(one)) !== (Array.isArray(other))) {
19850         return false;
19851     }
19852     var i, key;
19853     if (Array.isArray(one)) {
19854         if (one.length !== other.length) {
19855             return false;
19856         }
19857         for (i = 0; i < one.length; i++) {
19858             if (!equals(one[i], other[i])) {
19859                 return false;
19860             }
19861         }
19862     }
19863     else {
19864         var oneKeys = [];
19865         for (key in one) {
19866             oneKeys.push(key);
19867         }
19868         oneKeys.sort();
19869         var otherKeys = [];
19870         for (key in other) {
19871             otherKeys.push(key);
19872         }
19873         otherKeys.sort();
19874         if (!equals(oneKeys, otherKeys)) {
19875             return false;
19876         }
19877         for (i = 0; i < oneKeys.length; i++) {
19878             if (!equals(one[oneKeys[i]], other[oneKeys[i]])) {
19879                 return false;
19880             }
19881         }
19882     }
19883     return true;
19884 }
19885 function isNumber(val) {
19886     return typeof val === 'number';
19887 }
19888 function isDefined(val) {
19889     return typeof val !== 'undefined';
19890 }
19891 function isBoolean(val) {
19892     return typeof val === 'boolean';
19893 }
19894 function isString(val) {
19895     return typeof val === 'string';
19896 }
19897
19898
19899 /***/ }),
19900 /* 89 */
19901 /***/ (function(module, __webpack_exports__, __webpack_require__) {
19902
19903 "use strict";
19904 __webpack_require__.r(__webpack_exports__);
19905 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ErrorCode", function() { return ErrorCode; });
19906 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClientCapabilities", function() { return ClientCapabilities; });
19907 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80);
19908 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Range", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Range"]; });
19909
19910 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextEdit", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["TextEdit"]; });
19911
19912 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Color"]; });
19913
19914 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorInformation", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["ColorInformation"]; });
19915
19916 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorPresentation", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["ColorPresentation"]; });
19917
19918 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FoldingRange", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["FoldingRange"]; });
19919
19920 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FoldingRangeKind", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["FoldingRangeKind"]; });
19921
19922 /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SelectionRange", function() { return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["SelectionRange"]; });
19923
19924
19925
19926 /**
19927  * Error codes used by diagnostics
19928  */
19929 var ErrorCode;
19930 (function (ErrorCode) {
19931     ErrorCode[ErrorCode["Undefined"] = 0] = "Undefined";
19932     ErrorCode[ErrorCode["EnumValueMismatch"] = 1] = "EnumValueMismatch";
19933     ErrorCode[ErrorCode["UnexpectedEndOfComment"] = 257] = "UnexpectedEndOfComment";
19934     ErrorCode[ErrorCode["UnexpectedEndOfString"] = 258] = "UnexpectedEndOfString";
19935     ErrorCode[ErrorCode["UnexpectedEndOfNumber"] = 259] = "UnexpectedEndOfNumber";
19936     ErrorCode[ErrorCode["InvalidUnicode"] = 260] = "InvalidUnicode";
19937     ErrorCode[ErrorCode["InvalidEscapeCharacter"] = 261] = "InvalidEscapeCharacter";
19938     ErrorCode[ErrorCode["InvalidCharacter"] = 262] = "InvalidCharacter";
19939     ErrorCode[ErrorCode["PropertyExpected"] = 513] = "PropertyExpected";
19940     ErrorCode[ErrorCode["CommaExpected"] = 514] = "CommaExpected";
19941     ErrorCode[ErrorCode["ColonExpected"] = 515] = "ColonExpected";
19942     ErrorCode[ErrorCode["ValueExpected"] = 516] = "ValueExpected";
19943     ErrorCode[ErrorCode["CommaOrCloseBacketExpected"] = 517] = "CommaOrCloseBacketExpected";
19944     ErrorCode[ErrorCode["CommaOrCloseBraceExpected"] = 518] = "CommaOrCloseBraceExpected";
19945     ErrorCode[ErrorCode["TrailingComma"] = 519] = "TrailingComma";
19946     ErrorCode[ErrorCode["DuplicateKey"] = 520] = "DuplicateKey";
19947     ErrorCode[ErrorCode["CommentNotPermitted"] = 521] = "CommentNotPermitted";
19948     ErrorCode[ErrorCode["SchemaResolveError"] = 768] = "SchemaResolveError";
19949 })(ErrorCode || (ErrorCode = {}));
19950 var ClientCapabilities;
19951 (function (ClientCapabilities) {
19952     ClientCapabilities.LATEST = {
19953         textDocument: {
19954             completion: {
19955                 completionItem: {
19956                     documentationFormat: [vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["MarkupKind"].Markdown, vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["MarkupKind"].PlainText]
19957                 }
19958             }
19959         }
19960     };
19961 })(ClientCapabilities || (ClientCapabilities = {}));
19962
19963
19964 /***/ }),
19965 /* 90 */
19966 /***/ (function(module, __webpack_exports__, __webpack_require__) {
19967
19968 "use strict";
19969 __webpack_require__.r(__webpack_exports__);
19970 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stringifyObject", function() { return stringifyObject; });
19971 /*---------------------------------------------------------------------------------------------
19972 *  Copyright (c) Microsoft Corporation. All rights reserved.
19973 *  Licensed under the MIT License. See License.txt in the project root for license information.
19974 *--------------------------------------------------------------------------------------------*/
19975 function stringifyObject(obj, indent, stringifyLiteral) {
19976     if (obj !== null && typeof obj === 'object') {
19977         var newIndent = indent + '\t';
19978         if (Array.isArray(obj)) {
19979             if (obj.length === 0) {
19980                 return '[]';
19981             }
19982             var result = '[\n';
19983             for (var i = 0; i < obj.length; i++) {
19984                 result += newIndent + stringifyObject(obj[i], newIndent, stringifyLiteral);
19985                 if (i < obj.length - 1) {
19986                     result += ',';
19987                 }
19988                 result += '\n';
19989             }
19990             result += indent + ']';
19991             return result;
19992         }
19993         else {
19994             var keys = Object.keys(obj);
19995             if (keys.length === 0) {
19996                 return '{}';
19997             }
19998             var result = '{\n';
19999             for (var i = 0; i < keys.length; i++) {
20000                 var key = keys[i];
20001                 result += newIndent + JSON.stringify(key) + ': ' + stringifyObject(obj[key], newIndent, stringifyLiteral);
20002                 if (i < keys.length - 1) {
20003                     result += ',';
20004                 }
20005                 result += '\n';
20006             }
20007             result += indent + '}';
20008             return result;
20009         }
20010     }
20011     return stringifyLiteral(obj);
20012 }
20013
20014
20015 /***/ }),
20016 /* 91 */
20017 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20018
20019 "use strict";
20020 __webpack_require__.r(__webpack_exports__);
20021 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "startsWith", function() { return startsWith; });
20022 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "endsWith", function() { return endsWith; });
20023 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertSimple2RegExpPattern", function() { return convertSimple2RegExpPattern; });
20024 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "repeat", function() { return repeat; });
20025 /*---------------------------------------------------------------------------------------------
20026 *  Copyright (c) Microsoft Corporation. All rights reserved.
20027 *  Licensed under the MIT License. See License.txt in the project root for license information.
20028 *--------------------------------------------------------------------------------------------*/
20029 function startsWith(haystack, needle) {
20030     if (haystack.length < needle.length) {
20031         return false;
20032     }
20033     for (var i = 0; i < needle.length; i++) {
20034         if (haystack[i] !== needle[i]) {
20035             return false;
20036         }
20037     }
20038     return true;
20039 }
20040 /**
20041  * Determines if haystack ends with needle.
20042  */
20043 function endsWith(haystack, needle) {
20044     var diff = haystack.length - needle.length;
20045     if (diff > 0) {
20046         return haystack.lastIndexOf(needle) === diff;
20047     }
20048     else if (diff === 0) {
20049         return haystack === needle;
20050     }
20051     else {
20052         return false;
20053     }
20054 }
20055 function convertSimple2RegExpPattern(pattern) {
20056     return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
20057 }
20058 function repeat(value, count) {
20059     var s = '';
20060     while (count > 0) {
20061         if ((count & 1) === 1) {
20062             s += value;
20063         }
20064         value += value;
20065         count = count >>> 1;
20066     }
20067     return s;
20068 }
20069
20070
20071 /***/ }),
20072 /* 92 */
20073 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20074
20075 "use strict";
20076 __webpack_require__.r(__webpack_exports__);
20077 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONHover", function() { return JSONHover; });
20078 /* harmony import */ var _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82);
20079 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(80);
20080 /*---------------------------------------------------------------------------------------------
20081  *  Copyright (c) Microsoft Corporation. All rights reserved.
20082  *  Licensed under the MIT License. See License.txt in the project root for license information.
20083  *--------------------------------------------------------------------------------------------*/
20084
20085
20086 var JSONHover = /** @class */ (function () {
20087     function JSONHover(schemaService, contributions, promiseConstructor) {
20088         if (contributions === void 0) { contributions = []; }
20089         this.schemaService = schemaService;
20090         this.contributions = contributions;
20091         this.promise = promiseConstructor || Promise;
20092     }
20093     JSONHover.prototype.doHover = function (document, position, doc) {
20094         var offset = document.offsetAt(position);
20095         var node = doc.getNodeFromOffset(offset);
20096         if (!node || (node.type === 'object' || node.type === 'array') && offset > node.offset + 1 && offset < node.offset + node.length - 1) {
20097             return this.promise.resolve(null);
20098         }
20099         var hoverRangeNode = node;
20100         // use the property description when hovering over an object key
20101         if (node.type === 'string') {
20102             var parent = node.parent;
20103             if (parent && parent.type === 'property' && parent.keyNode === node) {
20104                 node = parent.valueNode;
20105                 if (!node) {
20106                     return this.promise.resolve(null);
20107                 }
20108             }
20109         }
20110         var hoverRange = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Range"].create(document.positionAt(hoverRangeNode.offset), document.positionAt(hoverRangeNode.offset + hoverRangeNode.length));
20111         var createHover = function (contents) {
20112             var result = {
20113                 contents: contents,
20114                 range: hoverRange
20115             };
20116             return result;
20117         };
20118         var location = _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodePath"](node);
20119         for (var i = this.contributions.length - 1; i >= 0; i--) {
20120             var contribution = this.contributions[i];
20121             var promise = contribution.getInfoContribution(document.uri, location);
20122             if (promise) {
20123                 return promise.then(function (htmlContent) { return createHover(htmlContent); });
20124             }
20125         }
20126         return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
20127             if (schema) {
20128                 var matchingSchemas = doc.getMatchingSchemas(schema.schema, node.offset);
20129                 var title_1 = null;
20130                 var markdownDescription_1 = null;
20131                 var markdownEnumValueDescription_1 = null, enumValue_1 = null;
20132                 matchingSchemas.every(function (s) {
20133                     if (s.node === node && !s.inverted && s.schema) {
20134                         title_1 = title_1 || s.schema.title;
20135                         markdownDescription_1 = markdownDescription_1 || s.schema.markdownDescription || toMarkdown(s.schema.description);
20136                         if (s.schema.enum) {
20137                             var idx = s.schema.enum.indexOf(_parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodeValue"](node));
20138                             if (s.schema.markdownEnumDescriptions) {
20139                                 markdownEnumValueDescription_1 = s.schema.markdownEnumDescriptions[idx];
20140                             }
20141                             else if (s.schema.enumDescriptions) {
20142                                 markdownEnumValueDescription_1 = toMarkdown(s.schema.enumDescriptions[idx]);
20143                             }
20144                             if (markdownEnumValueDescription_1) {
20145                                 enumValue_1 = s.schema.enum[idx];
20146                                 if (typeof enumValue_1 !== 'string') {
20147                                     enumValue_1 = JSON.stringify(enumValue_1);
20148                                 }
20149                             }
20150                         }
20151                     }
20152                     return true;
20153                 });
20154                 var result = '';
20155                 if (title_1) {
20156                     result = toMarkdown(title_1);
20157                 }
20158                 if (markdownDescription_1) {
20159                     if (result.length > 0) {
20160                         result += "\n\n";
20161                     }
20162                     result += markdownDescription_1;
20163                 }
20164                 if (markdownEnumValueDescription_1) {
20165                     if (result.length > 0) {
20166                         result += "\n\n";
20167                     }
20168                     result += "`" + toMarkdownCodeBlock(enumValue_1) + "`: " + markdownEnumValueDescription_1;
20169                 }
20170                 return createHover([result]);
20171             }
20172             return null;
20173         });
20174     };
20175     return JSONHover;
20176 }());
20177
20178 function toMarkdown(plain) {
20179     if (plain) {
20180         var res = plain.replace(/([^\n\r])(\r?\n)([^\n\r])/gm, '$1\n\n$3'); // single new lines to \n\n (Markdown paragraph)
20181         return res.replace(/[\\`*_{}[\]()#+\-.!]/g, "\\$&"); // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
20182     }
20183     return void 0;
20184 }
20185 function toMarkdownCodeBlock(content) {
20186     // see https://daringfireball.net/projects/markdown/syntax#precode
20187     if (content.indexOf('`') !== -1) {
20188         return '`` ' + content + ' ``';
20189     }
20190     return content;
20191 }
20192
20193
20194 /***/ }),
20195 /* 93 */
20196 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20197
20198 "use strict";
20199 __webpack_require__.r(__webpack_exports__);
20200 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONValidation", function() { return JSONValidation; });
20201 /* harmony import */ var _jsonSchemaService__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(94);
20202 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(80);
20203 /* harmony import */ var _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89);
20204 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(76);
20205 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(vscode_nls__WEBPACK_IMPORTED_MODULE_3__);
20206 /*---------------------------------------------------------------------------------------------
20207  *  Copyright (c) Microsoft Corporation. All rights reserved.
20208  *  Licensed under the MIT License. See License.txt in the project root for license information.
20209  *--------------------------------------------------------------------------------------------*/
20210
20211
20212
20213
20214 var localize = vscode_nls__WEBPACK_IMPORTED_MODULE_3__["loadMessageBundle"]();
20215 var JSONValidation = /** @class */ (function () {
20216     function JSONValidation(jsonSchemaService, promiseConstructor) {
20217         this.jsonSchemaService = jsonSchemaService;
20218         this.promise = promiseConstructor;
20219         this.validationEnabled = true;
20220     }
20221     JSONValidation.prototype.configure = function (raw) {
20222         if (raw) {
20223             this.validationEnabled = raw.validate;
20224             this.commentSeverity = raw.allowComments ? void 0 : vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Error;
20225         }
20226     };
20227     JSONValidation.prototype.doValidation = function (textDocument, jsonDocument, documentSettings, schema) {
20228         var _this = this;
20229         if (!this.validationEnabled) {
20230             return this.promise.resolve([]);
20231         }
20232         var diagnostics = [];
20233         var added = {};
20234         var addProblem = function (problem) {
20235             // remove duplicated messages
20236             var signature = problem.range.start.line + ' ' + problem.range.start.character + ' ' + problem.message;
20237             if (!added[signature]) {
20238                 added[signature] = true;
20239                 diagnostics.push(problem);
20240             }
20241         };
20242         var getDiagnostics = function (schema) {
20243             var trailingCommaSeverity = documentSettings ? toDiagnosticSeverity(documentSettings.trailingCommas) : vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Error;
20244             var commentSeverity = documentSettings ? toDiagnosticSeverity(documentSettings.comments) : _this.commentSeverity;
20245             if (schema) {
20246                 if (schema.errors.length && jsonDocument.root) {
20247                     var astRoot = jsonDocument.root;
20248                     var property = astRoot.type === 'object' ? astRoot.properties[0] : null;
20249                     if (property && property.keyNode.value === '$schema') {
20250                         var node = property.valueNode || property;
20251                         var range = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Range"].create(textDocument.positionAt(node.offset), textDocument.positionAt(node.offset + node.length));
20252                         addProblem(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Diagnostic"].create(range, schema.errors[0], vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Warning, _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].SchemaResolveError));
20253                     }
20254                     else {
20255                         var range = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Range"].create(textDocument.positionAt(astRoot.offset), textDocument.positionAt(astRoot.offset + 1));
20256                         addProblem(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Diagnostic"].create(range, schema.errors[0], vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Warning, _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].SchemaResolveError));
20257                     }
20258                 }
20259                 else {
20260                     var semanticErrors = jsonDocument.validate(textDocument, schema.schema);
20261                     if (semanticErrors) {
20262                         semanticErrors.forEach(addProblem);
20263                     }
20264                 }
20265                 if (schemaAllowsComments(schema.schema)) {
20266                     trailingCommaSeverity = commentSeverity = void 0;
20267                 }
20268             }
20269             for (var _i = 0, _a = jsonDocument.syntaxErrors; _i < _a.length; _i++) {
20270                 var p = _a[_i];
20271                 if (p.code === _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].TrailingComma) {
20272                     if (typeof trailingCommaSeverity !== 'number') {
20273                         continue;
20274                     }
20275                     p.severity = trailingCommaSeverity;
20276                 }
20277                 addProblem(p);
20278             }
20279             if (typeof commentSeverity === 'number') {
20280                 var message_1 = localize('InvalidCommentToken', 'Comments are not permitted in JSON.');
20281                 jsonDocument.comments.forEach(function (c) {
20282                     addProblem(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["Diagnostic"].create(c, message_1, commentSeverity, _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["ErrorCode"].CommentNotPermitted));
20283                 });
20284             }
20285             return diagnostics;
20286         };
20287         if (schema) {
20288             var id = schema.id || ('schemaservice://untitled/' + idCounter++);
20289             return this.jsonSchemaService.resolveSchemaContent(new _jsonSchemaService__WEBPACK_IMPORTED_MODULE_0__["UnresolvedSchema"](schema), id, {}).then(function (resolvedSchema) {
20290                 return getDiagnostics(resolvedSchema);
20291             });
20292         }
20293         return this.jsonSchemaService.getSchemaForResource(textDocument.uri, jsonDocument).then(function (schema) {
20294             return getDiagnostics(schema);
20295         });
20296     };
20297     return JSONValidation;
20298 }());
20299
20300 var idCounter = 0;
20301 function schemaAllowsComments(schemaRef) {
20302     if (schemaRef && typeof schemaRef === 'object') {
20303         if (schemaRef.allowComments) {
20304             return true;
20305         }
20306         if (schemaRef.allOf) {
20307             return schemaRef.allOf.some(schemaAllowsComments);
20308         }
20309     }
20310     return false;
20311 }
20312 function toDiagnosticSeverity(severityLevel) {
20313     switch (severityLevel) {
20314         case 'error': return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Error;
20315         case 'warning': return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_1__["DiagnosticSeverity"].Warning;
20316         case 'ignore': return void 0;
20317     }
20318     return void 0;
20319 }
20320
20321
20322 /***/ }),
20323 /* 94 */
20324 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20325
20326 "use strict";
20327 __webpack_require__.r(__webpack_exports__);
20328 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UnresolvedSchema", function() { return UnresolvedSchema; });
20329 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ResolvedSchema", function() { return ResolvedSchema; });
20330 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONSchemaService", function() { return JSONSchemaService; });
20331 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(83);
20332 /* harmony import */ var vscode_uri__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(95);
20333 /* harmony import */ var _utils_strings__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(91);
20334 /* harmony import */ var _parser_jsonParser__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(82);
20335 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(76);
20336 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(vscode_nls__WEBPACK_IMPORTED_MODULE_4__);
20337 /*---------------------------------------------------------------------------------------------
20338  *  Copyright (c) Microsoft Corporation. All rights reserved.
20339  *  Licensed under the MIT License. See License.txt in the project root for license information.
20340  *--------------------------------------------------------------------------------------------*/
20341
20342
20343
20344
20345
20346 var localize = vscode_nls__WEBPACK_IMPORTED_MODULE_4__["loadMessageBundle"]();
20347 var FilePatternAssociation = /** @class */ (function () {
20348     function FilePatternAssociation(pattern) {
20349         try {
20350             this.patternRegExp = new RegExp(_utils_strings__WEBPACK_IMPORTED_MODULE_2__["convertSimple2RegExpPattern"](pattern) + '$');
20351         }
20352         catch (e) {
20353             // invalid pattern
20354             this.patternRegExp = null;
20355         }
20356         this.schemas = [];
20357     }
20358     FilePatternAssociation.prototype.addSchema = function (id) {
20359         this.schemas.push(id);
20360     };
20361     FilePatternAssociation.prototype.matchesPattern = function (fileName) {
20362         return this.patternRegExp && this.patternRegExp.test(fileName);
20363     };
20364     FilePatternAssociation.prototype.getSchemas = function () {
20365         return this.schemas;
20366     };
20367     return FilePatternAssociation;
20368 }());
20369 var SchemaHandle = /** @class */ (function () {
20370     function SchemaHandle(service, url, unresolvedSchemaContent) {
20371         this.service = service;
20372         this.url = url;
20373         this.dependencies = {};
20374         if (unresolvedSchemaContent) {
20375             this.unresolvedSchema = this.service.promise.resolve(new UnresolvedSchema(unresolvedSchemaContent));
20376         }
20377     }
20378     SchemaHandle.prototype.getUnresolvedSchema = function () {
20379         if (!this.unresolvedSchema) {
20380             this.unresolvedSchema = this.service.loadSchema(this.url);
20381         }
20382         return this.unresolvedSchema;
20383     };
20384     SchemaHandle.prototype.getResolvedSchema = function () {
20385         var _this = this;
20386         if (!this.resolvedSchema) {
20387             this.resolvedSchema = this.getUnresolvedSchema().then(function (unresolved) {
20388                 return _this.service.resolveSchemaContent(unresolved, _this.url, _this.dependencies);
20389             });
20390         }
20391         return this.resolvedSchema;
20392     };
20393     SchemaHandle.prototype.clearSchema = function () {
20394         this.resolvedSchema = null;
20395         this.unresolvedSchema = null;
20396         this.dependencies = {};
20397     };
20398     return SchemaHandle;
20399 }());
20400 var UnresolvedSchema = /** @class */ (function () {
20401     function UnresolvedSchema(schema, errors) {
20402         if (errors === void 0) { errors = []; }
20403         this.schema = schema;
20404         this.errors = errors;
20405     }
20406     return UnresolvedSchema;
20407 }());
20408
20409 var ResolvedSchema = /** @class */ (function () {
20410     function ResolvedSchema(schema, errors) {
20411         if (errors === void 0) { errors = []; }
20412         this.schema = schema;
20413         this.errors = errors;
20414     }
20415     ResolvedSchema.prototype.getSection = function (path) {
20416         return _parser_jsonParser__WEBPACK_IMPORTED_MODULE_3__["asSchema"](this.getSectionRecursive(path, this.schema));
20417     };
20418     ResolvedSchema.prototype.getSectionRecursive = function (path, schema) {
20419         if (!schema || typeof schema === 'boolean' || path.length === 0) {
20420             return schema;
20421         }
20422         var next = path.shift();
20423         if (schema.properties && typeof schema.properties[next]) {
20424             return this.getSectionRecursive(path, schema.properties[next]);
20425         }
20426         else if (schema.patternProperties) {
20427             for (var _i = 0, _a = Object.keys(schema.patternProperties); _i < _a.length; _i++) {
20428                 var pattern = _a[_i];
20429                 var regex = new RegExp(pattern);
20430                 if (regex.test(next)) {
20431                     return this.getSectionRecursive(path, schema.patternProperties[pattern]);
20432                 }
20433             }
20434         }
20435         else if (typeof schema.additionalProperties === 'object') {
20436             return this.getSectionRecursive(path, schema.additionalProperties);
20437         }
20438         else if (next.match('[0-9]+')) {
20439             if (Array.isArray(schema.items)) {
20440                 var index = parseInt(next, 10);
20441                 if (!isNaN(index) && schema.items[index]) {
20442                     return this.getSectionRecursive(path, schema.items[index]);
20443                 }
20444             }
20445             else if (schema.items) {
20446                 return this.getSectionRecursive(path, schema.items);
20447             }
20448         }
20449         return null;
20450     };
20451     return ResolvedSchema;
20452 }());
20453
20454 var JSONSchemaService = /** @class */ (function () {
20455     function JSONSchemaService(requestService, contextService, promiseConstructor) {
20456         this.contextService = contextService;
20457         this.requestService = requestService;
20458         this.promiseConstructor = promiseConstructor || Promise;
20459         this.callOnDispose = [];
20460         this.contributionSchemas = {};
20461         this.contributionAssociations = {};
20462         this.schemasById = {};
20463         this.filePatternAssociations = [];
20464         this.filePatternAssociationById = {};
20465         this.registeredSchemasIds = {};
20466     }
20467     JSONSchemaService.prototype.getRegisteredSchemaIds = function (filter) {
20468         return Object.keys(this.registeredSchemasIds).filter(function (id) {
20469             var scheme = vscode_uri__WEBPACK_IMPORTED_MODULE_1__["URI"].parse(id).scheme;
20470             return scheme !== 'schemaservice' && (!filter || filter(scheme));
20471         });
20472     };
20473     Object.defineProperty(JSONSchemaService.prototype, "promise", {
20474         get: function () {
20475             return this.promiseConstructor;
20476         },
20477         enumerable: true,
20478         configurable: true
20479     });
20480     JSONSchemaService.prototype.dispose = function () {
20481         while (this.callOnDispose.length > 0) {
20482             this.callOnDispose.pop()();
20483         }
20484     };
20485     JSONSchemaService.prototype.onResourceChange = function (uri) {
20486         var _this = this;
20487         var hasChanges = false;
20488         uri = this.normalizeId(uri);
20489         var toWalk = [uri];
20490         var all = Object.keys(this.schemasById).map(function (key) { return _this.schemasById[key]; });
20491         while (toWalk.length) {
20492             var curr = toWalk.pop();
20493             for (var i = 0; i < all.length; i++) {
20494                 var handle = all[i];
20495                 if (handle && (handle.url === curr || handle.dependencies[curr])) {
20496                     if (handle.url !== curr) {
20497                         toWalk.push(handle.url);
20498                     }
20499                     handle.clearSchema();
20500                     all[i] = undefined;
20501                     hasChanges = true;
20502                 }
20503             }
20504         }
20505         return hasChanges;
20506     };
20507     JSONSchemaService.prototype.normalizeId = function (id) {
20508         // remove trailing '#', normalize drive capitalization
20509         try {
20510             return vscode_uri__WEBPACK_IMPORTED_MODULE_1__["URI"].parse(id).toString();
20511         }
20512         catch (e) {
20513             return id;
20514         }
20515     };
20516     JSONSchemaService.prototype.setSchemaContributions = function (schemaContributions) {
20517         if (schemaContributions.schemas) {
20518             var schemas = schemaContributions.schemas;
20519             for (var id in schemas) {
20520                 var normalizedId = this.normalizeId(id);
20521                 this.contributionSchemas[normalizedId] = this.addSchemaHandle(normalizedId, schemas[id]);
20522             }
20523         }
20524         if (schemaContributions.schemaAssociations) {
20525             var schemaAssociations = schemaContributions.schemaAssociations;
20526             for (var pattern in schemaAssociations) {
20527                 var associations = schemaAssociations[pattern];
20528                 this.contributionAssociations[pattern] = associations;
20529                 var fpa = this.getOrAddFilePatternAssociation(pattern);
20530                 for (var _i = 0, associations_1 = associations; _i < associations_1.length; _i++) {
20531                     var schemaId = associations_1[_i];
20532                     var id = this.normalizeId(schemaId);
20533                     fpa.addSchema(id);
20534                 }
20535             }
20536         }
20537     };
20538     JSONSchemaService.prototype.addSchemaHandle = function (id, unresolvedSchemaContent) {
20539         var schemaHandle = new SchemaHandle(this, id, unresolvedSchemaContent);
20540         this.schemasById[id] = schemaHandle;
20541         return schemaHandle;
20542     };
20543     JSONSchemaService.prototype.getOrAddSchemaHandle = function (id, unresolvedSchemaContent) {
20544         return this.schemasById[id] || this.addSchemaHandle(id, unresolvedSchemaContent);
20545     };
20546     JSONSchemaService.prototype.getOrAddFilePatternAssociation = function (pattern) {
20547         var fpa = this.filePatternAssociationById[pattern];
20548         if (!fpa) {
20549             fpa = new FilePatternAssociation(pattern);
20550             this.filePatternAssociationById[pattern] = fpa;
20551             this.filePatternAssociations.push(fpa);
20552         }
20553         return fpa;
20554     };
20555     JSONSchemaService.prototype.registerExternalSchema = function (uri, filePatterns, unresolvedSchemaContent) {
20556         if (filePatterns === void 0) { filePatterns = null; }
20557         var id = this.normalizeId(uri);
20558         this.registeredSchemasIds[id] = true;
20559         if (filePatterns) {
20560             for (var _i = 0, filePatterns_1 = filePatterns; _i < filePatterns_1.length; _i++) {
20561                 var pattern = filePatterns_1[_i];
20562                 this.getOrAddFilePatternAssociation(pattern).addSchema(id);
20563             }
20564         }
20565         return unresolvedSchemaContent ? this.addSchemaHandle(id, unresolvedSchemaContent) : this.getOrAddSchemaHandle(id);
20566     };
20567     JSONSchemaService.prototype.clearExternalSchemas = function () {
20568         this.schemasById = {};
20569         this.filePatternAssociations = [];
20570         this.filePatternAssociationById = {};
20571         this.registeredSchemasIds = {};
20572         for (var id in this.contributionSchemas) {
20573             this.schemasById[id] = this.contributionSchemas[id];
20574             this.registeredSchemasIds[id] = true;
20575         }
20576         for (var pattern in this.contributionAssociations) {
20577             var fpa = this.getOrAddFilePatternAssociation(pattern);
20578             for (var _i = 0, _a = this.contributionAssociations[pattern]; _i < _a.length; _i++) {
20579                 var schemaId = _a[_i];
20580                 var id = this.normalizeId(schemaId);
20581                 fpa.addSchema(id);
20582             }
20583         }
20584     };
20585     JSONSchemaService.prototype.getResolvedSchema = function (schemaId) {
20586         var id = this.normalizeId(schemaId);
20587         var schemaHandle = this.schemasById[id];
20588         if (schemaHandle) {
20589             return schemaHandle.getResolvedSchema();
20590         }
20591         return this.promise.resolve(null);
20592     };
20593     JSONSchemaService.prototype.loadSchema = function (url) {
20594         if (!this.requestService) {
20595             var errorMessage = localize('json.schema.norequestservice', 'Unable to load schema from \'{0}\'. No schema request service available', toDisplayString(url));
20596             return this.promise.resolve(new UnresolvedSchema({}, [errorMessage]));
20597         }
20598         return this.requestService(url).then(function (content) {
20599             if (!content) {
20600                 var errorMessage = localize('json.schema.nocontent', 'Unable to load schema from \'{0}\': No content.', toDisplayString(url));
20601                 return new UnresolvedSchema({}, [errorMessage]);
20602             }
20603             var schemaContent = {};
20604             var jsonErrors = [];
20605             schemaContent = jsonc_parser__WEBPACK_IMPORTED_MODULE_0__["parse"](content, jsonErrors);
20606             var errors = jsonErrors.length ? [localize('json.schema.invalidFormat', 'Unable to parse content from \'{0}\': Parse error at offset {1}.', toDisplayString(url), jsonErrors[0].offset)] : [];
20607             return new UnresolvedSchema(schemaContent, errors);
20608         }, function (error) {
20609             var errorMessage = error.toString();
20610             var errorSplit = error.toString().split('Error: ');
20611             if (errorSplit.length > 1) {
20612                 // more concise error message, URL and context are attached by caller anyways
20613                 errorMessage = errorSplit[1];
20614             }
20615             return new UnresolvedSchema({}, [errorMessage]);
20616         });
20617     };
20618     JSONSchemaService.prototype.resolveSchemaContent = function (schemaToResolve, schemaURL, dependencies) {
20619         var _this = this;
20620         var resolveErrors = schemaToResolve.errors.slice(0);
20621         var schema = schemaToResolve.schema;
20622         var contextService = this.contextService;
20623         var findSection = function (schema, path) {
20624             if (!path) {
20625                 return schema;
20626             }
20627             var current = schema;
20628             if (path[0] === '/') {
20629                 path = path.substr(1);
20630             }
20631             path.split('/').some(function (part) {
20632                 current = current[part];
20633                 return !current;
20634             });
20635             return current;
20636         };
20637         var merge = function (target, sourceRoot, sourceURI, path) {
20638             var section = findSection(sourceRoot, path);
20639             if (section) {
20640                 for (var key in section) {
20641                     if (section.hasOwnProperty(key) && !target.hasOwnProperty(key)) {
20642                         target[key] = section[key];
20643                     }
20644                 }
20645             }
20646             else {
20647                 resolveErrors.push(localize('json.schema.invalidref', '$ref \'{0}\' in \'{1}\' can not be resolved.', path, sourceURI));
20648             }
20649         };
20650         var resolveExternalLink = function (node, uri, linkPath, parentSchemaURL, parentSchemaDependencies) {
20651             if (contextService && !/^\w+:\/\/.*/.test(uri)) {
20652                 uri = contextService.resolveRelativePath(uri, parentSchemaURL);
20653             }
20654             uri = _this.normalizeId(uri);
20655             var referencedHandle = _this.getOrAddSchemaHandle(uri);
20656             return referencedHandle.getUnresolvedSchema().then(function (unresolvedSchema) {
20657                 parentSchemaDependencies[uri] = true;
20658                 if (unresolvedSchema.errors.length) {
20659                     var loc = linkPath ? uri + '#' + linkPath : uri;
20660                     resolveErrors.push(localize('json.schema.problemloadingref', 'Problems loading reference \'{0}\': {1}', loc, unresolvedSchema.errors[0]));
20661                 }
20662                 merge(node, unresolvedSchema.schema, uri, linkPath);
20663                 return resolveRefs(node, unresolvedSchema.schema, uri, referencedHandle.dependencies);
20664             });
20665         };
20666         var resolveRefs = function (node, parentSchema, parentSchemaURL, parentSchemaDependencies) {
20667             if (!node || typeof node !== 'object') {
20668                 return Promise.resolve(null);
20669             }
20670             var toWalk = [node];
20671             var seen = [];
20672             var openPromises = [];
20673             var collectEntries = function () {
20674                 var entries = [];
20675                 for (var _i = 0; _i < arguments.length; _i++) {
20676                     entries[_i] = arguments[_i];
20677                 }
20678                 for (var _a = 0, entries_1 = entries; _a < entries_1.length; _a++) {
20679                     var entry = entries_1[_a];
20680                     if (typeof entry === 'object') {
20681                         toWalk.push(entry);
20682                     }
20683                 }
20684             };
20685             var collectMapEntries = function () {
20686                 var maps = [];
20687                 for (var _i = 0; _i < arguments.length; _i++) {
20688                     maps[_i] = arguments[_i];
20689                 }
20690                 for (var _a = 0, maps_1 = maps; _a < maps_1.length; _a++) {
20691                     var map = maps_1[_a];
20692                     if (typeof map === 'object') {
20693                         for (var key in map) {
20694                             var entry = map[key];
20695                             if (typeof entry === 'object') {
20696                                 toWalk.push(entry);
20697                             }
20698                         }
20699                     }
20700                 }
20701             };
20702             var collectArrayEntries = function () {
20703                 var arrays = [];
20704                 for (var _i = 0; _i < arguments.length; _i++) {
20705                     arrays[_i] = arguments[_i];
20706                 }
20707                 for (var _a = 0, arrays_1 = arrays; _a < arrays_1.length; _a++) {
20708                     var array = arrays_1[_a];
20709                     if (Array.isArray(array)) {
20710                         for (var _b = 0, array_1 = array; _b < array_1.length; _b++) {
20711                             var entry = array_1[_b];
20712                             if (typeof entry === 'object') {
20713                                 toWalk.push(entry);
20714                             }
20715                         }
20716                     }
20717                 }
20718             };
20719             var handleRef = function (next) {
20720                 var seenRefs = [];
20721                 while (next.$ref) {
20722                     var ref = next.$ref;
20723                     var segments = ref.split('#', 2);
20724                     delete next.$ref;
20725                     if (segments[0].length > 0) {
20726                         openPromises.push(resolveExternalLink(next, segments[0], segments[1], parentSchemaURL, parentSchemaDependencies));
20727                         return;
20728                     }
20729                     else {
20730                         if (seenRefs.indexOf(ref) === -1) {
20731                             merge(next, parentSchema, parentSchemaURL, segments[1]); // can set next.$ref again, use seenRefs to avoid circle
20732                             seenRefs.push(ref);
20733                         }
20734                     }
20735                 }
20736                 collectEntries(next.items, next.additionalProperties, next.not, next.contains, next.propertyNames, next.if, next.then, next.else);
20737                 collectMapEntries(next.definitions, next.properties, next.patternProperties, next.dependencies);
20738                 collectArrayEntries(next.anyOf, next.allOf, next.oneOf, next.items);
20739             };
20740             while (toWalk.length) {
20741                 var next = toWalk.pop();
20742                 if (seen.indexOf(next) >= 0) {
20743                     continue;
20744                 }
20745                 seen.push(next);
20746                 handleRef(next);
20747             }
20748             return _this.promise.all(openPromises);
20749         };
20750         return resolveRefs(schema, schema, schemaURL, dependencies).then(function (_) { return new ResolvedSchema(schema, resolveErrors); });
20751     };
20752     JSONSchemaService.prototype.getSchemaForResource = function (resource, document) {
20753         // first use $schema if present
20754         if (document && document.root && document.root.type === 'object') {
20755             var schemaProperties = document.root.properties.filter(function (p) { return (p.keyNode.value === '$schema') && p.valueNode && p.valueNode.type === 'string'; });
20756             if (schemaProperties.length > 0) {
20757                 var schemeId = _parser_jsonParser__WEBPACK_IMPORTED_MODULE_3__["getNodeValue"](schemaProperties[0].valueNode);
20758                 if (schemeId && _utils_strings__WEBPACK_IMPORTED_MODULE_2__["startsWith"](schemeId, '.') && this.contextService) {
20759                     schemeId = this.contextService.resolveRelativePath(schemeId, resource);
20760                 }
20761                 if (schemeId) {
20762                     var id = this.normalizeId(schemeId);
20763                     return this.getOrAddSchemaHandle(id).getResolvedSchema();
20764                 }
20765             }
20766         }
20767         var seen = Object.create(null);
20768         var schemas = [];
20769         for (var _i = 0, _a = this.filePatternAssociations; _i < _a.length; _i++) {
20770             var entry = _a[_i];
20771             if (entry.matchesPattern(resource)) {
20772                 for (var _b = 0, _c = entry.getSchemas(); _b < _c.length; _b++) {
20773                     var schemaId = _c[_b];
20774                     if (!seen[schemaId]) {
20775                         schemas.push(schemaId);
20776                         seen[schemaId] = true;
20777                     }
20778                 }
20779             }
20780         }
20781         if (schemas.length > 0) {
20782             return this.createCombinedSchema(resource, schemas).getResolvedSchema();
20783         }
20784         return this.promise.resolve(null);
20785     };
20786     JSONSchemaService.prototype.createCombinedSchema = function (resource, schemaIds) {
20787         if (schemaIds.length === 1) {
20788             return this.getOrAddSchemaHandle(schemaIds[0]);
20789         }
20790         else {
20791             var combinedSchemaId = 'schemaservice://combinedSchema/' + encodeURIComponent(resource);
20792             var combinedSchema = {
20793                 allOf: schemaIds.map(function (schemaId) { return ({ $ref: schemaId }); })
20794             };
20795             return this.addSchemaHandle(combinedSchemaId, combinedSchema);
20796         }
20797     };
20798     return JSONSchemaService;
20799 }());
20800
20801 function toDisplayString(url) {
20802     try {
20803         var uri = vscode_uri__WEBPACK_IMPORTED_MODULE_1__["URI"].parse(url);
20804         if (uri.scheme === 'file') {
20805             return uri.fsPath;
20806         }
20807     }
20808     catch (e) {
20809         // ignore
20810     }
20811     return url;
20812 }
20813
20814
20815 /***/ }),
20816 /* 95 */
20817 /***/ (function(module, __webpack_exports__, __webpack_require__) {
20818
20819 "use strict";
20820 __webpack_require__.r(__webpack_exports__);
20821 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setUriThrowOnMissingScheme", function() { return setUriThrowOnMissingScheme; });
20822 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "URI", function() { return URI; });
20823 /*---------------------------------------------------------------------------------------------
20824  *  Copyright (c) Microsoft Corporation. All rights reserved.
20825  *  Licensed under the MIT License. See License.txt in the project root for license information.
20826  *--------------------------------------------------------------------------------------------*/
20827
20828 var __extends = (undefined && undefined.__extends) || (function () {
20829     var extendStatics = Object.setPrototypeOf ||
20830         ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
20831         function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
20832     return function (d, b) {
20833         extendStatics(d, b);
20834         function __() { this.constructor = d; }
20835         d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
20836     };
20837 })();
20838 var isWindows;
20839 if (typeof process === 'object') {
20840     isWindows = process.platform === 'win32';
20841 }
20842 else if (typeof navigator === 'object') {
20843     var userAgent = navigator.userAgent;
20844     isWindows = userAgent.indexOf('Windows') >= 0;
20845 }
20846 //#endregion
20847 var _schemePattern = /^\w[\w\d+.-]*$/;
20848 var _singleSlashStart = /^\//;
20849 var _doubleSlashStart = /^\/\//;
20850 var _throwOnMissingSchema = true;
20851 /**
20852  * @internal
20853  */
20854 function setUriThrowOnMissingScheme(value) {
20855     var old = _throwOnMissingSchema;
20856     _throwOnMissingSchema = value;
20857     return old;
20858 }
20859 function _validateUri(ret, _strict) {
20860     // scheme, must be set
20861     if (!ret.scheme) {
20862         if (_strict || _throwOnMissingSchema) {
20863             throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
20864         }
20865         else {
20866             // console.warn(`[UriError]: Scheme is missing: {scheme: "", authority: "${ret.authority}", path: "${ret.path}", query: "${ret.query}", fragment: "${ret.fragment}"}`);
20867         }
20868     }
20869     // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
20870     // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
20871     if (ret.scheme && !_schemePattern.test(ret.scheme)) {
20872         throw new Error('[UriError]: Scheme contains illegal characters.');
20873     }
20874     // path, http://tools.ietf.org/html/rfc3986#section-3.3
20875     // If a URI contains an authority component, then the path component
20876     // must either be empty or begin with a slash ("/") character.  If a URI
20877     // does not contain an authority component, then the path cannot begin
20878     // with two slash characters ("//").
20879     if (ret.path) {
20880         if (ret.authority) {
20881             if (!_singleSlashStart.test(ret.path)) {
20882                 throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
20883             }
20884         }
20885         else {
20886             if (_doubleSlashStart.test(ret.path)) {
20887                 throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
20888             }
20889         }
20890     }
20891 }
20892 // for a while we allowed uris *without* schemes and this is the migration
20893 // for them, e.g. an uri without scheme and without strict-mode warns and falls
20894 // back to the file-scheme. that should cause the least carnage and still be a
20895 // clear warning
20896 function _schemeFix(scheme, _strict) {
20897     if (_strict || _throwOnMissingSchema) {
20898         return scheme || _empty;
20899     }
20900     if (!scheme) {
20901         // console.trace('BAD uri lacks scheme, falling back to file-scheme.');
20902         scheme = 'file';
20903     }
20904     return scheme;
20905 }
20906 // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
20907 function _referenceResolution(scheme, path) {
20908     // the slash-character is our 'default base' as we don't
20909     // support constructing URIs relative to other URIs. This
20910     // also means that we alter and potentially break paths.
20911     // see https://tools.ietf.org/html/rfc3986#section-5.1.4
20912     switch (scheme) {
20913         case 'https':
20914         case 'http':
20915         case 'file':
20916             if (!path) {
20917                 path = _slash;
20918             }
20919             else if (path[0] !== _slash) {
20920                 path = _slash + path;
20921             }
20922             break;
20923     }
20924     return path;
20925 }
20926 var _empty = '';
20927 var _slash = '/';
20928 var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
20929 function _isQueryStringScheme(scheme) {
20930     if (!scheme) {
20931         return false;
20932     }
20933     switch (scheme.toLowerCase()) {
20934         case 'http':
20935         case 'https':
20936         case 'ftp':
20937             return true;
20938     }
20939     return false;
20940 }
20941 /**
20942  * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
20943  * This class is a simple parser which creates the basic component parts
20944  * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
20945  * and encoding.
20946  *
20947  *       foo://example.com:8042/over/there?name=ferret#nose
20948  *       \_/   \______________/\_________/ \_________/ \__/
20949  *        |           |            |            |        |
20950  *     scheme     authority       path        query   fragment
20951  *        |   _____________________|__
20952  *       / \ /                        \
20953  *       urn:example:animal:ferret:nose
20954  */
20955 var URI = (function () {
20956     /**
20957      * @internal
20958      */
20959     function URI(schemeOrData, authority, path, query, fragment, _strict) {
20960         if (_strict === void 0) { _strict = false; }
20961         if (typeof schemeOrData === 'object') {
20962             this.scheme = schemeOrData.scheme || _empty;
20963             this.authority = schemeOrData.authority || _empty;
20964             this.path = schemeOrData.path || _empty;
20965             this.query = schemeOrData.query || _empty;
20966             this.fragment = schemeOrData.fragment || _empty;
20967             // no validation because it's this URI
20968             // that creates uri components.
20969             // _validateUri(this);
20970         }
20971         else {
20972             this.scheme = _schemeFix(schemeOrData, _strict);
20973             this.authority = authority || _empty;
20974             this.path = _referenceResolution(this.scheme, path || _empty);
20975             this.query = query || _empty;
20976             this.fragment = fragment || _empty;
20977             _validateUri(this, _strict);
20978         }
20979     }
20980     URI.isUri = function (thing) {
20981         if (thing instanceof URI) {
20982             return true;
20983         }
20984         if (!thing) {
20985             return false;
20986         }
20987         return typeof thing.authority === 'string'
20988             && typeof thing.fragment === 'string'
20989             && typeof thing.path === 'string'
20990             && typeof thing.query === 'string'
20991             && typeof thing.scheme === 'string'
20992             && typeof thing.fsPath === 'function'
20993             && typeof thing.with === 'function'
20994             && typeof thing.toString === 'function';
20995     };
20996     Object.defineProperty(URI.prototype, "fsPath", {
20997         // ---- filesystem path -----------------------
20998         /**
20999          * Returns a string representing the corresponding file system path of this URI.
21000          * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
21001          * platform specific path separator.
21002          *
21003          * * Will *not* validate the path for invalid characters and semantics.
21004          * * Will *not* look at the scheme of this URI.
21005          * * The result shall *not* be used for display purposes but for accessing a file on disk.
21006          *
21007          *
21008          * The *difference* to `URI#path` is the use of the platform specific separator and the handling
21009          * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
21010          *
21011          * ```ts
21012             const u = URI.parse('file://server/c$/folder/file.txt')
21013             u.authority === 'server'
21014             u.path === '/shares/c$/file.txt'
21015             u.fsPath === '\\server\c$\folder\file.txt'
21016         ```
21017          *
21018          * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
21019          * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
21020          * with URIs that represent files on disk (`file` scheme).
21021          */
21022         get: function () {
21023             // if (this.scheme !== 'file') {
21024             //  console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
21025             // }
21026             return _makeFsPath(this);
21027         },
21028         enumerable: true,
21029         configurable: true
21030     });
21031     // ---- modify to new -------------------------
21032     URI.prototype.with = function (change) {
21033         if (!change) {
21034             return this;
21035         }
21036         var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
21037         if (scheme === undefined) {
21038             scheme = this.scheme;
21039         }
21040         else if (scheme === null) {
21041             scheme = _empty;
21042         }
21043         if (authority === undefined) {
21044             authority = this.authority;
21045         }
21046         else if (authority === null) {
21047             authority = _empty;
21048         }
21049         if (path === undefined) {
21050             path = this.path;
21051         }
21052         else if (path === null) {
21053             path = _empty;
21054         }
21055         if (query === undefined) {
21056             query = this.query;
21057         }
21058         else if (query === null) {
21059             query = _empty;
21060         }
21061         if (fragment === undefined) {
21062             fragment = this.fragment;
21063         }
21064         else if (fragment === null) {
21065             fragment = _empty;
21066         }
21067         if (scheme === this.scheme
21068             && authority === this.authority
21069             && path === this.path
21070             && query === this.query
21071             && fragment === this.fragment) {
21072             return this;
21073         }
21074         return new _URI(scheme, authority, path, query, fragment);
21075     };
21076     // ---- parse & validate ------------------------
21077     /**
21078      * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
21079      * `file:///usr/home`, or `scheme:with/path`.
21080      *
21081      * @param value A string which represents an URI (see `URI#toString`).
21082      */
21083     URI.parse = function (value, _strict) {
21084         if (_strict === void 0) { _strict = false; }
21085         var match = _regexp.exec(value);
21086         if (!match) {
21087             return new _URI(_empty, _empty, _empty, _empty, _empty, _strict);
21088         }
21089         return new _URI(match[2] || _empty, decodeURIComponentFast(match[4] || _empty, false, false), decodeURIComponentFast(match[5] || _empty, true, false), decodeURIComponentFast(match[7] || _empty, false, _isQueryStringScheme(match[2])), decodeURIComponentFast(match[9] || _empty, false, false), _strict);
21090     };
21091     /**
21092      * Creates a new URI from a file system path, e.g. `c:\my\files`,
21093      * `/usr/home`, or `\\server\share\some\path`.
21094      *
21095      * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
21096      * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
21097      * `URI.parse('file://' + path)` because the path might contain characters that are
21098      * interpreted (# and ?). See the following sample:
21099      * ```ts
21100     const good = URI.file('/coding/c#/project1');
21101     good.scheme === 'file';
21102     good.path === '/coding/c#/project1';
21103     good.fragment === '';
21104     const bad = URI.parse('file://' + '/coding/c#/project1');
21105     bad.scheme === 'file';
21106     bad.path === '/coding/c'; // path is now broken
21107     bad.fragment === '/project1';
21108     ```
21109      *
21110      * @param path A file system path (see `URI#fsPath`)
21111      */
21112     URI.file = function (path) {
21113         var authority = _empty;
21114         // normalize to fwd-slashes on windows,
21115         // on other systems bwd-slashes are valid
21116         // filename character, e.g. /f\oo/ba\r.txt
21117         if (isWindows) {
21118             path = path.replace(/\\/g, _slash);
21119         }
21120         // check for authority as used in UNC shares
21121         // or use the path as given
21122         if (path[0] === _slash && path[1] === _slash) {
21123             var idx = path.indexOf(_slash, 2);
21124             if (idx === -1) {
21125                 authority = path.substring(2);
21126                 path = _slash;
21127             }
21128             else {
21129                 authority = path.substring(2, idx);
21130                 path = path.substring(idx) || _slash;
21131             }
21132         }
21133         return new _URI('file', authority, path, _empty, _empty);
21134     };
21135     URI.from = function (components) {
21136         return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
21137     };
21138     // ---- printing/externalize ---------------------------
21139     /**
21140      * Creates a string representation for this URI. It's guaranteed that calling
21141      * `URI.parse` with the result of this function creates an URI which is equal
21142      * to this URI.
21143      *
21144      * * The result shall *not* be used for display purposes but for externalization or transport.
21145      * * The result will be encoded using the percentage encoding and encoding happens mostly
21146      * ignore the scheme-specific encoding rules.
21147      *
21148      * @param skipEncoding Do not encode the result, default is `false`
21149      */
21150     URI.prototype.toString = function (skipEncoding) {
21151         if (skipEncoding === void 0) { skipEncoding = false; }
21152         return _asFormatted(this, skipEncoding);
21153     };
21154     URI.prototype.toJSON = function () {
21155         return this;
21156     };
21157     URI.revive = function (data) {
21158         if (!data) {
21159             return data;
21160         }
21161         else if (data instanceof URI) {
21162             return data;
21163         }
21164         else {
21165             var result = new _URI(data);
21166             result._formatted = data.external;
21167             result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
21168             return result;
21169         }
21170     };
21171     return URI;
21172 }());
21173
21174 var _pathSepMarker = isWindows ? 1 : undefined;
21175 // tslint:disable-next-line:class-name
21176 var _URI = (function (_super) {
21177     __extends(_URI, _super);
21178     function _URI() {
21179         var _this = _super !== null && _super.apply(this, arguments) || this;
21180         _this._formatted = null;
21181         _this._fsPath = null;
21182         return _this;
21183     }
21184     Object.defineProperty(_URI.prototype, "fsPath", {
21185         get: function () {
21186             if (!this._fsPath) {
21187                 this._fsPath = _makeFsPath(this);
21188             }
21189             return this._fsPath;
21190         },
21191         enumerable: true,
21192         configurable: true
21193     });
21194     _URI.prototype.toString = function (skipEncoding) {
21195         if (skipEncoding === void 0) { skipEncoding = false; }
21196         if (!skipEncoding) {
21197             if (!this._formatted) {
21198                 this._formatted = _asFormatted(this, false);
21199             }
21200             return this._formatted;
21201         }
21202         else {
21203             // we don't cache that
21204             return _asFormatted(this, true);
21205         }
21206     };
21207     _URI.prototype.toJSON = function () {
21208         var res = {
21209             $mid: 1
21210         };
21211         // cached state
21212         if (this._fsPath) {
21213             res.fsPath = this._fsPath;
21214             res._sep = _pathSepMarker;
21215         }
21216         if (this._formatted) {
21217             res.external = this._formatted;
21218         }
21219         // uri components
21220         if (this.path) {
21221             res.path = this.path;
21222         }
21223         if (this.scheme) {
21224             res.scheme = this.scheme;
21225         }
21226         if (this.authority) {
21227             res.authority = this.authority;
21228         }
21229         if (this.query) {
21230             res.query = this.query;
21231         }
21232         if (this.fragment) {
21233             res.fragment = this.fragment;
21234         }
21235         return res;
21236     };
21237     return _URI;
21238 }(URI));
21239 function isHex(value, pos) {
21240     if (pos >= value.length) {
21241         return false;
21242     }
21243     var code = value.charCodeAt(pos);
21244     return (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */) // 0-9
21245         || (code >= 97 /* a */ && code <= 102 /* f */) //a-f
21246         || (code >= 65 /* A */ && code <= 70 /* F */); //A-F
21247 }
21248 function decodeURIComponentFast(uriComponent, isPath, isQueryString) {
21249     var res;
21250     var nativeDecodePos = -1;
21251     for (var pos = 0; pos < uriComponent.length; pos++) {
21252         var code = uriComponent.charCodeAt(pos);
21253         // decoding needed
21254         if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
21255             var chA = uriComponent.charCodeAt(pos + 1);
21256             var chB = uriComponent.charCodeAt(pos + 2);
21257             // when in a path -> check and accept %2f and %2F (fwd slash)
21258             // when in a query string -> check and accept %3D, %26, and %3B (equals, ampersand, semi-colon)
21259             if ((isPath && chA === 50 /* Digit2 */ && (chB === 70 /* F */ || chB === 102 /* f */))
21260                 ||
21261                     (isQueryString && ((chA === 50 /* Digit2 */ && chB === 54 /* Digit6 */) // %26
21262                         ||
21263                             (chA === 51 /* Digit3 */ && (chB === 66 /* B */ || chB === 98 /* b */ || chB === 68 /* D */ || chB === 100 /* d */)) // %3D, %3D
21264                     ))) {
21265                 if (nativeDecodePos !== -1) {
21266                     res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
21267                     nativeDecodePos = -1;
21268                 }
21269                 if (res !== undefined) {
21270                     res += uriComponent.substr(pos, 3);
21271                 }
21272                 pos += 2;
21273                 continue;
21274             }
21275             if (res === undefined) {
21276                 res = uriComponent.substring(0, pos);
21277             }
21278             if (nativeDecodePos === -1) {
21279                 nativeDecodePos = pos;
21280             }
21281             pos += 2;
21282         }
21283         else {
21284             if (nativeDecodePos !== -1) {
21285                 res += decodeURIComponent(uriComponent.substring(nativeDecodePos, pos));
21286                 nativeDecodePos = -1;
21287             }
21288             if (res !== undefined) {
21289                 res += String.fromCharCode(code);
21290             }
21291         }
21292     }
21293     if (nativeDecodePos !== -1) {
21294         res += decodeURIComponent(uriComponent.substr(nativeDecodePos));
21295     }
21296     return res !== undefined ? res : uriComponent;
21297 }
21298 // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
21299 var encodeTable = (_a = {},
21300     _a[58 /* Colon */] = '%3A',
21301     _a[47 /* Slash */] = '%2F',
21302     _a[63 /* QuestionMark */] = '%3F',
21303     _a[35 /* Hash */] = '%23',
21304     _a[91 /* OpenSquareBracket */] = '%5B',
21305     _a[93 /* CloseSquareBracket */] = '%5D',
21306     _a[64 /* AtSign */] = '%40',
21307     _a[33 /* ExclamationMark */] = '%21',
21308     _a[36 /* DollarSign */] = '%24',
21309     _a[38 /* Ampersand */] = '%26',
21310     _a[39 /* SingleQuote */] = '%27',
21311     _a[40 /* OpenParen */] = '%28',
21312     _a[41 /* CloseParen */] = '%29',
21313     _a[42 /* Asterisk */] = '%2A',
21314     _a[43 /* Plus */] = '%2B',
21315     _a[44 /* Comma */] = '%2C',
21316     _a[59 /* Semicolon */] = '%3B',
21317     _a[61 /* Equals */] = '%3D',
21318     _a[32 /* Space */] = '%20',
21319     _a);
21320 function encodeURIComponentFast(uriComponent, isPath, isQueryString) {
21321     var res = undefined;
21322     var nativeEncodePos = -1;
21323     for (var pos = 0; pos < uriComponent.length; pos++) {
21324         var code = uriComponent.charCodeAt(pos);
21325         // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
21326         if ((code >= 97 /* a */ && code <= 122 /* z */)
21327             || (code >= 65 /* A */ && code <= 90 /* Z */)
21328             || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
21329             || code === 45 /* Dash */
21330             || code === 46 /* Period */
21331             || code === 95 /* Underline */
21332             || code === 126 /* Tilde */
21333             || (isPath && code === 47 /* Slash */) // path => allow slash AS-IS
21334             || (isQueryString && (code === 61 /* Equals */ || code === 38 /* Ampersand */ || code === 59 /* Semicolon */)) // query string => allow &=;
21335         ) {
21336             // check if we are delaying native encode
21337             if (nativeEncodePos !== -1) {
21338                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
21339                 nativeEncodePos = -1;
21340             }
21341             // check if we write into a new string (by default we try to return the param)
21342             if (res !== undefined) {
21343                 res += uriComponent.charAt(pos);
21344             }
21345         }
21346         else if (code === 37 /* PercentSign */ && isHex(uriComponent, pos + 1) && isHex(uriComponent, pos + 2)) {
21347             // at percentage encoded value
21348             // check if we are delaying native encode
21349             if (nativeEncodePos !== -1) {
21350                 res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
21351                 nativeEncodePos = -1;
21352             }
21353             // check if we write into a new string (by default we try to return the param)
21354             if (res !== undefined) {
21355                 res += uriComponent.substr(pos, 3);
21356             }
21357             pos += 2;
21358         }
21359         else {
21360             // encoding needed, we need to allocate a new string
21361             if (res === undefined) {
21362                 res = uriComponent.substr(0, pos);
21363             }
21364             // check with default table first
21365             var escaped = encodeTable[code];
21366             if (escaped !== undefined) {
21367                 // check if we are delaying native encode
21368                 if (nativeEncodePos !== -1) {
21369                     res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
21370                     nativeEncodePos = -1;
21371                 }
21372                 // append escaped variant to result
21373                 res += escaped;
21374             }
21375             else if (nativeEncodePos === -1) {
21376                 // use native encode only when needed
21377                 nativeEncodePos = pos;
21378             }
21379         }
21380     }
21381     if (nativeEncodePos !== -1) {
21382         res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
21383     }
21384     return res !== undefined ? res : uriComponent;
21385 }
21386 function encodeURIComponentMinimal(path) {
21387     var res = undefined;
21388     for (var pos = 0; pos < path.length; pos++) {
21389         var code = path.charCodeAt(pos);
21390         if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
21391             if (res === undefined) {
21392                 res = path.substr(0, pos);
21393             }
21394             res += encodeTable[code];
21395         }
21396         else {
21397             if (res !== undefined) {
21398                 res += path[pos];
21399             }
21400         }
21401     }
21402     return res !== undefined ? res : path;
21403 }
21404 /**
21405  * Compute `fsPath` for the given uri
21406  */
21407 function _makeFsPath(uri) {
21408     var value;
21409     if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
21410         // unc path: file://shares/c$/far/boo
21411         value = "//" + uri.authority + uri.path;
21412     }
21413     else if (uri.path.charCodeAt(0) === 47 /* Slash */
21414         && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
21415         && uri.path.charCodeAt(2) === 58 /* Colon */) {
21416         // windows drive letter: file:///c:/far/boo
21417         value = uri.path[1].toLowerCase() + uri.path.substr(2);
21418     }
21419     else {
21420         // other path
21421         value = uri.path;
21422     }
21423     if (isWindows) {
21424         value = value.replace(/\//g, '\\');
21425     }
21426     return value;
21427 }
21428 /**
21429  * Create the external version of a uri
21430  */
21431 function _asFormatted(uri, skipEncoding) {
21432     var encoder = !skipEncoding
21433         ? encodeURIComponentFast
21434         : encodeURIComponentMinimal;
21435     var res = '';
21436     var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
21437     if (scheme) {
21438         res += scheme;
21439         res += ':';
21440     }
21441     if (authority || scheme === 'file') {
21442         res += _slash;
21443         res += _slash;
21444     }
21445     if (authority) {
21446         var idx = authority.indexOf('@');
21447         if (idx !== -1) {
21448             // <user>@<auth>
21449             var userinfo = authority.substr(0, idx);
21450             authority = authority.substr(idx + 1);
21451             idx = userinfo.indexOf(':');
21452             if (idx === -1) {
21453                 res += encoder(userinfo, false, false);
21454             }
21455             else {
21456                 // <user>:<pass>@<auth>
21457                 res += encoder(userinfo.substr(0, idx), false, false);
21458                 res += ':';
21459                 res += encoder(userinfo.substr(idx + 1), false, false);
21460             }
21461             res += '@';
21462         }
21463         authority = authority.toLowerCase();
21464         idx = authority.indexOf(':');
21465         if (idx === -1) {
21466             res += encoder(authority, false, false);
21467         }
21468         else {
21469             // <auth>:<port>
21470             res += encoder(authority.substr(0, idx), false, false);
21471             res += authority.substr(idx);
21472         }
21473     }
21474     if (path) {
21475         // lower-case windows drive letters in /C:/fff or C:/fff
21476         if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
21477             var code = path.charCodeAt(1);
21478             if (code >= 65 /* A */ && code <= 90 /* Z */) {
21479                 path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
21480             }
21481         }
21482         else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
21483             var code = path.charCodeAt(0);
21484             if (code >= 65 /* A */ && code <= 90 /* Z */) {
21485                 path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
21486             }
21487         }
21488         // encode the rest of the path
21489         res += encoder(path, true, false);
21490     }
21491     if (query) {
21492         res += '?';
21493         res += encoder(query, false, _isQueryStringScheme(scheme));
21494     }
21495     if (fragment) {
21496         res += '#';
21497         res += !skipEncoding ? encodeURIComponentFast(fragment, false, false) : fragment;
21498     }
21499     return res;
21500 }
21501 var _a;
21502
21503
21504 /***/ }),
21505 /* 96 */
21506 /***/ (function(module, __webpack_exports__, __webpack_require__) {
21507
21508 "use strict";
21509 __webpack_require__.r(__webpack_exports__);
21510 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JSONDocumentSymbols", function() { return JSONDocumentSymbols; });
21511 /* harmony import */ var _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(82);
21512 /* harmony import */ var _utils_strings__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(91);
21513 /* harmony import */ var _utils_colors__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(97);
21514 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(80);
21515 /*---------------------------------------------------------------------------------------------
21516  *  Copyright (c) Microsoft Corporation. All rights reserved.
21517  *  Licensed under the MIT License. See License.txt in the project root for license information.
21518  *--------------------------------------------------------------------------------------------*/
21519
21520
21521
21522
21523 var JSONDocumentSymbols = /** @class */ (function () {
21524     function JSONDocumentSymbols(schemaService) {
21525         this.schemaService = schemaService;
21526     }
21527     JSONDocumentSymbols.prototype.findDocumentSymbols = function (document, doc) {
21528         var _this = this;
21529         var root = doc.root;
21530         if (!root) {
21531             return null;
21532         }
21533         // special handling for key bindings
21534         var resourceString = document.uri;
21535         if ((resourceString === 'vscode://defaultsettings/keybindings.json') || _utils_strings__WEBPACK_IMPORTED_MODULE_1__["endsWith"](resourceString.toLowerCase(), '/user/keybindings.json')) {
21536             if (root.type === 'array') {
21537                 var result_1 = [];
21538                 root.items.forEach(function (item) {
21539                     if (item.type === 'object') {
21540                         for (var _i = 0, _a = item.properties; _i < _a.length; _i++) {
21541                             var property = _a[_i];
21542                             if (property.keyNode.value === 'key') {
21543                                 if (property.valueNode) {
21544                                     if (property.valueNode) {
21545                                         var location = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["Location"].create(document.uri, getRange(document, item));
21546                                         result_1.push({ name: _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodeValue"](property.valueNode), kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Function, location: location });
21547                                     }
21548                                     return;
21549                                 }
21550                             }
21551                         }
21552                     }
21553                 });
21554                 return result_1;
21555             }
21556         }
21557         var collectOutlineEntries = function (result, node, containerName) {
21558             if (node.type === 'array') {
21559                 node.items.forEach(function (node) { return collectOutlineEntries(result, node, containerName); });
21560             }
21561             else if (node.type === 'object') {
21562                 node.properties.forEach(function (property) {
21563                     var location = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["Location"].create(document.uri, getRange(document, property));
21564                     var valueNode = property.valueNode;
21565                     if (valueNode) {
21566                         var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value;
21567                         result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName });
21568                         collectOutlineEntries(result, valueNode, childContainerName);
21569                     }
21570                 });
21571             }
21572             return result;
21573         };
21574         var result = collectOutlineEntries([], root, void 0);
21575         return result;
21576     };
21577     JSONDocumentSymbols.prototype.findDocumentSymbols2 = function (document, doc) {
21578         var _this = this;
21579         var root = doc.root;
21580         if (!root) {
21581             return null;
21582         }
21583         // special handling for key bindings
21584         var resourceString = document.uri;
21585         if ((resourceString === 'vscode://defaultsettings/keybindings.json') || _utils_strings__WEBPACK_IMPORTED_MODULE_1__["endsWith"](resourceString.toLowerCase(), '/user/keybindings.json')) {
21586             if (root.type === 'array') {
21587                 var result_2 = [];
21588                 root.items.forEach(function (item) {
21589                     if (item.type === 'object') {
21590                         for (var _i = 0, _a = item.properties; _i < _a.length; _i++) {
21591                             var property = _a[_i];
21592                             if (property.keyNode.value === 'key') {
21593                                 if (property.valueNode) {
21594                                     var range = getRange(document, item);
21595                                     var selectionRange = getRange(document, property.keyNode);
21596                                     result_2.push({ name: _parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodeValue"](property.valueNode), kind: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Function, range: range, selectionRange: selectionRange });
21597                                 }
21598                                 return;
21599                             }
21600                         }
21601                     }
21602                 });
21603                 return result_2;
21604             }
21605         }
21606         var collectOutlineEntries = function (result, node) {
21607             if (node.type === 'array') {
21608                 node.items.forEach(function (node, index) {
21609                     if (node) {
21610                         var range = getRange(document, node);
21611                         var selectionRange = range;
21612                         var name = String(index);
21613                         var children = collectOutlineEntries([], node);
21614                         result.push({ name: name, kind: _this.getSymbolKind(node.type), range: range, selectionRange: selectionRange, children: children });
21615                     }
21616                 });
21617             }
21618             else if (node.type === 'object') {
21619                 node.properties.forEach(function (property) {
21620                     var valueNode = property.valueNode;
21621                     if (valueNode) {
21622                         var range = getRange(document, property);
21623                         var selectionRange = getRange(document, property.keyNode);
21624                         var children = collectOutlineEntries([], valueNode);
21625                         result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: children });
21626                     }
21627                 });
21628             }
21629             return result;
21630         };
21631         var result = collectOutlineEntries([], root);
21632         return result;
21633     };
21634     JSONDocumentSymbols.prototype.getSymbolKind = function (nodeType) {
21635         switch (nodeType) {
21636             case 'object':
21637                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Module;
21638             case 'string':
21639                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].String;
21640             case 'number':
21641                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Number;
21642             case 'array':
21643                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Array;
21644             case 'boolean':
21645                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Boolean;
21646             default: // 'null'
21647                 return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["SymbolKind"].Variable;
21648         }
21649     };
21650     JSONDocumentSymbols.prototype.getKeyLabel = function (property) {
21651         var name = property.keyNode.value;
21652         if (name) {
21653             name = name.replace(/[\n]/g, '↵');
21654         }
21655         if (name && name.trim()) {
21656             return name;
21657         }
21658         return "\"" + name + "\"";
21659     };
21660     JSONDocumentSymbols.prototype.findDocumentColors = function (document, doc) {
21661         return this.schemaService.getSchemaForResource(document.uri, doc).then(function (schema) {
21662             var result = [];
21663             if (schema) {
21664                 var matchingSchemas = doc.getMatchingSchemas(schema.schema);
21665                 var visitedNode = {};
21666                 for (var _i = 0, matchingSchemas_1 = matchingSchemas; _i < matchingSchemas_1.length; _i++) {
21667                     var s = matchingSchemas_1[_i];
21668                     if (!s.inverted && s.schema && (s.schema.format === 'color' || s.schema.format === 'color-hex') && s.node && s.node.type === 'string') {
21669                         var nodeId = String(s.node.offset);
21670                         if (!visitedNode[nodeId]) {
21671                             var color = Object(_utils_colors__WEBPACK_IMPORTED_MODULE_2__["colorFromHex"])(_parser_jsonParser__WEBPACK_IMPORTED_MODULE_0__["getNodeValue"](s.node));
21672                             if (color) {
21673                                 var range = getRange(document, s.node);
21674                                 result.push({ color: color, range: range });
21675                             }
21676                             visitedNode[nodeId] = true;
21677                         }
21678                     }
21679                 }
21680             }
21681             return result;
21682         });
21683     };
21684     JSONDocumentSymbols.prototype.getColorPresentations = function (document, doc, color, range) {
21685         var result = [];
21686         var red256 = Math.round(color.red * 255), green256 = Math.round(color.green * 255), blue256 = Math.round(color.blue * 255);
21687         function toTwoDigitHex(n) {
21688             var r = n.toString(16);
21689             return r.length !== 2 ? '0' + r : r;
21690         }
21691         var label;
21692         if (color.alpha === 1) {
21693             label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256);
21694         }
21695         else {
21696             label = "#" + toTwoDigitHex(red256) + toTwoDigitHex(green256) + toTwoDigitHex(blue256) + toTwoDigitHex(Math.round(color.alpha * 255));
21697         }
21698         result.push({ label: label, textEdit: vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["TextEdit"].replace(range, JSON.stringify(label)) });
21699         return result;
21700     };
21701     return JSONDocumentSymbols;
21702 }());
21703
21704 function getRange(document, node) {
21705     return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_3__["Range"].create(document.positionAt(node.offset), document.positionAt(node.offset + node.length));
21706 }
21707
21708
21709 /***/ }),
21710 /* 97 */
21711 /***/ (function(module, __webpack_exports__, __webpack_require__) {
21712
21713 "use strict";
21714 __webpack_require__.r(__webpack_exports__);
21715 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hexDigit", function() { return hexDigit; });
21716 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorFromHex", function() { return colorFromHex; });
21717 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorFrom256RGB", function() { return colorFrom256RGB; });
21718 /*---------------------------------------------------------------------------------------------
21719  *  Copyright (c) Microsoft Corporation. All rights reserved.
21720  *  Licensed under the MIT License. See License.txt in the project root for license information.
21721  *--------------------------------------------------------------------------------------------*/
21722 var Digit0 = 48;
21723 var Digit9 = 57;
21724 var A = 65;
21725 var a = 97;
21726 var f = 102;
21727 function hexDigit(charCode) {
21728     if (charCode < Digit0) {
21729         return 0;
21730     }
21731     if (charCode <= Digit9) {
21732         return charCode - Digit0;
21733     }
21734     if (charCode < a) {
21735         charCode += (a - A);
21736     }
21737     if (charCode >= a && charCode <= f) {
21738         return charCode - a + 10;
21739     }
21740     return 0;
21741 }
21742 function colorFromHex(text) {
21743     if (text[0] !== '#') {
21744         return null;
21745     }
21746     switch (text.length) {
21747         case 4:
21748             return {
21749                 red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
21750                 green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
21751                 blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
21752                 alpha: 1
21753             };
21754         case 5:
21755             return {
21756                 red: (hexDigit(text.charCodeAt(1)) * 0x11) / 255.0,
21757                 green: (hexDigit(text.charCodeAt(2)) * 0x11) / 255.0,
21758                 blue: (hexDigit(text.charCodeAt(3)) * 0x11) / 255.0,
21759                 alpha: (hexDigit(text.charCodeAt(4)) * 0x11) / 255.0,
21760             };
21761         case 7:
21762             return {
21763                 red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
21764                 green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
21765                 blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
21766                 alpha: 1
21767             };
21768         case 9:
21769             return {
21770                 red: (hexDigit(text.charCodeAt(1)) * 0x10 + hexDigit(text.charCodeAt(2))) / 255.0,
21771                 green: (hexDigit(text.charCodeAt(3)) * 0x10 + hexDigit(text.charCodeAt(4))) / 255.0,
21772                 blue: (hexDigit(text.charCodeAt(5)) * 0x10 + hexDigit(text.charCodeAt(6))) / 255.0,
21773                 alpha: (hexDigit(text.charCodeAt(7)) * 0x10 + hexDigit(text.charCodeAt(8))) / 255.0
21774             };
21775     }
21776     return null;
21777 }
21778 function colorFrom256RGB(red, green, blue, alpha) {
21779     if (alpha === void 0) { alpha = 1.0; }
21780     return {
21781         red: red / 255.0,
21782         green: green / 255.0,
21783         blue: blue / 255.0,
21784         alpha: alpha
21785     };
21786 }
21787
21788
21789 /***/ }),
21790 /* 98 */
21791 /***/ (function(module, __webpack_exports__, __webpack_require__) {
21792
21793 "use strict";
21794 __webpack_require__.r(__webpack_exports__);
21795 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "schemaContributions", function() { return schemaContributions; });
21796 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(76);
21797 /* harmony import */ var vscode_nls__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(vscode_nls__WEBPACK_IMPORTED_MODULE_0__);
21798 /*---------------------------------------------------------------------------------------------
21799  *  Copyright (c) Microsoft Corporation. All rights reserved.
21800  *  Licensed under the MIT License. See License.txt in the project root for license information.
21801  *--------------------------------------------------------------------------------------------*/
21802
21803 var localize = vscode_nls__WEBPACK_IMPORTED_MODULE_0__["loadMessageBundle"]();
21804 var schemaContributions = {
21805     schemaAssociations: {},
21806     schemas: {
21807         // bundle the schema-schema to include (localized) descriptions
21808         'http://json-schema.org/draft-04/schema#': {
21809             'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
21810             '$schema': 'http://json-schema.org/draft-04/schema#',
21811             'definitions': {
21812                 'schemaArray': {
21813                     'type': 'array',
21814                     'minItems': 1,
21815                     'items': {
21816                         '$ref': '#'
21817                     }
21818                 },
21819                 'positiveInteger': {
21820                     'type': 'integer',
21821                     'minimum': 0
21822                 },
21823                 'positiveIntegerDefault0': {
21824                     'allOf': [
21825                         {
21826                             '$ref': '#/definitions/positiveInteger'
21827                         },
21828                         {
21829                             'default': 0
21830                         }
21831                     ]
21832                 },
21833                 'simpleTypes': {
21834                     'type': 'string',
21835                     'enum': [
21836                         'array',
21837                         'boolean',
21838                         'integer',
21839                         'null',
21840                         'number',
21841                         'object',
21842                         'string'
21843                     ]
21844                 },
21845                 'stringArray': {
21846                     'type': 'array',
21847                     'items': {
21848                         'type': 'string'
21849                     },
21850                     'minItems': 1,
21851                     'uniqueItems': true
21852                 }
21853             },
21854             'type': 'object',
21855             'properties': {
21856                 'id': {
21857                     'type': 'string',
21858                     'format': 'uri'
21859                 },
21860                 '$schema': {
21861                     'type': 'string',
21862                     'format': 'uri'
21863                 },
21864                 'title': {
21865                     'type': 'string'
21866                 },
21867                 'description': {
21868                     'type': 'string'
21869                 },
21870                 'default': {},
21871                 'multipleOf': {
21872                     'type': 'number',
21873                     'minimum': 0,
21874                     'exclusiveMinimum': true
21875                 },
21876                 'maximum': {
21877                     'type': 'number'
21878                 },
21879                 'exclusiveMaximum': {
21880                     'type': 'boolean',
21881                     'default': false
21882                 },
21883                 'minimum': {
21884                     'type': 'number'
21885                 },
21886                 'exclusiveMinimum': {
21887                     'type': 'boolean',
21888                     'default': false
21889                 },
21890                 'maxLength': {
21891                     'allOf': [
21892                         {
21893                             '$ref': '#/definitions/positiveInteger'
21894                         }
21895                     ]
21896                 },
21897                 'minLength': {
21898                     'allOf': [
21899                         {
21900                             '$ref': '#/definitions/positiveIntegerDefault0'
21901                         }
21902                     ]
21903                 },
21904                 'pattern': {
21905                     'type': 'string',
21906                     'format': 'regex'
21907                 },
21908                 'additionalItems': {
21909                     'anyOf': [
21910                         {
21911                             'type': 'boolean'
21912                         },
21913                         {
21914                             '$ref': '#'
21915                         }
21916                     ],
21917                     'default': {}
21918                 },
21919                 'items': {
21920                     'anyOf': [
21921                         {
21922                             '$ref': '#'
21923                         },
21924                         {
21925                             '$ref': '#/definitions/schemaArray'
21926                         }
21927                     ],
21928                     'default': {}
21929                 },
21930                 'maxItems': {
21931                     'allOf': [
21932                         {
21933                             '$ref': '#/definitions/positiveInteger'
21934                         }
21935                     ]
21936                 },
21937                 'minItems': {
21938                     'allOf': [
21939                         {
21940                             '$ref': '#/definitions/positiveIntegerDefault0'
21941                         }
21942                     ]
21943                 },
21944                 'uniqueItems': {
21945                     'type': 'boolean',
21946                     'default': false
21947                 },
21948                 'maxProperties': {
21949                     'allOf': [
21950                         {
21951                             '$ref': '#/definitions/positiveInteger'
21952                         }
21953                     ]
21954                 },
21955                 'minProperties': {
21956                     'allOf': [
21957                         {
21958                             '$ref': '#/definitions/positiveIntegerDefault0'
21959                         }
21960                     ]
21961                 },
21962                 'required': {
21963                     'allOf': [
21964                         {
21965                             '$ref': '#/definitions/stringArray'
21966                         }
21967                     ]
21968                 },
21969                 'additionalProperties': {
21970                     'anyOf': [
21971                         {
21972                             'type': 'boolean'
21973                         },
21974                         {
21975                             '$ref': '#'
21976                         }
21977                     ],
21978                     'default': {}
21979                 },
21980                 'definitions': {
21981                     'type': 'object',
21982                     'additionalProperties': {
21983                         '$ref': '#'
21984                     },
21985                     'default': {}
21986                 },
21987                 'properties': {
21988                     'type': 'object',
21989                     'additionalProperties': {
21990                         '$ref': '#'
21991                     },
21992                     'default': {}
21993                 },
21994                 'patternProperties': {
21995                     'type': 'object',
21996                     'additionalProperties': {
21997                         '$ref': '#'
21998                     },
21999                     'default': {}
22000                 },
22001                 'dependencies': {
22002                     'type': 'object',
22003                     'additionalProperties': {
22004                         'anyOf': [
22005                             {
22006                                 '$ref': '#'
22007                             },
22008                             {
22009                                 '$ref': '#/definitions/stringArray'
22010                             }
22011                         ]
22012                     }
22013                 },
22014                 'enum': {
22015                     'type': 'array',
22016                     'minItems': 1,
22017                     'uniqueItems': true
22018                 },
22019                 'type': {
22020                     'anyOf': [
22021                         {
22022                             '$ref': '#/definitions/simpleTypes'
22023                         },
22024                         {
22025                             'type': 'array',
22026                             'items': {
22027                                 '$ref': '#/definitions/simpleTypes'
22028                             },
22029                             'minItems': 1,
22030                             'uniqueItems': true
22031                         }
22032                     ]
22033                 },
22034                 'format': {
22035                     'anyOf': [
22036                         {
22037                             'type': 'string',
22038                             'enum': [
22039                                 'date-time',
22040                                 'uri',
22041                                 'email',
22042                                 'hostname',
22043                                 'ipv4',
22044                                 'ipv6',
22045                                 'regex'
22046                             ]
22047                         },
22048                         {
22049                             'type': 'string'
22050                         }
22051                     ]
22052                 },
22053                 'allOf': {
22054                     'allOf': [
22055                         {
22056                             '$ref': '#/definitions/schemaArray'
22057                         }
22058                     ]
22059                 },
22060                 'anyOf': {
22061                     'allOf': [
22062                         {
22063                             '$ref': '#/definitions/schemaArray'
22064                         }
22065                     ]
22066                 },
22067                 'oneOf': {
22068                     'allOf': [
22069                         {
22070                             '$ref': '#/definitions/schemaArray'
22071                         }
22072                     ]
22073                 },
22074                 'not': {
22075                     'allOf': [
22076                         {
22077                             '$ref': '#'
22078                         }
22079                     ]
22080                 }
22081             },
22082             'dependencies': {
22083                 'exclusiveMaximum': [
22084                     'maximum'
22085                 ],
22086                 'exclusiveMinimum': [
22087                     'minimum'
22088                 ]
22089             },
22090             'default': {}
22091         },
22092         'http://json-schema.org/draft-07/schema#': {
22093             'title': localize('schema.json', 'Describes a JSON file using a schema. See json-schema.org for more info.'),
22094             'definitions': {
22095                 'schemaArray': {
22096                     'type': 'array',
22097                     'minItems': 1,
22098                     'items': { '$ref': '#' }
22099                 },
22100                 'nonNegativeInteger': {
22101                     'type': 'integer',
22102                     'minimum': 0
22103                 },
22104                 'nonNegativeIntegerDefault0': {
22105                     'allOf': [
22106                         { '$ref': '#/definitions/nonNegativeInteger' },
22107                         { 'default': 0 }
22108                     ]
22109                 },
22110                 'simpleTypes': {
22111                     'enum': [
22112                         'array',
22113                         'boolean',
22114                         'integer',
22115                         'null',
22116                         'number',
22117                         'object',
22118                         'string'
22119                     ]
22120                 },
22121                 'stringArray': {
22122                     'type': 'array',
22123                     'items': { 'type': 'string' },
22124                     'uniqueItems': true,
22125                     'default': []
22126                 }
22127             },
22128             'type': ['object', 'boolean'],
22129             'properties': {
22130                 '$id': {
22131                     'type': 'string',
22132                     'format': 'uri-reference'
22133                 },
22134                 '$schema': {
22135                     'type': 'string',
22136                     'format': 'uri'
22137                 },
22138                 '$ref': {
22139                     'type': 'string',
22140                     'format': 'uri-reference'
22141                 },
22142                 '$comment': {
22143                     'type': 'string'
22144                 },
22145                 'title': {
22146                     'type': 'string'
22147                 },
22148                 'description': {
22149                     'type': 'string'
22150                 },
22151                 'default': true,
22152                 'readOnly': {
22153                     'type': 'boolean',
22154                     'default': false
22155                 },
22156                 'examples': {
22157                     'type': 'array',
22158                     'items': true
22159                 },
22160                 'multipleOf': {
22161                     'type': 'number',
22162                     'exclusiveMinimum': 0
22163                 },
22164                 'maximum': {
22165                     'type': 'number'
22166                 },
22167                 'exclusiveMaximum': {
22168                     'type': 'number'
22169                 },
22170                 'minimum': {
22171                     'type': 'number'
22172                 },
22173                 'exclusiveMinimum': {
22174                     'type': 'number'
22175                 },
22176                 'maxLength': { '$ref': '#/definitions/nonNegativeInteger' },
22177                 'minLength': { '$ref': '#/definitions/nonNegativeIntegerDefault0' },
22178                 'pattern': {
22179                     'type': 'string',
22180                     'format': 'regex'
22181                 },
22182                 'additionalItems': { '$ref': '#' },
22183                 'items': {
22184                     'anyOf': [
22185                         { '$ref': '#' },
22186                         { '$ref': '#/definitions/schemaArray' }
22187                     ],
22188                     'default': true
22189                 },
22190                 'maxItems': { '$ref': '#/definitions/nonNegativeInteger' },
22191                 'minItems': { '$ref': '#/definitions/nonNegativeIntegerDefault0' },
22192                 'uniqueItems': {
22193                     'type': 'boolean',
22194                     'default': false
22195                 },
22196                 'contains': { '$ref': '#' },
22197                 'maxProperties': { '$ref': '#/definitions/nonNegativeInteger' },
22198                 'minProperties': { '$ref': '#/definitions/nonNegativeIntegerDefault0' },
22199                 'required': { '$ref': '#/definitions/stringArray' },
22200                 'additionalProperties': { '$ref': '#' },
22201                 'definitions': {
22202                     'type': 'object',
22203                     'additionalProperties': { '$ref': '#' },
22204                     'default': {}
22205                 },
22206                 'properties': {
22207                     'type': 'object',
22208                     'additionalProperties': { '$ref': '#' },
22209                     'default': {}
22210                 },
22211                 'patternProperties': {
22212                     'type': 'object',
22213                     'additionalProperties': { '$ref': '#' },
22214                     'propertyNames': { 'format': 'regex' },
22215                     'default': {}
22216                 },
22217                 'dependencies': {
22218                     'type': 'object',
22219                     'additionalProperties': {
22220                         'anyOf': [
22221                             { '$ref': '#' },
22222                             { '$ref': '#/definitions/stringArray' }
22223                         ]
22224                     }
22225                 },
22226                 'propertyNames': { '$ref': '#' },
22227                 'const': true,
22228                 'enum': {
22229                     'type': 'array',
22230                     'items': true,
22231                     'minItems': 1,
22232                     'uniqueItems': true
22233                 },
22234                 'type': {
22235                     'anyOf': [
22236                         { '$ref': '#/definitions/simpleTypes' },
22237                         {
22238                             'type': 'array',
22239                             'items': { '$ref': '#/definitions/simpleTypes' },
22240                             'minItems': 1,
22241                             'uniqueItems': true
22242                         }
22243                     ]
22244                 },
22245                 'format': { 'type': 'string' },
22246                 'contentMediaType': { 'type': 'string' },
22247                 'contentEncoding': { 'type': 'string' },
22248                 'if': { '$ref': '#' },
22249                 'then': { '$ref': '#' },
22250                 'else': { '$ref': '#' },
22251                 'allOf': { '$ref': '#/definitions/schemaArray' },
22252                 'anyOf': { '$ref': '#/definitions/schemaArray' },
22253                 'oneOf': { '$ref': '#/definitions/schemaArray' },
22254                 'not': { '$ref': '#' }
22255             },
22256             'default': true
22257         }
22258     }
22259 };
22260 var descriptions = {
22261     id: localize('schema.json.id', "A unique identifier for the schema."),
22262     $schema: localize('schema.json.$schema', "The schema to verify this document against."),
22263     title: localize('schema.json.title', "A descriptive title of the element."),
22264     description: localize('schema.json.description', "A long description of the element. Used in hover menus and suggestions."),
22265     default: localize('schema.json.default', "A default value. Used by suggestions."),
22266     multipleOf: localize('schema.json.multipleOf', "A number that should cleanly divide the current value (i.e. have no remainder)."),
22267     maximum: localize('schema.json.maximum', "The maximum numerical value, inclusive by default."),
22268     exclusiveMaximum: localize('schema.json.exclusiveMaximum', "Makes the maximum property exclusive."),
22269     minimum: localize('schema.json.minimum', "The minimum numerical value, inclusive by default."),
22270     exclusiveMinimum: localize('schema.json.exclusiveMininum', "Makes the minimum property exclusive."),
22271     maxLength: localize('schema.json.maxLength', "The maximum length of a string."),
22272     minLength: localize('schema.json.minLength', "The minimum length of a string."),
22273     pattern: localize('schema.json.pattern', "A regular expression to match the string against. It is not implicitly anchored."),
22274     additionalItems: localize('schema.json.additionalItems', "For arrays, only when items is set as an array. If it is a schema, then this schema validates items after the ones specified by the items array. If it is false, then additional items will cause validation to fail."),
22275     items: localize('schema.json.items', "For arrays. Can either be a schema to validate every element against or an array of schemas to validate each item against in order (the first schema will validate the first element, the second schema will validate the second element, and so on."),
22276     maxItems: localize('schema.json.maxItems', "The maximum number of items that can be inside an array. Inclusive."),
22277     minItems: localize('schema.json.minItems', "The minimum number of items that can be inside an array. Inclusive."),
22278     uniqueItems: localize('schema.json.uniqueItems', "If all of the items in the array must be unique. Defaults to false."),
22279     maxProperties: localize('schema.json.maxProperties', "The maximum number of properties an object can have. Inclusive."),
22280     minProperties: localize('schema.json.minProperties', "The minimum number of properties an object can have. Inclusive."),
22281     required: localize('schema.json.required', "An array of strings that lists the names of all properties required on this object."),
22282     additionalProperties: localize('schema.json.additionalProperties', "Either a schema or a boolean. If a schema, then used to validate all properties not matched by 'properties' or 'patternProperties'. If false, then any properties not matched by either will cause this schema to fail."),
22283     definitions: localize('schema.json.definitions', "Not used for validation. Place subschemas here that you wish to reference inline with $ref."),
22284     properties: localize('schema.json.properties', "A map of property names to schemas for each property."),
22285     patternProperties: localize('schema.json.patternProperties', "A map of regular expressions on property names to schemas for matching properties."),
22286     dependencies: localize('schema.json.dependencies', "A map of property names to either an array of property names or a schema. An array of property names means the property named in the key depends on the properties in the array being present in the object in order to be valid. If the value is a schema, then the schema is only applied to the object if the property in the key exists on the object."),
22287     enum: localize('schema.json.enum', "The set of literal values that are valid."),
22288     type: localize('schema.json.type', "Either a string of one of the basic schema types (number, integer, null, array, object, boolean, string) or an array of strings specifying a subset of those types."),
22289     format: localize('schema.json.format', "Describes the format expected for the value."),
22290     allOf: localize('schema.json.allOf', "An array of schemas, all of which must match."),
22291     anyOf: localize('schema.json.anyOf', "An array of schemas, where at least one must match."),
22292     oneOf: localize('schema.json.oneOf', "An array of schemas, exactly one of which must match."),
22293     not: localize('schema.json.not', "A schema which must not match."),
22294     $id: localize('schema.json.$id', "A unique identifier for the schema."),
22295     $ref: localize('schema.json.$ref', "Reference a definition hosted on any location."),
22296     $comment: localize('schema.json.$comment', "Comments from schema authors to readers or maintainers of the schema."),
22297     readOnly: localize('schema.json.readOnly', "Indicates that the value of the instance is managed exclusively by the owning authority."),
22298     examples: localize('schema.json.examples', "Sample JSON values associated with a particular schema, for the purpose of illustrating usage."),
22299     contains: localize('schema.json.contains', "An array instance is valid against \"contains\" if at least one of its elements is valid against the given schema."),
22300     propertyNames: localize('schema.json.propertyNames', "If the instance is an object, this keyword validates if every property name in the instance validates against the provided schema."),
22301     const: localize('schema.json.const', "An instance validates successfully against this keyword if its value is equal to the value of the keyword."),
22302     contentMediaType: localize('schema.json.contentMediaType', "Describes the media type of a string property."),
22303     contentEncoding: localize('schema.json.contentEncoding', "Describes the content encoding of a string property."),
22304     if: localize('schema.json.if', "The validation outcome of the \"if\" subschema controls which of the \"then\" or \"else\" keywords are evaluated."),
22305     then: localize('schema.json.then', "The \"if\" subschema is used for validation when the \"if\" subschema succeeds."),
22306     else: localize('schema.json.else', "The \"else\" subschema is used for validation when the \"if\" subschema fails.")
22307 };
22308 for (var schemaName in schemaContributions.schemas) {
22309     var schema = schemaContributions.schemas[schemaName];
22310     for (var property in schema.properties) {
22311         var propertyObject = schema.properties[property];
22312         if (propertyObject === true) {
22313             propertyObject = schema.properties[property] = {};
22314         }
22315         var description = descriptions[property];
22316         if (description) {
22317             propertyObject['description'] = description;
22318         }
22319         else {
22320             console.log(property + ": localize('schema.json." + property + "', \"\")");
22321         }
22322     }
22323 }
22324
22325
22326 /***/ }),
22327 /* 99 */
22328 /***/ (function(module, __webpack_exports__, __webpack_require__) {
22329
22330 "use strict";
22331 __webpack_require__.r(__webpack_exports__);
22332 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getFoldingRanges", function() { return getFoldingRanges; });
22333 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80);
22334 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(83);
22335 /* harmony import */ var _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(89);
22336 /*---------------------------------------------------------------------------------------------
22337  *  Copyright (c) Microsoft Corporation. All rights reserved.
22338  *  Licensed under the MIT License. See License.txt in the project root for license information.
22339  *--------------------------------------------------------------------------------------------*/
22340
22341
22342
22343 function getFoldingRanges(document, context) {
22344     var ranges = [];
22345     var nestingLevels = [];
22346     var stack = [];
22347     var prevStart = -1;
22348     var scanner = Object(jsonc_parser__WEBPACK_IMPORTED_MODULE_1__["createScanner"])(document.getText(), false);
22349     var token = scanner.scan();
22350     function addRange(range) {
22351         ranges.push(range);
22352         nestingLevels.push(stack.length);
22353     }
22354     while (token !== 17 /* EOF */) {
22355         switch (token) {
22356             case 1 /* OpenBraceToken */:
22357             case 3 /* OpenBracketToken */: {
22358                 var startLine = document.positionAt(scanner.getTokenOffset()).line;
22359                 var range = { startLine: startLine, endLine: startLine, kind: token === 1 /* OpenBraceToken */ ? 'object' : 'array' };
22360                 stack.push(range);
22361                 break;
22362             }
22363             case 2 /* CloseBraceToken */:
22364             case 4 /* CloseBracketToken */: {
22365                 var kind = token === 2 /* CloseBraceToken */ ? 'object' : 'array';
22366                 if (stack.length > 0 && stack[stack.length - 1].kind === kind) {
22367                     var range = stack.pop();
22368                     var line = document.positionAt(scanner.getTokenOffset()).line;
22369                     if (range && line > range.startLine + 1 && prevStart !== range.startLine) {
22370                         range.endLine = line - 1;
22371                         addRange(range);
22372                         prevStart = range.startLine;
22373                     }
22374                 }
22375                 break;
22376             }
22377             case 13 /* BlockCommentTrivia */: {
22378                 var startLine = document.positionAt(scanner.getTokenOffset()).line;
22379                 var endLine = document.positionAt(scanner.getTokenOffset() + scanner.getTokenLength()).line;
22380                 if (scanner.getTokenError() === 1 /* UnexpectedEndOfComment */ && startLine + 1 < document.lineCount) {
22381                     scanner.setPosition(document.offsetAt(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Position"].create(startLine + 1, 0)));
22382                 }
22383                 else {
22384                     if (startLine < endLine) {
22385                         addRange({ startLine: startLine, endLine: endLine, kind: _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["FoldingRangeKind"].Comment });
22386                         prevStart = startLine;
22387                     }
22388                 }
22389                 break;
22390             }
22391             case 12 /* LineCommentTrivia */: {
22392                 var text = document.getText().substr(scanner.getTokenOffset(), scanner.getTokenLength());
22393                 var m = text.match(/^\/\/\s*#(region\b)|(endregion\b)/);
22394                 if (m) {
22395                     var line = document.positionAt(scanner.getTokenOffset()).line;
22396                     if (m[1]) { // start pattern match
22397                         var range = { startLine: line, endLine: line, kind: _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["FoldingRangeKind"].Region };
22398                         stack.push(range);
22399                     }
22400                     else {
22401                         var i = stack.length - 1;
22402                         while (i >= 0 && stack[i].kind !== _jsonLanguageTypes__WEBPACK_IMPORTED_MODULE_2__["FoldingRangeKind"].Region) {
22403                             i--;
22404                         }
22405                         if (i >= 0) {
22406                             var range = stack[i];
22407                             stack.length = i;
22408                             if (line > range.startLine && prevStart !== range.startLine) {
22409                                 range.endLine = line;
22410                                 addRange(range);
22411                                 prevStart = range.startLine;
22412                             }
22413                         }
22414                     }
22415                 }
22416                 break;
22417             }
22418         }
22419         token = scanner.scan();
22420     }
22421     var rangeLimit = context && context.rangeLimit;
22422     if (typeof rangeLimit !== 'number' || ranges.length <= rangeLimit) {
22423         return ranges;
22424     }
22425     var counts = [];
22426     for (var _i = 0, nestingLevels_1 = nestingLevels; _i < nestingLevels_1.length; _i++) {
22427         var level = nestingLevels_1[_i];
22428         if (level < 30) {
22429             counts[level] = (counts[level] || 0) + 1;
22430         }
22431     }
22432     var entries = 0;
22433     var maxLevel = 0;
22434     for (var i = 0; i < counts.length; i++) {
22435         var n = counts[i];
22436         if (n) {
22437             if (n + entries > rangeLimit) {
22438                 maxLevel = i;
22439                 break;
22440             }
22441             entries += n;
22442         }
22443     }
22444     var result = [];
22445     for (var i = 0; i < ranges.length; i++) {
22446         var level = nestingLevels[i];
22447         if (typeof level === 'number') {
22448             if (level < maxLevel || (level === maxLevel && entries++ < rangeLimit)) {
22449                 result.push(ranges[i]);
22450             }
22451         }
22452     }
22453     return result;
22454 }
22455
22456
22457 /***/ }),
22458 /* 100 */
22459 /***/ (function(module, __webpack_exports__, __webpack_require__) {
22460
22461 "use strict";
22462 __webpack_require__.r(__webpack_exports__);
22463 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getSelectionRanges", function() { return getSelectionRanges; });
22464 /* harmony import */ var vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(80);
22465 /* harmony import */ var jsonc_parser__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(83);
22466 /*---------------------------------------------------------------------------------------------
22467  *  Copyright (c) Microsoft Corporation. All rights reserved.
22468  *  Licensed under the MIT License. See License.txt in the project root for license information.
22469  *--------------------------------------------------------------------------------------------*/
22470
22471
22472 function getSelectionRanges(document, positions, doc) {
22473     function getSelectionRange(position) {
22474         var offset = document.offsetAt(position);
22475         var node = doc.getNodeFromOffset(offset, true);
22476         var result = [];
22477         while (node) {
22478             switch (node.type) {
22479                 case 'string':
22480                 case 'object':
22481                 case 'array':
22482                     // range without ", [ or {
22483                     var cStart = node.offset + 1, cEnd = node.offset + node.length - 1;
22484                     if (cStart < cEnd && offset >= cStart && offset <= cEnd) {
22485                         result.push(newRange(cStart, cEnd));
22486                     }
22487                     result.push(newRange(node.offset, node.offset + node.length));
22488                     break;
22489                 case 'number':
22490                 case 'boolean':
22491                 case 'null':
22492                 case 'property':
22493                     result.push(newRange(node.offset, node.offset + node.length));
22494                     break;
22495             }
22496             if (node.type === 'property' || node.parent && node.parent.type === 'array') {
22497                 var afterCommaOffset = getOffsetAfterNextToken(node.offset + node.length, 5 /* CommaToken */);
22498                 if (afterCommaOffset !== -1) {
22499                     result.push(newRange(node.offset, afterCommaOffset));
22500                 }
22501             }
22502             node = node.parent;
22503         }
22504         var current = undefined;
22505         for (var index = result.length - 1; index >= 0; index--) {
22506             current = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["SelectionRange"].create(result[index], current);
22507         }
22508         if (!current) {
22509             current = vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["SelectionRange"].create(vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Range"].create(position, position));
22510         }
22511         return current;
22512     }
22513     function newRange(start, end) {
22514         return vscode_languageserver_types__WEBPACK_IMPORTED_MODULE_0__["Range"].create(document.positionAt(start), document.positionAt(end));
22515     }
22516     var scanner = Object(jsonc_parser__WEBPACK_IMPORTED_MODULE_1__["createScanner"])(document.getText(), true);
22517     function getOffsetAfterNextToken(offset, expectedToken) {
22518         scanner.setPosition(offset);
22519         var token = scanner.scan();
22520         if (token === expectedToken) {
22521             return scanner.getTokenOffset() + scanner.getTokenLength();
22522         }
22523         return -1;
22524     }
22525     return positions.map(getSelectionRange);
22526 }
22527
22528
22529 /***/ }),
22530 /* 101 */
22531 /***/ (function(module, exports, __webpack_require__) {
22532
22533 "use strict";
22534
22535 /*---------------------------------------------------------------------------------------------
22536  *  Copyright (c) Microsoft Corporation. All rights reserved.
22537  *  Licensed under the MIT License. See License.txt in the project root for license information.
22538  *--------------------------------------------------------------------------------------------*/
22539 Object.defineProperty(exports, "__esModule", { value: true });
22540 function getLanguageModelCache(maxEntries, cleanupIntervalTimeInSec, parse) {
22541     let languageModels = {};
22542     let nModels = 0;
22543     let cleanupInterval = undefined;
22544     if (cleanupIntervalTimeInSec > 0) {
22545         cleanupInterval = setInterval(() => {
22546             let cutoffTime = Date.now() - cleanupIntervalTimeInSec * 1000;
22547             let uris = Object.keys(languageModels);
22548             for (let uri of uris) {
22549                 let languageModelInfo = languageModels[uri];
22550                 if (languageModelInfo.cTime < cutoffTime) {
22551                     delete languageModels[uri];
22552                     nModels--;
22553                 }
22554             }
22555         }, cleanupIntervalTimeInSec * 1000);
22556     }
22557     return {
22558         get(document) {
22559             let version = document.version;
22560             let languageId = document.languageId;
22561             let languageModelInfo = languageModels[document.uri];
22562             if (languageModelInfo && languageModelInfo.version === version && languageModelInfo.languageId === languageId) {
22563                 languageModelInfo.cTime = Date.now();
22564                 return languageModelInfo.languageModel;
22565             }
22566             let languageModel = parse(document);
22567             languageModels[document.uri] = { languageModel, version, languageId, cTime: Date.now() };
22568             if (!languageModelInfo) {
22569                 nModels++;
22570             }
22571             if (nModels === maxEntries) {
22572                 let oldestTime = Number.MAX_VALUE;
22573                 let oldestUri = null;
22574                 for (let uri in languageModels) {
22575                     let languageModelInfo = languageModels[uri];
22576                     if (languageModelInfo.cTime < oldestTime) {
22577                         oldestUri = uri;
22578                         oldestTime = languageModelInfo.cTime;
22579                     }
22580                 }
22581                 if (oldestUri) {
22582                     delete languageModels[oldestUri];
22583                     nModels--;
22584                 }
22585             }
22586             return languageModel;
22587         },
22588         onDocumentRemoved(document) {
22589             let uri = document.uri;
22590             if (languageModels[uri]) {
22591                 delete languageModels[uri];
22592                 nModels--;
22593             }
22594         },
22595         dispose() {
22596             if (typeof cleanupInterval !== 'undefined') {
22597                 clearInterval(cleanupInterval);
22598                 cleanupInterval = undefined;
22599                 languageModels = {};
22600                 nModels = 0;
22601             }
22602         }
22603     };
22604 }
22605 exports.getLanguageModelCache = getLanguageModelCache;
22606
22607
22608 /***/ })
22609 /******/ ])));