yks-element 1.5.2 → 1.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/lib/07567125b93045706d81f17f7d04e262.js +120 -0
  2. package/lib/0d56a1f26e052a1bafd10a87782fc74b.js +3380 -0
  3. package/lib/27846e85433e54a3ec0ab34d62233dc5.js +186 -0
  4. package/lib/2f25a4dc442bc9aebc58cae30c50c3e2.js +192 -0
  5. package/lib/2f55cddc8eb85b63ee5b4ce0e5488230.js +67 -0
  6. package/lib/2fe2904fc024afaf81732563cb83e547.js +116 -0
  7. package/lib/3b02cca9e95276a74f3ed2bbc7a64ce6.js +409 -0
  8. package/lib/6e40b726d91e9138d9eaef6fd012c740.js +1332 -0
  9. package/lib/70efbabef77fb217f904f41dbf7fe8bf.js +380 -0
  10. package/lib/7cec85e554cfaf2464511da505025098.js +74 -0
  11. package/lib/852f0ecd7b17e3bfd700a821ff438f7e.js +330 -0
  12. package/lib/88730abfeb4a23e692ac7933882f12eb.js +255 -0
  13. package/lib/8b8336037f074d9dcbd20eab535b803f.js +227 -0
  14. package/lib/9979f39c4d2773e02151a6cf1558101b.js +768 -0
  15. package/lib/9ebb9ac2c9c875649c72722bc585d445.js +1381 -0
  16. package/lib/af6e31c060c273848b5fec9fdba8814d.js +3066 -0
  17. package/lib/babd8df6809ef43238f1b280c2cebfe3.js +265 -0
  18. package/lib/bb1365c0983ce5ad50060b24788b9630.js +459 -0
  19. package/lib/c0a8aa1d5e0611259e47c2008cb203ee.js +197 -0
  20. package/lib/c530988d2b1966fd10a4d99fa3877e1b.js +9 -0
  21. package/lib/c8acc93023012737a3bf8fb767b66838.js +1293 -0
  22. package/lib/d0415105402964718010284fcfa8b2ea.js +48 -0
  23. package/lib/d11ab4aa7dd9123fdecb075ff5c5a748.js +790 -0
  24. package/lib/d1907231dc06c32481fefd6d47da973b.js +344 -0
  25. package/lib/d429602e0ebf3c1ec040e070e9b05b9b.js +184 -0
  26. package/lib/e4fc956693373117f057fe9914e983fc.js +7090 -0
  27. package/lib/f15362a7feef894b2e7f706252e6c510.js +45 -0
  28. package/lib/f666b5647087bcfdf6623f8b14d56657.js +136 -0
  29. package/lib/fac0ce75e0690947a9e9e6f5b35c1ea8.js +1067 -0
  30. package/lib/fec23c6964d6cf25681d1f3e24b076a4.js +56 -0
  31. package/lib/yks.js +1 -1
  32. package/package.json +1 -1
  33. package/lib/6c6d192b6860b4508a14c2d04769a35e.js +0 -15404
  34. package/lib/c3832579be376308fa819b04e7b0c66f.js +0 -3788
@@ -0,0 +1,3066 @@
1
+ ace.define("ace/autocomplete/popup",["require","exports","module","ace/virtual_renderer","ace/editor","ace/range","ace/lib/event","ace/lib/lang","ace/lib/dom","ace/config","ace/lib/useragent"], function(require, exports, module){"use strict";
2
+ var Renderer = require("../virtual_renderer").VirtualRenderer;
3
+ var Editor = require("../editor").Editor;
4
+ var Range = require("../range").Range;
5
+ var event = require("../lib/event");
6
+ var lang = require("../lib/lang");
7
+ var dom = require("../lib/dom");
8
+ var nls = require("../config").nls;
9
+ var userAgent = require("./../lib/useragent");
10
+ var getAriaId = function (index) {
11
+ return "suggest-aria-id:".concat(index);
12
+ };
13
+ var popupAriaRole = userAgent.isSafari ? "menu" : "listbox";
14
+ var optionAriaRole = userAgent.isSafari ? "menuitem" : "option";
15
+ var ariaActiveState = userAgent.isSafari ? "aria-current" : "aria-selected";
16
+ var $singleLineEditor = function (el) {
17
+ var renderer = new Renderer(el);
18
+ renderer.$maxLines = 4;
19
+ var editor = new Editor(renderer);
20
+ editor.setHighlightActiveLine(false);
21
+ editor.setShowPrintMargin(false);
22
+ editor.renderer.setShowGutter(false);
23
+ editor.renderer.setHighlightGutterLine(false);
24
+ editor.$mouseHandler.$focusTimeout = 0;
25
+ editor.$highlightTagPending = true;
26
+ return editor;
27
+ };
28
+ var AcePopup = /** @class */ (function () {
29
+ function AcePopup(parentNode) {
30
+ var el = dom.createElement("div");
31
+ var popup = $singleLineEditor(el);
32
+ if (parentNode) {
33
+ parentNode.appendChild(el);
34
+ }
35
+ el.style.display = "none";
36
+ popup.renderer.content.style.cursor = "default";
37
+ popup.renderer.setStyle("ace_autocomplete");
38
+ popup.renderer.$textLayer.element.setAttribute("role", popupAriaRole);
39
+ popup.renderer.$textLayer.element.setAttribute("aria-roledescription", nls("autocomplete.popup.aria-roledescription", "Autocomplete suggestions"));
40
+ popup.renderer.$textLayer.element.setAttribute("aria-label", nls("autocomplete.popup.aria-label", "Autocomplete suggestions"));
41
+ popup.renderer.textarea.setAttribute("aria-hidden", "true");
42
+ popup.setOption("displayIndentGuides", false);
43
+ popup.setOption("dragDelay", 150);
44
+ var noop = function () { };
45
+ popup.focus = noop;
46
+ popup.$isFocused = true;
47
+ popup.renderer.$cursorLayer.restartTimer = noop;
48
+ popup.renderer.$cursorLayer.element.style.opacity = "0";
49
+ popup.renderer.$maxLines = 8;
50
+ popup.renderer.$keepTextAreaAtCursor = false;
51
+ popup.setHighlightActiveLine(false);
52
+ popup.session.highlight("");
53
+ popup.session.$searchHighlight.clazz = "ace_highlight-marker";
54
+ popup.on("mousedown", function (e) {
55
+ var pos = e.getDocumentPosition();
56
+ popup.selection.moveToPosition(pos);
57
+ selectionMarker.start.row = selectionMarker.end.row = pos.row;
58
+ e.stop();
59
+ });
60
+ var lastMouseEvent;
61
+ var hoverMarker = new Range(-1, 0, -1, Infinity);
62
+ var selectionMarker = new Range(-1, 0, -1, Infinity);
63
+ selectionMarker.id = popup.session.addMarker(selectionMarker, "ace_active-line", "fullLine");
64
+ popup.setSelectOnHover = function (val) {
65
+ if (!val) {
66
+ hoverMarker.id = popup.session.addMarker(hoverMarker, "ace_line-hover", "fullLine");
67
+ }
68
+ else if (hoverMarker.id) {
69
+ popup.session.removeMarker(hoverMarker.id);
70
+ hoverMarker.id = null;
71
+ }
72
+ };
73
+ popup.setSelectOnHover(false);
74
+ popup.on("mousemove", function (e) {
75
+ if (!lastMouseEvent) {
76
+ lastMouseEvent = e;
77
+ return;
78
+ }
79
+ if (lastMouseEvent.x == e.x && lastMouseEvent.y == e.y) {
80
+ return;
81
+ }
82
+ lastMouseEvent = e;
83
+ lastMouseEvent.scrollTop = popup.renderer.scrollTop;
84
+ popup.isMouseOver = true;
85
+ var row = lastMouseEvent.getDocumentPosition().row;
86
+ if (hoverMarker.start.row != row) {
87
+ if (!hoverMarker.id)
88
+ popup.setRow(row);
89
+ setHoverMarker(row);
90
+ }
91
+ });
92
+ popup.renderer.on("beforeRender", function () {
93
+ if (lastMouseEvent && hoverMarker.start.row != -1) {
94
+ lastMouseEvent.$pos = null;
95
+ var row = lastMouseEvent.getDocumentPosition().row;
96
+ if (!hoverMarker.id)
97
+ popup.setRow(row);
98
+ setHoverMarker(row, true);
99
+ }
100
+ });
101
+ popup.renderer.on("afterRender", function () {
102
+ var row = popup.getRow();
103
+ var t = popup.renderer.$textLayer;
104
+ var selected = /** @type {HTMLElement|null} */ (t.element.childNodes[row - t.config.firstRow]);
105
+ var el = document.activeElement; // Active element is textarea of main editor
106
+ if (selected !== popup.selectedNode && popup.selectedNode) {
107
+ dom.removeCssClass(popup.selectedNode, "ace_selected");
108
+ el.removeAttribute("aria-activedescendant");
109
+ popup.selectedNode.removeAttribute(ariaActiveState);
110
+ popup.selectedNode.removeAttribute("id");
111
+ }
112
+ popup.selectedNode = selected;
113
+ if (selected) {
114
+ dom.addCssClass(selected, "ace_selected");
115
+ var ariaId = getAriaId(row);
116
+ selected.id = ariaId;
117
+ t.element.setAttribute("aria-activedescendant", ariaId);
118
+ el.setAttribute("aria-activedescendant", ariaId);
119
+ selected.setAttribute("role", optionAriaRole);
120
+ selected.setAttribute("aria-roledescription", nls("autocomplete.popup.item.aria-roledescription", "item"));
121
+ selected.setAttribute("aria-label", popup.getData(row).caption || popup.getData(row).value);
122
+ selected.setAttribute("aria-setsize", popup.data.length);
123
+ selected.setAttribute("aria-posinset", row + 1);
124
+ selected.setAttribute("aria-describedby", "doc-tooltip");
125
+ selected.setAttribute(ariaActiveState, "true");
126
+ }
127
+ });
128
+ var hideHoverMarker = function () { setHoverMarker(-1); };
129
+ var setHoverMarker = function (row, suppressRedraw) {
130
+ if (row !== hoverMarker.start.row) {
131
+ hoverMarker.start.row = hoverMarker.end.row = row;
132
+ if (!suppressRedraw)
133
+ popup.session._emit("changeBackMarker");
134
+ popup._emit("changeHoverMarker");
135
+ }
136
+ };
137
+ popup.getHoveredRow = function () {
138
+ return hoverMarker.start.row;
139
+ };
140
+ event.addListener(popup.container, "mouseout", function () {
141
+ popup.isMouseOver = false;
142
+ hideHoverMarker();
143
+ });
144
+ popup.on("hide", hideHoverMarker);
145
+ popup.on("changeSelection", hideHoverMarker);
146
+ popup.session.doc.getLength = function () {
147
+ return popup.data.length;
148
+ };
149
+ popup.session.doc.getLine = function (i) {
150
+ var data = popup.data[i];
151
+ if (typeof data == "string")
152
+ return data;
153
+ return (data && data.value) || "";
154
+ };
155
+ var bgTokenizer = popup.session.bgTokenizer;
156
+ bgTokenizer.$tokenizeRow = function (row) {
157
+ var data = popup.data[row];
158
+ var tokens = [];
159
+ if (!data)
160
+ return tokens;
161
+ if (typeof data == "string")
162
+ data = { value: data };
163
+ var caption = data.caption || data.value || data.name;
164
+ function addToken(value, className) {
165
+ value && tokens.push({
166
+ type: (data.className || "") + (className || ""),
167
+ value: value
168
+ });
169
+ }
170
+ var lower = caption.toLowerCase();
171
+ var filterText = (popup.filterText || "").toLowerCase();
172
+ var lastIndex = 0;
173
+ var lastI = 0;
174
+ for (var i = 0; i <= filterText.length; i++) {
175
+ if (i != lastI && (data.matchMask & (1 << i) || i == filterText.length)) {
176
+ var sub = filterText.slice(lastI, i);
177
+ lastI = i;
178
+ var index = lower.indexOf(sub, lastIndex);
179
+ if (index == -1)
180
+ continue;
181
+ addToken(caption.slice(lastIndex, index), "");
182
+ lastIndex = index + sub.length;
183
+ addToken(caption.slice(index, lastIndex), "completion-highlight");
184
+ }
185
+ }
186
+ addToken(caption.slice(lastIndex, caption.length), "");
187
+ tokens.push({ type: "completion-spacer", value: " " });
188
+ if (data.meta)
189
+ tokens.push({ type: "completion-meta", value: data.meta });
190
+ if (data.message)
191
+ tokens.push({ type: "completion-message", value: data.message });
192
+ return tokens;
193
+ };
194
+ bgTokenizer.$updateOnChange = noop;
195
+ bgTokenizer.start = noop;
196
+ popup.session.$computeWidth = function () {
197
+ return this.screenWidth = 0;
198
+ };
199
+ popup.isOpen = false;
200
+ popup.isTopdown = false;
201
+ popup.autoSelect = true;
202
+ popup.filterText = "";
203
+ popup.isMouseOver = false;
204
+ popup.data = [];
205
+ popup.setData = function (list, filterText) {
206
+ popup.filterText = filterText || "";
207
+ popup.setValue(lang.stringRepeat("\n", list.length), -1);
208
+ popup.data = list || [];
209
+ popup.setRow(0);
210
+ };
211
+ popup.getData = function (row) {
212
+ return popup.data[row];
213
+ };
214
+ popup.getRow = function () {
215
+ return selectionMarker.start.row;
216
+ };
217
+ popup.setRow = function (line) {
218
+ line = Math.max(this.autoSelect ? 0 : -1, Math.min(this.data.length - 1, line));
219
+ if (selectionMarker.start.row != line) {
220
+ popup.selection.clearSelection();
221
+ selectionMarker.start.row = selectionMarker.end.row = line || 0;
222
+ popup.session._emit("changeBackMarker");
223
+ popup.moveCursorTo(line || 0, 0);
224
+ if (popup.isOpen)
225
+ popup._signal("select");
226
+ }
227
+ };
228
+ popup.on("changeSelection", function () {
229
+ if (popup.isOpen)
230
+ popup.setRow(popup.selection.lead.row);
231
+ popup.renderer.scrollCursorIntoView();
232
+ });
233
+ popup.hide = function () {
234
+ this.container.style.display = "none";
235
+ popup.anchorPos = null;
236
+ popup.anchor = null;
237
+ if (popup.isOpen) {
238
+ popup.isOpen = false;
239
+ this._signal("hide");
240
+ }
241
+ };
242
+ popup.tryShow = function (pos, lineHeight, anchor, forceShow) {
243
+ if (!forceShow && popup.isOpen && popup.anchorPos && popup.anchor &&
244
+ popup.anchorPos.top === pos.top && popup.anchorPos.left === pos.left &&
245
+ popup.anchor === anchor) {
246
+ return true;
247
+ }
248
+ var el = this.container;
249
+ var screenHeight = window.innerHeight;
250
+ var screenWidth = window.innerWidth;
251
+ var renderer = this.renderer;
252
+ var maxH = renderer.$maxLines * lineHeight * 1.4;
253
+ var dims = { top: 0, bottom: 0, left: 0 };
254
+ var spaceBelow = screenHeight - pos.top - 3 * this.$borderSize - lineHeight;
255
+ var spaceAbove = pos.top - 3 * this.$borderSize;
256
+ if (!anchor) {
257
+ if (spaceAbove <= spaceBelow || spaceBelow >= maxH) {
258
+ anchor = "bottom";
259
+ }
260
+ else {
261
+ anchor = "top";
262
+ }
263
+ }
264
+ if (anchor === "top") {
265
+ dims.bottom = pos.top - this.$borderSize;
266
+ dims.top = dims.bottom - maxH;
267
+ }
268
+ else if (anchor === "bottom") {
269
+ dims.top = pos.top + lineHeight + this.$borderSize;
270
+ dims.bottom = dims.top + maxH;
271
+ }
272
+ var fitsX = dims.top >= 0 && dims.bottom <= screenHeight;
273
+ if (!forceShow && !fitsX) {
274
+ return false;
275
+ }
276
+ if (!fitsX) {
277
+ if (anchor === "top") {
278
+ renderer.$maxPixelHeight = spaceAbove;
279
+ }
280
+ else {
281
+ renderer.$maxPixelHeight = spaceBelow;
282
+ }
283
+ }
284
+ else {
285
+ renderer.$maxPixelHeight = null;
286
+ }
287
+ if (anchor === "top") {
288
+ el.style.top = "";
289
+ el.style.bottom = (screenHeight - dims.bottom) + "px";
290
+ popup.isTopdown = false;
291
+ }
292
+ else {
293
+ el.style.top = dims.top + "px";
294
+ el.style.bottom = "";
295
+ popup.isTopdown = true;
296
+ }
297
+ el.style.display = "";
298
+ var left = pos.left;
299
+ if (left + el.offsetWidth > screenWidth)
300
+ left = screenWidth - el.offsetWidth;
301
+ el.style.left = left + "px";
302
+ el.style.right = "";
303
+ if (!popup.isOpen) {
304
+ popup.isOpen = true;
305
+ this._signal("show");
306
+ lastMouseEvent = null;
307
+ }
308
+ popup.anchorPos = pos;
309
+ popup.anchor = anchor;
310
+ return true;
311
+ };
312
+ popup.show = function (pos, lineHeight, topdownOnly) {
313
+ this.tryShow(pos, lineHeight, topdownOnly ? "bottom" : undefined, true);
314
+ };
315
+ popup.goTo = function (where) {
316
+ var row = this.getRow();
317
+ var max = this.session.getLength() - 1;
318
+ switch (where) {
319
+ case "up":
320
+ row = row <= 0 ? max : row - 1;
321
+ break;
322
+ case "down":
323
+ row = row >= max ? -1 : row + 1;
324
+ break;
325
+ case "start":
326
+ row = 0;
327
+ break;
328
+ case "end":
329
+ row = max;
330
+ break;
331
+ }
332
+ this.setRow(row);
333
+ };
334
+ popup.getTextLeftOffset = function () {
335
+ return this.$borderSize + this.renderer.$padding + this.$imageSize;
336
+ };
337
+ popup.$imageSize = 0;
338
+ popup.$borderSize = 1;
339
+ return popup;
340
+ }
341
+ return AcePopup;
342
+ }());
343
+ dom.importCssString("\n.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #CAD6FA;\n z-index: 1;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_marker-layer .ace_active-line {\n background-color: #3a674e;\n}\n.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid #abbffe;\n margin-top: -1px;\n background: rgba(233,233,253,0.4);\n position: absolute;\n z-index: 2;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_line-hover {\n border: 1px solid rgba(109, 150, 13, 0.8);\n background: rgba(58, 103, 78, 0.62);\n}\n.ace_completion-meta {\n opacity: 0.5;\n margin-left: 0.9em;\n}\n.ace_completion-message {\n margin-left: 0.9em;\n color: blue;\n}\n.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #2d69c7;\n}\n.ace_dark.ace_editor.ace_autocomplete .ace_completion-highlight{\n color: #93ca12;\n}\n.ace_editor.ace_autocomplete {\n width: 300px;\n z-index: 200000;\n border: 1px lightgray solid;\n position: fixed;\n box-shadow: 2px 3px 5px rgba(0,0,0,.2);\n line-height: 1.4;\n background: #fefefe;\n color: #111;\n}\n.ace_dark.ace_editor.ace_autocomplete {\n border: 1px #484747 solid;\n box-shadow: 2px 3px 5px rgba(0, 0, 0, 0.51);\n line-height: 1.4;\n background: #25282c;\n color: #c1c1c1;\n}\n.ace_autocomplete .ace_text-layer {\n width: calc(100% - 8px);\n}\n.ace_autocomplete .ace_line {\n display: flex;\n align-items: center;\n}\n.ace_autocomplete .ace_line > * {\n min-width: 0;\n flex: 0 0 auto;\n}\n.ace_autocomplete .ace_line .ace_ {\n flex: 0 1 auto;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n.ace_autocomplete .ace_completion-spacer {\n flex: 1;\n}\n.ace_autocomplete.ace_loading:after {\n content: \"\";\n position: absolute;\n top: 0px;\n height: 2px;\n width: 8%;\n background: blue;\n z-index: 100;\n animation: ace_progress 3s infinite linear;\n animation-delay: 300ms;\n transform: translateX(-100%) scaleX(1);\n}\n@keyframes ace_progress {\n 0% { transform: translateX(-100%) scaleX(1) }\n 50% { transform: translateX(625%) scaleX(2) } \n 100% { transform: translateX(1500%) scaleX(3) } \n}\n@media (prefers-reduced-motion) {\n .ace_autocomplete.ace_loading:after {\n transform: translateX(625%) scaleX(2);\n animation: none;\n }\n}\n", "autocompletion.css", false);
344
+ exports.AcePopup = AcePopup;
345
+ exports.$singleLineEditor = $singleLineEditor;
346
+ exports.getAriaId = getAriaId;
347
+
348
+ });
349
+
350
+ ace.define("ace/snippets",["require","exports","module","ace/lib/dom","ace/lib/oop","ace/lib/event_emitter","ace/lib/lang","ace/range","ace/range_list","ace/keyboard/hash_handler","ace/tokenizer","ace/clipboard","ace/editor"], function(require, exports, module){"use strict";
351
+ var dom = require("./lib/dom");
352
+ var oop = require("./lib/oop");
353
+ var EventEmitter = require("./lib/event_emitter").EventEmitter;
354
+ var lang = require("./lib/lang");
355
+ var Range = require("./range").Range;
356
+ var RangeList = require("./range_list").RangeList;
357
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
358
+ var Tokenizer = require("./tokenizer").Tokenizer;
359
+ var clipboard = require("./clipboard");
360
+ var VARIABLES = {
361
+ CURRENT_WORD: function (editor) {
362
+ return editor.session.getTextRange(editor.session.getWordRange());
363
+ },
364
+ SELECTION: function (editor, name, indentation) {
365
+ var text = editor.session.getTextRange();
366
+ if (indentation)
367
+ return text.replace(/\n\r?([ \t]*\S)/g, "\n" + indentation + "$1");
368
+ return text;
369
+ },
370
+ CURRENT_LINE: function (editor) {
371
+ return editor.session.getLine(editor.getCursorPosition().row);
372
+ },
373
+ PREV_LINE: function (editor) {
374
+ return editor.session.getLine(editor.getCursorPosition().row - 1);
375
+ },
376
+ LINE_INDEX: function (editor) {
377
+ return editor.getCursorPosition().row;
378
+ },
379
+ LINE_NUMBER: function (editor) {
380
+ return editor.getCursorPosition().row + 1;
381
+ },
382
+ SOFT_TABS: function (editor) {
383
+ return editor.session.getUseSoftTabs() ? "YES" : "NO";
384
+ },
385
+ TAB_SIZE: function (editor) {
386
+ return editor.session.getTabSize();
387
+ },
388
+ CLIPBOARD: function (editor) {
389
+ return clipboard.getText && clipboard.getText();
390
+ },
391
+ FILENAME: function (editor) {
392
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0];
393
+ },
394
+ FILENAME_BASE: function (editor) {
395
+ return /[^/\\]*$/.exec(this.FILEPATH(editor))[0].replace(/\.[^.]*$/, "");
396
+ },
397
+ DIRECTORY: function (editor) {
398
+ return this.FILEPATH(editor).replace(/[^/\\]*$/, "");
399
+ },
400
+ FILEPATH: function (editor) { return "/not implemented.txt"; },
401
+ WORKSPACE_NAME: function () { return "Unknown"; },
402
+ FULLNAME: function () { return "Unknown"; },
403
+ BLOCK_COMMENT_START: function (editor) {
404
+ var mode = editor.session.$mode || {};
405
+ return mode.blockComment && mode.blockComment.start || "";
406
+ },
407
+ BLOCK_COMMENT_END: function (editor) {
408
+ var mode = editor.session.$mode || {};
409
+ return mode.blockComment && mode.blockComment.end || "";
410
+ },
411
+ LINE_COMMENT: function (editor) {
412
+ var mode = editor.session.$mode || {};
413
+ return mode.lineCommentStart || "";
414
+ },
415
+ CURRENT_YEAR: date.bind(null, { year: "numeric" }),
416
+ CURRENT_YEAR_SHORT: date.bind(null, { year: "2-digit" }),
417
+ CURRENT_MONTH: date.bind(null, { month: "numeric" }),
418
+ CURRENT_MONTH_NAME: date.bind(null, { month: "long" }),
419
+ CURRENT_MONTH_NAME_SHORT: date.bind(null, { month: "short" }),
420
+ CURRENT_DATE: date.bind(null, { day: "2-digit" }),
421
+ CURRENT_DAY_NAME: date.bind(null, { weekday: "long" }),
422
+ CURRENT_DAY_NAME_SHORT: date.bind(null, { weekday: "short" }),
423
+ CURRENT_HOUR: date.bind(null, { hour: "2-digit", hour12: false }),
424
+ CURRENT_MINUTE: date.bind(null, { minute: "2-digit" }),
425
+ CURRENT_SECOND: date.bind(null, { second: "2-digit" })
426
+ };
427
+ VARIABLES.SELECTED_TEXT = VARIABLES.SELECTION;
428
+ function date(dateFormat) {
429
+ var str = new Date().toLocaleString("en-us", dateFormat);
430
+ return str.length == 1 ? "0" + str : str;
431
+ }
432
+ var SnippetManager = /** @class */ (function () {
433
+ function SnippetManager() {
434
+ this.snippetMap = {};
435
+ this.snippetNameMap = {};
436
+ this.variables = VARIABLES;
437
+ }
438
+ SnippetManager.prototype.getTokenizer = function () {
439
+ return SnippetManager["$tokenizer"] || this.createTokenizer();
440
+ };
441
+ SnippetManager.prototype.createTokenizer = function () {
442
+ function TabstopToken(str) {
443
+ str = str.substr(1);
444
+ if (/^\d+$/.test(str))
445
+ return [{ tabstopId: parseInt(str, 10) }];
446
+ return [{ text: str }];
447
+ }
448
+ function escape(ch) {
449
+ return "(?:[^\\\\" + ch + "]|\\\\.)";
450
+ }
451
+ var formatMatcher = {
452
+ regex: "/(" + escape("/") + "+)/",
453
+ onMatch: function (val, state, stack) {
454
+ var ts = stack[0];
455
+ ts.fmtString = true;
456
+ ts.guard = val.slice(1, -1);
457
+ ts.flag = "";
458
+ return "";
459
+ },
460
+ next: "formatString"
461
+ };
462
+ SnippetManager["$tokenizer"] = new Tokenizer({
463
+ start: [
464
+ { regex: /\\./, onMatch: function (val, state, stack) {
465
+ var ch = val[1];
466
+ if (ch == "}" && stack.length) {
467
+ val = ch;
468
+ }
469
+ else if ("`$\\".indexOf(ch) != -1) {
470
+ val = ch;
471
+ }
472
+ return [val];
473
+ } },
474
+ { regex: /}/, onMatch: function (val, state, stack) {
475
+ return [stack.length ? stack.shift() : val];
476
+ } },
477
+ { regex: /\$(?:\d+|\w+)/, onMatch: TabstopToken },
478
+ { regex: /\$\{[\dA-Z_a-z]+/, onMatch: function (str, state, stack) {
479
+ var t = TabstopToken(str.substr(1));
480
+ stack.unshift(t[0]);
481
+ return t;
482
+ }, next: "snippetVar" },
483
+ { regex: /\n/, token: "newline", merge: false }
484
+ ],
485
+ snippetVar: [
486
+ { regex: "\\|" + escape("\\|") + "*\\|", onMatch: function (val, state, stack) {
487
+ var choices = val.slice(1, -1).replace(/\\[,|\\]|,/g, function (operator) {
488
+ return operator.length == 2 ? operator[1] : "\x00";
489
+ }).split("\x00").map(function (value) {
490
+ return { value: value };
491
+ });
492
+ stack[0].choices = choices;
493
+ return [choices[0]];
494
+ }, next: "start" },
495
+ formatMatcher,
496
+ { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "start" }
497
+ ],
498
+ formatString: [
499
+ { regex: /:/, onMatch: function (val, state, stack) {
500
+ if (stack.length && stack[0].expectElse) {
501
+ stack[0].expectElse = false;
502
+ stack[0].ifEnd = { elseEnd: stack[0] };
503
+ return [stack[0].ifEnd];
504
+ }
505
+ return ":";
506
+ } },
507
+ { regex: /\\./, onMatch: function (val, state, stack) {
508
+ var ch = val[1];
509
+ if (ch == "}" && stack.length)
510
+ val = ch;
511
+ else if ("`$\\".indexOf(ch) != -1)
512
+ val = ch;
513
+ else if (ch == "n")
514
+ val = "\n";
515
+ else if (ch == "t")
516
+ val = "\t";
517
+ else if ("ulULE".indexOf(ch) != -1)
518
+ val = { changeCase: ch, local: ch > "a" };
519
+ return [val];
520
+ } },
521
+ { regex: "/\\w*}", onMatch: function (val, state, stack) {
522
+ var next = stack.shift();
523
+ if (next)
524
+ next.flag = val.slice(1, -1);
525
+ this.next = next && next.tabstopId ? "start" : "";
526
+ return [next || val];
527
+ }, next: "start" },
528
+ { regex: /\$(?:\d+|\w+)/, onMatch: function (val, state, stack) {
529
+ return [{ text: val.slice(1) }];
530
+ } },
531
+ { regex: /\${\w+/, onMatch: function (val, state, stack) {
532
+ var token = { text: val.slice(2) };
533
+ stack.unshift(token);
534
+ return [token];
535
+ }, next: "formatStringVar" },
536
+ { regex: /\n/, token: "newline", merge: false },
537
+ { regex: /}/, onMatch: function (val, state, stack) {
538
+ var next = stack.shift();
539
+ this.next = next && next.tabstopId ? "start" : "";
540
+ return [next || val];
541
+ }, next: "start" }
542
+ ],
543
+ formatStringVar: [
544
+ { regex: /:\/\w+}/, onMatch: function (val, state, stack) {
545
+ var ts = stack[0];
546
+ ts.formatFunction = val.slice(2, -1);
547
+ return [stack.shift()];
548
+ }, next: "formatString" },
549
+ formatMatcher,
550
+ { regex: /:[\?\-+]?/, onMatch: function (val, state, stack) {
551
+ if (val[1] == "+")
552
+ stack[0].ifEnd = stack[0];
553
+ if (val[1] == "?")
554
+ stack[0].expectElse = true;
555
+ }, next: "formatString" },
556
+ { regex: "([^:}\\\\]|\\\\.)*:?", token: "", next: "formatString" }
557
+ ]
558
+ });
559
+ return SnippetManager["$tokenizer"];
560
+ };
561
+ SnippetManager.prototype.tokenizeTmSnippet = function (str, startState) {
562
+ return this.getTokenizer().getLineTokens(str, startState).tokens.map(function (x) {
563
+ return x.value || x;
564
+ });
565
+ };
566
+ SnippetManager.prototype.getVariableValue = function (editor, name, indentation) {
567
+ if (/^\d+$/.test(name))
568
+ return (this.variables.__ || {})[name] || "";
569
+ if (/^[A-Z]\d+$/.test(name))
570
+ return (this.variables[name[0] + "__"] || {})[name.substr(1)] || "";
571
+ name = name.replace(/^TM_/, "");
572
+ if (!this.variables.hasOwnProperty(name))
573
+ return "";
574
+ var value = this.variables[name];
575
+ if (typeof value == "function")
576
+ value = this.variables[name](editor, name, indentation);
577
+ return value == null ? "" : value;
578
+ };
579
+ SnippetManager.prototype.tmStrFormat = function (str, ch, editor) {
580
+ if (!ch.fmt)
581
+ return str;
582
+ var flag = ch.flag || "";
583
+ var re = ch.guard;
584
+ re = new RegExp(re, flag.replace(/[^gim]/g, ""));
585
+ var fmtTokens = typeof ch.fmt == "string" ? this.tokenizeTmSnippet(ch.fmt, "formatString") : ch.fmt;
586
+ var _self = this;
587
+ var formatted = str.replace(re, function () {
588
+ var oldArgs = _self.variables.__;
589
+ _self.variables.__ = [].slice.call(arguments);
590
+ var fmtParts = _self.resolveVariables(fmtTokens, editor);
591
+ var gChangeCase = "E";
592
+ for (var i = 0; i < fmtParts.length; i++) {
593
+ var ch = fmtParts[i];
594
+ if (typeof ch == "object") {
595
+ fmtParts[i] = "";
596
+ if (ch.changeCase && ch.local) {
597
+ var next = fmtParts[i + 1];
598
+ if (next && typeof next == "string") {
599
+ if (ch.changeCase == "u")
600
+ fmtParts[i] = next[0].toUpperCase();
601
+ else
602
+ fmtParts[i] = next[0].toLowerCase();
603
+ fmtParts[i + 1] = next.substr(1);
604
+ }
605
+ }
606
+ else if (ch.changeCase) {
607
+ gChangeCase = ch.changeCase;
608
+ }
609
+ }
610
+ else if (gChangeCase == "U") {
611
+ fmtParts[i] = ch.toUpperCase();
612
+ }
613
+ else if (gChangeCase == "L") {
614
+ fmtParts[i] = ch.toLowerCase();
615
+ }
616
+ }
617
+ _self.variables.__ = oldArgs;
618
+ return fmtParts.join("");
619
+ });
620
+ return formatted;
621
+ };
622
+ SnippetManager.prototype.tmFormatFunction = function (str, ch, editor) {
623
+ if (ch.formatFunction == "upcase")
624
+ return str.toUpperCase();
625
+ if (ch.formatFunction == "downcase")
626
+ return str.toLowerCase();
627
+ return str;
628
+ };
629
+ SnippetManager.prototype.resolveVariables = function (snippet, editor) {
630
+ var result = [];
631
+ var indentation = "";
632
+ var afterNewLine = true;
633
+ for (var i = 0; i < snippet.length; i++) {
634
+ var ch = snippet[i];
635
+ if (typeof ch == "string") {
636
+ result.push(ch);
637
+ if (ch == "\n") {
638
+ afterNewLine = true;
639
+ indentation = "";
640
+ }
641
+ else if (afterNewLine) {
642
+ indentation = /^\t*/.exec(ch)[0];
643
+ afterNewLine = /\S/.test(ch);
644
+ }
645
+ continue;
646
+ }
647
+ if (!ch)
648
+ continue;
649
+ afterNewLine = false;
650
+ if (ch.fmtString) {
651
+ var j = snippet.indexOf(ch, i + 1);
652
+ if (j == -1)
653
+ j = snippet.length;
654
+ ch.fmt = snippet.slice(i + 1, j);
655
+ i = j;
656
+ }
657
+ if (ch.text) {
658
+ var value = this.getVariableValue(editor, ch.text, indentation) + "";
659
+ if (ch.fmtString)
660
+ value = this.tmStrFormat(value, ch, editor);
661
+ if (ch.formatFunction)
662
+ value = this.tmFormatFunction(value, ch, editor);
663
+ if (value && !ch.ifEnd) {
664
+ result.push(value);
665
+ gotoNext(ch);
666
+ }
667
+ else if (!value && ch.ifEnd) {
668
+ gotoNext(ch.ifEnd);
669
+ }
670
+ }
671
+ else if (ch.elseEnd) {
672
+ gotoNext(ch.elseEnd);
673
+ }
674
+ else if (ch.tabstopId != null) {
675
+ result.push(ch);
676
+ }
677
+ else if (ch.changeCase != null) {
678
+ result.push(ch);
679
+ }
680
+ }
681
+ function gotoNext(ch) {
682
+ var i1 = snippet.indexOf(ch, i + 1);
683
+ if (i1 != -1)
684
+ i = i1;
685
+ }
686
+ return result;
687
+ };
688
+ SnippetManager.prototype.getDisplayTextForSnippet = function (editor, snippetText) {
689
+ var processedSnippet = processSnippetText.call(this, editor, snippetText);
690
+ return processedSnippet.text;
691
+ };
692
+ SnippetManager.prototype.insertSnippetForSelection = function (editor, snippetText, options) {
693
+ if (options === void 0) { options = {}; }
694
+ var processedSnippet = processSnippetText.call(this, editor, snippetText, options);
695
+ var range = editor.getSelectionRange();
696
+ var end = editor.session.replace(range, processedSnippet.text);
697
+ var tabstopManager = new TabstopManager(editor);
698
+ var selectionId = editor.inVirtualSelectionMode && editor.selection.index;
699
+ tabstopManager.addTabstops(processedSnippet.tabstops, range.start, end, selectionId);
700
+ };
701
+ SnippetManager.prototype.insertSnippet = function (editor, snippetText, options) {
702
+ if (options === void 0) { options = {}; }
703
+ var self = this;
704
+ if (editor.inVirtualSelectionMode)
705
+ return self.insertSnippetForSelection(editor, snippetText, options);
706
+ editor.forEachSelection(function () {
707
+ self.insertSnippetForSelection(editor, snippetText, options);
708
+ }, null, { keepOrder: true });
709
+ if (editor.tabstopManager)
710
+ editor.tabstopManager.tabNext();
711
+ };
712
+ SnippetManager.prototype.$getScope = function (editor) {
713
+ var scope = editor.session.$mode.$id || "";
714
+ scope = scope.split("/").pop();
715
+ if (scope === "html" || scope === "php") {
716
+ if (scope === "php" && !editor.session.$mode.inlinePhp)
717
+ scope = "html";
718
+ var c = editor.getCursorPosition();
719
+ var state = editor.session.getState(c.row);
720
+ if (typeof state === "object") {
721
+ state = state[0];
722
+ }
723
+ if (state.substring) {
724
+ if (state.substring(0, 3) == "js-")
725
+ scope = "javascript";
726
+ else if (state.substring(0, 4) == "css-")
727
+ scope = "css";
728
+ else if (state.substring(0, 4) == "php-")
729
+ scope = "php";
730
+ }
731
+ }
732
+ return scope;
733
+ };
734
+ SnippetManager.prototype.getActiveScopes = function (editor) {
735
+ var scope = this.$getScope(editor);
736
+ var scopes = [scope];
737
+ var snippetMap = this.snippetMap;
738
+ if (snippetMap[scope] && snippetMap[scope].includeScopes) {
739
+ scopes.push.apply(scopes, snippetMap[scope].includeScopes);
740
+ }
741
+ scopes.push("_");
742
+ return scopes;
743
+ };
744
+ SnippetManager.prototype.expandWithTab = function (editor, options) {
745
+ var self = this;
746
+ var result = editor.forEachSelection(function () {
747
+ return self.expandSnippetForSelection(editor, options);
748
+ }, null, { keepOrder: true });
749
+ if (result && editor.tabstopManager)
750
+ editor.tabstopManager.tabNext();
751
+ return result;
752
+ };
753
+ SnippetManager.prototype.expandSnippetForSelection = function (editor, options) {
754
+ var cursor = editor.getCursorPosition();
755
+ var line = editor.session.getLine(cursor.row);
756
+ var before = line.substring(0, cursor.column);
757
+ var after = line.substr(cursor.column);
758
+ var snippetMap = this.snippetMap;
759
+ var snippet;
760
+ this.getActiveScopes(editor).some(function (scope) {
761
+ var snippets = snippetMap[scope];
762
+ if (snippets)
763
+ snippet = this.findMatchingSnippet(snippets, before, after);
764
+ return !!snippet;
765
+ }, this);
766
+ if (!snippet)
767
+ return false;
768
+ if (options && options.dryRun)
769
+ return true;
770
+ editor.session.doc.removeInLine(cursor.row, cursor.column - snippet.replaceBefore.length, cursor.column + snippet.replaceAfter.length);
771
+ this.variables.M__ = snippet.matchBefore;
772
+ this.variables.T__ = snippet.matchAfter;
773
+ this.insertSnippetForSelection(editor, snippet.content);
774
+ this.variables.M__ = this.variables.T__ = null;
775
+ return true;
776
+ };
777
+ SnippetManager.prototype.findMatchingSnippet = function (snippetList, before, after) {
778
+ for (var i = snippetList.length; i--;) {
779
+ var s = snippetList[i];
780
+ if (s.startRe && !s.startRe.test(before))
781
+ continue;
782
+ if (s.endRe && !s.endRe.test(after))
783
+ continue;
784
+ if (!s.startRe && !s.endRe)
785
+ continue;
786
+ s.matchBefore = s.startRe ? s.startRe.exec(before) : [""];
787
+ s.matchAfter = s.endRe ? s.endRe.exec(after) : [""];
788
+ s.replaceBefore = s.triggerRe ? s.triggerRe.exec(before)[0] : "";
789
+ s.replaceAfter = s.endTriggerRe ? s.endTriggerRe.exec(after)[0] : "";
790
+ return s;
791
+ }
792
+ };
793
+ SnippetManager.prototype.register = function (snippets, scope) {
794
+ var snippetMap = this.snippetMap;
795
+ var snippetNameMap = this.snippetNameMap;
796
+ var self = this;
797
+ if (!snippets)
798
+ snippets = [];
799
+ function wrapRegexp(src) {
800
+ if (src && !/^\^?\(.*\)\$?$|^\\b$/.test(src))
801
+ src = "(?:" + src + ")";
802
+ return src || "";
803
+ }
804
+ function guardedRegexp(re, guard, opening) {
805
+ re = wrapRegexp(re);
806
+ guard = wrapRegexp(guard);
807
+ if (opening) {
808
+ re = guard + re;
809
+ if (re && re[re.length - 1] != "$")
810
+ re = re + "$";
811
+ }
812
+ else {
813
+ re = re + guard;
814
+ if (re && re[0] != "^")
815
+ re = "^" + re;
816
+ }
817
+ return new RegExp(re);
818
+ }
819
+ function addSnippet(s) {
820
+ if (!s.scope)
821
+ s.scope = scope || "_";
822
+ scope = s.scope;
823
+ if (!snippetMap[scope]) {
824
+ snippetMap[scope] = [];
825
+ snippetNameMap[scope] = {};
826
+ }
827
+ var map = snippetNameMap[scope];
828
+ if (s.name) {
829
+ var old = map[s.name];
830
+ if (old)
831
+ self.unregister(old);
832
+ map[s.name] = s;
833
+ }
834
+ snippetMap[scope].push(s);
835
+ if (s.prefix)
836
+ s.tabTrigger = s.prefix;
837
+ if (!s.content && s.body)
838
+ s.content = Array.isArray(s.body) ? s.body.join("\n") : s.body;
839
+ if (s.tabTrigger && !s.trigger) {
840
+ if (!s.guard && /^\w/.test(s.tabTrigger))
841
+ s.guard = "\\b";
842
+ s.trigger = lang.escapeRegExp(s.tabTrigger);
843
+ }
844
+ if (!s.trigger && !s.guard && !s.endTrigger && !s.endGuard)
845
+ return;
846
+ s.startRe = guardedRegexp(s.trigger, s.guard, true);
847
+ s.triggerRe = new RegExp(s.trigger);
848
+ s.endRe = guardedRegexp(s.endTrigger, s.endGuard, true);
849
+ s.endTriggerRe = new RegExp(s.endTrigger);
850
+ }
851
+ if (Array.isArray(snippets)) {
852
+ snippets.forEach(addSnippet);
853
+ }
854
+ else {
855
+ Object.keys(snippets).forEach(function (key) {
856
+ addSnippet(snippets[key]);
857
+ });
858
+ }
859
+ this._signal("registerSnippets", { scope: scope });
860
+ };
861
+ SnippetManager.prototype.unregister = function (snippets, scope) {
862
+ var snippetMap = this.snippetMap;
863
+ var snippetNameMap = this.snippetNameMap;
864
+ function removeSnippet(s) {
865
+ var nameMap = snippetNameMap[s.scope || scope];
866
+ if (nameMap && nameMap[s.name]) {
867
+ delete nameMap[s.name];
868
+ var map = snippetMap[s.scope || scope];
869
+ var i = map && map.indexOf(s);
870
+ if (i >= 0)
871
+ map.splice(i, 1);
872
+ }
873
+ }
874
+ if (snippets.content)
875
+ removeSnippet(snippets);
876
+ else if (Array.isArray(snippets))
877
+ snippets.forEach(removeSnippet);
878
+ };
879
+ SnippetManager.prototype.parseSnippetFile = function (str) {
880
+ str = str.replace(/\r/g, "");
881
+ var list = [], /**@type{Snippet}*/ snippet = {};
882
+ var re = /^#.*|^({[\s\S]*})\s*$|^(\S+) (.*)$|^((?:\n*\t.*)+)/gm;
883
+ var m;
884
+ while (m = re.exec(str)) {
885
+ if (m[1]) {
886
+ try {
887
+ snippet = JSON.parse(m[1]);
888
+ list.push(snippet);
889
+ }
890
+ catch (e) { }
891
+ }
892
+ if (m[4]) {
893
+ snippet.content = m[4].replace(/^\t/gm, "");
894
+ list.push(snippet);
895
+ snippet = {};
896
+ }
897
+ else {
898
+ var key = m[2], val = m[3];
899
+ if (key == "regex") {
900
+ var guardRe = /\/((?:[^\/\\]|\\.)*)|$/g;
901
+ snippet.guard = guardRe.exec(val)[1];
902
+ snippet.trigger = guardRe.exec(val)[1];
903
+ snippet.endTrigger = guardRe.exec(val)[1];
904
+ snippet.endGuard = guardRe.exec(val)[1];
905
+ }
906
+ else if (key == "snippet") {
907
+ snippet.tabTrigger = val.match(/^\S*/)[0];
908
+ if (!snippet.name)
909
+ snippet.name = val;
910
+ }
911
+ else if (key) {
912
+ snippet[key] = val;
913
+ }
914
+ }
915
+ }
916
+ return list;
917
+ };
918
+ SnippetManager.prototype.getSnippetByName = function (name, editor) {
919
+ var snippetMap = this.snippetNameMap;
920
+ var snippet;
921
+ this.getActiveScopes(editor).some(function (scope) {
922
+ var snippets = snippetMap[scope];
923
+ if (snippets)
924
+ snippet = snippets[name];
925
+ return !!snippet;
926
+ }, this);
927
+ return snippet;
928
+ };
929
+ return SnippetManager;
930
+ }());
931
+ oop.implement(SnippetManager.prototype, EventEmitter);
932
+ var processSnippetText = function (editor, snippetText, options) {
933
+ if (options === void 0) { options = {}; }
934
+ var cursor = editor.getCursorPosition();
935
+ var line = editor.session.getLine(cursor.row);
936
+ var tabString = editor.session.getTabString();
937
+ var indentString = line.match(/^\s*/)[0];
938
+ if (cursor.column < indentString.length)
939
+ indentString = indentString.slice(0, cursor.column);
940
+ snippetText = snippetText.replace(/\r/g, "");
941
+ var tokens = this.tokenizeTmSnippet(snippetText);
942
+ tokens = this.resolveVariables(tokens, editor);
943
+ tokens = tokens.map(function (x) {
944
+ if (x == "\n" && !options.excludeExtraIndent)
945
+ return x + indentString;
946
+ if (typeof x == "string")
947
+ return x.replace(/\t/g, tabString);
948
+ return x;
949
+ });
950
+ var tabstops = [];
951
+ tokens.forEach(function (p, i) {
952
+ if (typeof p != "object")
953
+ return;
954
+ var id = p.tabstopId;
955
+ var ts = tabstops[id];
956
+ if (!ts) {
957
+ ts = tabstops[id] = [];
958
+ ts.index = id;
959
+ ts.value = "";
960
+ ts.parents = {};
961
+ }
962
+ if (ts.indexOf(p) !== -1)
963
+ return;
964
+ if (p.choices && !ts.choices)
965
+ ts.choices = p.choices;
966
+ ts.push(p);
967
+ var i1 = tokens.indexOf(p, i + 1);
968
+ if (i1 === -1)
969
+ return;
970
+ var value = tokens.slice(i + 1, i1);
971
+ var isNested = value.some(function (t) { return typeof t === "object"; });
972
+ if (isNested && !ts.value) {
973
+ ts.value = value;
974
+ }
975
+ else if (value.length && (!ts.value || typeof ts.value !== "string")) {
976
+ ts.value = value.join("");
977
+ }
978
+ });
979
+ tabstops.forEach(function (ts) { ts.length = 0; });
980
+ var expanding = {};
981
+ function copyValue(val) {
982
+ var copy = [];
983
+ for (var i = 0; i < val.length; i++) {
984
+ var p = val[i];
985
+ if (typeof p == "object") {
986
+ if (expanding[p.tabstopId])
987
+ continue;
988
+ var j = val.lastIndexOf(p, i - 1);
989
+ p = copy[j] || { tabstopId: p.tabstopId };
990
+ }
991
+ copy[i] = p;
992
+ }
993
+ return copy;
994
+ }
995
+ for (var i = 0; i < tokens.length; i++) {
996
+ var p = tokens[i];
997
+ if (typeof p != "object")
998
+ continue;
999
+ var id = p.tabstopId;
1000
+ var ts = tabstops[id];
1001
+ var i1 = tokens.indexOf(p, i + 1);
1002
+ if (expanding[id]) {
1003
+ if (expanding[id] === p) {
1004
+ delete expanding[id];
1005
+ Object.keys(expanding).forEach(function (parentId) {
1006
+ ts.parents[parentId] = true;
1007
+ });
1008
+ }
1009
+ continue;
1010
+ }
1011
+ expanding[id] = p;
1012
+ var value = ts.value;
1013
+ if (typeof value !== "string")
1014
+ value = copyValue(value);
1015
+ else if (p.fmt)
1016
+ value = this.tmStrFormat(value, p, editor);
1017
+ tokens.splice.apply(tokens, [i + 1, Math.max(0, i1 - i)].concat(value, p));
1018
+ if (ts.indexOf(p) === -1)
1019
+ ts.push(p);
1020
+ }
1021
+ var row = 0, column = 0;
1022
+ var text = "";
1023
+ tokens.forEach(function (t) {
1024
+ if (typeof t === "string") {
1025
+ var lines = t.split("\n");
1026
+ if (lines.length > 1) {
1027
+ column = lines[lines.length - 1].length;
1028
+ row += lines.length - 1;
1029
+ }
1030
+ else
1031
+ column += t.length;
1032
+ text += t;
1033
+ }
1034
+ else if (t) {
1035
+ if (!t.start)
1036
+ t.start = { row: row, column: column };
1037
+ else
1038
+ t.end = { row: row, column: column };
1039
+ }
1040
+ });
1041
+ return {
1042
+ text: text,
1043
+ tabstops: tabstops,
1044
+ tokens: tokens
1045
+ };
1046
+ };
1047
+ var TabstopManager = /** @class */ (function () {
1048
+ function TabstopManager(editor) {
1049
+ this.index = 0;
1050
+ this.ranges = [];
1051
+ this.tabstops = [];
1052
+ if (editor.tabstopManager)
1053
+ return editor.tabstopManager;
1054
+ editor.tabstopManager = this;
1055
+ this.$onChange = this.onChange.bind(this);
1056
+ this.$onChangeSelection = lang.delayedCall(this.onChangeSelection.bind(this)).schedule;
1057
+ this.$onChangeSession = this.onChangeSession.bind(this);
1058
+ this.$onAfterExec = this.onAfterExec.bind(this);
1059
+ this.attach(editor);
1060
+ }
1061
+ TabstopManager.prototype.attach = function (editor) {
1062
+ this.$openTabstops = null;
1063
+ this.selectedTabstop = null;
1064
+ this.editor = editor;
1065
+ this.session = editor.session;
1066
+ this.editor.on("change", this.$onChange);
1067
+ this.editor.on("changeSelection", this.$onChangeSelection);
1068
+ this.editor.on("changeSession", this.$onChangeSession);
1069
+ this.editor.commands.on("afterExec", this.$onAfterExec);
1070
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1071
+ };
1072
+ TabstopManager.prototype.detach = function () {
1073
+ this.tabstops.forEach(this.removeTabstopMarkers, this);
1074
+ this.ranges.length = 0;
1075
+ this.tabstops.length = 0;
1076
+ this.selectedTabstop = null;
1077
+ this.editor.off("change", this.$onChange);
1078
+ this.editor.off("changeSelection", this.$onChangeSelection);
1079
+ this.editor.off("changeSession", this.$onChangeSession);
1080
+ this.editor.commands.off("afterExec", this.$onAfterExec);
1081
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1082
+ this.editor.tabstopManager = null;
1083
+ this.session = null;
1084
+ this.editor = null;
1085
+ };
1086
+ TabstopManager.prototype.onChange = function (delta) {
1087
+ var isRemove = delta.action[0] == "r";
1088
+ var selectedTabstop = this.selectedTabstop || {};
1089
+ var parents = selectedTabstop.parents || {};
1090
+ var tabstops = this.tabstops.slice();
1091
+ for (var i = 0; i < tabstops.length; i++) {
1092
+ var ts = tabstops[i];
1093
+ var active = ts == selectedTabstop || parents[ts.index];
1094
+ ts.rangeList.$bias = active ? 0 : 1;
1095
+ if (delta.action == "remove" && ts !== selectedTabstop) {
1096
+ var parentActive = ts.parents && ts.parents[selectedTabstop.index];
1097
+ var startIndex = ts.rangeList.pointIndex(delta.start, parentActive);
1098
+ startIndex = startIndex < 0 ? -startIndex - 1 : startIndex + 1;
1099
+ var endIndex = ts.rangeList.pointIndex(delta.end, parentActive);
1100
+ endIndex = endIndex < 0 ? -endIndex - 1 : endIndex - 1;
1101
+ var toRemove = ts.rangeList.ranges.slice(startIndex, endIndex);
1102
+ for (var j = 0; j < toRemove.length; j++)
1103
+ this.removeRange(toRemove[j]);
1104
+ }
1105
+ ts.rangeList.$onChange(delta);
1106
+ }
1107
+ var session = this.session;
1108
+ if (!this.$inChange && isRemove && session.getLength() == 1 && !session.getValue())
1109
+ this.detach();
1110
+ };
1111
+ TabstopManager.prototype.updateLinkedFields = function () {
1112
+ var ts = this.selectedTabstop;
1113
+ if (!ts || !ts.hasLinkedRanges || !ts.firstNonLinked)
1114
+ return;
1115
+ this.$inChange = true;
1116
+ var session = this.session;
1117
+ var text = session.getTextRange(ts.firstNonLinked);
1118
+ for (var i = 0; i < ts.length; i++) {
1119
+ var range = ts[i];
1120
+ if (!range.linked)
1121
+ continue;
1122
+ var original = range.original;
1123
+ var fmt = exports.snippetManager.tmStrFormat(text, original, this.editor);
1124
+ session.replace(range, fmt);
1125
+ }
1126
+ this.$inChange = false;
1127
+ };
1128
+ TabstopManager.prototype.onAfterExec = function (e) {
1129
+ if (e.command && !e.command.readOnly)
1130
+ this.updateLinkedFields();
1131
+ };
1132
+ TabstopManager.prototype.onChangeSelection = function () {
1133
+ if (!this.editor)
1134
+ return;
1135
+ var lead = this.editor.selection.lead;
1136
+ var anchor = this.editor.selection.anchor;
1137
+ var isEmpty = this.editor.selection.isEmpty();
1138
+ for (var i = 0; i < this.ranges.length; i++) {
1139
+ if (this.ranges[i].linked)
1140
+ continue;
1141
+ var containsLead = this.ranges[i].contains(lead.row, lead.column);
1142
+ var containsAnchor = isEmpty || this.ranges[i].contains(anchor.row, anchor.column);
1143
+ if (containsLead && containsAnchor)
1144
+ return;
1145
+ }
1146
+ this.detach();
1147
+ };
1148
+ TabstopManager.prototype.onChangeSession = function () {
1149
+ this.detach();
1150
+ };
1151
+ TabstopManager.prototype.tabNext = function (dir) {
1152
+ var max = this.tabstops.length;
1153
+ var index = this.index + (dir || 1);
1154
+ index = Math.min(Math.max(index, 1), max);
1155
+ if (index == max)
1156
+ index = 0;
1157
+ this.selectTabstop(index);
1158
+ this.updateTabstopMarkers();
1159
+ if (index === 0) {
1160
+ this.detach();
1161
+ }
1162
+ };
1163
+ TabstopManager.prototype.selectTabstop = function (index) {
1164
+ this.$openTabstops = null;
1165
+ var ts = this.tabstops[this.index];
1166
+ if (ts)
1167
+ this.addTabstopMarkers(ts);
1168
+ this.index = index;
1169
+ ts = this.tabstops[this.index];
1170
+ if (!ts || !ts.length)
1171
+ return;
1172
+ this.selectedTabstop = ts;
1173
+ var range = ts.firstNonLinked || ts;
1174
+ if (ts.choices)
1175
+ range.cursor = range.start;
1176
+ if (!this.editor.inVirtualSelectionMode) {
1177
+ var sel = this.editor.multiSelect;
1178
+ sel.toSingleRange(range);
1179
+ for (var i = 0; i < ts.length; i++) {
1180
+ if (ts.hasLinkedRanges && ts[i].linked)
1181
+ continue;
1182
+ sel.addRange(ts[i].clone(), true);
1183
+ }
1184
+ }
1185
+ else {
1186
+ this.editor.selection.fromOrientedRange(range);
1187
+ }
1188
+ this.editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1189
+ if (this.selectedTabstop && this.selectedTabstop.choices)
1190
+ this.editor.execCommand("startAutocomplete", { matches: this.selectedTabstop.choices });
1191
+ };
1192
+ TabstopManager.prototype.addTabstops = function (tabstops, start, end) {
1193
+ var useLink = this.useLink || !this.editor.getOption("enableMultiselect");
1194
+ if (!this.$openTabstops)
1195
+ this.$openTabstops = [];
1196
+ if (!tabstops[0]) {
1197
+ var p = Range.fromPoints(end, end);
1198
+ moveRelative(p.start, start);
1199
+ moveRelative(p.end, start);
1200
+ tabstops[0] = [p];
1201
+ tabstops[0].index = 0;
1202
+ }
1203
+ var i = this.index;
1204
+ var arg = [i + 1, 0];
1205
+ var ranges = this.ranges;
1206
+ var snippetId = this.snippetId = (this.snippetId || 0) + 1;
1207
+ tabstops.forEach(function (ts, index) {
1208
+ var dest = this.$openTabstops[index] || ts;
1209
+ dest.snippetId = snippetId;
1210
+ for (var i = 0; i < ts.length; i++) {
1211
+ var p = ts[i];
1212
+ var range = Range.fromPoints(p.start, p.end || p.start);
1213
+ movePoint(range.start, start);
1214
+ movePoint(range.end, start);
1215
+ range.original = p;
1216
+ range.tabstop = dest;
1217
+ ranges.push(range);
1218
+ if (dest != ts)
1219
+ dest.unshift(range);
1220
+ else
1221
+ dest[i] = range;
1222
+ if (p.fmtString || (dest.firstNonLinked && useLink)) {
1223
+ range.linked = true;
1224
+ dest.hasLinkedRanges = true;
1225
+ }
1226
+ else if (!dest.firstNonLinked)
1227
+ dest.firstNonLinked = range;
1228
+ }
1229
+ if (!dest.firstNonLinked)
1230
+ dest.hasLinkedRanges = false;
1231
+ if (dest === ts) {
1232
+ arg.push(dest);
1233
+ this.$openTabstops[index] = dest;
1234
+ }
1235
+ this.addTabstopMarkers(dest);
1236
+ dest.rangeList = dest.rangeList || new RangeList();
1237
+ dest.rangeList.$bias = 0;
1238
+ dest.rangeList.addList(dest);
1239
+ }, this);
1240
+ if (arg.length > 2) {
1241
+ if (this.tabstops.length)
1242
+ arg.push(arg.splice(2, 1)[0]);
1243
+ this.tabstops.splice.apply(this.tabstops, arg);
1244
+ }
1245
+ };
1246
+ TabstopManager.prototype.addTabstopMarkers = function (ts) {
1247
+ var session = this.session;
1248
+ ts.forEach(function (range) {
1249
+ if (!range.markerId)
1250
+ range.markerId = session.addMarker(range, "ace_snippet-marker", "text");
1251
+ });
1252
+ };
1253
+ TabstopManager.prototype.removeTabstopMarkers = function (ts) {
1254
+ var session = this.session;
1255
+ ts.forEach(function (range) {
1256
+ session.removeMarker(range.markerId);
1257
+ range.markerId = null;
1258
+ });
1259
+ };
1260
+ TabstopManager.prototype.updateTabstopMarkers = function () {
1261
+ if (!this.selectedTabstop)
1262
+ return;
1263
+ var currentSnippetId = this.selectedTabstop.snippetId;
1264
+ if (this.selectedTabstop.index === 0) {
1265
+ currentSnippetId--;
1266
+ }
1267
+ this.tabstops.forEach(function (ts) {
1268
+ if (ts.snippetId === currentSnippetId)
1269
+ this.addTabstopMarkers(ts);
1270
+ else
1271
+ this.removeTabstopMarkers(ts);
1272
+ }, this);
1273
+ };
1274
+ TabstopManager.prototype.removeRange = function (range) {
1275
+ var i = range.tabstop.indexOf(range);
1276
+ if (i != -1)
1277
+ range.tabstop.splice(i, 1);
1278
+ i = this.ranges.indexOf(range);
1279
+ if (i != -1)
1280
+ this.ranges.splice(i, 1);
1281
+ i = range.tabstop.rangeList.ranges.indexOf(range);
1282
+ if (i != -1)
1283
+ range.tabstop.splice(i, 1);
1284
+ this.session.removeMarker(range.markerId);
1285
+ if (!range.tabstop.length) {
1286
+ i = this.tabstops.indexOf(range.tabstop);
1287
+ if (i != -1)
1288
+ this.tabstops.splice(i, 1);
1289
+ if (!this.tabstops.length)
1290
+ this.detach();
1291
+ }
1292
+ };
1293
+ return TabstopManager;
1294
+ }());
1295
+ TabstopManager.prototype.keyboardHandler = new HashHandler();
1296
+ TabstopManager.prototype.keyboardHandler.bindKeys({
1297
+ "Tab": function (editor) {
1298
+ if (exports.snippetManager && exports.snippetManager.expandWithTab(editor))
1299
+ return;
1300
+ editor.tabstopManager.tabNext(1);
1301
+ editor.renderer.scrollCursorIntoView();
1302
+ },
1303
+ "Shift-Tab": function (editor) {
1304
+ editor.tabstopManager.tabNext(-1);
1305
+ editor.renderer.scrollCursorIntoView();
1306
+ },
1307
+ "Esc": function (editor) {
1308
+ editor.tabstopManager.detach();
1309
+ }
1310
+ });
1311
+ var movePoint = function (point, diff) {
1312
+ if (point.row == 0)
1313
+ point.column += diff.column;
1314
+ point.row += diff.row;
1315
+ };
1316
+ var moveRelative = function (point, start) {
1317
+ if (point.row == start.row)
1318
+ point.column -= start.column;
1319
+ point.row -= start.row;
1320
+ };
1321
+ dom.importCssString("\n.ace_snippet-marker {\n -moz-box-sizing: border-box;\n box-sizing: border-box;\n background: rgba(194, 193, 208, 0.09);\n border: 1px dotted rgba(211, 208, 235, 0.62);\n position: absolute;\n}", "snippets.css", false);
1322
+ exports.snippetManager = new SnippetManager();
1323
+ var Editor = require("./editor").Editor;
1324
+ (function () {
1325
+ this.insertSnippet = function (content, options) {
1326
+ return exports.snippetManager.insertSnippet(this, content, options);
1327
+ };
1328
+ this.expandSnippet = function (options) {
1329
+ return exports.snippetManager.expandWithTab(this, options);
1330
+ };
1331
+ }).call(Editor.prototype);
1332
+
1333
+ });
1334
+
1335
+ ace.define("ace/autocomplete/inline_screenreader",["require","exports","module"], function(require, exports, module){"use strict";
1336
+ var AceInlineScreenReader = /** @class */ (function () {
1337
+ function AceInlineScreenReader(editor) {
1338
+ this.editor = editor;
1339
+ this.screenReaderDiv = document.createElement("div");
1340
+ this.screenReaderDiv.classList.add("ace_screenreader-only");
1341
+ this.editor.container.appendChild(this.screenReaderDiv);
1342
+ }
1343
+ AceInlineScreenReader.prototype.setScreenReaderContent = function (content) {
1344
+ if (!this.popup && this.editor.completer && /**@type{import("../autocomplete").Autocomplete}*/ (this.editor.completer).popup) {
1345
+ this.popup = /**@type{import("../autocomplete").Autocomplete}*/ (this.editor.completer).popup;
1346
+ this.popup.renderer.on("afterRender", function () {
1347
+ var row = this.popup.getRow();
1348
+ var t = this.popup.renderer.$textLayer;
1349
+ var selected = t.element.childNodes[row - t.config.firstRow];
1350
+ if (selected) {
1351
+ var idString = "doc-tooltip ";
1352
+ for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
1353
+ idString += "ace-inline-screenreader-line-".concat(lineIndex, " ");
1354
+ }
1355
+ selected.setAttribute("aria-describedby", idString);
1356
+ }
1357
+ }.bind(this));
1358
+ }
1359
+ while (this.screenReaderDiv.firstChild) {
1360
+ this.screenReaderDiv.removeChild(this.screenReaderDiv.firstChild);
1361
+ }
1362
+ this._lines = content.split(/\r\n|\r|\n/);
1363
+ var codeElement = this.createCodeBlock();
1364
+ this.screenReaderDiv.appendChild(codeElement);
1365
+ };
1366
+ AceInlineScreenReader.prototype.destroy = function () {
1367
+ this.screenReaderDiv.remove();
1368
+ };
1369
+ AceInlineScreenReader.prototype.createCodeBlock = function () {
1370
+ var container = document.createElement("pre");
1371
+ container.setAttribute("id", "ace-inline-screenreader");
1372
+ for (var lineIndex = 0; lineIndex < this._lines.length; lineIndex++) {
1373
+ var codeElement = document.createElement("code");
1374
+ codeElement.setAttribute("id", "ace-inline-screenreader-line-".concat(lineIndex));
1375
+ var line = document.createTextNode(this._lines[lineIndex]);
1376
+ codeElement.appendChild(line);
1377
+ container.appendChild(codeElement);
1378
+ }
1379
+ return container;
1380
+ };
1381
+ return AceInlineScreenReader;
1382
+ }());
1383
+ exports.AceInlineScreenReader = AceInlineScreenReader;
1384
+
1385
+ });
1386
+
1387
+ ace.define("ace/autocomplete/inline",["require","exports","module","ace/snippets","ace/autocomplete/inline_screenreader"], function(require, exports, module){"use strict";
1388
+ var snippetManager = require("../snippets").snippetManager;
1389
+ var AceInlineScreenReader = require("./inline_screenreader").AceInlineScreenReader;
1390
+ var AceInline = /** @class */ (function () {
1391
+ function AceInline() {
1392
+ this.editor = null;
1393
+ }
1394
+ AceInline.prototype.show = function (editor, completion, prefix) {
1395
+ prefix = prefix || "";
1396
+ if (editor && this.editor && this.editor !== editor) {
1397
+ this.hide();
1398
+ this.editor = null;
1399
+ this.inlineScreenReader = null;
1400
+ }
1401
+ if (!editor || !completion) {
1402
+ return false;
1403
+ }
1404
+ if (!this.inlineScreenReader) {
1405
+ this.inlineScreenReader = new AceInlineScreenReader(editor);
1406
+ }
1407
+ var displayText = completion.snippet ? snippetManager.getDisplayTextForSnippet(editor, completion.snippet) : completion.value;
1408
+ if (completion.hideInlinePreview || !displayText || !displayText.startsWith(prefix)) {
1409
+ return false;
1410
+ }
1411
+ this.editor = editor;
1412
+ this.inlineScreenReader.setScreenReaderContent(displayText);
1413
+ displayText = displayText.slice(prefix.length);
1414
+ if (displayText === "") {
1415
+ editor.removeGhostText();
1416
+ }
1417
+ else {
1418
+ editor.setGhostText(displayText);
1419
+ }
1420
+ return true;
1421
+ };
1422
+ AceInline.prototype.isOpen = function () {
1423
+ if (!this.editor) {
1424
+ return false;
1425
+ }
1426
+ return !!this.editor.renderer.$ghostText;
1427
+ };
1428
+ AceInline.prototype.hide = function () {
1429
+ if (!this.editor) {
1430
+ return false;
1431
+ }
1432
+ this.editor.removeGhostText();
1433
+ return true;
1434
+ };
1435
+ AceInline.prototype.destroy = function () {
1436
+ this.hide();
1437
+ this.editor = null;
1438
+ if (this.inlineScreenReader) {
1439
+ this.inlineScreenReader.destroy();
1440
+ this.inlineScreenReader = null;
1441
+ }
1442
+ };
1443
+ return AceInline;
1444
+ }());
1445
+ exports.AceInline = AceInline;
1446
+
1447
+ });
1448
+
1449
+ ace.define("ace/autocomplete/util",["require","exports","module"], function(require, exports, module){"use strict";
1450
+ exports.parForEach = function (array, fn, callback) {
1451
+ var completed = 0;
1452
+ var arLength = array.length;
1453
+ if (arLength === 0)
1454
+ callback();
1455
+ for (var i = 0; i < arLength; i++) {
1456
+ fn(array[i], function (result, err) {
1457
+ completed++;
1458
+ if (completed === arLength)
1459
+ callback(result, err);
1460
+ });
1461
+ }
1462
+ };
1463
+ var ID_REGEX = /[a-zA-Z_0-9\$\-\u00A2-\u2000\u2070-\uFFFF]/;
1464
+ exports.retrievePrecedingIdentifier = function (text, pos, regex) {
1465
+ regex = regex || ID_REGEX;
1466
+ var buf = [];
1467
+ for (var i = pos - 1; i >= 0; i--) {
1468
+ if (regex.test(text[i]))
1469
+ buf.push(text[i]);
1470
+ else
1471
+ break;
1472
+ }
1473
+ return buf.reverse().join("");
1474
+ };
1475
+ exports.retrieveFollowingIdentifier = function (text, pos, regex) {
1476
+ regex = regex || ID_REGEX;
1477
+ var buf = [];
1478
+ for (var i = pos; i < text.length; i++) {
1479
+ if (regex.test(text[i]))
1480
+ buf.push(text[i]);
1481
+ else
1482
+ break;
1483
+ }
1484
+ return buf;
1485
+ };
1486
+ exports.getCompletionPrefix = function (editor) {
1487
+ var pos = editor.getCursorPosition();
1488
+ var line = editor.session.getLine(pos.row);
1489
+ var prefix;
1490
+ editor.completers.forEach(function (completer) {
1491
+ if (completer.identifierRegexps) {
1492
+ completer.identifierRegexps.forEach(function (identifierRegex) {
1493
+ if (!prefix && identifierRegex)
1494
+ prefix = this.retrievePrecedingIdentifier(line, pos.column, identifierRegex);
1495
+ }.bind(this));
1496
+ }
1497
+ }.bind(this));
1498
+ return prefix || this.retrievePrecedingIdentifier(line, pos.column);
1499
+ };
1500
+ exports.triggerAutocomplete = function (editor, previousChar) {
1501
+ var previousChar = previousChar == null
1502
+ ? editor.session.getPrecedingCharacter()
1503
+ : previousChar;
1504
+ return editor.completers.some(function (completer) {
1505
+ if (completer.triggerCharacters && Array.isArray(completer.triggerCharacters)) {
1506
+ return completer.triggerCharacters.includes(previousChar);
1507
+ }
1508
+ });
1509
+ };
1510
+
1511
+ });
1512
+
1513
+ ace.define("ace/autocomplete",["require","exports","module","ace/keyboard/hash_handler","ace/autocomplete/popup","ace/autocomplete/inline","ace/autocomplete/popup","ace/autocomplete/util","ace/lib/lang","ace/lib/dom","ace/snippets","ace/config","ace/lib/event","ace/lib/scroll"], function(require, exports, module){"use strict";
1514
+ var HashHandler = require("./keyboard/hash_handler").HashHandler;
1515
+ var AcePopup = require("./autocomplete/popup").AcePopup;
1516
+ var AceInline = require("./autocomplete/inline").AceInline;
1517
+ var getAriaId = require("./autocomplete/popup").getAriaId;
1518
+ var util = require("./autocomplete/util");
1519
+ var lang = require("./lib/lang");
1520
+ var dom = require("./lib/dom");
1521
+ var snippetManager = require("./snippets").snippetManager;
1522
+ var config = require("./config");
1523
+ var event = require("./lib/event");
1524
+ var preventParentScroll = require("./lib/scroll").preventParentScroll;
1525
+ var destroyCompleter = function (e, editor) {
1526
+ editor.completer && editor.completer.destroy();
1527
+ };
1528
+ var Autocomplete = /** @class */ (function () {
1529
+ function Autocomplete() {
1530
+ this.autoInsert = false;
1531
+ this.autoSelect = true;
1532
+ this.autoShown = false;
1533
+ this.exactMatch = false;
1534
+ this.inlineEnabled = false;
1535
+ this.keyboardHandler = new HashHandler();
1536
+ this.keyboardHandler.bindKeys(this.commands);
1537
+ this.parentNode = null;
1538
+ this.setSelectOnHover = false;
1539
+ this.hasSeen = new Set();
1540
+ this.showLoadingState = false;
1541
+ this.stickySelectionDelay = 500;
1542
+ this.blurListener = this.blurListener.bind(this);
1543
+ this.changeListener = this.changeListener.bind(this);
1544
+ this.mousedownListener = this.mousedownListener.bind(this);
1545
+ this.mousewheelListener = this.mousewheelListener.bind(this);
1546
+ this.onLayoutChange = this.onLayoutChange.bind(this);
1547
+ this.changeTimer = lang.delayedCall(function () {
1548
+ this.updateCompletions(true);
1549
+ }.bind(this));
1550
+ this.tooltipTimer = lang.delayedCall(this.updateDocTooltip.bind(this), 50);
1551
+ this.popupTimer = lang.delayedCall(this.$updatePopupPosition.bind(this), 50);
1552
+ this.stickySelectionTimer = lang.delayedCall(function () {
1553
+ this.stickySelection = true;
1554
+ }.bind(this), this.stickySelectionDelay);
1555
+ this.$firstOpenTimer = lang.delayedCall(/**@this{Autocomplete}*/ function () {
1556
+ var initialPosition = this.completionProvider && this.completionProvider.initialPosition;
1557
+ if (this.autoShown || (this.popup && this.popup.isOpen) || !initialPosition || this.editor.completers.length === 0)
1558
+ return;
1559
+ this.completions = new FilteredList(Autocomplete.completionsForLoading);
1560
+ this.openPopup(this.editor, initialPosition.prefix, false);
1561
+ this.popup.renderer.setStyle("ace_loading", true);
1562
+ }.bind(this), this.stickySelectionDelay);
1563
+ }
1564
+ Object.defineProperty(Autocomplete, "completionsForLoading", {
1565
+ get: function () {
1566
+ return [{
1567
+ caption: config.nls("autocomplete.loading", "Loading..."),
1568
+ value: ""
1569
+ }];
1570
+ },
1571
+ enumerable: false,
1572
+ configurable: true
1573
+ });
1574
+ Autocomplete.prototype.$init = function () {
1575
+ this.popup = new AcePopup(this.parentNode || document.body || document.documentElement);
1576
+ this.popup.on("click", function (e) {
1577
+ this.insertMatch();
1578
+ e.stop();
1579
+ }.bind(this));
1580
+ this.popup.focus = this.editor.focus.bind(this.editor);
1581
+ this.popup.on("show", this.$onPopupShow.bind(this));
1582
+ this.popup.on("hide", this.$onHidePopup.bind(this));
1583
+ this.popup.on("select", this.$onPopupChange.bind(this));
1584
+ event.addListener(this.popup.container, "mouseout", this.mouseOutListener.bind(this));
1585
+ this.popup.on("changeHoverMarker", this.tooltipTimer.bind(null, null));
1586
+ this.popup.renderer.on("afterRender", this.$onPopupRender.bind(this));
1587
+ return this.popup;
1588
+ };
1589
+ Autocomplete.prototype.$initInline = function () {
1590
+ if (!this.inlineEnabled || this.inlineRenderer)
1591
+ return;
1592
+ this.inlineRenderer = new AceInline();
1593
+ return this.inlineRenderer;
1594
+ };
1595
+ Autocomplete.prototype.getPopup = function () {
1596
+ return this.popup || this.$init();
1597
+ };
1598
+ Autocomplete.prototype.$onHidePopup = function () {
1599
+ if (this.inlineRenderer) {
1600
+ this.inlineRenderer.hide();
1601
+ }
1602
+ this.hideDocTooltip();
1603
+ this.stickySelectionTimer.cancel();
1604
+ this.popupTimer.cancel();
1605
+ this.stickySelection = false;
1606
+ };
1607
+ Autocomplete.prototype.$seen = function (completion) {
1608
+ if (!this.hasSeen.has(completion) && completion && completion.completer && completion.completer.onSeen && typeof completion.completer.onSeen === "function") {
1609
+ completion.completer.onSeen(this.editor, completion);
1610
+ this.hasSeen.add(completion);
1611
+ }
1612
+ };
1613
+ Autocomplete.prototype.$onPopupChange = function (hide) {
1614
+ if (this.inlineRenderer && this.inlineEnabled) {
1615
+ var completion = hide ? null : this.popup.getData(this.popup.getRow());
1616
+ this.$updateGhostText(completion);
1617
+ if (this.popup.isMouseOver && this.setSelectOnHover) {
1618
+ this.tooltipTimer.call(null, null);
1619
+ return;
1620
+ }
1621
+ this.popupTimer.schedule();
1622
+ this.tooltipTimer.schedule();
1623
+ }
1624
+ else {
1625
+ this.popupTimer.call(null, null);
1626
+ this.tooltipTimer.call(null, null);
1627
+ }
1628
+ };
1629
+ Autocomplete.prototype.$updateGhostText = function (completion) {
1630
+ var row = this.base.row;
1631
+ var column = this.base.column;
1632
+ var cursorColumn = this.editor.getCursorPosition().column;
1633
+ var prefix = this.editor.session.getLine(row).slice(column, cursorColumn);
1634
+ if (!this.inlineRenderer.show(this.editor, completion, prefix)) {
1635
+ this.inlineRenderer.hide();
1636
+ }
1637
+ else {
1638
+ this.$seen(completion);
1639
+ }
1640
+ };
1641
+ Autocomplete.prototype.$onPopupRender = function () {
1642
+ var inlineEnabled = this.inlineRenderer && this.inlineEnabled;
1643
+ if (this.completions && this.completions.filtered && this.completions.filtered.length > 0) {
1644
+ for (var i = this.popup.getFirstVisibleRow(); i <= this.popup.getLastVisibleRow(); i++) {
1645
+ var completion = this.popup.getData(i);
1646
+ if (completion && (!inlineEnabled || completion.hideInlinePreview)) {
1647
+ this.$seen(completion);
1648
+ }
1649
+ }
1650
+ }
1651
+ };
1652
+ Autocomplete.prototype.$onPopupShow = function (hide) {
1653
+ this.$onPopupChange(hide);
1654
+ this.stickySelection = false;
1655
+ if (this.stickySelectionDelay >= 0)
1656
+ this.stickySelectionTimer.schedule(this.stickySelectionDelay);
1657
+ };
1658
+ Autocomplete.prototype.observeLayoutChanges = function () {
1659
+ if (this.$elements || !this.editor)
1660
+ return;
1661
+ window.addEventListener("resize", this.onLayoutChange, { passive: true });
1662
+ window.addEventListener("wheel", this.mousewheelListener);
1663
+ var el = this.editor.container.parentNode;
1664
+ var elements = [];
1665
+ while (el) {
1666
+ elements.push(el);
1667
+ el.addEventListener("scroll", this.onLayoutChange, { passive: true });
1668
+ el = el.parentNode;
1669
+ }
1670
+ this.$elements = elements;
1671
+ };
1672
+ Autocomplete.prototype.unObserveLayoutChanges = function () {
1673
+ var _this = this;
1674
+ window.removeEventListener("resize", this.onLayoutChange, { passive: true });
1675
+ window.removeEventListener("wheel", this.mousewheelListener);
1676
+ this.$elements && this.$elements.forEach(function (el) {
1677
+ el.removeEventListener("scroll", _this.onLayoutChange, { passive: true });
1678
+ });
1679
+ this.$elements = null;
1680
+ };
1681
+ Autocomplete.prototype.onLayoutChange = function () {
1682
+ if (!this.popup.isOpen)
1683
+ return this.unObserveLayoutChanges();
1684
+ this.$updatePopupPosition();
1685
+ this.updateDocTooltip();
1686
+ };
1687
+ Autocomplete.prototype.$updatePopupPosition = function () {
1688
+ var editor = this.editor;
1689
+ var renderer = editor.renderer;
1690
+ var lineHeight = renderer.layerConfig.lineHeight;
1691
+ var pos = renderer.$cursorLayer.getPixelPosition(this.base, true);
1692
+ pos.left -= this.popup.getTextLeftOffset();
1693
+ var rect = editor.container.getBoundingClientRect();
1694
+ pos.top += rect.top - renderer.layerConfig.offset;
1695
+ pos.left += rect.left - editor.renderer.scrollLeft;
1696
+ pos.left += renderer.gutterWidth;
1697
+ var posGhostText = {
1698
+ top: pos.top,
1699
+ left: pos.left
1700
+ };
1701
+ if (renderer.$ghostText && renderer.$ghostTextWidget) {
1702
+ if (this.base.row === renderer.$ghostText.position.row) {
1703
+ posGhostText.top += renderer.$ghostTextWidget.el.offsetHeight;
1704
+ }
1705
+ }
1706
+ var editorContainerBottom = editor.container.getBoundingClientRect().bottom - lineHeight;
1707
+ var lowestPosition = editorContainerBottom < posGhostText.top ?
1708
+ { top: editorContainerBottom, left: posGhostText.left } :
1709
+ posGhostText;
1710
+ if (this.popup.tryShow(lowestPosition, lineHeight, "bottom")) {
1711
+ return;
1712
+ }
1713
+ if (this.popup.tryShow(pos, lineHeight, "top")) {
1714
+ return;
1715
+ }
1716
+ this.popup.show(pos, lineHeight);
1717
+ };
1718
+ Autocomplete.prototype.openPopup = function (editor, prefix, keepPopupPosition) {
1719
+ this.$firstOpenTimer.cancel();
1720
+ if (!this.popup)
1721
+ this.$init();
1722
+ if (this.inlineEnabled && !this.inlineRenderer)
1723
+ this.$initInline();
1724
+ this.popup.autoSelect = this.autoSelect;
1725
+ this.popup.setSelectOnHover(this.setSelectOnHover);
1726
+ var oldRow = this.popup.getRow();
1727
+ var previousSelectedItem = this.popup.data[oldRow];
1728
+ this.popup.setData(this.completions.filtered, this.completions.filterText);
1729
+ if (this.editor.textInput.setAriaOptions) {
1730
+ this.editor.textInput.setAriaOptions({
1731
+ activeDescendant: getAriaId(this.popup.getRow()),
1732
+ inline: this.inlineEnabled
1733
+ });
1734
+ }
1735
+ editor.keyBinding.addKeyboardHandler(this.keyboardHandler);
1736
+ var newRow;
1737
+ if (this.stickySelection)
1738
+ newRow = this.popup.data.indexOf(previousSelectedItem);
1739
+ if (!newRow || newRow === -1)
1740
+ newRow = 0;
1741
+ this.popup.setRow(this.autoSelect ? newRow : -1);
1742
+ if (newRow === oldRow && previousSelectedItem !== this.completions.filtered[newRow])
1743
+ this.$onPopupChange();
1744
+ var inlineEnabled = this.inlineRenderer && this.inlineEnabled;
1745
+ if (newRow === oldRow && inlineEnabled) {
1746
+ var completion = this.popup.getData(this.popup.getRow());
1747
+ this.$updateGhostText(completion);
1748
+ }
1749
+ if (!keepPopupPosition) {
1750
+ this.popup.setTheme(editor.getTheme());
1751
+ this.popup.setFontSize(editor.getFontSize());
1752
+ this.$updatePopupPosition();
1753
+ if (this.tooltipNode) {
1754
+ this.updateDocTooltip();
1755
+ }
1756
+ }
1757
+ this.changeTimer.cancel();
1758
+ this.observeLayoutChanges();
1759
+ };
1760
+ Autocomplete.prototype.detach = function () {
1761
+ if (this.editor) {
1762
+ this.editor.keyBinding.removeKeyboardHandler(this.keyboardHandler);
1763
+ this.editor.off("changeSelection", this.changeListener);
1764
+ this.editor.off("blur", this.blurListener);
1765
+ this.editor.off("mousedown", this.mousedownListener);
1766
+ this.editor.off("mousewheel", this.mousewheelListener);
1767
+ }
1768
+ this.$firstOpenTimer.cancel();
1769
+ this.changeTimer.cancel();
1770
+ this.hideDocTooltip();
1771
+ if (this.completionProvider) {
1772
+ this.completionProvider.detach();
1773
+ }
1774
+ if (this.popup && this.popup.isOpen)
1775
+ this.popup.hide();
1776
+ if (this.popup && this.popup.renderer) {
1777
+ this.popup.renderer.off("afterRender", this.$onPopupRender);
1778
+ }
1779
+ if (this.base)
1780
+ this.base.detach();
1781
+ this.activated = false;
1782
+ this.completionProvider = this.completions = this.base = null;
1783
+ this.unObserveLayoutChanges();
1784
+ };
1785
+ Autocomplete.prototype.changeListener = function (e) {
1786
+ var cursor = this.editor.selection.lead;
1787
+ if (cursor.row != this.base.row || cursor.column < this.base.column) {
1788
+ this.detach();
1789
+ }
1790
+ if (this.activated)
1791
+ this.changeTimer.schedule();
1792
+ else
1793
+ this.detach();
1794
+ };
1795
+ Autocomplete.prototype.blurListener = function (e) {
1796
+ var el = document.activeElement;
1797
+ var text = this.editor.textInput.getElement();
1798
+ var fromTooltip = e.relatedTarget && this.tooltipNode && this.tooltipNode.contains(e.relatedTarget);
1799
+ var container = this.popup && this.popup.container;
1800
+ if (el != text && el.parentNode != container && !fromTooltip
1801
+ && el != this.tooltipNode && e.relatedTarget != text) {
1802
+ this.detach();
1803
+ }
1804
+ };
1805
+ Autocomplete.prototype.mousedownListener = function (e) {
1806
+ this.detach();
1807
+ };
1808
+ Autocomplete.prototype.mousewheelListener = function (e) {
1809
+ if (this.popup && !this.popup.isMouseOver)
1810
+ this.detach();
1811
+ };
1812
+ Autocomplete.prototype.mouseOutListener = function (e) {
1813
+ if (this.popup.isOpen)
1814
+ this.$updatePopupPosition();
1815
+ };
1816
+ Autocomplete.prototype.goTo = function (where) {
1817
+ this.popup.goTo(where);
1818
+ };
1819
+ Autocomplete.prototype.insertMatch = function (data, options) {
1820
+ if (!data)
1821
+ data = this.popup.getData(this.popup.getRow());
1822
+ if (!data)
1823
+ return false;
1824
+ if (data.value === "") // Explicitly given nothing to insert, e.g. "No suggestion state"
1825
+ return this.detach();
1826
+ var completions = this.completions;
1827
+ var result = this.getCompletionProvider().insertMatch(this.editor, data, completions.filterText, options);
1828
+ if (this.completions == completions)
1829
+ this.detach();
1830
+ return result;
1831
+ };
1832
+ Autocomplete.prototype.showPopup = function (editor, options) {
1833
+ if (this.editor)
1834
+ this.detach();
1835
+ this.activated = true;
1836
+ this.editor = editor;
1837
+ if (editor.completer != this) {
1838
+ if (editor.completer)
1839
+ editor.completer.detach();
1840
+ editor.completer = this;
1841
+ }
1842
+ editor.on("changeSelection", this.changeListener);
1843
+ editor.on("blur", this.blurListener);
1844
+ editor.on("mousedown", this.mousedownListener);
1845
+ editor.on("mousewheel", this.mousewheelListener);
1846
+ this.updateCompletions(false, options);
1847
+ };
1848
+ Autocomplete.prototype.getCompletionProvider = function (initialPosition) {
1849
+ if (!this.completionProvider)
1850
+ this.completionProvider = new CompletionProvider(initialPosition);
1851
+ return this.completionProvider;
1852
+ };
1853
+ Autocomplete.prototype.gatherCompletions = function (editor, callback) {
1854
+ return this.getCompletionProvider().gatherCompletions(editor, callback);
1855
+ };
1856
+ Autocomplete.prototype.updateCompletions = function (keepPopupPosition, options) {
1857
+ if (keepPopupPosition && this.base && this.completions) {
1858
+ var pos = this.editor.getCursorPosition();
1859
+ var prefix = this.editor.session.getTextRange({ start: this.base, end: pos });
1860
+ if (prefix == this.completions.filterText)
1861
+ return;
1862
+ this.completions.setFilter(prefix);
1863
+ if (!this.completions.filtered.length)
1864
+ return this.detach();
1865
+ if (this.completions.filtered.length == 1
1866
+ && this.completions.filtered[0].value == prefix
1867
+ && !this.completions.filtered[0].snippet)
1868
+ return this.detach();
1869
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1870
+ return;
1871
+ }
1872
+ if (options && options.matches) {
1873
+ var pos = this.editor.getSelectionRange().start;
1874
+ this.base = this.editor.session.doc.createAnchor(pos.row, pos.column);
1875
+ this.base.$insertRight = true;
1876
+ this.completions = new FilteredList(options.matches);
1877
+ this.getCompletionProvider().completions = this.completions;
1878
+ return this.openPopup(this.editor, "", keepPopupPosition);
1879
+ }
1880
+ var session = this.editor.getSession();
1881
+ var pos = this.editor.getCursorPosition();
1882
+ var prefix = util.getCompletionPrefix(this.editor);
1883
+ this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length);
1884
+ this.base.$insertRight = true;
1885
+ var completionOptions = {
1886
+ exactMatch: this.exactMatch,
1887
+ ignoreCaption: this.ignoreCaption
1888
+ };
1889
+ this.getCompletionProvider({
1890
+ prefix: prefix,
1891
+ pos: pos
1892
+ }).provideCompletions(this.editor, completionOptions,
1893
+ function (err, completions, finished) {
1894
+ var filtered = completions.filtered;
1895
+ var prefix = util.getCompletionPrefix(this.editor);
1896
+ this.$firstOpenTimer.cancel();
1897
+ if (finished) {
1898
+ if (!filtered.length) {
1899
+ var emptyMessage = !this.autoShown && this.emptyMessage;
1900
+ if (typeof emptyMessage == "function")
1901
+ emptyMessage = this.emptyMessage(prefix);
1902
+ if (emptyMessage) {
1903
+ var completionsForEmpty = [{
1904
+ caption: emptyMessage,
1905
+ value: ""
1906
+ }
1907
+ ];
1908
+ this.completions = new FilteredList(completionsForEmpty);
1909
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1910
+ this.popup.renderer.setStyle("ace_loading", false);
1911
+ this.popup.renderer.setStyle("ace_empty-message", true);
1912
+ return;
1913
+ }
1914
+ return this.detach();
1915
+ }
1916
+ if (filtered.length == 1 && filtered[0].value == prefix
1917
+ && !filtered[0].snippet)
1918
+ return this.detach();
1919
+ if (this.autoInsert && !this.autoShown && filtered.length == 1)
1920
+ return this.insertMatch(filtered[0]);
1921
+ }
1922
+ this.completions = !finished && this.showLoadingState ?
1923
+ new FilteredList(Autocomplete.completionsForLoading.concat(filtered), completions.filterText) :
1924
+ completions;
1925
+ this.openPopup(this.editor, prefix, keepPopupPosition);
1926
+ this.popup.renderer.setStyle("ace_empty-message", false);
1927
+ this.popup.renderer.setStyle("ace_loading", !finished);
1928
+ }.bind(this));
1929
+ if (this.showLoadingState && !this.autoShown && !(this.popup && this.popup.isOpen)) {
1930
+ this.$firstOpenTimer.delay(this.stickySelectionDelay / 2);
1931
+ }
1932
+ };
1933
+ Autocomplete.prototype.cancelContextMenu = function () {
1934
+ this.editor.$mouseHandler.cancelContextMenu();
1935
+ };
1936
+ Autocomplete.prototype.updateDocTooltip = function () {
1937
+ var popup = this.popup;
1938
+ var all = this.completions.filtered;
1939
+ var selected = all && (all[popup.getHoveredRow()] || all[popup.getRow()]);
1940
+ var doc = null;
1941
+ if (!selected || !this.editor || !this.popup.isOpen)
1942
+ return this.hideDocTooltip();
1943
+ var completersLength = this.editor.completers.length;
1944
+ for (var i = 0; i < completersLength; i++) {
1945
+ var completer = this.editor.completers[i];
1946
+ if (completer.getDocTooltip && selected.completerId === completer.id) {
1947
+ doc = completer.getDocTooltip(selected);
1948
+ break;
1949
+ }
1950
+ }
1951
+ if (!doc && typeof selected != "string")
1952
+ doc = selected;
1953
+ if (typeof doc == "string")
1954
+ doc = { docText: doc };
1955
+ if (!doc || !(doc.docHTML || doc.docText))
1956
+ return this.hideDocTooltip();
1957
+ this.showDocTooltip(doc);
1958
+ };
1959
+ Autocomplete.prototype.showDocTooltip = function (item) {
1960
+ if (!this.tooltipNode) {
1961
+ this.tooltipNode = dom.createElement("div");
1962
+ this.tooltipNode.style.margin = "0";
1963
+ this.tooltipNode.style.pointerEvents = "auto";
1964
+ this.tooltipNode.style.overscrollBehavior = "contain";
1965
+ this.tooltipNode.tabIndex = -1;
1966
+ this.tooltipNode.onblur = this.blurListener.bind(this);
1967
+ this.tooltipNode.onclick = this.onTooltipClick.bind(this);
1968
+ this.tooltipNode.id = "doc-tooltip";
1969
+ this.tooltipNode.setAttribute("role", "tooltip");
1970
+ this.tooltipNode.addEventListener("wheel", preventParentScroll);
1971
+ }
1972
+ var theme = this.editor.renderer.theme;
1973
+ this.tooltipNode.className = "ace_tooltip ace_doc-tooltip " +
1974
+ (theme.isDark ? "ace_dark " : "") + (theme.cssClass || "");
1975
+ var tooltipNode = this.tooltipNode;
1976
+ if (item.docHTML) {
1977
+ tooltipNode.innerHTML = item.docHTML;
1978
+ }
1979
+ else if (item.docText) {
1980
+ tooltipNode.textContent = item.docText;
1981
+ }
1982
+ if (!tooltipNode.parentNode)
1983
+ this.popup.container.appendChild(this.tooltipNode);
1984
+ var popup = this.popup;
1985
+ var rect = popup.container.getBoundingClientRect();
1986
+ tooltipNode.style.top = popup.container.style.top;
1987
+ tooltipNode.style.bottom = popup.container.style.bottom;
1988
+ tooltipNode.style.display = "block";
1989
+ if (window.innerWidth - rect.right < 320) {
1990
+ if (rect.left < 320) {
1991
+ if (popup.isTopdown) {
1992
+ tooltipNode.style.top = rect.bottom + "px";
1993
+ tooltipNode.style.left = rect.left + "px";
1994
+ tooltipNode.style.right = "";
1995
+ tooltipNode.style.bottom = "";
1996
+ }
1997
+ else {
1998
+ tooltipNode.style.top = popup.container.offsetTop - tooltipNode.offsetHeight + "px";
1999
+ tooltipNode.style.left = rect.left + "px";
2000
+ tooltipNode.style.right = "";
2001
+ tooltipNode.style.bottom = "";
2002
+ }
2003
+ }
2004
+ else {
2005
+ tooltipNode.style.right = window.innerWidth - rect.left + "px";
2006
+ tooltipNode.style.left = "";
2007
+ }
2008
+ }
2009
+ else {
2010
+ tooltipNode.style.left = (rect.right + 1) + "px";
2011
+ tooltipNode.style.right = "";
2012
+ }
2013
+ };
2014
+ Autocomplete.prototype.hideDocTooltip = function () {
2015
+ this.tooltipTimer.cancel();
2016
+ if (!this.tooltipNode)
2017
+ return;
2018
+ var el = this.tooltipNode;
2019
+ if (!this.editor.isFocused() && document.activeElement == el)
2020
+ this.editor.focus();
2021
+ this.tooltipNode = null;
2022
+ if (el.parentNode)
2023
+ el.parentNode.removeChild(el);
2024
+ };
2025
+ Autocomplete.prototype.onTooltipClick = function (e) {
2026
+ var a = e.target;
2027
+ while (a && a != this.tooltipNode) {
2028
+ if (a.nodeName == "A" && a.href) {
2029
+ a.rel = "noreferrer";
2030
+ a.target = "_blank";
2031
+ break;
2032
+ }
2033
+ a = a.parentNode;
2034
+ }
2035
+ };
2036
+ Autocomplete.prototype.destroy = function () {
2037
+ this.detach();
2038
+ if (this.popup) {
2039
+ this.popup.destroy();
2040
+ var el = this.popup.container;
2041
+ if (el && el.parentNode)
2042
+ el.parentNode.removeChild(el);
2043
+ }
2044
+ if (this.editor && this.editor.completer == this) {
2045
+ this.editor.off("destroy", destroyCompleter);
2046
+ this.editor.completer = null;
2047
+ }
2048
+ this.inlineRenderer = this.popup = this.editor = null;
2049
+ };
2050
+ Autocomplete.for = function (editor) {
2051
+ if (editor.completer instanceof Autocomplete) {
2052
+ return editor.completer;
2053
+ }
2054
+ if (editor.completer) {
2055
+ editor.completer.destroy();
2056
+ editor.completer = null;
2057
+ }
2058
+ if (config.get("sharedPopups")) {
2059
+ if (!Autocomplete["$sharedInstance"])
2060
+ Autocomplete["$sharedInstance"] = new Autocomplete();
2061
+ editor.completer = Autocomplete["$sharedInstance"];
2062
+ }
2063
+ else {
2064
+ editor.completer = new Autocomplete();
2065
+ editor.once("destroy", destroyCompleter);
2066
+ }
2067
+ return editor.completer;
2068
+ };
2069
+ return Autocomplete;
2070
+ }());
2071
+ Autocomplete.prototype.commands = {
2072
+ "Up": function (editor) { editor.completer.goTo("up"); },
2073
+ "Down": function (editor) { editor.completer.goTo("down"); },
2074
+ "Ctrl-Up|Ctrl-Home": function (editor) { editor.completer.goTo("start"); },
2075
+ "Ctrl-Down|Ctrl-End": function (editor) { editor.completer.goTo("end"); },
2076
+ "Esc": function (editor) { editor.completer.detach(); },
2077
+ "Return": function (editor) { return editor.completer.insertMatch(); },
2078
+ "Shift-Return": function (editor) { editor.completer.insertMatch(null, { deleteSuffix: true }); },
2079
+ "Tab": function (editor) {
2080
+ var result = editor.completer.insertMatch();
2081
+ if (!result && !editor.tabstopManager)
2082
+ editor.completer.goTo("down");
2083
+ else
2084
+ return result;
2085
+ },
2086
+ "Backspace": function (editor) {
2087
+ editor.execCommand("backspace");
2088
+ var prefix = util.getCompletionPrefix(editor);
2089
+ if (!prefix && editor.completer)
2090
+ editor.completer.detach();
2091
+ },
2092
+ "PageUp": function (editor) { editor.completer.popup.gotoPageUp(); },
2093
+ "PageDown": function (editor) { editor.completer.popup.gotoPageDown(); }
2094
+ };
2095
+ Autocomplete.startCommand = {
2096
+ name: "startAutocomplete",
2097
+ exec: function (editor, options) {
2098
+ var completer = Autocomplete.for(editor);
2099
+ completer.autoInsert = false;
2100
+ completer.autoSelect = true;
2101
+ completer.autoShown = false;
2102
+ completer.showPopup(editor, options);
2103
+ completer.cancelContextMenu();
2104
+ },
2105
+ bindKey: "Ctrl-Space|Ctrl-Shift-Space|Alt-Space"
2106
+ };
2107
+ var CompletionProvider = /** @class */ (function () {
2108
+ function CompletionProvider(initialPosition) {
2109
+ this.initialPosition = initialPosition;
2110
+ this.active = true;
2111
+ }
2112
+ CompletionProvider.prototype.insertByIndex = function (editor, index, options) {
2113
+ if (!this.completions || !this.completions.filtered) {
2114
+ return false;
2115
+ }
2116
+ return this.insertMatch(editor, this.completions.filtered[index], options);
2117
+ };
2118
+ CompletionProvider.prototype.insertMatch = function (editor, data, options) {
2119
+ if (!data)
2120
+ return false;
2121
+ editor.startOperation({ command: { name: "insertMatch" } });
2122
+ if (data.completer && data.completer.insertMatch) {
2123
+ data.completer.insertMatch(editor, data);
2124
+ }
2125
+ else {
2126
+ if (!this.completions)
2127
+ return false;
2128
+ var replaceBefore = this.completions.filterText.length;
2129
+ var replaceAfter = 0;
2130
+ if (data.range && data.range.start.row === data.range.end.row) {
2131
+ replaceBefore -= this.initialPosition.prefix.length;
2132
+ replaceBefore += this.initialPosition.pos.column - data.range.start.column;
2133
+ replaceAfter += data.range.end.column - this.initialPosition.pos.column;
2134
+ }
2135
+ if (replaceBefore || replaceAfter) {
2136
+ var ranges;
2137
+ if (editor.selection.getAllRanges) {
2138
+ ranges = editor.selection.getAllRanges();
2139
+ }
2140
+ else {
2141
+ ranges = [editor.getSelectionRange()];
2142
+ }
2143
+ for (var i = 0, range; range = ranges[i]; i++) {
2144
+ range.start.column -= replaceBefore;
2145
+ range.end.column += replaceAfter;
2146
+ editor.session.remove(range);
2147
+ }
2148
+ }
2149
+ if (data.snippet) {
2150
+ snippetManager.insertSnippet(editor, data.snippet);
2151
+ }
2152
+ else {
2153
+ this.$insertString(editor, data);
2154
+ }
2155
+ if (data.completer && data.completer.onInsert && typeof data.completer.onInsert == "function") {
2156
+ data.completer.onInsert(editor, data);
2157
+ }
2158
+ if (data.command && data.command === "startAutocomplete") {
2159
+ editor.execCommand(data.command);
2160
+ }
2161
+ }
2162
+ editor.endOperation();
2163
+ return true;
2164
+ };
2165
+ CompletionProvider.prototype.$insertString = function (editor, data) {
2166
+ var text = data.value || data;
2167
+ editor.execCommand("insertstring", text);
2168
+ };
2169
+ CompletionProvider.prototype.gatherCompletions = function (editor, callback) {
2170
+ var session = editor.getSession();
2171
+ var pos = editor.getCursorPosition();
2172
+ var prefix = util.getCompletionPrefix(editor);
2173
+ var matches = [];
2174
+ this.completers = editor.completers;
2175
+ var total = editor.completers.length;
2176
+ editor.completers.forEach(function (completer, i) {
2177
+ completer.getCompletions(editor, session, pos, prefix, function (err, results) {
2178
+ if (completer.hideInlinePreview)
2179
+ results = results.map(function (result) {
2180
+ return Object.assign(result, { hideInlinePreview: completer.hideInlinePreview });
2181
+ });
2182
+ if (!err && results)
2183
+ matches = matches.concat(results);
2184
+ callback(null, {
2185
+ prefix: util.getCompletionPrefix(editor),
2186
+ matches: matches,
2187
+ finished: (--total === 0)
2188
+ });
2189
+ });
2190
+ });
2191
+ return true;
2192
+ };
2193
+ CompletionProvider.prototype.provideCompletions = function (editor, options, callback) {
2194
+ var processResults = function (results) {
2195
+ var prefix = results.prefix;
2196
+ var matches = results.matches;
2197
+ this.completions = new FilteredList(matches);
2198
+ if (options.exactMatch)
2199
+ this.completions.exactMatch = true;
2200
+ if (options.ignoreCaption)
2201
+ this.completions.ignoreCaption = true;
2202
+ this.completions.setFilter(prefix);
2203
+ if (results.finished || this.completions.filtered.length)
2204
+ callback(null, this.completions, results.finished);
2205
+ }.bind(this);
2206
+ var isImmediate = true;
2207
+ var immediateResults = null;
2208
+ this.gatherCompletions(editor, function (err, results) {
2209
+ if (!this.active) {
2210
+ return;
2211
+ }
2212
+ if (err) {
2213
+ callback(err, [], true);
2214
+ this.detach();
2215
+ }
2216
+ var prefix = results.prefix;
2217
+ if (prefix.indexOf(results.prefix) !== 0)
2218
+ return;
2219
+ if (isImmediate) {
2220
+ immediateResults = results;
2221
+ return;
2222
+ }
2223
+ processResults(results);
2224
+ }.bind(this));
2225
+ isImmediate = false;
2226
+ if (immediateResults) {
2227
+ var results = immediateResults;
2228
+ immediateResults = null;
2229
+ processResults(results);
2230
+ }
2231
+ };
2232
+ CompletionProvider.prototype.detach = function () {
2233
+ this.active = false;
2234
+ this.completers && this.completers.forEach(function (completer) {
2235
+ if (typeof completer.cancel === "function") {
2236
+ completer.cancel();
2237
+ }
2238
+ });
2239
+ };
2240
+ return CompletionProvider;
2241
+ }());
2242
+ var FilteredList = /** @class */ (function () {
2243
+ function FilteredList(array, filterText) {
2244
+ this.all = array;
2245
+ this.filtered = array;
2246
+ this.filterText = filterText || "";
2247
+ this.exactMatch = false;
2248
+ this.ignoreCaption = false;
2249
+ }
2250
+ FilteredList.prototype.setFilter = function (str) {
2251
+ if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0)
2252
+ var matches = this.filtered;
2253
+ else
2254
+ var matches = this.all;
2255
+ this.filterText = str;
2256
+ matches = this.filterCompletions(matches, this.filterText);
2257
+ matches = matches.sort(function (a, b) {
2258
+ return b.exactMatch - a.exactMatch || b.$score - a.$score
2259
+ || (a.caption || a.value).localeCompare(b.caption || b.value);
2260
+ });
2261
+ var prev = null;
2262
+ matches = matches.filter(function (item) {
2263
+ var caption = item.snippet || item.caption || item.value;
2264
+ if (caption === prev)
2265
+ return false;
2266
+ prev = caption;
2267
+ return true;
2268
+ });
2269
+ this.filtered = matches;
2270
+ };
2271
+ FilteredList.prototype.filterCompletions = function (items, needle) {
2272
+ var results = [];
2273
+ var upper = needle.toUpperCase();
2274
+ var lower = needle.toLowerCase();
2275
+ loop: for (var i = 0, item; item = items[i]; i++) {
2276
+ var caption = (!this.ignoreCaption && item.caption) || item.value || item.snippet;
2277
+ if (!caption)
2278
+ continue;
2279
+ var lastIndex = -1;
2280
+ var matchMask = 0;
2281
+ var penalty = 0;
2282
+ var index, distance;
2283
+ if (this.exactMatch) {
2284
+ if (needle !== caption.substr(0, needle.length))
2285
+ continue loop;
2286
+ }
2287
+ else {
2288
+ var fullMatchIndex = caption.toLowerCase().indexOf(lower);
2289
+ if (fullMatchIndex > -1) {
2290
+ penalty = fullMatchIndex;
2291
+ }
2292
+ else {
2293
+ for (var j = 0; j < needle.length; j++) {
2294
+ var i1 = caption.indexOf(lower[j], lastIndex + 1);
2295
+ var i2 = caption.indexOf(upper[j], lastIndex + 1);
2296
+ index = (i1 >= 0) ? ((i2 < 0 || i1 < i2) ? i1 : i2) : i2;
2297
+ if (index < 0)
2298
+ continue loop;
2299
+ distance = index - lastIndex - 1;
2300
+ if (distance > 0) {
2301
+ if (lastIndex === -1)
2302
+ penalty += 10;
2303
+ penalty += distance;
2304
+ matchMask = matchMask | (1 << j);
2305
+ }
2306
+ lastIndex = index;
2307
+ }
2308
+ }
2309
+ }
2310
+ item.matchMask = matchMask;
2311
+ item.exactMatch = penalty ? 0 : 1;
2312
+ item.$score = (item.score || 0) - penalty;
2313
+ results.push(item);
2314
+ }
2315
+ return results;
2316
+ };
2317
+ return FilteredList;
2318
+ }());
2319
+ exports.Autocomplete = Autocomplete;
2320
+ exports.CompletionProvider = CompletionProvider;
2321
+ exports.FilteredList = FilteredList;
2322
+
2323
+ });
2324
+
2325
+ ace.define("ace/ext/menu_tools/settings_menu.css",["require","exports","module"], function(require, exports, module){module.exports = "#ace_settingsmenu, #kbshortcutmenu {\n background-color: #F7F7F7;\n color: black;\n box-shadow: -5px 4px 5px rgba(126, 126, 126, 0.55);\n padding: 1em 0.5em 2em 1em;\n overflow: auto;\n position: absolute;\n margin: 0;\n bottom: 0;\n right: 0;\n top: 0;\n z-index: 9991;\n cursor: default;\n}\n\n.ace_dark #ace_settingsmenu, .ace_dark #kbshortcutmenu {\n box-shadow: -20px 10px 25px rgba(126, 126, 126, 0.25);\n background-color: rgba(255, 255, 255, 0.6);\n color: black;\n}\n\n.ace_optionsMenuEntry:hover {\n background-color: rgba(100, 100, 100, 0.1);\n transition: all 0.3s\n}\n\n.ace_closeButton {\n background: rgba(245, 146, 146, 0.5);\n border: 1px solid #F48A8A;\n border-radius: 50%;\n padding: 7px;\n position: absolute;\n right: -8px;\n top: -8px;\n z-index: 100000;\n}\n.ace_closeButton{\n background: rgba(245, 146, 146, 0.9);\n}\n.ace_optionsMenuKey {\n color: darkslateblue;\n font-weight: bold;\n}\n.ace_optionsMenuCommand {\n color: darkcyan;\n font-weight: normal;\n}\n.ace_optionsMenuEntry input, .ace_optionsMenuEntry button {\n vertical-align: middle;\n}\n\n.ace_optionsMenuEntry button[ace_selected_button=true] {\n background: #e7e7e7;\n box-shadow: 1px 0px 2px 0px #adadad inset;\n border-color: #adadad;\n}\n.ace_optionsMenuEntry button {\n background: white;\n border: 1px solid lightgray;\n margin: 0px;\n}\n.ace_optionsMenuEntry button:hover{\n background: #f0f0f0;\n}";
2326
+
2327
+ });
2328
+
2329
+ ace.define("ace/ext/menu_tools/overlay_page",["require","exports","module","ace/lib/dom","ace/ext/menu_tools/settings_menu.css"], function(require, exports, module){/*jslint indent: 4, maxerr: 50, white: true, browser: true, vars: true*/
2330
+ 'use strict';
2331
+ var dom = require("../../lib/dom");
2332
+ var cssText = require("./settings_menu.css");
2333
+ dom.importCssString(cssText, "settings_menu.css", false);
2334
+ module.exports.overlayPage = function overlayPage(editor, contentElement, callback) {
2335
+ var closer = document.createElement('div');
2336
+ var ignoreFocusOut = false;
2337
+ function documentEscListener(e) {
2338
+ if (e.keyCode === 27) {
2339
+ close();
2340
+ }
2341
+ }
2342
+ function close() {
2343
+ if (!closer)
2344
+ return;
2345
+ document.removeEventListener('keydown', documentEscListener);
2346
+ closer.parentNode.removeChild(closer);
2347
+ if (editor) {
2348
+ editor.focus();
2349
+ }
2350
+ closer = null;
2351
+ callback && callback();
2352
+ }
2353
+ function setIgnoreFocusOut(ignore) {
2354
+ ignoreFocusOut = ignore;
2355
+ if (ignore) {
2356
+ closer.style.pointerEvents = "none";
2357
+ contentElement.style.pointerEvents = "auto";
2358
+ }
2359
+ }
2360
+ closer.style.cssText = 'margin: 0; padding: 0; ' +
2361
+ 'position: fixed; top:0; bottom:0; left:0; right:0;' +
2362
+ 'z-index: 9990; ' +
2363
+ (editor ? 'background-color: rgba(0, 0, 0, 0.3);' : '');
2364
+ closer.addEventListener('click', function (e) {
2365
+ if (!ignoreFocusOut) {
2366
+ close();
2367
+ }
2368
+ });
2369
+ document.addEventListener('keydown', documentEscListener);
2370
+ contentElement.addEventListener('click', function (e) {
2371
+ e.stopPropagation();
2372
+ });
2373
+ closer.appendChild(contentElement);
2374
+ document.body.appendChild(closer);
2375
+ if (editor) {
2376
+ editor.blur();
2377
+ }
2378
+ return {
2379
+ close: close,
2380
+ setIgnoreFocusOut: setIgnoreFocusOut
2381
+ };
2382
+ };
2383
+
2384
+ });
2385
+
2386
+ ace.define("ace/ext/modelist",["require","exports","module"], function(require, exports, module){"use strict";
2387
+ var modes = [];
2388
+ function getModeForPath(path) {
2389
+ var mode = modesByName.text;
2390
+ var fileName = path.split(/[\/\\]/).pop();
2391
+ for (var i = 0; i < modes.length; i++) {
2392
+ if (modes[i].supportsFile(fileName)) {
2393
+ mode = modes[i];
2394
+ break;
2395
+ }
2396
+ }
2397
+ return mode;
2398
+ }
2399
+ var Mode = /** @class */ (function () {
2400
+ function Mode(name, caption, extensions) {
2401
+ this.name = name;
2402
+ this.caption = caption;
2403
+ this.mode = "ace/mode/" + name;
2404
+ this.extensions = extensions;
2405
+ var re;
2406
+ if (/\^/.test(extensions)) {
2407
+ re = extensions.replace(/\|(\^)?/g, function (a, b) {
2408
+ return "$|" + (b ? "^" : "^.*\\.");
2409
+ }) + "$";
2410
+ }
2411
+ else {
2412
+ re = "^.*\\.(" + extensions + ")$";
2413
+ }
2414
+ this.extRe = new RegExp(re, "gi");
2415
+ }
2416
+ Mode.prototype.supportsFile = function (filename) {
2417
+ return filename.match(this.extRe);
2418
+ };
2419
+ return Mode;
2420
+ }());
2421
+ var supportedModes = {
2422
+ ABAP: ["abap"],
2423
+ ABC: ["abc"],
2424
+ ActionScript: ["as"],
2425
+ ADA: ["ada|adb"],
2426
+ Alda: ["alda"],
2427
+ Apache_Conf: ["^htaccess|^htgroups|^htpasswd|^conf|htaccess|htgroups|htpasswd"],
2428
+ Apex: ["apex|cls|trigger|tgr"],
2429
+ AQL: ["aql"],
2430
+ AsciiDoc: ["asciidoc|adoc"],
2431
+ ASL: ["dsl|asl|asl.json"],
2432
+ Assembly_ARM32: ["s"],
2433
+ Assembly_x86: ["asm|a"],
2434
+ Astro: ["astro"],
2435
+ AutoHotKey: ["ahk"],
2436
+ BatchFile: ["bat|cmd"],
2437
+ Basic: ["bas|bak"],
2438
+ BibTeX: ["bib"],
2439
+ C_Cpp: ["cpp|c|cc|cxx|h|hh|hpp|ino"],
2440
+ C9Search: ["c9search_results"],
2441
+ Cirru: ["cirru|cr"],
2442
+ Clojure: ["clj|cljs"],
2443
+ Cobol: ["CBL|COB"],
2444
+ coffee: ["coffee|cf|cson|^Cakefile"],
2445
+ ColdFusion: ["cfm|cfc"],
2446
+ Crystal: ["cr"],
2447
+ CSharp: ["cs"],
2448
+ Csound_Document: ["csd"],
2449
+ Csound_Orchestra: ["orc"],
2450
+ Csound_Score: ["sco"],
2451
+ CSS: ["css"],
2452
+ Curly: ["curly"],
2453
+ Cuttlefish: ["conf"],
2454
+ D: ["d|di"],
2455
+ Dart: ["dart"],
2456
+ Diff: ["diff|patch"],
2457
+ Django: ["djt|html.djt|dj.html|djhtml"],
2458
+ Dockerfile: ["^Dockerfile"],
2459
+ Dot: ["dot"],
2460
+ Drools: ["drl"],
2461
+ Edifact: ["edi"],
2462
+ Eiffel: ["e|ge"],
2463
+ EJS: ["ejs"],
2464
+ Elixir: ["ex|exs"],
2465
+ Elm: ["elm"],
2466
+ Erlang: ["erl|hrl"],
2467
+ Flix: ["flix"],
2468
+ Forth: ["frt|fs|ldr|fth|4th"],
2469
+ Fortran: ["f|f90"],
2470
+ FSharp: ["fsi|fs|ml|mli|fsx|fsscript"],
2471
+ FSL: ["fsl"],
2472
+ FTL: ["ftl"],
2473
+ Gcode: ["gcode"],
2474
+ Gherkin: ["feature"],
2475
+ Gitignore: ["^.gitignore"],
2476
+ Glsl: ["glsl|frag|vert"],
2477
+ Gobstones: ["gbs"],
2478
+ golang: ["go"],
2479
+ GraphQLSchema: ["gql"],
2480
+ Groovy: ["groovy"],
2481
+ HAML: ["haml"],
2482
+ Handlebars: ["hbs|handlebars|tpl|mustache"],
2483
+ Haskell: ["hs"],
2484
+ Haskell_Cabal: ["cabal"],
2485
+ haXe: ["hx"],
2486
+ Hjson: ["hjson"],
2487
+ HTML: ["html|htm|xhtml|we|wpy"],
2488
+ HTML_Elixir: ["eex|html.eex"],
2489
+ HTML_Ruby: ["erb|rhtml|html.erb"],
2490
+ INI: ["ini|conf|cfg|prefs"],
2491
+ Io: ["io"],
2492
+ Ion: ["ion"],
2493
+ Jack: ["jack"],
2494
+ Jade: ["jade|pug"],
2495
+ Java: ["java"],
2496
+ JavaScript: ["js|jsm|cjs|mjs"],
2497
+ JEXL: ["jexl"],
2498
+ JSON: ["json"],
2499
+ JSON5: ["json5"],
2500
+ JSONiq: ["jq"],
2501
+ JSP: ["jsp"],
2502
+ JSSM: ["jssm|jssm_state"],
2503
+ JSX: ["jsx"],
2504
+ Julia: ["jl"],
2505
+ Kotlin: ["kt|kts"],
2506
+ LaTeX: ["tex|latex|ltx|bib"],
2507
+ Latte: ["latte"],
2508
+ LESS: ["less"],
2509
+ Liquid: ["liquid"],
2510
+ Lisp: ["lisp"],
2511
+ LiveScript: ["ls"],
2512
+ Log: ["log"],
2513
+ LogiQL: ["logic|lql"],
2514
+ Logtalk: ["lgt"],
2515
+ LSL: ["lsl"],
2516
+ Lua: ["lua"],
2517
+ LuaPage: ["lp"],
2518
+ Lucene: ["lucene"],
2519
+ Makefile: ["^Makefile|^GNUmakefile|^makefile|^OCamlMakefile|make"],
2520
+ Markdown: ["md|markdown"],
2521
+ Mask: ["mask"],
2522
+ MATLAB: ["matlab"],
2523
+ Maze: ["mz"],
2524
+ MediaWiki: ["wiki|mediawiki"],
2525
+ MEL: ["mel"],
2526
+ MIPS: ["s|asm"],
2527
+ MIXAL: ["mixal"],
2528
+ MUSHCode: ["mc|mush"],
2529
+ MySQL: ["mysql"],
2530
+ Nasal: ["nas"],
2531
+ Nginx: ["nginx|conf"],
2532
+ Nim: ["nim"],
2533
+ Nix: ["nix"],
2534
+ NSIS: ["nsi|nsh"],
2535
+ Nunjucks: ["nunjucks|nunjs|nj|njk"],
2536
+ ObjectiveC: ["m|mm"],
2537
+ OCaml: ["ml|mli"],
2538
+ Odin: ["odin"],
2539
+ PartiQL: ["partiql|pql"],
2540
+ Pascal: ["pas|p"],
2541
+ Perl: ["pl|pm"],
2542
+ pgSQL: ["pgsql"],
2543
+ PHP: ["php|inc|phtml|shtml|php3|php4|php5|phps|phpt|aw|ctp|module"],
2544
+ PHP_Laravel_blade: ["blade.php"],
2545
+ Pig: ["pig"],
2546
+ PLSQL: ["plsql"],
2547
+ Powershell: ["ps1"],
2548
+ Praat: ["praat|praatscript|psc|proc"],
2549
+ Prisma: ["prisma"],
2550
+ Prolog: ["plg|prolog"],
2551
+ Properties: ["properties"],
2552
+ Protobuf: ["proto"],
2553
+ PRQL: ["prql"],
2554
+ Puppet: ["epp|pp"],
2555
+ Python: ["py"],
2556
+ QML: ["qml"],
2557
+ R: ["r"],
2558
+ Raku: ["raku|rakumod|rakutest|p6|pl6|pm6"],
2559
+ Razor: ["cshtml|asp"],
2560
+ RDoc: ["Rd"],
2561
+ Red: ["red|reds"],
2562
+ RHTML: ["Rhtml"],
2563
+ Robot: ["robot|resource"],
2564
+ RST: ["rst"],
2565
+ Ruby: ["rb|ru|gemspec|rake|^Guardfile|^Rakefile|^Gemfile"],
2566
+ Rust: ["rs"],
2567
+ SaC: ["sac"],
2568
+ SASS: ["sass"],
2569
+ SCAD: ["scad"],
2570
+ Scala: ["scala|sbt"],
2571
+ Scheme: ["scm|sm|rkt|oak|scheme"],
2572
+ Scrypt: ["scrypt"],
2573
+ SCSS: ["scss"],
2574
+ SH: ["sh|bash|^.bashrc"],
2575
+ SJS: ["sjs"],
2576
+ Slim: ["slim|skim"],
2577
+ Smarty: ["smarty|tpl"],
2578
+ Smithy: ["smithy"],
2579
+ snippets: ["snippets"],
2580
+ Soy_Template: ["soy"],
2581
+ Space: ["space"],
2582
+ SPARQL: ["rq"],
2583
+ SQL: ["sql"],
2584
+ SQLServer: ["sqlserver"],
2585
+ Stylus: ["styl|stylus"],
2586
+ SVG: ["svg"],
2587
+ Swift: ["swift"],
2588
+ Tcl: ["tcl"],
2589
+ Terraform: ["tf", "tfvars", "terragrunt"],
2590
+ Tex: ["tex"],
2591
+ Text: ["txt"],
2592
+ Textile: ["textile"],
2593
+ Toml: ["toml"],
2594
+ TSX: ["tsx"],
2595
+ Turtle: ["ttl"],
2596
+ Twig: ["twig|swig"],
2597
+ Typescript: ["ts|mts|cts|typescript|str"],
2598
+ Vala: ["vala"],
2599
+ VBScript: ["vbs|vb"],
2600
+ Velocity: ["vm"],
2601
+ Verilog: ["v|vh|sv|svh"],
2602
+ VHDL: ["vhd|vhdl"],
2603
+ Visualforce: ["vfp|component|page"],
2604
+ Vue: ["vue"],
2605
+ Wollok: ["wlk|wpgm|wtest"],
2606
+ XML: ["xml|rdf|rss|wsdl|xslt|atom|mathml|mml|xul|xbl|xaml"],
2607
+ XQuery: ["xq"],
2608
+ YAML: ["yaml|yml"],
2609
+ Zeek: ["zeek|bro"],
2610
+ Zig: ["zig"]
2611
+ };
2612
+ var nameOverrides = {
2613
+ ObjectiveC: "Objective-C",
2614
+ CSharp: "C#",
2615
+ golang: "Go",
2616
+ C_Cpp: "C and C++",
2617
+ Csound_Document: "Csound Document",
2618
+ Csound_Orchestra: "Csound",
2619
+ Csound_Score: "Csound Score",
2620
+ coffee: "CoffeeScript",
2621
+ HTML_Ruby: "HTML (Ruby)",
2622
+ HTML_Elixir: "HTML (Elixir)",
2623
+ FTL: "FreeMarker",
2624
+ PHP_Laravel_blade: "PHP (Blade Template)",
2625
+ Perl6: "Perl 6",
2626
+ AutoHotKey: "AutoHotkey / AutoIt"
2627
+ };
2628
+ var modesByName = {};
2629
+ for (var name in supportedModes) {
2630
+ var data = supportedModes[name];
2631
+ var displayName = (nameOverrides[name] || name).replace(/_/g, " ");
2632
+ var filename = name.toLowerCase();
2633
+ var mode = new Mode(filename, displayName, data[0]);
2634
+ modesByName[filename] = mode;
2635
+ modes.push(mode);
2636
+ }
2637
+ module.exports = {
2638
+ getModeForPath: getModeForPath,
2639
+ modes: modes,
2640
+ modesByName: modesByName
2641
+ };
2642
+
2643
+ });
2644
+
2645
+ ace.define("ace/ext/prompt",["require","exports","module","ace/config","ace/range","ace/lib/dom","ace/autocomplete","ace/autocomplete/popup","ace/autocomplete/popup","ace/undomanager","ace/tokenizer","ace/ext/menu_tools/overlay_page","ace/ext/modelist"], function(require, exports, module){/**
2646
+ * @typedef {import("../editor").Editor} Editor
2647
+ */
2648
+ "use strict";
2649
+ var nls = require("../config").nls;
2650
+ var Range = require("../range").Range;
2651
+ var dom = require("../lib/dom");
2652
+ var FilteredList = require("../autocomplete").FilteredList;
2653
+ var AcePopup = require('../autocomplete/popup').AcePopup;
2654
+ var $singleLineEditor = require('../autocomplete/popup').$singleLineEditor;
2655
+ var UndoManager = require("../undomanager").UndoManager;
2656
+ var Tokenizer = require("../tokenizer").Tokenizer;
2657
+ var overlayPage = require("./menu_tools/overlay_page").overlayPage;
2658
+ var modelist = require("./modelist");
2659
+ var openPrompt;
2660
+ function prompt(editor, message, options, callback) {
2661
+ if (typeof message == "object") {
2662
+ return prompt(editor, "", message, options);
2663
+ }
2664
+ if (openPrompt) {
2665
+ var lastPrompt = openPrompt;
2666
+ editor = lastPrompt.editor;
2667
+ lastPrompt.close();
2668
+ if (lastPrompt.name && lastPrompt.name == options.name)
2669
+ return;
2670
+ }
2671
+ if (options.$type)
2672
+ return prompt[options.$type](editor, callback);
2673
+ var cmdLine = $singleLineEditor();
2674
+ cmdLine.session.setUndoManager(new UndoManager());
2675
+ var el = dom.buildDom(["div", { class: "ace_prompt_container" + (options.hasDescription ? " input-box-with-description" : "") }]);
2676
+ var overlay = overlayPage(editor, el, done);
2677
+ el.appendChild(cmdLine.container);
2678
+ if (editor) {
2679
+ editor.cmdLine = cmdLine;
2680
+ cmdLine.setOption("fontSize", editor.getOption("fontSize"));
2681
+ }
2682
+ if (message) {
2683
+ cmdLine.setValue(message, 1);
2684
+ }
2685
+ if (options.selection) {
2686
+ cmdLine.selection.setRange({
2687
+ start: cmdLine.session.doc.indexToPosition(options.selection[0]),
2688
+ end: cmdLine.session.doc.indexToPosition(options.selection[1])
2689
+ });
2690
+ }
2691
+ if (options.getCompletions) {
2692
+ var popup = new AcePopup();
2693
+ popup.renderer.setStyle("ace_autocomplete_inline");
2694
+ popup.container.style.display = "block";
2695
+ popup.container.style.maxWidth = "600px";
2696
+ popup.container.style.width = "100%";
2697
+ popup.container.style.marginTop = "3px";
2698
+ popup.renderer.setScrollMargin(2, 2, 0, 0);
2699
+ popup.autoSelect = false;
2700
+ popup.renderer.$maxLines = 15;
2701
+ popup.setRow(-1);
2702
+ popup.on("click", function (e) {
2703
+ var data = popup.getData(popup.getRow());
2704
+ if (!data["error"]) {
2705
+ cmdLine.setValue(data.value || data["name"] || data);
2706
+ accept();
2707
+ e.stop();
2708
+ }
2709
+ });
2710
+ el.appendChild(popup.container);
2711
+ updateCompletions();
2712
+ }
2713
+ if (options.$rules) {
2714
+ var tokenizer = new Tokenizer(options.$rules);
2715
+ cmdLine.session.bgTokenizer.setTokenizer(tokenizer);
2716
+ }
2717
+ if (options.placeholder) {
2718
+ cmdLine.setOption("placeholder", options.placeholder);
2719
+ }
2720
+ if (options.hasDescription) {
2721
+ var promptTextContainer = dom.buildDom(["div", { class: "ace_prompt_text_container" }]);
2722
+ dom.buildDom(options.prompt || "Press 'Enter' to confirm or 'Escape' to cancel", promptTextContainer);
2723
+ el.appendChild(promptTextContainer);
2724
+ }
2725
+ overlay.setIgnoreFocusOut(options.ignoreFocusOut);
2726
+ function accept() {
2727
+ var val;
2728
+ if (popup && popup.getCursorPosition().row > 0) {
2729
+ val = valueFromRecentList();
2730
+ }
2731
+ else {
2732
+ val = cmdLine.getValue();
2733
+ }
2734
+ var curData = popup ? popup.getData(popup.getRow()) : val;
2735
+ if (curData && !curData["error"]) {
2736
+ done();
2737
+ options.onAccept && options.onAccept({
2738
+ value: val,
2739
+ item: curData
2740
+ }, cmdLine);
2741
+ }
2742
+ }
2743
+ var keys = {
2744
+ "Enter": accept,
2745
+ "Esc|Shift-Esc": function () {
2746
+ options.onCancel && options.onCancel(cmdLine.getValue(), cmdLine);
2747
+ done();
2748
+ }
2749
+ };
2750
+ if (popup) {
2751
+ Object.assign(keys, {
2752
+ "Up": function (editor) { popup.goTo("up"); valueFromRecentList(); },
2753
+ "Down": function (editor) { popup.goTo("down"); valueFromRecentList(); },
2754
+ "Ctrl-Up|Ctrl-Home": function (editor) { popup.goTo("start"); valueFromRecentList(); },
2755
+ "Ctrl-Down|Ctrl-End": function (editor) { popup.goTo("end"); valueFromRecentList(); },
2756
+ "Tab": function (editor) {
2757
+ popup.goTo("down");
2758
+ valueFromRecentList();
2759
+ },
2760
+ "PageUp": function (editor) { popup.gotoPageUp(); valueFromRecentList(); },
2761
+ "PageDown": function (editor) { popup.gotoPageDown(); valueFromRecentList(); }
2762
+ });
2763
+ }
2764
+ cmdLine.commands.bindKeys(keys);
2765
+ function done() {
2766
+ overlay.close();
2767
+ callback && callback();
2768
+ openPrompt = null;
2769
+ }
2770
+ cmdLine.on("input", function () {
2771
+ options.onInput && options.onInput();
2772
+ updateCompletions();
2773
+ });
2774
+ function updateCompletions() {
2775
+ if (options.getCompletions) {
2776
+ var prefix;
2777
+ if (options.getPrefix) {
2778
+ prefix = options.getPrefix(cmdLine);
2779
+ }
2780
+ var completions = options.getCompletions(cmdLine);
2781
+ popup.setData(completions, prefix);
2782
+ popup.resize(true);
2783
+ }
2784
+ }
2785
+ function valueFromRecentList() {
2786
+ var current = popup.getData(popup.getRow());
2787
+ if (current && !current["error"])
2788
+ return current.value || current.caption || current;
2789
+ }
2790
+ cmdLine.resize(true);
2791
+ if (popup) {
2792
+ popup.resize(true);
2793
+ }
2794
+ cmdLine.focus();
2795
+ openPrompt = {
2796
+ close: done,
2797
+ name: options.name,
2798
+ editor: editor
2799
+ };
2800
+ }
2801
+ prompt.gotoLine = function (editor, callback) {
2802
+ function stringifySelection(selection) {
2803
+ if (!Array.isArray(selection))
2804
+ selection = [selection];
2805
+ return selection.map(function (r) {
2806
+ var cursor = r.isBackwards ? r.start : r.end;
2807
+ var anchor = r.isBackwards ? r.end : r.start;
2808
+ var row = anchor.row;
2809
+ var s = (row + 1) + ":" + anchor.column;
2810
+ if (anchor.row == cursor.row) {
2811
+ if (anchor.column != cursor.column)
2812
+ s += ">" + ":" + cursor.column;
2813
+ }
2814
+ else {
2815
+ s += ">" + (cursor.row + 1) + ":" + cursor.column;
2816
+ }
2817
+ return s;
2818
+ }).reverse().join(", ");
2819
+ }
2820
+ prompt(editor, ":" + stringifySelection(editor.selection.toJSON()), {
2821
+ name: "gotoLine",
2822
+ selection: [1, Number.MAX_VALUE],
2823
+ onAccept: function (data) {
2824
+ var value = data.value;
2825
+ var _history = prompt.gotoLine["_history"];
2826
+ if (!_history)
2827
+ prompt.gotoLine["_history"] = _history = [];
2828
+ if (_history.indexOf(value) != -1)
2829
+ _history.splice(_history.indexOf(value), 1);
2830
+ _history.unshift(value);
2831
+ if (_history.length > 20)
2832
+ _history.length = 20;
2833
+ var pos = editor.getCursorPosition();
2834
+ var ranges = [];
2835
+ value.replace(/^:/, "").split(/,/).map(function (str) {
2836
+ var parts = str.split(/([<>:+-]|c?\d+)|[^c\d<>:+-]+/).filter(Boolean);
2837
+ var i = 0;
2838
+ function readPosition() {
2839
+ var c = parts[i++];
2840
+ if (!c)
2841
+ return;
2842
+ if (c[0] == "c") {
2843
+ var index = parseInt(c.slice(1)) || 0;
2844
+ return editor.session.doc.indexToPosition(index);
2845
+ }
2846
+ var row = pos.row;
2847
+ var column = 0;
2848
+ if (/\d/.test(c)) {
2849
+ row = parseInt(c) - 1;
2850
+ c = parts[i++];
2851
+ }
2852
+ if (c == ":") {
2853
+ c = parts[i++];
2854
+ if (/\d/.test(c)) {
2855
+ column = parseInt(c) || 0;
2856
+ }
2857
+ }
2858
+ return { row: row, column: column };
2859
+ }
2860
+ pos = readPosition();
2861
+ var range = Range.fromPoints(pos, pos);
2862
+ if (parts[i] == ">") {
2863
+ i++;
2864
+ range.end = readPosition();
2865
+ }
2866
+ else if (parts[i] == "<") {
2867
+ i++;
2868
+ range.start = readPosition();
2869
+ }
2870
+ ranges.unshift(range);
2871
+ });
2872
+ editor.selection.fromJSON(ranges);
2873
+ var scrollTop = editor.renderer.scrollTop;
2874
+ editor.renderer.scrollSelectionIntoView(editor.selection.anchor, editor.selection.cursor, 0.5);
2875
+ editor.renderer.animateScrolling(scrollTop);
2876
+ },
2877
+ history: function () {
2878
+ if (!prompt.gotoLine["_history"])
2879
+ return [];
2880
+ return prompt.gotoLine["_history"];
2881
+ },
2882
+ getCompletions: function (cmdLine) {
2883
+ var value = cmdLine.getValue();
2884
+ var m = value.replace(/^:/, "").split(":");
2885
+ var row = Math.min(parseInt(m[0]) || 1, editor.session.getLength()) - 1;
2886
+ var line = editor.session.getLine(row);
2887
+ var current = value + " " + line;
2888
+ return [current].concat(this.history());
2889
+ },
2890
+ $rules: {
2891
+ start: [{
2892
+ regex: /\d+/,
2893
+ token: "string"
2894
+ }, {
2895
+ regex: /[:,><+\-c]/,
2896
+ token: "keyword"
2897
+ }]
2898
+ }
2899
+ });
2900
+ };
2901
+ prompt.commands = function (editor, callback) {
2902
+ function normalizeName(name) {
2903
+ return (name || "").replace(/^./, function (x) {
2904
+ return x.toUpperCase(x);
2905
+ }).replace(/[a-z][A-Z]/g, function (x) {
2906
+ return x[0] + " " + x[1].toLowerCase(x);
2907
+ });
2908
+ }
2909
+ function getEditorCommandsByName(excludeCommands) {
2910
+ var commandsByName = [];
2911
+ var commandMap = {};
2912
+ editor.keyBinding.$handlers.forEach(function (handler) {
2913
+ var platform = handler["platform"];
2914
+ var cbn = handler["byName"];
2915
+ for (var i in cbn) {
2916
+ var key = cbn[i].bindKey;
2917
+ if (typeof key !== "string") {
2918
+ key = key && key[platform] || "";
2919
+ }
2920
+ var commands = cbn[i];
2921
+ var description = commands.description || normalizeName(commands.name);
2922
+ if (!Array.isArray(commands))
2923
+ commands = [commands];
2924
+ commands.forEach(function (command) {
2925
+ if (typeof command != "string")
2926
+ command = command.name;
2927
+ var needle = excludeCommands.find(function (el) {
2928
+ return el === command;
2929
+ });
2930
+ if (!needle) {
2931
+ if (commandMap[command]) {
2932
+ commandMap[command].key += "|" + key;
2933
+ }
2934
+ else {
2935
+ commandMap[command] = { key: key, command: command, description: description };
2936
+ commandsByName.push(commandMap[command]);
2937
+ }
2938
+ }
2939
+ });
2940
+ }
2941
+ });
2942
+ return commandsByName;
2943
+ }
2944
+ var excludeCommandsList = ["insertstring", "inserttext", "setIndentation", "paste"];
2945
+ var shortcutsArray = getEditorCommandsByName(excludeCommandsList);
2946
+ shortcutsArray = shortcutsArray.map(function (item) {
2947
+ return { value: item.description, meta: item.key, command: item.command };
2948
+ });
2949
+ prompt(editor, "", {
2950
+ name: "commands",
2951
+ selection: [0, Number.MAX_VALUE],
2952
+ maxHistoryCount: 5,
2953
+ onAccept: function (data) {
2954
+ if (data.item) {
2955
+ var commandName = data.item.command;
2956
+ this.addToHistory(data.item);
2957
+ editor.execCommand(commandName);
2958
+ }
2959
+ },
2960
+ addToHistory: function (item) {
2961
+ var history = this.history();
2962
+ history.unshift(item);
2963
+ delete item.message;
2964
+ for (var i = 1; i < history.length; i++) {
2965
+ if (history[i]["command"] == item.command) {
2966
+ history.splice(i, 1);
2967
+ break;
2968
+ }
2969
+ }
2970
+ if (this.maxHistoryCount > 0 && history.length > this.maxHistoryCount) {
2971
+ history.splice(history.length - 1, 1);
2972
+ }
2973
+ prompt.commands["history"] = history;
2974
+ },
2975
+ history: function () {
2976
+ return prompt.commands["history"] || [];
2977
+ },
2978
+ getPrefix: function (cmdLine) {
2979
+ var currentPos = cmdLine.getCursorPosition();
2980
+ var filterValue = cmdLine.getValue();
2981
+ return filterValue.substring(0, currentPos.column);
2982
+ },
2983
+ getCompletions: function (cmdLine) {
2984
+ function getFilteredCompletions(commands, prefix) {
2985
+ var resultCommands = JSON.parse(JSON.stringify(commands));
2986
+ var filtered = new FilteredList(resultCommands);
2987
+ return filtered.filterCompletions(resultCommands, prefix);
2988
+ }
2989
+ function getUniqueCommandList(commands, usedCommands) {
2990
+ if (!usedCommands || !usedCommands.length) {
2991
+ return commands;
2992
+ }
2993
+ var excludeCommands = [];
2994
+ usedCommands.forEach(function (item) {
2995
+ excludeCommands.push(item.command);
2996
+ });
2997
+ var resultCommands = [];
2998
+ commands.forEach(function (item) {
2999
+ if (excludeCommands.indexOf(item.command) === -1) {
3000
+ resultCommands.push(item);
3001
+ }
3002
+ });
3003
+ return resultCommands;
3004
+ }
3005
+ var prefix = this.getPrefix(cmdLine);
3006
+ var recentlyUsedCommands = getFilteredCompletions(this.history(), prefix);
3007
+ var otherCommands = getUniqueCommandList(shortcutsArray, recentlyUsedCommands);
3008
+ otherCommands = getFilteredCompletions(otherCommands, prefix);
3009
+ if (recentlyUsedCommands.length && otherCommands.length) {
3010
+ recentlyUsedCommands[0].message = nls("prompt.recently-used", "Recently used");
3011
+ otherCommands[0].message = nls("prompt.other-commands", "Other commands");
3012
+ }
3013
+ var completions = recentlyUsedCommands.concat(otherCommands);
3014
+ return completions.length > 0 ? completions : [{
3015
+ value: nls("prompt.no-matching-commands", "No matching commands"),
3016
+ error: 1
3017
+ }];
3018
+ }
3019
+ });
3020
+ };
3021
+ prompt.modes = function (editor, callback) {
3022
+ var modesArray = modelist.modes;
3023
+ modesArray = modesArray.map(function (item) {
3024
+ return { value: item.caption, mode: item.name };
3025
+ });
3026
+ prompt(editor, "", {
3027
+ name: "modes",
3028
+ selection: [0, Number.MAX_VALUE],
3029
+ onAccept: function (data) {
3030
+ if (data.item) {
3031
+ var modeName = "ace/mode/" + data.item.mode;
3032
+ editor.session.setMode(modeName);
3033
+ }
3034
+ },
3035
+ getPrefix: function (cmdLine) {
3036
+ var currentPos = cmdLine.getCursorPosition();
3037
+ var filterValue = cmdLine.getValue();
3038
+ return filterValue.substring(0, currentPos.column);
3039
+ },
3040
+ getCompletions: function (cmdLine) {
3041
+ function getFilteredCompletions(modes, prefix) {
3042
+ var resultCommands = JSON.parse(JSON.stringify(modes));
3043
+ var filtered = new FilteredList(resultCommands);
3044
+ return filtered.filterCompletions(resultCommands, prefix);
3045
+ }
3046
+ var prefix = this.getPrefix(cmdLine);
3047
+ var completions = getFilteredCompletions(modesArray, prefix);
3048
+ return completions.length > 0 ? completions : [{
3049
+ "caption": "No mode matching",
3050
+ "value": "No mode matching",
3051
+ "error": 1
3052
+ }];
3053
+ }
3054
+ });
3055
+ };
3056
+ dom.importCssString(".ace_prompt_container {\n max-width: 603px;\n width: 100%;\n margin: 20px auto;\n padding: 3px;\n background: white;\n border-radius: 2px;\n box-shadow: 0px 2px 3px 0px #555;\n}", "promtp.css", false);
3057
+ exports.prompt = prompt;
3058
+
3059
+ }); (function() {
3060
+ ace.require(["ace/ext/prompt"], function(m) {
3061
+ if (typeof module == "object" && typeof exports == "object" && module) {
3062
+ module.exports = m;
3063
+ }
3064
+ });
3065
+ })();
3066
+