prettier 1.5.2 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +58 -1
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +41 -12
  5. data/node_modules/prettier/bin-prettier.js +13848 -11589
  6. data/node_modules/prettier/doc.js +4961 -0
  7. data/node_modules/prettier/index.js +19466 -16783
  8. data/node_modules/prettier/package.json +23 -0
  9. data/node_modules/prettier/parser-angular.js +67 -0
  10. data/node_modules/prettier/parser-babel.js +22 -0
  11. data/node_modules/prettier/parser-espree.js +22 -0
  12. data/node_modules/prettier/parser-flow.js +22 -0
  13. data/node_modules/prettier/parser-glimmer.js +1 -0
  14. data/node_modules/prettier/parser-graphql.js +1 -0
  15. data/node_modules/prettier/parser-html.js +132 -0
  16. data/node_modules/prettier/parser-markdown.js +34 -0
  17. data/node_modules/prettier/parser-meriyah.js +22 -0
  18. data/node_modules/prettier/parser-postcss.js +22 -0
  19. data/node_modules/prettier/parser-typescript.js +22 -0
  20. data/node_modules/prettier/parser-yaml.js +15 -0
  21. data/node_modules/prettier/third-party.js +1671 -864
  22. data/package.json +5 -5
  23. data/rubocop.yml +12 -0
  24. data/src/haml/parser.js +6 -5
  25. data/src/haml/parser.rb +8 -3
  26. data/src/haml/printer.js +428 -18
  27. data/src/parser/netcat.js +0 -2
  28. data/src/parser/parseSync.js +153 -14
  29. data/src/parser/server.rb +5 -0
  30. data/src/plugin.js +7 -1
  31. data/src/rbs/parser.js +3 -5
  32. data/src/rbs/parser.rb +7 -3
  33. data/src/rbs/printer.js +46 -8
  34. data/src/ruby/nodes/args.js +111 -19
  35. data/src/ruby/nodes/calls.js +50 -3
  36. data/src/ruby/nodes/conditionals.js +47 -45
  37. data/src/ruby/nodes/hashes.js +5 -14
  38. data/src/ruby/nodes/params.js +2 -9
  39. data/src/ruby/nodes/strings.js +97 -2
  40. data/src/ruby/parser.js +3 -5
  41. data/src/ruby/parser.rb +76 -31
  42. data/src/ruby/printer.js +10 -1
  43. data/src/utils/inlineEnsureParens.js +1 -0
  44. data/src/utils/noIndent.js +0 -1
  45. data/src/utils/skipAssignIndent.js +8 -1
  46. metadata +16 -14
  47. data/src/haml/nodes/comment.js +0 -27
  48. data/src/haml/nodes/doctype.js +0 -34
  49. data/src/haml/nodes/filter.js +0 -16
  50. data/src/haml/nodes/hamlComment.js +0 -21
  51. data/src/haml/nodes/plain.js +0 -6
  52. data/src/haml/nodes/root.js +0 -8
  53. data/src/haml/nodes/script.js +0 -33
  54. data/src/haml/nodes/silentScript.js +0 -59
  55. data/src/haml/nodes/tag.js +0 -193
  56. data/src/parser/getLang.js +0 -32
  57. data/src/parser/getNetcat.js +0 -50
  58. data/src/parser/requestParse.js +0 -74
@@ -0,0 +1,4961 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.doc = factory());
5
+ }(this, (function () { 'use strict';
6
+
7
+ /**
8
+ * @param {Doc[]} parts
9
+ * @returns Doc
10
+ */
11
+
12
+
13
+ function concat(parts) {
14
+ // access the internals of a document directly.
15
+ // if(parts.length === 1) {
16
+ // // If it's a single document, no need to concat it.
17
+ // return parts[0];
18
+ // }
19
+
20
+
21
+ return {
22
+ type: "concat",
23
+ parts
24
+ };
25
+ }
26
+ /**
27
+ * @param {Doc} contents
28
+ * @returns Doc
29
+ */
30
+
31
+
32
+ function indent$1(contents) {
33
+
34
+ return {
35
+ type: "indent",
36
+ contents
37
+ };
38
+ }
39
+ /**
40
+ * @param {number | string} widthOrString
41
+ * @param {Doc} contents
42
+ * @returns Doc
43
+ */
44
+
45
+
46
+ function align(widthOrString, contents) {
47
+
48
+ return {
49
+ type: "align",
50
+ contents,
51
+ n: widthOrString
52
+ };
53
+ }
54
+ /**
55
+ * @param {Doc} contents
56
+ * @param {object} [opts] - TBD ???
57
+ * @returns Doc
58
+ */
59
+
60
+
61
+ function group(contents, opts = {}) {
62
+
63
+ return {
64
+ type: "group",
65
+ id: opts.id,
66
+ contents,
67
+ break: Boolean(opts.shouldBreak),
68
+ expandedStates: opts.expandedStates
69
+ };
70
+ }
71
+ /**
72
+ * @param {Doc} contents
73
+ * @returns Doc
74
+ */
75
+
76
+
77
+ function dedentToRoot(contents) {
78
+ return align(Number.NEGATIVE_INFINITY, contents);
79
+ }
80
+ /**
81
+ * @param {Doc} contents
82
+ * @returns Doc
83
+ */
84
+
85
+
86
+ function markAsRoot(contents) {
87
+ // @ts-ignore - TBD ???:
88
+ return align({
89
+ type: "root"
90
+ }, contents);
91
+ }
92
+ /**
93
+ * @param {Doc} contents
94
+ * @returns Doc
95
+ */
96
+
97
+
98
+ function dedent(contents) {
99
+ return align(-1, contents);
100
+ }
101
+ /**
102
+ * @param {Doc[]} states
103
+ * @param {object} [opts] - TBD ???
104
+ * @returns Doc
105
+ */
106
+
107
+
108
+ function conditionalGroup(states, opts) {
109
+ return group(states[0], Object.assign(Object.assign({}, opts), {}, {
110
+ expandedStates: states
111
+ }));
112
+ }
113
+ /**
114
+ * @param {Doc[]} parts
115
+ * @returns Doc
116
+ */
117
+
118
+
119
+ function fill$1(parts) {
120
+
121
+ return {
122
+ type: "fill",
123
+ parts
124
+ };
125
+ }
126
+ /**
127
+ * @param {Doc} [breakContents]
128
+ * @param {Doc} [flatContents]
129
+ * @param {object} [opts] - TBD ???
130
+ * @returns Doc
131
+ */
132
+
133
+
134
+ function ifBreak(breakContents, flatContents, opts = {}) {
135
+
136
+ return {
137
+ type: "if-break",
138
+ breakContents,
139
+ flatContents,
140
+ groupId: opts.groupId
141
+ };
142
+ }
143
+ /**
144
+ * Optimized version of `ifBreak(indent(doc), doc, { groupId: ... })`
145
+ * @param {Doc} contents
146
+ * @param {{ groupId: symbol, negate?: boolean }} opts
147
+ * @returns Doc
148
+ */
149
+
150
+
151
+ function indentIfBreak(contents, opts) {
152
+ return {
153
+ type: "indent-if-break",
154
+ contents,
155
+ groupId: opts.groupId,
156
+ negate: opts.negate
157
+ };
158
+ }
159
+ /**
160
+ * @param {Doc} contents
161
+ * @returns Doc
162
+ */
163
+
164
+
165
+ function lineSuffix(contents) {
166
+
167
+ return {
168
+ type: "line-suffix",
169
+ contents
170
+ };
171
+ }
172
+
173
+ const lineSuffixBoundary = {
174
+ type: "line-suffix-boundary"
175
+ };
176
+ const breakParent = {
177
+ type: "break-parent"
178
+ };
179
+ const trim$1 = {
180
+ type: "trim"
181
+ };
182
+ const hardlineWithoutBreakParent = {
183
+ type: "line",
184
+ hard: true
185
+ };
186
+ const literallineWithoutBreakParent = {
187
+ type: "line",
188
+ hard: true,
189
+ literal: true
190
+ };
191
+ const line = {
192
+ type: "line"
193
+ };
194
+ const softline = {
195
+ type: "line",
196
+ soft: true
197
+ }; // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
198
+
199
+ const hardline = concat([hardlineWithoutBreakParent, breakParent]); // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
200
+
201
+ const literalline$1 = concat([literallineWithoutBreakParent, breakParent]);
202
+ const cursor$1 = {
203
+ type: "cursor",
204
+ placeholder: Symbol("cursor")
205
+ };
206
+ /**
207
+ * @param {Doc} sep
208
+ * @param {Doc[]} arr
209
+ * @returns Doc
210
+ */
211
+
212
+ function join$1(sep, arr) {
213
+ const res = [];
214
+
215
+ for (let i = 0; i < arr.length; i++) {
216
+ if (i !== 0) {
217
+ res.push(sep);
218
+ }
219
+
220
+ res.push(arr[i]);
221
+ } // eslint-disable-next-line prettier-internal-rules/no-doc-builder-concat
222
+
223
+
224
+ return concat(res);
225
+ }
226
+ /**
227
+ * @param {Doc} doc
228
+ * @param {number} size
229
+ * @param {number} tabWidth
230
+ */
231
+
232
+
233
+ function addAlignmentToDoc(doc, size, tabWidth) {
234
+ let aligned = doc;
235
+
236
+ if (size > 0) {
237
+ // Use indent to add tabs for all the levels of tabs we need
238
+ for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
239
+ aligned = indent$1(aligned);
240
+ } // Use align for all the spaces that are needed
241
+
242
+
243
+ aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
244
+ // indentation, so we use -Infinity to reset the indentation to 0
245
+
246
+ aligned = align(Number.NEGATIVE_INFINITY, aligned);
247
+ }
248
+
249
+ return aligned;
250
+ }
251
+
252
+ function label(label, contents) {
253
+ return {
254
+ type: "label",
255
+ label,
256
+ contents
257
+ };
258
+ }
259
+
260
+ var docBuilders = {
261
+ concat,
262
+ join: join$1,
263
+ line,
264
+ softline,
265
+ hardline,
266
+ literalline: literalline$1,
267
+ group,
268
+ conditionalGroup,
269
+ fill: fill$1,
270
+ lineSuffix,
271
+ lineSuffixBoundary,
272
+ cursor: cursor$1,
273
+ breakParent,
274
+ ifBreak,
275
+ trim: trim$1,
276
+ indent: indent$1,
277
+ indentIfBreak,
278
+ align,
279
+ addAlignmentToDoc,
280
+ markAsRoot,
281
+ dedentToRoot,
282
+ dedent,
283
+ hardlineWithoutBreakParent,
284
+ literallineWithoutBreakParent,
285
+ label
286
+ };
287
+
288
+ var ansiRegex = ({
289
+ onlyFirst = false
290
+ } = {}) => {
291
+ const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
292
+ return new RegExp(pattern, onlyFirst ? undefined : 'g');
293
+ };
294
+
295
+ var stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
296
+
297
+ /* eslint-disable yoda */
298
+
299
+ const isFullwidthCodePoint = codePoint => {
300
+ if (Number.isNaN(codePoint)) {
301
+ return false;
302
+ } // Code points are derived from:
303
+ // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
304
+
305
+
306
+ if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
307
+ codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
308
+ codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
309
+ // CJK Radicals Supplement .. Enclosed CJK Letters and Months
310
+ 0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
311
+ 0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
312
+ 0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
313
+ 0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
314
+ 0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
315
+ 0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
316
+ 0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
317
+ 0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
318
+ 0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
319
+ 0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
320
+ 0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
321
+ 0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
322
+ return true;
323
+ }
324
+
325
+ return false;
326
+ };
327
+
328
+ var isFullwidthCodePoint_1 = isFullwidthCodePoint;
329
+ var _default$1 = isFullwidthCodePoint;
330
+ isFullwidthCodePoint_1.default = _default$1;
331
+
332
+ var emojiRegex = function () {
333
+ // https://mths.be/emoji
334
+ return /\uD83C\uDFF4\uDB40\uDC67\uDB40\uDC62(?:\uDB40\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDB40\uDC73\uDB40\uDC63\uDB40\uDC74|\uDB40\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F|\uD83D\uDC68(?:\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68\uD83C\uDFFB|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFE])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D)?\uD83D\uDC68|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D[\uDC68\uDC69])\u200D(?:\uD83D[\uDC66\uDC67])|[\u2695\u2696\u2708]\uFE0F|\uD83D[\uDC66\uDC67]|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|(?:\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708])\uFE0F|\uD83C\uDFFB\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C[\uDFFB-\uDFFF])|(?:\uD83E\uDDD1\uD83C\uDFFB\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)\uD83C\uDFFB|\uD83E\uDDD1(?:\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1)|(?:\uD83E\uDDD1\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFF\u200D\uD83E\uDD1D\u200D(?:\uD83D[\uDC68\uDC69]))(?:\uD83C[\uDFFB-\uDFFE])|(?:\uD83E\uDDD1\uD83C\uDFFC\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB\uDFFC])|\uD83D\uDC69(?:\uD83C\uDFFE\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFC\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFB\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFC-\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFD\u200D(?:\uD83E\uDD1D\u200D\uD83D\uDC68(?:\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\u200D(?:\u2764\uFE0F\u200D(?:\uD83D\uDC8B\u200D(?:\uD83D[\uDC68\uDC69])|\uD83D[\uDC68\uDC69])|\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C\uDFFF\u200D(?:\uD83C[\uDF3E\uDF73\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD]))|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67]))|(?:\uD83E\uDDD1\uD83C\uDFFD\u200D\uD83E\uDD1D\u200D\uD83E\uDDD1|\uD83D\uDC69\uD83C\uDFFE\u200D\uD83E\uDD1D\u200D\uD83D\uDC69)(?:\uD83C[\uDFFB-\uDFFD])|\uD83D\uDC69\u200D\uD83D\uDC66\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC69\u200D(?:\uD83D[\uDC66\uDC67])|(?:\uD83D\uDC41\uFE0F\u200D\uD83D\uDDE8|\uD83D\uDC69(?:\uD83C\uDFFF\u200D[\u2695\u2696\u2708]|\uD83C\uDFFE\u200D[\u2695\u2696\u2708]|\uD83C\uDFFC\u200D[\u2695\u2696\u2708]|\uD83C\uDFFB\u200D[\u2695\u2696\u2708]|\uD83C\uDFFD\u200D[\u2695\u2696\u2708]|\u200D[\u2695\u2696\u2708])|(?:(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)\uFE0F|\uD83D\uDC6F|\uD83E[\uDD3C\uDDDE\uDDDF])\u200D[\u2640\u2642]|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:(?:\uD83C[\uDFFB-\uDFFF])\u200D[\u2640\u2642]|\u200D[\u2640\u2642])|\uD83C\uDFF4\u200D\u2620)\uFE0F|\uD83D\uDC69\u200D\uD83D\uDC67\u200D(?:\uD83D[\uDC66\uDC67])|\uD83C\uDFF3\uFE0F\u200D\uD83C\uDF08|\uD83D\uDC15\u200D\uD83E\uDDBA|\uD83D\uDC69\u200D\uD83D\uDC66|\uD83D\uDC69\u200D\uD83D\uDC67|\uD83C\uDDFD\uD83C\uDDF0|\uD83C\uDDF4\uD83C\uDDF2|\uD83C\uDDF6\uD83C\uDDE6|[#\*0-9]\uFE0F\u20E3|\uD83C\uDDE7(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF])|\uD83C\uDDF9(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF])|\uD83C\uDDEA(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA])|\uD83E\uDDD1(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF7(?:\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC])|\uD83D\uDC69(?:\uD83C[\uDFFB-\uDFFF])|\uD83C\uDDF2(?:\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF])|\uD83C\uDDE6(?:\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF])|\uD83C\uDDF0(?:\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF])|\uD83C\uDDED(?:\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA])|\uD83C\uDDE9(?:\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF])|\uD83C\uDDFE(?:\uD83C[\uDDEA\uDDF9])|\uD83C\uDDEC(?:\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE])|\uD83C\uDDF8(?:\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF])|\uD83C\uDDEB(?:\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7])|\uD83C\uDDF5(?:\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE])|\uD83C\uDDFB(?:\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA])|\uD83C\uDDF3(?:\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF])|\uD83C\uDDE8(?:\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF])|\uD83C\uDDF1(?:\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE])|\uD83C\uDDFF(?:\uD83C[\uDDE6\uDDF2\uDDFC])|\uD83C\uDDFC(?:\uD83C[\uDDEB\uDDF8])|\uD83C\uDDFA(?:\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF])|\uD83C\uDDEE(?:\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9])|\uD83C\uDDEF(?:\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5])|(?:\uD83C[\uDFC3\uDFC4\uDFCA]|\uD83D[\uDC6E\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6]|\uD83E[\uDD26\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD6-\uDDDD])(?:\uD83C[\uDFFB-\uDFFF])|(?:\u26F9|\uD83C[\uDFCB\uDFCC]|\uD83D\uDD75)(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u261D\u270A-\u270D]|\uD83C[\uDF85\uDFC2\uDFC7]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC70\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDCAA\uDD74\uDD7A\uDD90\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1C\uDD1E\uDD1F\uDD30-\uDD36\uDDB5\uDDB6\uDDBB\uDDD2-\uDDD5])(?:\uD83C[\uDFFB-\uDFFF])|(?:[\u231A\u231B\u23E9-\u23EC\u23F0\u23F3\u25FD\u25FE\u2614\u2615\u2648-\u2653\u267F\u2693\u26A1\u26AA\u26AB\u26BD\u26BE\u26C4\u26C5\u26CE\u26D4\u26EA\u26F2\u26F3\u26F5\u26FA\u26FD\u2705\u270A\u270B\u2728\u274C\u274E\u2753-\u2755\u2757\u2795-\u2797\u27B0\u27BF\u2B1B\u2B1C\u2B50\u2B55]|\uD83C[\uDC04\uDCCF\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF93\uDFA0-\uDFCA\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF4\uDFF8-\uDFFF]|\uD83D[\uDC00-\uDC3E\uDC40\uDC42-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDD7A\uDD95\uDD96\uDDA4\uDDFB-\uDE4F\uDE80-\uDEC5\uDECC\uDED0-\uDED2\uDED5\uDEEB\uDEEC\uDEF4-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])|(?:[#\*0-9\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u261D\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692-\u2697\u2699\u269B\u269C\u26A0\u26A1\u26AA\u26AB\u26B0\u26B1\u26BD\u26BE\u26C4\u26C5\u26C8\u26CE\u26CF\u26D1\u26D3\u26D4\u26E9\u26EA\u26F0-\u26F5\u26F7-\u26FA\u26FD\u2702\u2705\u2708-\u270D\u270F\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763\u2764\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC04\uDCCF\uDD70\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDE6-\uDDFF\uDE01\uDE02\uDE1A\uDE2F\uDE32-\uDE3A\uDE50\uDE51\uDF00-\uDF21\uDF24-\uDF93\uDF96\uDF97\uDF99-\uDF9B\uDF9E-\uDFF0\uDFF3-\uDFF5\uDFF7-\uDFFF]|\uD83D[\uDC00-\uDCFD\uDCFF-\uDD3D\uDD49-\uDD4E\uDD50-\uDD67\uDD6F\uDD70\uDD73-\uDD7A\uDD87\uDD8A-\uDD8D\uDD90\uDD95\uDD96\uDDA4\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA-\uDE4F\uDE80-\uDEC5\uDECB-\uDED2\uDED5\uDEE0-\uDEE5\uDEE9\uDEEB\uDEEC\uDEF0\uDEF3-\uDEFA\uDFE0-\uDFEB]|\uD83E[\uDD0D-\uDD3A\uDD3C-\uDD45\uDD47-\uDD71\uDD73-\uDD76\uDD7A-\uDDA2\uDDA5-\uDDAA\uDDAE-\uDDCA\uDDCD-\uDDFF\uDE70-\uDE73\uDE78-\uDE7A\uDE80-\uDE82\uDE90-\uDE95])\uFE0F|(?:[\u261D\u26F9\u270A-\u270D]|\uD83C[\uDF85\uDFC2-\uDFC4\uDFC7\uDFCA-\uDFCC]|\uD83D[\uDC42\uDC43\uDC46-\uDC50\uDC66-\uDC78\uDC7C\uDC81-\uDC83\uDC85-\uDC87\uDC8F\uDC91\uDCAA\uDD74\uDD75\uDD7A\uDD90\uDD95\uDD96\uDE45-\uDE47\uDE4B-\uDE4F\uDEA3\uDEB4-\uDEB6\uDEC0\uDECC]|\uD83E[\uDD0F\uDD18-\uDD1F\uDD26\uDD30-\uDD39\uDD3C-\uDD3E\uDDB5\uDDB6\uDDB8\uDDB9\uDDBB\uDDCD-\uDDCF\uDDD1-\uDDDD])/g;
335
+ };
336
+
337
+ const stringWidth = string => {
338
+ if (typeof string !== 'string' || string.length === 0) {
339
+ return 0;
340
+ }
341
+
342
+ string = stripAnsi(string);
343
+
344
+ if (string.length === 0) {
345
+ return 0;
346
+ }
347
+
348
+ string = string.replace(emojiRegex(), ' ');
349
+ let width = 0;
350
+
351
+ for (let i = 0; i < string.length; i++) {
352
+ const code = string.codePointAt(i); // Ignore control characters
353
+
354
+ if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
355
+ continue;
356
+ } // Ignore combining characters
357
+
358
+
359
+ if (code >= 0x300 && code <= 0x36F) {
360
+ continue;
361
+ } // Surrogates
362
+
363
+
364
+ if (code > 0xFFFF) {
365
+ i++;
366
+ }
367
+
368
+ width += isFullwidthCodePoint_1(code) ? 2 : 1;
369
+ }
370
+
371
+ return width;
372
+ };
373
+
374
+ var stringWidth_1 = stringWidth; // TODO: remove this in the next major version
375
+
376
+ var _default = stringWidth;
377
+ stringWidth_1.default = _default;
378
+
379
+ var escapeStringRegexp = string => {
380
+ if (typeof string !== 'string') {
381
+ throw new TypeError('Expected a string');
382
+ } // Escape characters with special meaning either inside or outside character sets.
383
+ // Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
384
+
385
+
386
+ return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
387
+ };
388
+
389
+ const getLast$1 = arr => arr[arr.length - 1];
390
+
391
+ var getLast_1 = getLast$1;
392
+
393
+ function _objectWithoutPropertiesLoose(source, excluded) {
394
+ if (source == null) return {};
395
+ var target = {};
396
+ var sourceKeys = Object.keys(source);
397
+ var key, i;
398
+
399
+ for (i = 0; i < sourceKeys.length; i++) {
400
+ key = sourceKeys[i];
401
+ if (excluded.indexOf(key) >= 0) continue;
402
+ target[key] = source[key];
403
+ }
404
+
405
+ return target;
406
+ }
407
+
408
+ function _objectWithoutProperties(source, excluded) {
409
+ if (source == null) return {};
410
+
411
+ var target = _objectWithoutPropertiesLoose(source, excluded);
412
+
413
+ var key, i;
414
+
415
+ if (Object.getOwnPropertySymbols) {
416
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
417
+
418
+ for (i = 0; i < sourceSymbolKeys.length; i++) {
419
+ key = sourceSymbolKeys[i];
420
+ if (excluded.indexOf(key) >= 0) continue;
421
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
422
+ target[key] = source[key];
423
+ }
424
+ }
425
+
426
+ return target;
427
+ }
428
+
429
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
430
+
431
+ function createCommonjsModule(fn) {
432
+ var module = { exports: {} };
433
+ return fn(module, module.exports), module.exports;
434
+ }
435
+
436
+ var check = function (it) {
437
+ return it && it.Math == Math && it;
438
+ };
439
+
440
+ // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
441
+ var global$2 =
442
+ // eslint-disable-next-line es/no-global-this -- safe
443
+ check(typeof globalThis == 'object' && globalThis) ||
444
+ check(typeof window == 'object' && window) ||
445
+ // eslint-disable-next-line no-restricted-globals -- safe
446
+ check(typeof self == 'object' && self) ||
447
+ check(typeof commonjsGlobal == 'object' && commonjsGlobal) ||
448
+ // eslint-disable-next-line no-new-func -- fallback
449
+ (function () { return this; })() || Function('return this')();
450
+
451
+ var fails = function (exec) {
452
+ try {
453
+ return !!exec();
454
+ } catch (error) {
455
+ return true;
456
+ }
457
+ };
458
+
459
+ // Detect IE8's incomplete defineProperty implementation
460
+ var descriptors = !fails(function () {
461
+ // eslint-disable-next-line es/no-object-defineproperty -- required for testing
462
+ return Object.defineProperty({}, 1, { get: function () { return 7; } })[1] != 7;
463
+ });
464
+
465
+ var $propertyIsEnumerable = {}.propertyIsEnumerable;
466
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
467
+ var getOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
468
+
469
+ // Nashorn ~ JDK8 bug
470
+ var NASHORN_BUG = getOwnPropertyDescriptor$1 && !$propertyIsEnumerable.call({ 1: 2 }, 1);
471
+
472
+ // `Object.prototype.propertyIsEnumerable` method implementation
473
+ // https://tc39.es/ecma262/#sec-object.prototype.propertyisenumerable
474
+ var f$4 = NASHORN_BUG ? function propertyIsEnumerable(V) {
475
+ var descriptor = getOwnPropertyDescriptor$1(this, V);
476
+ return !!descriptor && descriptor.enumerable;
477
+ } : $propertyIsEnumerable;
478
+
479
+ var objectPropertyIsEnumerable = {
480
+ f: f$4
481
+ };
482
+
483
+ var createPropertyDescriptor = function (bitmap, value) {
484
+ return {
485
+ enumerable: !(bitmap & 1),
486
+ configurable: !(bitmap & 2),
487
+ writable: !(bitmap & 4),
488
+ value: value
489
+ };
490
+ };
491
+
492
+ var toString = {}.toString;
493
+
494
+ var classofRaw = function (it) {
495
+ return toString.call(it).slice(8, -1);
496
+ };
497
+
498
+ var split = ''.split;
499
+
500
+ // fallback for non-array-like ES3 and non-enumerable old V8 strings
501
+ var indexedObject = fails(function () {
502
+ // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
503
+ // eslint-disable-next-line no-prototype-builtins -- safe
504
+ return !Object('z').propertyIsEnumerable(0);
505
+ }) ? function (it) {
506
+ return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
507
+ } : Object;
508
+
509
+ // `RequireObjectCoercible` abstract operation
510
+ // https://tc39.es/ecma262/#sec-requireobjectcoercible
511
+ var requireObjectCoercible = function (it) {
512
+ if (it == undefined) throw TypeError("Can't call method on " + it);
513
+ return it;
514
+ };
515
+
516
+ // toObject with fallback for non-array-like ES3 strings
517
+
518
+
519
+
520
+ var toIndexedObject = function (it) {
521
+ return indexedObject(requireObjectCoercible(it));
522
+ };
523
+
524
+ var isObject = function (it) {
525
+ return typeof it === 'object' ? it !== null : typeof it === 'function';
526
+ };
527
+
528
+ // `ToPrimitive` abstract operation
529
+ // https://tc39.es/ecma262/#sec-toprimitive
530
+ // instead of the ES6 spec version, we didn't implement @@toPrimitive case
531
+ // and the second argument - flag - preferred type is a string
532
+ var toPrimitive = function (input, PREFERRED_STRING) {
533
+ if (!isObject(input)) return input;
534
+ var fn, val;
535
+ if (PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
536
+ if (typeof (fn = input.valueOf) == 'function' && !isObject(val = fn.call(input))) return val;
537
+ if (!PREFERRED_STRING && typeof (fn = input.toString) == 'function' && !isObject(val = fn.call(input))) return val;
538
+ throw TypeError("Can't convert object to primitive value");
539
+ };
540
+
541
+ // `ToObject` abstract operation
542
+ // https://tc39.es/ecma262/#sec-toobject
543
+ var toObject = function (argument) {
544
+ return Object(requireObjectCoercible(argument));
545
+ };
546
+
547
+ var hasOwnProperty = {}.hasOwnProperty;
548
+
549
+ var has$1 = Object.hasOwn || function hasOwn(it, key) {
550
+ return hasOwnProperty.call(toObject(it), key);
551
+ };
552
+
553
+ var document$1 = global$2.document;
554
+ // typeof document.createElement is 'object' in old IE
555
+ var EXISTS = isObject(document$1) && isObject(document$1.createElement);
556
+
557
+ var documentCreateElement = function (it) {
558
+ return EXISTS ? document$1.createElement(it) : {};
559
+ };
560
+
561
+ // Thank's IE8 for his funny defineProperty
562
+ var ie8DomDefine = !descriptors && !fails(function () {
563
+ // eslint-disable-next-line es/no-object-defineproperty -- requied for testing
564
+ return Object.defineProperty(documentCreateElement('div'), 'a', {
565
+ get: function () { return 7; }
566
+ }).a != 7;
567
+ });
568
+
569
+ // eslint-disable-next-line es/no-object-getownpropertydescriptor -- safe
570
+ var $getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
571
+
572
+ // `Object.getOwnPropertyDescriptor` method
573
+ // https://tc39.es/ecma262/#sec-object.getownpropertydescriptor
574
+ var f$3 = descriptors ? $getOwnPropertyDescriptor : function getOwnPropertyDescriptor(O, P) {
575
+ O = toIndexedObject(O);
576
+ P = toPrimitive(P, true);
577
+ if (ie8DomDefine) try {
578
+ return $getOwnPropertyDescriptor(O, P);
579
+ } catch (error) { /* empty */ }
580
+ if (has$1(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
581
+ };
582
+
583
+ var objectGetOwnPropertyDescriptor = {
584
+ f: f$3
585
+ };
586
+
587
+ var anObject = function (it) {
588
+ if (!isObject(it)) {
589
+ throw TypeError(String(it) + ' is not an object');
590
+ } return it;
591
+ };
592
+
593
+ // eslint-disable-next-line es/no-object-defineproperty -- safe
594
+ var $defineProperty = Object.defineProperty;
595
+
596
+ // `Object.defineProperty` method
597
+ // https://tc39.es/ecma262/#sec-object.defineproperty
598
+ var f$2 = descriptors ? $defineProperty : function defineProperty(O, P, Attributes) {
599
+ anObject(O);
600
+ P = toPrimitive(P, true);
601
+ anObject(Attributes);
602
+ if (ie8DomDefine) try {
603
+ return $defineProperty(O, P, Attributes);
604
+ } catch (error) { /* empty */ }
605
+ if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
606
+ if ('value' in Attributes) O[P] = Attributes.value;
607
+ return O;
608
+ };
609
+
610
+ var objectDefineProperty = {
611
+ f: f$2
612
+ };
613
+
614
+ var createNonEnumerableProperty = descriptors ? function (object, key, value) {
615
+ return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
616
+ } : function (object, key, value) {
617
+ object[key] = value;
618
+ return object;
619
+ };
620
+
621
+ var setGlobal = function (key, value) {
622
+ try {
623
+ createNonEnumerableProperty(global$2, key, value);
624
+ } catch (error) {
625
+ global$2[key] = value;
626
+ } return value;
627
+ };
628
+
629
+ var SHARED = '__core-js_shared__';
630
+ var store$1 = global$2[SHARED] || setGlobal(SHARED, {});
631
+
632
+ var sharedStore = store$1;
633
+
634
+ var functionToString = Function.toString;
635
+
636
+ // this helper broken in `core-js@3.4.1-3.4.4`, so we can't use `shared` helper
637
+ if (typeof sharedStore.inspectSource != 'function') {
638
+ sharedStore.inspectSource = function (it) {
639
+ return functionToString.call(it);
640
+ };
641
+ }
642
+
643
+ var inspectSource = sharedStore.inspectSource;
644
+
645
+ var WeakMap$2 = global$2.WeakMap;
646
+
647
+ var nativeWeakMap = typeof WeakMap$2 === 'function' && /native code/.test(inspectSource(WeakMap$2));
648
+
649
+ var shared = createCommonjsModule(function (module) {
650
+ (module.exports = function (key, value) {
651
+ return sharedStore[key] || (sharedStore[key] = value !== undefined ? value : {});
652
+ })('versions', []).push({
653
+ version: '3.14.0',
654
+ mode: 'global',
655
+ copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
656
+ });
657
+ });
658
+
659
+ var id = 0;
660
+ var postfix = Math.random();
661
+
662
+ var uid = function (key) {
663
+ return 'Symbol(' + String(key === undefined ? '' : key) + ')_' + (++id + postfix).toString(36);
664
+ };
665
+
666
+ var keys = shared('keys');
667
+
668
+ var sharedKey = function (key) {
669
+ return keys[key] || (keys[key] = uid(key));
670
+ };
671
+
672
+ var hiddenKeys$1 = {};
673
+
674
+ var OBJECT_ALREADY_INITIALIZED = 'Object already initialized';
675
+ var WeakMap$1 = global$2.WeakMap;
676
+ var set, get, has;
677
+
678
+ var enforce = function (it) {
679
+ return has(it) ? get(it) : set(it, {});
680
+ };
681
+
682
+ var getterFor = function (TYPE) {
683
+ return function (it) {
684
+ var state;
685
+ if (!isObject(it) || (state = get(it)).type !== TYPE) {
686
+ throw TypeError('Incompatible receiver, ' + TYPE + ' required');
687
+ } return state;
688
+ };
689
+ };
690
+
691
+ if (nativeWeakMap || sharedStore.state) {
692
+ var store = sharedStore.state || (sharedStore.state = new WeakMap$1());
693
+ var wmget = store.get;
694
+ var wmhas = store.has;
695
+ var wmset = store.set;
696
+ set = function (it, metadata) {
697
+ if (wmhas.call(store, it)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
698
+ metadata.facade = it;
699
+ wmset.call(store, it, metadata);
700
+ return metadata;
701
+ };
702
+ get = function (it) {
703
+ return wmget.call(store, it) || {};
704
+ };
705
+ has = function (it) {
706
+ return wmhas.call(store, it);
707
+ };
708
+ } else {
709
+ var STATE = sharedKey('state');
710
+ hiddenKeys$1[STATE] = true;
711
+ set = function (it, metadata) {
712
+ if (has$1(it, STATE)) throw new TypeError(OBJECT_ALREADY_INITIALIZED);
713
+ metadata.facade = it;
714
+ createNonEnumerableProperty(it, STATE, metadata);
715
+ return metadata;
716
+ };
717
+ get = function (it) {
718
+ return has$1(it, STATE) ? it[STATE] : {};
719
+ };
720
+ has = function (it) {
721
+ return has$1(it, STATE);
722
+ };
723
+ }
724
+
725
+ var internalState = {
726
+ set: set,
727
+ get: get,
728
+ has: has,
729
+ enforce: enforce,
730
+ getterFor: getterFor
731
+ };
732
+
733
+ var redefine = createCommonjsModule(function (module) {
734
+ var getInternalState = internalState.get;
735
+ var enforceInternalState = internalState.enforce;
736
+ var TEMPLATE = String(String).split('String');
737
+
738
+ (module.exports = function (O, key, value, options) {
739
+ var unsafe = options ? !!options.unsafe : false;
740
+ var simple = options ? !!options.enumerable : false;
741
+ var noTargetGet = options ? !!options.noTargetGet : false;
742
+ var state;
743
+ if (typeof value == 'function') {
744
+ if (typeof key == 'string' && !has$1(value, 'name')) {
745
+ createNonEnumerableProperty(value, 'name', key);
746
+ }
747
+ state = enforceInternalState(value);
748
+ if (!state.source) {
749
+ state.source = TEMPLATE.join(typeof key == 'string' ? key : '');
750
+ }
751
+ }
752
+ if (O === global$2) {
753
+ if (simple) O[key] = value;
754
+ else setGlobal(key, value);
755
+ return;
756
+ } else if (!unsafe) {
757
+ delete O[key];
758
+ } else if (!noTargetGet && O[key]) {
759
+ simple = true;
760
+ }
761
+ if (simple) O[key] = value;
762
+ else createNonEnumerableProperty(O, key, value);
763
+ // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
764
+ })(Function.prototype, 'toString', function toString() {
765
+ return typeof this == 'function' && getInternalState(this).source || inspectSource(this);
766
+ });
767
+ });
768
+
769
+ var path = global$2;
770
+
771
+ var aFunction$1 = function (variable) {
772
+ return typeof variable == 'function' ? variable : undefined;
773
+ };
774
+
775
+ var getBuiltIn = function (namespace, method) {
776
+ return arguments.length < 2 ? aFunction$1(path[namespace]) || aFunction$1(global$2[namespace])
777
+ : path[namespace] && path[namespace][method] || global$2[namespace] && global$2[namespace][method];
778
+ };
779
+
780
+ var ceil = Math.ceil;
781
+ var floor$1 = Math.floor;
782
+
783
+ // `ToInteger` abstract operation
784
+ // https://tc39.es/ecma262/#sec-tointeger
785
+ var toInteger = function (argument) {
786
+ return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor$1 : ceil)(argument);
787
+ };
788
+
789
+ var min$1 = Math.min;
790
+
791
+ // `ToLength` abstract operation
792
+ // https://tc39.es/ecma262/#sec-tolength
793
+ var toLength = function (argument) {
794
+ return argument > 0 ? min$1(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
795
+ };
796
+
797
+ var max = Math.max;
798
+ var min = Math.min;
799
+
800
+ // Helper for a popular repeating case of the spec:
801
+ // Let integer be ? ToInteger(index).
802
+ // If integer < 0, let result be max((length + integer), 0); else let result be min(integer, length).
803
+ var toAbsoluteIndex = function (index, length) {
804
+ var integer = toInteger(index);
805
+ return integer < 0 ? max(integer + length, 0) : min(integer, length);
806
+ };
807
+
808
+ // `Array.prototype.{ indexOf, includes }` methods implementation
809
+ var createMethod = function (IS_INCLUDES) {
810
+ return function ($this, el, fromIndex) {
811
+ var O = toIndexedObject($this);
812
+ var length = toLength(O.length);
813
+ var index = toAbsoluteIndex(fromIndex, length);
814
+ var value;
815
+ // Array#includes uses SameValueZero equality algorithm
816
+ // eslint-disable-next-line no-self-compare -- NaN check
817
+ if (IS_INCLUDES && el != el) while (length > index) {
818
+ value = O[index++];
819
+ // eslint-disable-next-line no-self-compare -- NaN check
820
+ if (value != value) return true;
821
+ // Array#indexOf ignores holes, Array#includes - not
822
+ } else for (;length > index; index++) {
823
+ if ((IS_INCLUDES || index in O) && O[index] === el) return IS_INCLUDES || index || 0;
824
+ } return !IS_INCLUDES && -1;
825
+ };
826
+ };
827
+
828
+ var arrayIncludes = {
829
+ // `Array.prototype.includes` method
830
+ // https://tc39.es/ecma262/#sec-array.prototype.includes
831
+ includes: createMethod(true),
832
+ // `Array.prototype.indexOf` method
833
+ // https://tc39.es/ecma262/#sec-array.prototype.indexof
834
+ indexOf: createMethod(false)
835
+ };
836
+
837
+ var indexOf = arrayIncludes.indexOf;
838
+
839
+
840
+ var objectKeysInternal = function (object, names) {
841
+ var O = toIndexedObject(object);
842
+ var i = 0;
843
+ var result = [];
844
+ var key;
845
+ for (key in O) !has$1(hiddenKeys$1, key) && has$1(O, key) && result.push(key);
846
+ // Don't enum bug & hidden keys
847
+ while (names.length > i) if (has$1(O, key = names[i++])) {
848
+ ~indexOf(result, key) || result.push(key);
849
+ }
850
+ return result;
851
+ };
852
+
853
+ // IE8- don't enum bug keys
854
+ var enumBugKeys = [
855
+ 'constructor',
856
+ 'hasOwnProperty',
857
+ 'isPrototypeOf',
858
+ 'propertyIsEnumerable',
859
+ 'toLocaleString',
860
+ 'toString',
861
+ 'valueOf'
862
+ ];
863
+
864
+ var hiddenKeys = enumBugKeys.concat('length', 'prototype');
865
+
866
+ // `Object.getOwnPropertyNames` method
867
+ // https://tc39.es/ecma262/#sec-object.getownpropertynames
868
+ // eslint-disable-next-line es/no-object-getownpropertynames -- safe
869
+ var f$1 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
870
+ return objectKeysInternal(O, hiddenKeys);
871
+ };
872
+
873
+ var objectGetOwnPropertyNames = {
874
+ f: f$1
875
+ };
876
+
877
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- safe
878
+ var f = Object.getOwnPropertySymbols;
879
+
880
+ var objectGetOwnPropertySymbols = {
881
+ f: f
882
+ };
883
+
884
+ // all object keys, includes non-enumerable and symbols
885
+ var ownKeys = getBuiltIn('Reflect', 'ownKeys') || function ownKeys(it) {
886
+ var keys = objectGetOwnPropertyNames.f(anObject(it));
887
+ var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
888
+ return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
889
+ };
890
+
891
+ var copyConstructorProperties = function (target, source) {
892
+ var keys = ownKeys(source);
893
+ var defineProperty = objectDefineProperty.f;
894
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
895
+ for (var i = 0; i < keys.length; i++) {
896
+ var key = keys[i];
897
+ if (!has$1(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
898
+ }
899
+ };
900
+
901
+ var replacement = /#|\.prototype\./;
902
+
903
+ var isForced = function (feature, detection) {
904
+ var value = data[normalize(feature)];
905
+ return value == POLYFILL ? true
906
+ : value == NATIVE ? false
907
+ : typeof detection == 'function' ? fails(detection)
908
+ : !!detection;
909
+ };
910
+
911
+ var normalize = isForced.normalize = function (string) {
912
+ return String(string).replace(replacement, '.').toLowerCase();
913
+ };
914
+
915
+ var data = isForced.data = {};
916
+ var NATIVE = isForced.NATIVE = 'N';
917
+ var POLYFILL = isForced.POLYFILL = 'P';
918
+
919
+ var isForced_1 = isForced;
920
+
921
+ var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
922
+
923
+
924
+
925
+
926
+
927
+
928
+ /*
929
+ options.target - name of the target object
930
+ options.global - target is the global object
931
+ options.stat - export as static methods of target
932
+ options.proto - export as prototype methods of target
933
+ options.real - real prototype method for the `pure` version
934
+ options.forced - export even if the native feature is available
935
+ options.bind - bind methods to the target, required for the `pure` version
936
+ options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
937
+ options.unsafe - use the simple assignment of property instead of delete + defineProperty
938
+ options.sham - add a flag to not completely full polyfills
939
+ options.enumerable - export as enumerable property
940
+ options.noTargetGet - prevent calling a getter on target
941
+ */
942
+ var _export = function (options, source) {
943
+ var TARGET = options.target;
944
+ var GLOBAL = options.global;
945
+ var STATIC = options.stat;
946
+ var FORCED, target, key, targetProperty, sourceProperty, descriptor;
947
+ if (GLOBAL) {
948
+ target = global$2;
949
+ } else if (STATIC) {
950
+ target = global$2[TARGET] || setGlobal(TARGET, {});
951
+ } else {
952
+ target = (global$2[TARGET] || {}).prototype;
953
+ }
954
+ if (target) for (key in source) {
955
+ sourceProperty = source[key];
956
+ if (options.noTargetGet) {
957
+ descriptor = getOwnPropertyDescriptor(target, key);
958
+ targetProperty = descriptor && descriptor.value;
959
+ } else targetProperty = target[key];
960
+ FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
961
+ // contained in target
962
+ if (!FORCED && targetProperty !== undefined) {
963
+ if (typeof sourceProperty === typeof targetProperty) continue;
964
+ copyConstructorProperties(sourceProperty, targetProperty);
965
+ }
966
+ // add a flag to not completely full polyfills
967
+ if (options.sham || (targetProperty && targetProperty.sham)) {
968
+ createNonEnumerableProperty(sourceProperty, 'sham', true);
969
+ }
970
+ // extend global
971
+ redefine(target, key, sourceProperty, options);
972
+ }
973
+ };
974
+
975
+ // `IsArray` abstract operation
976
+ // https://tc39.es/ecma262/#sec-isarray
977
+ // eslint-disable-next-line es/no-array-isarray -- safe
978
+ var isArray = Array.isArray || function isArray(arg) {
979
+ return classofRaw(arg) == 'Array';
980
+ };
981
+
982
+ var aFunction = function (it) {
983
+ if (typeof it != 'function') {
984
+ throw TypeError(String(it) + ' is not a function');
985
+ } return it;
986
+ };
987
+
988
+ // optional / simple context binding
989
+ var functionBindContext = function (fn, that, length) {
990
+ aFunction(fn);
991
+ if (that === undefined) return fn;
992
+ switch (length) {
993
+ case 0: return function () {
994
+ return fn.call(that);
995
+ };
996
+ case 1: return function (a) {
997
+ return fn.call(that, a);
998
+ };
999
+ case 2: return function (a, b) {
1000
+ return fn.call(that, a, b);
1001
+ };
1002
+ case 3: return function (a, b, c) {
1003
+ return fn.call(that, a, b, c);
1004
+ };
1005
+ }
1006
+ return function (/* ...args */) {
1007
+ return fn.apply(that, arguments);
1008
+ };
1009
+ };
1010
+
1011
+ // `FlattenIntoArray` abstract operation
1012
+ // https://tc39.github.io/proposal-flatMap/#sec-FlattenIntoArray
1013
+ var flattenIntoArray = function (target, original, source, sourceLen, start, depth, mapper, thisArg) {
1014
+ var targetIndex = start;
1015
+ var sourceIndex = 0;
1016
+ var mapFn = mapper ? functionBindContext(mapper, thisArg, 3) : false;
1017
+ var element;
1018
+
1019
+ while (sourceIndex < sourceLen) {
1020
+ if (sourceIndex in source) {
1021
+ element = mapFn ? mapFn(source[sourceIndex], sourceIndex, original) : source[sourceIndex];
1022
+
1023
+ if (depth > 0 && isArray(element)) {
1024
+ targetIndex = flattenIntoArray(target, original, element, toLength(element.length), targetIndex, depth - 1) - 1;
1025
+ } else {
1026
+ if (targetIndex >= 0x1FFFFFFFFFFFFF) throw TypeError('Exceed the acceptable array length');
1027
+ target[targetIndex] = element;
1028
+ }
1029
+
1030
+ targetIndex++;
1031
+ }
1032
+ sourceIndex++;
1033
+ }
1034
+ return targetIndex;
1035
+ };
1036
+
1037
+ var flattenIntoArray_1 = flattenIntoArray;
1038
+
1039
+ var engineUserAgent = getBuiltIn('navigator', 'userAgent') || '';
1040
+
1041
+ var process = global$2.process;
1042
+ var versions$1 = process && process.versions;
1043
+ var v8 = versions$1 && versions$1.v8;
1044
+ var match, version$2;
1045
+
1046
+ if (v8) {
1047
+ match = v8.split('.');
1048
+ version$2 = match[0] < 4 ? 1 : match[0] + match[1];
1049
+ } else if (engineUserAgent) {
1050
+ match = engineUserAgent.match(/Edge\/(\d+)/);
1051
+ if (!match || match[1] >= 74) {
1052
+ match = engineUserAgent.match(/Chrome\/(\d+)/);
1053
+ if (match) version$2 = match[1];
1054
+ }
1055
+ }
1056
+
1057
+ var engineV8Version = version$2 && +version$2;
1058
+
1059
+ /* eslint-disable es/no-symbol -- required for testing */
1060
+
1061
+ // eslint-disable-next-line es/no-object-getownpropertysymbols -- required for testing
1062
+ var nativeSymbol = !!Object.getOwnPropertySymbols && !fails(function () {
1063
+ var symbol = Symbol();
1064
+ // Chrome 38 Symbol has incorrect toString conversion
1065
+ // `get-own-property-symbols` polyfill symbols converted to object are not Symbol instances
1066
+ return !String(symbol) || !(Object(symbol) instanceof Symbol) ||
1067
+ // Chrome 38-40 symbols are not inherited from DOM collections prototypes to instances
1068
+ !Symbol.sham && engineV8Version && engineV8Version < 41;
1069
+ });
1070
+
1071
+ /* eslint-disable es/no-symbol -- required for testing */
1072
+
1073
+ var useSymbolAsUid = nativeSymbol
1074
+ && !Symbol.sham
1075
+ && typeof Symbol.iterator == 'symbol';
1076
+
1077
+ var WellKnownSymbolsStore = shared('wks');
1078
+ var Symbol$1 = global$2.Symbol;
1079
+ var createWellKnownSymbol = useSymbolAsUid ? Symbol$1 : Symbol$1 && Symbol$1.withoutSetter || uid;
1080
+
1081
+ var wellKnownSymbol = function (name) {
1082
+ if (!has$1(WellKnownSymbolsStore, name) || !(nativeSymbol || typeof WellKnownSymbolsStore[name] == 'string')) {
1083
+ if (nativeSymbol && has$1(Symbol$1, name)) {
1084
+ WellKnownSymbolsStore[name] = Symbol$1[name];
1085
+ } else {
1086
+ WellKnownSymbolsStore[name] = createWellKnownSymbol('Symbol.' + name);
1087
+ }
1088
+ } return WellKnownSymbolsStore[name];
1089
+ };
1090
+
1091
+ var SPECIES = wellKnownSymbol('species');
1092
+
1093
+ // `ArraySpeciesCreate` abstract operation
1094
+ // https://tc39.es/ecma262/#sec-arrayspeciescreate
1095
+ var arraySpeciesCreate = function (originalArray, length) {
1096
+ var C;
1097
+ if (isArray(originalArray)) {
1098
+ C = originalArray.constructor;
1099
+ // cross-realm fallback
1100
+ if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
1101
+ else if (isObject(C)) {
1102
+ C = C[SPECIES];
1103
+ if (C === null) C = undefined;
1104
+ }
1105
+ } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
1106
+ };
1107
+
1108
+ // `Array.prototype.flatMap` method
1109
+ // https://tc39.es/ecma262/#sec-array.prototype.flatmap
1110
+ _export({ target: 'Array', proto: true }, {
1111
+ flatMap: function flatMap(callbackfn /* , thisArg */) {
1112
+ var O = toObject(this);
1113
+ var sourceLen = toLength(O.length);
1114
+ var A;
1115
+ aFunction(callbackfn);
1116
+ A = arraySpeciesCreate(O, 0);
1117
+ A.length = flattenIntoArray_1(A, O, O, sourceLen, 0, 1, callbackfn, arguments.length > 1 ? arguments[1] : undefined);
1118
+ return A;
1119
+ }
1120
+ });
1121
+
1122
+ // TODO: use something more complex like timsort?
1123
+ var floor = Math.floor;
1124
+
1125
+ var mergeSort = function (array, comparefn) {
1126
+ var length = array.length;
1127
+ var middle = floor(length / 2);
1128
+ return length < 8 ? insertionSort(array, comparefn) : merge(
1129
+ mergeSort(array.slice(0, middle), comparefn),
1130
+ mergeSort(array.slice(middle), comparefn),
1131
+ comparefn
1132
+ );
1133
+ };
1134
+
1135
+ var insertionSort = function (array, comparefn) {
1136
+ var length = array.length;
1137
+ var i = 1;
1138
+ var element, j;
1139
+
1140
+ while (i < length) {
1141
+ j = i;
1142
+ element = array[i];
1143
+ while (j && comparefn(array[j - 1], element) > 0) {
1144
+ array[j] = array[--j];
1145
+ }
1146
+ if (j !== i++) array[j] = element;
1147
+ } return array;
1148
+ };
1149
+
1150
+ var merge = function (left, right, comparefn) {
1151
+ var llength = left.length;
1152
+ var rlength = right.length;
1153
+ var lindex = 0;
1154
+ var rindex = 0;
1155
+ var result = [];
1156
+
1157
+ while (lindex < llength || rindex < rlength) {
1158
+ if (lindex < llength && rindex < rlength) {
1159
+ result.push(comparefn(left[lindex], right[rindex]) <= 0 ? left[lindex++] : right[rindex++]);
1160
+ } else {
1161
+ result.push(lindex < llength ? left[lindex++] : right[rindex++]);
1162
+ }
1163
+ } return result;
1164
+ };
1165
+
1166
+ var arraySort = mergeSort;
1167
+
1168
+ var arrayMethodIsStrict = function (METHOD_NAME, argument) {
1169
+ var method = [][METHOD_NAME];
1170
+ return !!method && fails(function () {
1171
+ // eslint-disable-next-line no-useless-call,no-throw-literal -- required for testing
1172
+ method.call(null, argument || function () { throw 1; }, 1);
1173
+ });
1174
+ };
1175
+
1176
+ var firefox = engineUserAgent.match(/firefox\/(\d+)/i);
1177
+
1178
+ var engineFfVersion = !!firefox && +firefox[1];
1179
+
1180
+ var engineIsIeOrEdge = /MSIE|Trident/.test(engineUserAgent);
1181
+
1182
+ var webkit = engineUserAgent.match(/AppleWebKit\/(\d+)\./);
1183
+
1184
+ var engineWebkitVersion = !!webkit && +webkit[1];
1185
+
1186
+ var test$1 = [];
1187
+ var nativeSort = test$1.sort;
1188
+
1189
+ // IE8-
1190
+ var FAILS_ON_UNDEFINED = fails(function () {
1191
+ test$1.sort(undefined);
1192
+ });
1193
+ // V8 bug
1194
+ var FAILS_ON_NULL = fails(function () {
1195
+ test$1.sort(null);
1196
+ });
1197
+ // Old WebKit
1198
+ var STRICT_METHOD = arrayMethodIsStrict('sort');
1199
+
1200
+ var STABLE_SORT = !fails(function () {
1201
+ // feature detection can be too slow, so check engines versions
1202
+ if (engineV8Version) return engineV8Version < 70;
1203
+ if (engineFfVersion && engineFfVersion > 3) return;
1204
+ if (engineIsIeOrEdge) return true;
1205
+ if (engineWebkitVersion) return engineWebkitVersion < 603;
1206
+
1207
+ var result = '';
1208
+ var code, chr, value, index;
1209
+
1210
+ // generate an array with more 512 elements (Chakra and old V8 fails only in this case)
1211
+ for (code = 65; code < 76; code++) {
1212
+ chr = String.fromCharCode(code);
1213
+
1214
+ switch (code) {
1215
+ case 66: case 69: case 70: case 72: value = 3; break;
1216
+ case 68: case 71: value = 4; break;
1217
+ default: value = 2;
1218
+ }
1219
+
1220
+ for (index = 0; index < 47; index++) {
1221
+ test$1.push({ k: chr + index, v: value });
1222
+ }
1223
+ }
1224
+
1225
+ test$1.sort(function (a, b) { return b.v - a.v; });
1226
+
1227
+ for (index = 0; index < test$1.length; index++) {
1228
+ chr = test$1[index].k.charAt(0);
1229
+ if (result.charAt(result.length - 1) !== chr) result += chr;
1230
+ }
1231
+
1232
+ return result !== 'DGBEFHACIJK';
1233
+ });
1234
+
1235
+ var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
1236
+
1237
+ var getSortCompare = function (comparefn) {
1238
+ return function (x, y) {
1239
+ if (y === undefined) return -1;
1240
+ if (x === undefined) return 1;
1241
+ if (comparefn !== undefined) return +comparefn(x, y) || 0;
1242
+ return String(x) > String(y) ? 1 : -1;
1243
+ };
1244
+ };
1245
+
1246
+ // `Array.prototype.sort` method
1247
+ // https://tc39.es/ecma262/#sec-array.prototype.sort
1248
+ _export({ target: 'Array', proto: true, forced: FORCED }, {
1249
+ sort: function sort(comparefn) {
1250
+ if (comparefn !== undefined) aFunction(comparefn);
1251
+
1252
+ var array = toObject(this);
1253
+
1254
+ if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn);
1255
+
1256
+ var items = [];
1257
+ var arrayLength = toLength(array.length);
1258
+ var itemsLength, index;
1259
+
1260
+ for (index = 0; index < arrayLength; index++) {
1261
+ if (index in array) items.push(array[index]);
1262
+ }
1263
+
1264
+ items = arraySort(items, getSortCompare(comparefn));
1265
+ itemsLength = items.length;
1266
+ index = 0;
1267
+
1268
+ while (index < itemsLength) array[index] = items[index++];
1269
+ while (index < arrayLength) delete array[index++];
1270
+
1271
+ return array;
1272
+ }
1273
+ });
1274
+
1275
+ var iterators = {};
1276
+
1277
+ var ITERATOR$1 = wellKnownSymbol('iterator');
1278
+ var ArrayPrototype = Array.prototype;
1279
+
1280
+ // check on default Array iterator
1281
+ var isArrayIteratorMethod = function (it) {
1282
+ return it !== undefined && (iterators.Array === it || ArrayPrototype[ITERATOR$1] === it);
1283
+ };
1284
+
1285
+ var TO_STRING_TAG$1 = wellKnownSymbol('toStringTag');
1286
+ var test = {};
1287
+
1288
+ test[TO_STRING_TAG$1] = 'z';
1289
+
1290
+ var toStringTagSupport = String(test) === '[object z]';
1291
+
1292
+ var TO_STRING_TAG = wellKnownSymbol('toStringTag');
1293
+ // ES3 wrong here
1294
+ var CORRECT_ARGUMENTS = classofRaw(function () { return arguments; }()) == 'Arguments';
1295
+
1296
+ // fallback for IE11 Script Access Denied error
1297
+ var tryGet = function (it, key) {
1298
+ try {
1299
+ return it[key];
1300
+ } catch (error) { /* empty */ }
1301
+ };
1302
+
1303
+ // getting tag from ES6+ `Object.prototype.toString`
1304
+ var classof = toStringTagSupport ? classofRaw : function (it) {
1305
+ var O, tag, result;
1306
+ return it === undefined ? 'Undefined' : it === null ? 'Null'
1307
+ // @@toStringTag case
1308
+ : typeof (tag = tryGet(O = Object(it), TO_STRING_TAG)) == 'string' ? tag
1309
+ // builtinTag case
1310
+ : CORRECT_ARGUMENTS ? classofRaw(O)
1311
+ // ES3 arguments fallback
1312
+ : (result = classofRaw(O)) == 'Object' && typeof O.callee == 'function' ? 'Arguments' : result;
1313
+ };
1314
+
1315
+ var ITERATOR = wellKnownSymbol('iterator');
1316
+
1317
+ var getIteratorMethod = function (it) {
1318
+ if (it != undefined) return it[ITERATOR]
1319
+ || it['@@iterator']
1320
+ || iterators[classof(it)];
1321
+ };
1322
+
1323
+ var iteratorClose = function (iterator) {
1324
+ var returnMethod = iterator['return'];
1325
+ if (returnMethod !== undefined) {
1326
+ return anObject(returnMethod.call(iterator)).value;
1327
+ }
1328
+ };
1329
+
1330
+ var Result = function (stopped, result) {
1331
+ this.stopped = stopped;
1332
+ this.result = result;
1333
+ };
1334
+
1335
+ var iterate = function (iterable, unboundFunction, options) {
1336
+ var that = options && options.that;
1337
+ var AS_ENTRIES = !!(options && options.AS_ENTRIES);
1338
+ var IS_ITERATOR = !!(options && options.IS_ITERATOR);
1339
+ var INTERRUPTED = !!(options && options.INTERRUPTED);
1340
+ var fn = functionBindContext(unboundFunction, that, 1 + AS_ENTRIES + INTERRUPTED);
1341
+ var iterator, iterFn, index, length, result, next, step;
1342
+
1343
+ var stop = function (condition) {
1344
+ if (iterator) iteratorClose(iterator);
1345
+ return new Result(true, condition);
1346
+ };
1347
+
1348
+ var callFn = function (value) {
1349
+ if (AS_ENTRIES) {
1350
+ anObject(value);
1351
+ return INTERRUPTED ? fn(value[0], value[1], stop) : fn(value[0], value[1]);
1352
+ } return INTERRUPTED ? fn(value, stop) : fn(value);
1353
+ };
1354
+
1355
+ if (IS_ITERATOR) {
1356
+ iterator = iterable;
1357
+ } else {
1358
+ iterFn = getIteratorMethod(iterable);
1359
+ if (typeof iterFn != 'function') throw TypeError('Target is not iterable');
1360
+ // optimisation for array iterators
1361
+ if (isArrayIteratorMethod(iterFn)) {
1362
+ for (index = 0, length = toLength(iterable.length); length > index; index++) {
1363
+ result = callFn(iterable[index]);
1364
+ if (result && result instanceof Result) return result;
1365
+ } return new Result(false);
1366
+ }
1367
+ iterator = iterFn.call(iterable);
1368
+ }
1369
+
1370
+ next = iterator.next;
1371
+ while (!(step = next.call(iterator)).done) {
1372
+ try {
1373
+ result = callFn(step.value);
1374
+ } catch (error) {
1375
+ iteratorClose(iterator);
1376
+ throw error;
1377
+ }
1378
+ if (typeof result == 'object' && result && result instanceof Result) return result;
1379
+ } return new Result(false);
1380
+ };
1381
+
1382
+ var createProperty = function (object, key, value) {
1383
+ var propertyKey = toPrimitive(key);
1384
+ if (propertyKey in object) objectDefineProperty.f(object, propertyKey, createPropertyDescriptor(0, value));
1385
+ else object[propertyKey] = value;
1386
+ };
1387
+
1388
+ // `Object.fromEntries` method
1389
+ // https://github.com/tc39/proposal-object-from-entries
1390
+ _export({ target: 'Object', stat: true }, {
1391
+ fromEntries: function fromEntries(iterable) {
1392
+ var obj = {};
1393
+ iterate(iterable, function (k, v) {
1394
+ createProperty(obj, k, v);
1395
+ }, { AS_ENTRIES: true });
1396
+ return obj;
1397
+ }
1398
+ });
1399
+
1400
+ var global$1 = (typeof global$1 !== "undefined" ? global$1 :
1401
+ typeof self !== "undefined" ? self :
1402
+ typeof window !== "undefined" ? window : {});
1403
+
1404
+ // shim for using process in browser
1405
+ // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
1406
+
1407
+ function defaultSetTimout() {
1408
+ throw new Error('setTimeout has not been defined');
1409
+ }
1410
+ function defaultClearTimeout () {
1411
+ throw new Error('clearTimeout has not been defined');
1412
+ }
1413
+ var cachedSetTimeout = defaultSetTimout;
1414
+ var cachedClearTimeout = defaultClearTimeout;
1415
+ if (typeof global$1.setTimeout === 'function') {
1416
+ cachedSetTimeout = setTimeout;
1417
+ }
1418
+ if (typeof global$1.clearTimeout === 'function') {
1419
+ cachedClearTimeout = clearTimeout;
1420
+ }
1421
+
1422
+ function runTimeout(fun) {
1423
+ if (cachedSetTimeout === setTimeout) {
1424
+ //normal enviroments in sane situations
1425
+ return setTimeout(fun, 0);
1426
+ }
1427
+ // if setTimeout wasn't available but was latter defined
1428
+ if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
1429
+ cachedSetTimeout = setTimeout;
1430
+ return setTimeout(fun, 0);
1431
+ }
1432
+ try {
1433
+ // when when somebody has screwed with setTimeout but no I.E. maddness
1434
+ return cachedSetTimeout(fun, 0);
1435
+ } catch(e){
1436
+ try {
1437
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1438
+ return cachedSetTimeout.call(null, fun, 0);
1439
+ } catch(e){
1440
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
1441
+ return cachedSetTimeout.call(this, fun, 0);
1442
+ }
1443
+ }
1444
+
1445
+
1446
+ }
1447
+ function runClearTimeout(marker) {
1448
+ if (cachedClearTimeout === clearTimeout) {
1449
+ //normal enviroments in sane situations
1450
+ return clearTimeout(marker);
1451
+ }
1452
+ // if clearTimeout wasn't available but was latter defined
1453
+ if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
1454
+ cachedClearTimeout = clearTimeout;
1455
+ return clearTimeout(marker);
1456
+ }
1457
+ try {
1458
+ // when when somebody has screwed with setTimeout but no I.E. maddness
1459
+ return cachedClearTimeout(marker);
1460
+ } catch (e){
1461
+ try {
1462
+ // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
1463
+ return cachedClearTimeout.call(null, marker);
1464
+ } catch (e){
1465
+ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
1466
+ // Some versions of I.E. have different rules for clearTimeout vs setTimeout
1467
+ return cachedClearTimeout.call(this, marker);
1468
+ }
1469
+ }
1470
+
1471
+
1472
+
1473
+ }
1474
+ var queue = [];
1475
+ var draining = false;
1476
+ var currentQueue;
1477
+ var queueIndex = -1;
1478
+
1479
+ function cleanUpNextTick() {
1480
+ if (!draining || !currentQueue) {
1481
+ return;
1482
+ }
1483
+ draining = false;
1484
+ if (currentQueue.length) {
1485
+ queue = currentQueue.concat(queue);
1486
+ } else {
1487
+ queueIndex = -1;
1488
+ }
1489
+ if (queue.length) {
1490
+ drainQueue();
1491
+ }
1492
+ }
1493
+
1494
+ function drainQueue() {
1495
+ if (draining) {
1496
+ return;
1497
+ }
1498
+ var timeout = runTimeout(cleanUpNextTick);
1499
+ draining = true;
1500
+
1501
+ var len = queue.length;
1502
+ while(len) {
1503
+ currentQueue = queue;
1504
+ queue = [];
1505
+ while (++queueIndex < len) {
1506
+ if (currentQueue) {
1507
+ currentQueue[queueIndex].run();
1508
+ }
1509
+ }
1510
+ queueIndex = -1;
1511
+ len = queue.length;
1512
+ }
1513
+ currentQueue = null;
1514
+ draining = false;
1515
+ runClearTimeout(timeout);
1516
+ }
1517
+ function nextTick(fun) {
1518
+ var args = new Array(arguments.length - 1);
1519
+ if (arguments.length > 1) {
1520
+ for (var i = 1; i < arguments.length; i++) {
1521
+ args[i - 1] = arguments[i];
1522
+ }
1523
+ }
1524
+ queue.push(new Item(fun, args));
1525
+ if (queue.length === 1 && !draining) {
1526
+ runTimeout(drainQueue);
1527
+ }
1528
+ }
1529
+ // v8 likes predictible objects
1530
+ function Item(fun, array) {
1531
+ this.fun = fun;
1532
+ this.array = array;
1533
+ }
1534
+ Item.prototype.run = function () {
1535
+ this.fun.apply(null, this.array);
1536
+ };
1537
+ var title = 'browser';
1538
+ var platform = 'browser';
1539
+ var browser$1 = true;
1540
+ var env = {};
1541
+ var argv = [];
1542
+ var version$1 = ''; // empty string to avoid regexp issues
1543
+ var versions = {};
1544
+ var release = {};
1545
+ var config = {};
1546
+
1547
+ function noop() {}
1548
+
1549
+ var on = noop;
1550
+ var addListener = noop;
1551
+ var once = noop;
1552
+ var off = noop;
1553
+ var removeListener = noop;
1554
+ var removeAllListeners = noop;
1555
+ var emit = noop;
1556
+
1557
+ function binding(name) {
1558
+ throw new Error('process.binding is not supported');
1559
+ }
1560
+
1561
+ function cwd () { return '/' }
1562
+ function chdir (dir) {
1563
+ throw new Error('process.chdir is not supported');
1564
+ }function umask() { return 0; }
1565
+
1566
+ // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
1567
+ var performance = global$1.performance || {};
1568
+ var performanceNow =
1569
+ performance.now ||
1570
+ performance.mozNow ||
1571
+ performance.msNow ||
1572
+ performance.oNow ||
1573
+ performance.webkitNow ||
1574
+ function(){ return (new Date()).getTime() };
1575
+
1576
+ // generate timestamp or delta
1577
+ // see http://nodejs.org/api/process.html#process_process_hrtime
1578
+ function hrtime(previousTimestamp){
1579
+ var clocktime = performanceNow.call(performance)*1e-3;
1580
+ var seconds = Math.floor(clocktime);
1581
+ var nanoseconds = Math.floor((clocktime%1)*1e9);
1582
+ if (previousTimestamp) {
1583
+ seconds = seconds - previousTimestamp[0];
1584
+ nanoseconds = nanoseconds - previousTimestamp[1];
1585
+ if (nanoseconds<0) {
1586
+ seconds--;
1587
+ nanoseconds += 1e9;
1588
+ }
1589
+ }
1590
+ return [seconds,nanoseconds]
1591
+ }
1592
+
1593
+ var startTime = new Date();
1594
+ function uptime() {
1595
+ var currentTime = new Date();
1596
+ var dif = currentTime - startTime;
1597
+ return dif / 1000;
1598
+ }
1599
+
1600
+ var browser$1$1 = {
1601
+ nextTick: nextTick,
1602
+ title: title,
1603
+ browser: browser$1,
1604
+ env: env,
1605
+ argv: argv,
1606
+ version: version$1,
1607
+ versions: versions,
1608
+ on: on,
1609
+ addListener: addListener,
1610
+ once: once,
1611
+ off: off,
1612
+ removeListener: removeListener,
1613
+ removeAllListeners: removeAllListeners,
1614
+ emit: emit,
1615
+ binding: binding,
1616
+ cwd: cwd,
1617
+ chdir: chdir,
1618
+ umask: umask,
1619
+ hrtime: hrtime,
1620
+ platform: platform,
1621
+ release: release,
1622
+ config: config,
1623
+ uptime: uptime
1624
+ };
1625
+
1626
+ const debug = typeof browser$1$1 === 'object' && browser$1$1.env && browser$1$1.env.NODE_DEBUG && /\bsemver\b/i.test(browser$1$1.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
1627
+ var debug_1 = debug;
1628
+
1629
+ // Note: this is the semver.org version of the spec that it implements
1630
+ // Not necessarily the package version of this code.
1631
+ const SEMVER_SPEC_VERSION = '2.0.0';
1632
+ const MAX_LENGTH$1 = 256;
1633
+ const MAX_SAFE_INTEGER$1 = Number.MAX_SAFE_INTEGER ||
1634
+ /* istanbul ignore next */
1635
+ 9007199254740991; // Max safe segment length for coercion.
1636
+
1637
+ const MAX_SAFE_COMPONENT_LENGTH = 16;
1638
+ var constants = {
1639
+ SEMVER_SPEC_VERSION,
1640
+ MAX_LENGTH: MAX_LENGTH$1,
1641
+ MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1,
1642
+ MAX_SAFE_COMPONENT_LENGTH
1643
+ };
1644
+
1645
+ var re_1 = createCommonjsModule(function (module, exports) {
1646
+ const {
1647
+ MAX_SAFE_COMPONENT_LENGTH
1648
+ } = constants;
1649
+ exports = module.exports = {}; // The actual regexps go on exports.re
1650
+
1651
+ const re = exports.re = [];
1652
+ const src = exports.src = [];
1653
+ const t = exports.t = {};
1654
+ let R = 0;
1655
+
1656
+ const createToken = (name, value, isGlobal) => {
1657
+ const index = R++;
1658
+ debug_1(index, value);
1659
+ t[name] = index;
1660
+ src[index] = value;
1661
+ re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
1662
+ }; // The following Regular Expressions can be used for tokenizing,
1663
+ // validating, and parsing SemVer version strings.
1664
+ // ## Numeric Identifier
1665
+ // A single `0`, or a non-zero digit followed by zero or more digits.
1666
+
1667
+
1668
+ createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
1669
+ createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
1670
+ // Zero or more digits, followed by a letter or hyphen, and then zero or
1671
+ // more letters, digits, or hyphens.
1672
+
1673
+ createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
1674
+ // Three dot-separated numeric identifiers.
1675
+
1676
+ createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})\\.` + `(${src[t.NUMERICIDENTIFIER]})`);
1677
+ createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` + `(${src[t.NUMERICIDENTIFIERLOOSE]})`); // ## Pre-release Version Identifier
1678
+ // A numeric identifier, or a non-numeric identifier.
1679
+
1680
+ createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]}|${src[t.NONNUMERICIDENTIFIER]})`);
1681
+ createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]}|${src[t.NONNUMERICIDENTIFIER]})`); // ## Pre-release Version
1682
+ // Hyphen, followed by one or more dot-separated pre-release version
1683
+ // identifiers.
1684
+
1685
+ createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`);
1686
+ createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`); // ## Build Metadata Identifier
1687
+ // Any combination of digits, letters, or hyphens.
1688
+
1689
+ createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
1690
+ // Plus sign, followed by one or more period-separated build metadata
1691
+ // identifiers.
1692
+
1693
+ createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]}(?:\\.${src[t.BUILDIDENTIFIER]})*))`); // ## Full Version String
1694
+ // A main version, followed optionally by a pre-release version and
1695
+ // build metadata.
1696
+ // Note that the only major, minor, patch, and pre-release sections of
1697
+ // the version string are capturing groups. The build metadata is not a
1698
+ // capturing group, because it should not ever be used in version
1699
+ // comparison.
1700
+
1701
+ createToken('FULLPLAIN', `v?${src[t.MAINVERSION]}${src[t.PRERELEASE]}?${src[t.BUILD]}?`);
1702
+ createToken('FULL', `^${src[t.FULLPLAIN]}$`); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
1703
+ // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
1704
+ // common in the npm registry.
1705
+
1706
+ createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]}${src[t.PRERELEASELOOSE]}?${src[t.BUILD]}?`);
1707
+ createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`);
1708
+ createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
1709
+ // Note that "x.x" is a valid xRange identifer, meaning "any version"
1710
+ // Only the first item is strictly required.
1711
+
1712
+ createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`);
1713
+ createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`);
1714
+ createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:\\.(${src[t.XRANGEIDENTIFIER]})` + `(?:${src[t.PRERELEASE]})?${src[t.BUILD]}?` + `)?)?`);
1715
+ createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` + `(?:${src[t.PRERELEASELOOSE]})?${src[t.BUILD]}?` + `)?)?`);
1716
+ createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`);
1717
+ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`); // Coercion.
1718
+ // Extract anything that could conceivably be a part of a valid semver
1719
+
1720
+ createToken('COERCE', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + `(?:$|[^\\d])`);
1721
+ createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
1722
+ // Meaning is "reasonably at or greater than"
1723
+
1724
+ createToken('LONETILDE', '(?:~>?)');
1725
+ createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true);
1726
+ exports.tildeTrimReplace = '$1~';
1727
+ createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`);
1728
+ createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`); // Caret ranges.
1729
+ // Meaning is "at least and backwards compatible with"
1730
+
1731
+ createToken('LONECARET', '(?:\\^)');
1732
+ createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true);
1733
+ exports.caretTrimReplace = '$1^';
1734
+ createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`);
1735
+ createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`); // A simple gt/lt/eq thing, or just "" to indicate "any version"
1736
+
1737
+ createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`);
1738
+ createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`); // An expression to strip any whitespace between the gtlt and the thing
1739
+ // it modifies, so that `> 1.2.3` ==> `>1.2.3`
1740
+
1741
+ createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true);
1742
+ exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
1743
+ // Note that these all use the loose form, because they'll be
1744
+ // checked against either the strict or loose comparator form
1745
+ // later.
1746
+
1747
+ createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAIN]})` + `\\s*$`);
1748
+ createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` + `\\s+-\\s+` + `(${src[t.XRANGEPLAINLOOSE]})` + `\\s*$`); // Star ranges basically just allow anything at all.
1749
+
1750
+ createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
1751
+
1752
+ createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
1753
+ createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
1754
+ });
1755
+
1756
+ // parse out just the options we care about so we always get a consistent
1757
+ // obj with keys in a consistent order.
1758
+ const opts = ['includePrerelease', 'loose', 'rtl'];
1759
+
1760
+ const parseOptions = options => !options ? {} : typeof options !== 'object' ? {
1761
+ loose: true
1762
+ } : opts.filter(k => options[k]).reduce((options, k) => {
1763
+ options[k] = true;
1764
+ return options;
1765
+ }, {});
1766
+
1767
+ var parseOptions_1 = parseOptions;
1768
+
1769
+ const numeric = /^[0-9]+$/;
1770
+
1771
+ const compareIdentifiers$1 = (a, b) => {
1772
+ const anum = numeric.test(a);
1773
+ const bnum = numeric.test(b);
1774
+
1775
+ if (anum && bnum) {
1776
+ a = +a;
1777
+ b = +b;
1778
+ }
1779
+
1780
+ return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
1781
+ };
1782
+
1783
+ const rcompareIdentifiers = (a, b) => compareIdentifiers$1(b, a);
1784
+
1785
+ var identifiers = {
1786
+ compareIdentifiers: compareIdentifiers$1,
1787
+ rcompareIdentifiers
1788
+ };
1789
+
1790
+ const {
1791
+ MAX_LENGTH,
1792
+ MAX_SAFE_INTEGER
1793
+ } = constants;
1794
+ const {
1795
+ re,
1796
+ t
1797
+ } = re_1;
1798
+ const {
1799
+ compareIdentifiers
1800
+ } = identifiers;
1801
+
1802
+ class SemVer {
1803
+ constructor(version, options) {
1804
+ options = parseOptions_1(options);
1805
+
1806
+ if (version instanceof SemVer) {
1807
+ if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
1808
+ return version;
1809
+ } else {
1810
+ version = version.version;
1811
+ }
1812
+ } else if (typeof version !== 'string') {
1813
+ throw new TypeError(`Invalid Version: ${version}`);
1814
+ }
1815
+
1816
+ if (version.length > MAX_LENGTH) {
1817
+ throw new TypeError(`version is longer than ${MAX_LENGTH} characters`);
1818
+ }
1819
+
1820
+ debug_1('SemVer', version, options);
1821
+ this.options = options;
1822
+ this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
1823
+ // don't run into trouble passing this.options around.
1824
+
1825
+ this.includePrerelease = !!options.includePrerelease;
1826
+ const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
1827
+
1828
+ if (!m) {
1829
+ throw new TypeError(`Invalid Version: ${version}`);
1830
+ }
1831
+
1832
+ this.raw = version; // these are actually numbers
1833
+
1834
+ this.major = +m[1];
1835
+ this.minor = +m[2];
1836
+ this.patch = +m[3];
1837
+
1838
+ if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
1839
+ throw new TypeError('Invalid major version');
1840
+ }
1841
+
1842
+ if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
1843
+ throw new TypeError('Invalid minor version');
1844
+ }
1845
+
1846
+ if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
1847
+ throw new TypeError('Invalid patch version');
1848
+ } // numberify any prerelease numeric ids
1849
+
1850
+
1851
+ if (!m[4]) {
1852
+ this.prerelease = [];
1853
+ } else {
1854
+ this.prerelease = m[4].split('.').map(id => {
1855
+ if (/^[0-9]+$/.test(id)) {
1856
+ const num = +id;
1857
+
1858
+ if (num >= 0 && num < MAX_SAFE_INTEGER) {
1859
+ return num;
1860
+ }
1861
+ }
1862
+
1863
+ return id;
1864
+ });
1865
+ }
1866
+
1867
+ this.build = m[5] ? m[5].split('.') : [];
1868
+ this.format();
1869
+ }
1870
+
1871
+ format() {
1872
+ this.version = `${this.major}.${this.minor}.${this.patch}`;
1873
+
1874
+ if (this.prerelease.length) {
1875
+ this.version += `-${this.prerelease.join('.')}`;
1876
+ }
1877
+
1878
+ return this.version;
1879
+ }
1880
+
1881
+ toString() {
1882
+ return this.version;
1883
+ }
1884
+
1885
+ compare(other) {
1886
+ debug_1('SemVer.compare', this.version, this.options, other);
1887
+
1888
+ if (!(other instanceof SemVer)) {
1889
+ if (typeof other === 'string' && other === this.version) {
1890
+ return 0;
1891
+ }
1892
+
1893
+ other = new SemVer(other, this.options);
1894
+ }
1895
+
1896
+ if (other.version === this.version) {
1897
+ return 0;
1898
+ }
1899
+
1900
+ return this.compareMain(other) || this.comparePre(other);
1901
+ }
1902
+
1903
+ compareMain(other) {
1904
+ if (!(other instanceof SemVer)) {
1905
+ other = new SemVer(other, this.options);
1906
+ }
1907
+
1908
+ return compareIdentifiers(this.major, other.major) || compareIdentifiers(this.minor, other.minor) || compareIdentifiers(this.patch, other.patch);
1909
+ }
1910
+
1911
+ comparePre(other) {
1912
+ if (!(other instanceof SemVer)) {
1913
+ other = new SemVer(other, this.options);
1914
+ } // NOT having a prerelease is > having one
1915
+
1916
+
1917
+ if (this.prerelease.length && !other.prerelease.length) {
1918
+ return -1;
1919
+ } else if (!this.prerelease.length && other.prerelease.length) {
1920
+ return 1;
1921
+ } else if (!this.prerelease.length && !other.prerelease.length) {
1922
+ return 0;
1923
+ }
1924
+
1925
+ let i = 0;
1926
+
1927
+ do {
1928
+ const a = this.prerelease[i];
1929
+ const b = other.prerelease[i];
1930
+ debug_1('prerelease compare', i, a, b);
1931
+
1932
+ if (a === undefined && b === undefined) {
1933
+ return 0;
1934
+ } else if (b === undefined) {
1935
+ return 1;
1936
+ } else if (a === undefined) {
1937
+ return -1;
1938
+ } else if (a === b) {
1939
+ continue;
1940
+ } else {
1941
+ return compareIdentifiers(a, b);
1942
+ }
1943
+ } while (++i);
1944
+ }
1945
+
1946
+ compareBuild(other) {
1947
+ if (!(other instanceof SemVer)) {
1948
+ other = new SemVer(other, this.options);
1949
+ }
1950
+
1951
+ let i = 0;
1952
+
1953
+ do {
1954
+ const a = this.build[i];
1955
+ const b = other.build[i];
1956
+ debug_1('prerelease compare', i, a, b);
1957
+
1958
+ if (a === undefined && b === undefined) {
1959
+ return 0;
1960
+ } else if (b === undefined) {
1961
+ return 1;
1962
+ } else if (a === undefined) {
1963
+ return -1;
1964
+ } else if (a === b) {
1965
+ continue;
1966
+ } else {
1967
+ return compareIdentifiers(a, b);
1968
+ }
1969
+ } while (++i);
1970
+ } // preminor will bump the version up to the next minor release, and immediately
1971
+ // down to pre-release. premajor and prepatch work the same way.
1972
+
1973
+
1974
+ inc(release, identifier) {
1975
+ switch (release) {
1976
+ case 'premajor':
1977
+ this.prerelease.length = 0;
1978
+ this.patch = 0;
1979
+ this.minor = 0;
1980
+ this.major++;
1981
+ this.inc('pre', identifier);
1982
+ break;
1983
+
1984
+ case 'preminor':
1985
+ this.prerelease.length = 0;
1986
+ this.patch = 0;
1987
+ this.minor++;
1988
+ this.inc('pre', identifier);
1989
+ break;
1990
+
1991
+ case 'prepatch':
1992
+ // If this is already a prerelease, it will bump to the next version
1993
+ // drop any prereleases that might already exist, since they are not
1994
+ // relevant at this point.
1995
+ this.prerelease.length = 0;
1996
+ this.inc('patch', identifier);
1997
+ this.inc('pre', identifier);
1998
+ break;
1999
+ // If the input is a non-prerelease version, this acts the same as
2000
+ // prepatch.
2001
+
2002
+ case 'prerelease':
2003
+ if (this.prerelease.length === 0) {
2004
+ this.inc('patch', identifier);
2005
+ }
2006
+
2007
+ this.inc('pre', identifier);
2008
+ break;
2009
+
2010
+ case 'major':
2011
+ // If this is a pre-major version, bump up to the same major version.
2012
+ // Otherwise increment major.
2013
+ // 1.0.0-5 bumps to 1.0.0
2014
+ // 1.1.0 bumps to 2.0.0
2015
+ if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
2016
+ this.major++;
2017
+ }
2018
+
2019
+ this.minor = 0;
2020
+ this.patch = 0;
2021
+ this.prerelease = [];
2022
+ break;
2023
+
2024
+ case 'minor':
2025
+ // If this is a pre-minor version, bump up to the same minor version.
2026
+ // Otherwise increment minor.
2027
+ // 1.2.0-5 bumps to 1.2.0
2028
+ // 1.2.1 bumps to 1.3.0
2029
+ if (this.patch !== 0 || this.prerelease.length === 0) {
2030
+ this.minor++;
2031
+ }
2032
+
2033
+ this.patch = 0;
2034
+ this.prerelease = [];
2035
+ break;
2036
+
2037
+ case 'patch':
2038
+ // If this is not a pre-release version, it will increment the patch.
2039
+ // If it is a pre-release it will bump up to the same patch version.
2040
+ // 1.2.0-5 patches to 1.2.0
2041
+ // 1.2.0 patches to 1.2.1
2042
+ if (this.prerelease.length === 0) {
2043
+ this.patch++;
2044
+ }
2045
+
2046
+ this.prerelease = [];
2047
+ break;
2048
+ // This probably shouldn't be used publicly.
2049
+ // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
2050
+
2051
+ case 'pre':
2052
+ if (this.prerelease.length === 0) {
2053
+ this.prerelease = [0];
2054
+ } else {
2055
+ let i = this.prerelease.length;
2056
+
2057
+ while (--i >= 0) {
2058
+ if (typeof this.prerelease[i] === 'number') {
2059
+ this.prerelease[i]++;
2060
+ i = -2;
2061
+ }
2062
+ }
2063
+
2064
+ if (i === -1) {
2065
+ // didn't increment anything
2066
+ this.prerelease.push(0);
2067
+ }
2068
+ }
2069
+
2070
+ if (identifier) {
2071
+ // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
2072
+ // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
2073
+ if (this.prerelease[0] === identifier) {
2074
+ if (isNaN(this.prerelease[1])) {
2075
+ this.prerelease = [identifier, 0];
2076
+ }
2077
+ } else {
2078
+ this.prerelease = [identifier, 0];
2079
+ }
2080
+ }
2081
+
2082
+ break;
2083
+
2084
+ default:
2085
+ throw new Error(`invalid increment argument: ${release}`);
2086
+ }
2087
+
2088
+ this.format();
2089
+ this.raw = this.version;
2090
+ return this;
2091
+ }
2092
+
2093
+ }
2094
+
2095
+ var semver$1 = SemVer;
2096
+
2097
+ const compare = (a, b, loose) => new semver$1(a, loose).compare(new semver$1(b, loose));
2098
+
2099
+ var compare_1 = compare;
2100
+
2101
+ const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
2102
+
2103
+ var lt_1 = lt;
2104
+
2105
+ const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
2106
+
2107
+ var gte_1 = gte;
2108
+
2109
+ var arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
2110
+ [keyName]: key
2111
+ }, value));
2112
+
2113
+ var name = "prettier";
2114
+ var version = "2.3.2";
2115
+ var description = "Prettier is an opinionated code formatter";
2116
+ var bin = "./bin/prettier.js";
2117
+ var repository = "prettier/prettier";
2118
+ var homepage = "https://prettier.io";
2119
+ var author = "James Long";
2120
+ var license = "MIT";
2121
+ var main = "./index.js";
2122
+ var browser = "./standalone.js";
2123
+ var unpkg = "./standalone.js";
2124
+ var engines = {
2125
+ node: ">=12.17.0"
2126
+ };
2127
+ var files = [
2128
+ "index.js",
2129
+ "standalone.js",
2130
+ "src",
2131
+ "bin"
2132
+ ];
2133
+ var dependencies = {
2134
+ "@angular/compiler": "12.0.5",
2135
+ "@babel/code-frame": "7.14.5",
2136
+ "@babel/parser": "7.14.6",
2137
+ "@glimmer/syntax": "0.79.3",
2138
+ "@iarna/toml": "2.2.5",
2139
+ "@typescript-eslint/typescript-estree": "4.27.0",
2140
+ "angular-estree-parser": "2.4.0",
2141
+ "angular-html-parser": "1.8.0",
2142
+ camelcase: "6.2.0",
2143
+ chalk: "4.1.1",
2144
+ "ci-info": "3.2.0",
2145
+ "cjk-regex": "2.0.1",
2146
+ cosmiconfig: "7.0.0",
2147
+ dashify: "2.0.0",
2148
+ diff: "5.0.0",
2149
+ editorconfig: "0.15.3",
2150
+ "editorconfig-to-prettier": "0.2.0",
2151
+ "escape-string-regexp": "4.0.0",
2152
+ espree: "7.3.1",
2153
+ esutils: "2.0.3",
2154
+ "fast-glob": "3.2.5",
2155
+ "fast-json-stable-stringify": "2.1.0",
2156
+ "find-parent-dir": "0.3.1",
2157
+ "flow-parser": "0.153.0",
2158
+ "get-stdin": "8.0.0",
2159
+ globby: "11.0.4",
2160
+ graphql: "15.5.0",
2161
+ "html-element-attributes": "2.3.0",
2162
+ "html-styles": "1.0.0",
2163
+ "html-tag-names": "1.1.5",
2164
+ "html-void-elements": "1.0.5",
2165
+ ignore: "4.0.6",
2166
+ "jest-docblock": "27.0.1",
2167
+ json5: "2.2.0",
2168
+ leven: "3.1.0",
2169
+ "lines-and-columns": "1.1.6",
2170
+ "linguist-languages": "7.15.0",
2171
+ lodash: "4.17.21",
2172
+ mem: "8.1.1",
2173
+ meriyah: "4.1.5",
2174
+ minimatch: "3.0.4",
2175
+ minimist: "1.2.5",
2176
+ "n-readlines": "1.0.1",
2177
+ outdent: "0.8.0",
2178
+ "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
2179
+ "please-upgrade-node": "3.2.0",
2180
+ "postcss-less": "3.1.4",
2181
+ "postcss-media-query-parser": "0.2.3",
2182
+ "postcss-scss": "2.1.1",
2183
+ "postcss-selector-parser": "2.2.3",
2184
+ "postcss-values-parser": "2.0.1",
2185
+ "regexp-util": "1.2.2",
2186
+ "remark-footnotes": "2.0.0",
2187
+ "remark-math": "3.0.1",
2188
+ "remark-parse": "8.0.3",
2189
+ resolve: "1.20.0",
2190
+ semver: "7.3.5",
2191
+ "string-width": "4.2.2",
2192
+ "strip-ansi": "6.0.0",
2193
+ typescript: "4.3.4",
2194
+ "unicode-regex": "3.0.0",
2195
+ unified: "9.2.1",
2196
+ vnopts: "1.0.2",
2197
+ wcwidth: "1.0.1",
2198
+ "yaml-unist-parser": "1.3.1"
2199
+ };
2200
+ var devDependencies = {
2201
+ "@babel/core": "7.14.6",
2202
+ "@babel/preset-env": "7.14.5",
2203
+ "@babel/types": "7.14.5",
2204
+ "@glimmer/reference": "0.79.3",
2205
+ "@rollup/plugin-alias": "3.1.2",
2206
+ "@rollup/plugin-babel": "5.3.0",
2207
+ "@rollup/plugin-commonjs": "18.1.0",
2208
+ "@rollup/plugin-json": "4.1.0",
2209
+ "@rollup/plugin-node-resolve": "13.0.0",
2210
+ "@rollup/plugin-replace": "2.4.2",
2211
+ "@types/estree": "0.0.48",
2212
+ "babel-jest": "27.0.2",
2213
+ "babel-loader": "8.2.2",
2214
+ benchmark: "2.1.4",
2215
+ "builtin-modules": "3.2.0",
2216
+ "core-js": "3.14.0",
2217
+ "cross-env": "7.0.3",
2218
+ cspell: "4.2.8",
2219
+ eslint: "7.29.0",
2220
+ "eslint-config-prettier": "8.3.0",
2221
+ "eslint-formatter-friendly": "7.0.0",
2222
+ "eslint-plugin-import": "2.23.4",
2223
+ "eslint-plugin-jest": "24.3.6",
2224
+ "eslint-plugin-prettier-internal-rules": "link:scripts/tools/eslint-plugin-prettier-internal-rules",
2225
+ "eslint-plugin-react": "7.24.0",
2226
+ "eslint-plugin-regexp": "0.12.1",
2227
+ "eslint-plugin-unicorn": "33.0.1",
2228
+ "esm-utils": "1.1.0",
2229
+ execa: "5.1.1",
2230
+ jest: "27.0.4",
2231
+ "jest-snapshot-serializer-ansi": "1.0.0",
2232
+ "jest-snapshot-serializer-raw": "1.2.0",
2233
+ "jest-watch-typeahead": "0.6.4",
2234
+ "npm-run-all": "4.1.5",
2235
+ "path-browserify": "1.0.1",
2236
+ prettier: "2.3.1",
2237
+ "pretty-bytes": "5.6.0",
2238
+ rimraf: "3.0.2",
2239
+ rollup: "2.52.1",
2240
+ "rollup-plugin-polyfill-node": "0.6.2",
2241
+ "rollup-plugin-terser": "7.0.2",
2242
+ shelljs: "0.8.4",
2243
+ "snapshot-diff": "0.9.0",
2244
+ tempy: "1.0.1",
2245
+ "terser-webpack-plugin": "5.1.3",
2246
+ webpack: "5.39.1"
2247
+ };
2248
+ var scripts = {
2249
+ prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1",
2250
+ "prepare-release": "yarn && yarn build && yarn test:dist",
2251
+ test: "jest",
2252
+ "test:dev-package": "cross-env INSTALL_PACKAGE=1 jest",
2253
+ "test:dist": "cross-env NODE_ENV=production jest",
2254
+ "test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 jest",
2255
+ "test:integration": "jest tests/integration",
2256
+ "perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
2257
+ "perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
2258
+ "perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
2259
+ lint: "run-p lint:*",
2260
+ "lint:typecheck": "tsc",
2261
+ "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
2262
+ "lint:changelog": "node ./scripts/lint-changelog.mjs",
2263
+ "lint:prettier": "prettier . \"!test*\" --check",
2264
+ "lint:dist": "eslint --no-eslintrc --no-ignore --no-inline-config --env=es6,browser --parser-options=ecmaVersion:2019 \"dist/!(bin-prettier|index|third-party).js\"",
2265
+ "lint:spellcheck": "cspell \"**/*\" \".github/**/*\"",
2266
+ "lint:deps": "node ./scripts/check-deps.mjs",
2267
+ fix: "run-s fix:eslint fix:prettier",
2268
+ "fix:eslint": "yarn lint:eslint --fix",
2269
+ "fix:prettier": "yarn lint:prettier --write",
2270
+ build: "node --max-old-space-size=3072 ./scripts/build/build.mjs",
2271
+ "build-docs": "node ./scripts/build-docs.mjs"
2272
+ };
2273
+ var require$$3 = {
2274
+ name: name,
2275
+ version: version,
2276
+ description: description,
2277
+ bin: bin,
2278
+ repository: repository,
2279
+ homepage: homepage,
2280
+ author: author,
2281
+ license: license,
2282
+ main: main,
2283
+ browser: browser,
2284
+ unpkg: unpkg,
2285
+ engines: engines,
2286
+ files: files,
2287
+ dependencies: dependencies,
2288
+ devDependencies: devDependencies,
2289
+ scripts: scripts
2290
+ };
2291
+
2292
+ var lib = createCommonjsModule(function (module, exports) {
2293
+
2294
+ Object.defineProperty(exports, "__esModule", {
2295
+ value: true
2296
+ });
2297
+ exports.outdent = void 0; // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
2298
+
2299
+ function noop() {
2300
+ var args = [];
2301
+
2302
+ for (var _i = 0; _i < arguments.length; _i++) {
2303
+ args[_i] = arguments[_i];
2304
+ }
2305
+ }
2306
+
2307
+ function createWeakMap() {
2308
+ if (typeof WeakMap !== "undefined") {
2309
+ return new WeakMap();
2310
+ } else {
2311
+ return fakeSetOrMap();
2312
+ }
2313
+ }
2314
+ /**
2315
+ * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
2316
+ */
2317
+
2318
+
2319
+ function fakeSetOrMap() {
2320
+ return {
2321
+ add: noop,
2322
+ delete: noop,
2323
+ get: noop,
2324
+ set: noop,
2325
+ has: function (k) {
2326
+ return false;
2327
+ }
2328
+ };
2329
+ } // Safe hasOwnProperty
2330
+
2331
+
2332
+ var hop = Object.prototype.hasOwnProperty;
2333
+
2334
+ var has = function (obj, prop) {
2335
+ return hop.call(obj, prop);
2336
+ }; // Copy all own enumerable properties from source to target
2337
+
2338
+
2339
+ function extend(target, source) {
2340
+ for (var prop in source) {
2341
+ if (has(source, prop)) {
2342
+ target[prop] = source[prop];
2343
+ }
2344
+ }
2345
+
2346
+ return target;
2347
+ }
2348
+
2349
+ var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
2350
+ var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
2351
+ var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
2352
+ var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
2353
+ var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
2354
+
2355
+ function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
2356
+ // If first interpolated value is a reference to outdent,
2357
+ // determine indentation level from the indentation of the interpolated value.
2358
+ var indentationLevel = 0;
2359
+ var match = strings[0].match(reDetectIndentation);
2360
+
2361
+ if (match) {
2362
+ indentationLevel = match[1].length;
2363
+ }
2364
+
2365
+ var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
2366
+ var reMatchIndent = new RegExp(reSource, "g");
2367
+
2368
+ if (firstInterpolatedValueSetsIndentationLevel) {
2369
+ strings = strings.slice(1);
2370
+ }
2371
+
2372
+ var newline = options.newline,
2373
+ trimLeadingNewline = options.trimLeadingNewline,
2374
+ trimTrailingNewline = options.trimTrailingNewline;
2375
+ var normalizeNewlines = typeof newline === "string";
2376
+ var l = strings.length;
2377
+ var outdentedStrings = strings.map(function (v, i) {
2378
+ // Remove leading indentation from all lines
2379
+ v = v.replace(reMatchIndent, "$1"); // Trim a leading newline from the first string
2380
+
2381
+ if (i === 0 && trimLeadingNewline) {
2382
+ v = v.replace(reLeadingNewline, "");
2383
+ } // Trim a trailing newline from the last string
2384
+
2385
+
2386
+ if (i === l - 1 && trimTrailingNewline) {
2387
+ v = v.replace(reTrailingNewline, "");
2388
+ } // Normalize newlines
2389
+
2390
+
2391
+ if (normalizeNewlines) {
2392
+ v = v.replace(/\r\n|\n|\r/g, function (_) {
2393
+ return newline;
2394
+ });
2395
+ }
2396
+
2397
+ return v;
2398
+ });
2399
+ return outdentedStrings;
2400
+ }
2401
+
2402
+ function concatStringsAndValues(strings, values) {
2403
+ var ret = "";
2404
+
2405
+ for (var i = 0, l = strings.length; i < l; i++) {
2406
+ ret += strings[i];
2407
+
2408
+ if (i < l - 1) {
2409
+ ret += values[i];
2410
+ }
2411
+ }
2412
+
2413
+ return ret;
2414
+ }
2415
+
2416
+ function isTemplateStringsArray(v) {
2417
+ return has(v, "raw") && has(v, "length");
2418
+ }
2419
+ /**
2420
+ * It is assumed that opts will not change. If this is a problem, clone your options object and pass the clone to
2421
+ * makeInstance
2422
+ * @param options
2423
+ * @return {outdent}
2424
+ */
2425
+
2426
+
2427
+ function createInstance(options) {
2428
+ /** Cache of pre-processed template literal arrays */
2429
+ var arrayAutoIndentCache = createWeakMap();
2430
+ /**
2431
+ * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
2432
+ * before interpolated values are injected.
2433
+ */
2434
+
2435
+ var arrayFirstInterpSetsIndentCache = createWeakMap();
2436
+
2437
+ function outdent(stringsOrOptions) {
2438
+ var values = [];
2439
+
2440
+ for (var _i = 1; _i < arguments.length; _i++) {
2441
+ values[_i - 1] = arguments[_i];
2442
+ }
2443
+ /* tslint:enable:no-shadowed-variable */
2444
+
2445
+
2446
+ if (isTemplateStringsArray(stringsOrOptions)) {
2447
+ var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
2448
+
2449
+ var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
2450
+
2451
+ var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
2452
+ var renderedArray = cache.get(strings);
2453
+
2454
+ if (!renderedArray) {
2455
+ renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
2456
+ cache.set(strings, renderedArray);
2457
+ }
2458
+ /** If no interpolated values, skip concatenation step */
2459
+
2460
+
2461
+ if (values.length === 0) {
2462
+ return renderedArray[0];
2463
+ }
2464
+ /** Concatenate string literals with interpolated values */
2465
+
2466
+
2467
+ var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
2468
+ return rendered;
2469
+ } else {
2470
+ // Create and return a new instance of outdent with the given options
2471
+ return createInstance(extend(extend({}, options), stringsOrOptions || {}));
2472
+ }
2473
+ }
2474
+
2475
+ var fullOutdent = extend(outdent, {
2476
+ string: function (str) {
2477
+ return _outdentArray([str], false, options)[0];
2478
+ }
2479
+ });
2480
+ return fullOutdent;
2481
+ }
2482
+
2483
+ var defaultOutdent = createInstance({
2484
+ trimLeadingNewline: true,
2485
+ trimTrailingNewline: true
2486
+ });
2487
+ exports.outdent = defaultOutdent; // Named exports. Simple and preferred.
2488
+ // import outdent from 'outdent';
2489
+
2490
+ exports.default = defaultOutdent;
2491
+
2492
+ {
2493
+ // In webpack harmony-modules environments, module.exports is read-only,
2494
+ // so we fail gracefully.
2495
+ try {
2496
+ module.exports = defaultOutdent;
2497
+ Object.defineProperty(defaultOutdent, "__esModule", {
2498
+ value: true
2499
+ });
2500
+ defaultOutdent.default = defaultOutdent;
2501
+ defaultOutdent.outdent = defaultOutdent;
2502
+ } catch (e) {}
2503
+ }
2504
+ });
2505
+
2506
+ const {
2507
+ outdent
2508
+ } = lib;
2509
+ const CATEGORY_CONFIG = "Config";
2510
+ const CATEGORY_EDITOR = "Editor";
2511
+ const CATEGORY_FORMAT = "Format";
2512
+ const CATEGORY_OTHER = "Other";
2513
+ const CATEGORY_OUTPUT = "Output";
2514
+ const CATEGORY_GLOBAL = "Global";
2515
+ const CATEGORY_SPECIAL = "Special";
2516
+ /**
2517
+ * @typedef {Object} OptionInfo
2518
+ * @property {string} [since] - available since version
2519
+ * @property {string} category
2520
+ * @property {'int' | 'boolean' | 'choice' | 'path'} type
2521
+ * @property {boolean} [array] - indicate it's an array of the specified type
2522
+ * @property {OptionValueInfo} [default]
2523
+ * @property {OptionRangeInfo} [range] - for type int
2524
+ * @property {string} description
2525
+ * @property {string} [deprecated] - deprecated since version
2526
+ * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
2527
+ * @property {(value: any) => boolean} [exception]
2528
+ * @property {OptionChoiceInfo[]} [choices] - for type choice
2529
+ * @property {string} [cliName]
2530
+ * @property {string} [cliCategory]
2531
+ * @property {string} [cliDescription]
2532
+ *
2533
+ * @typedef {number | boolean | string} OptionValue
2534
+ * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
2535
+ *
2536
+ * @typedef {Object} OptionRedirectInfo
2537
+ * @property {string} option
2538
+ * @property {OptionValue} value
2539
+ *
2540
+ * @typedef {Object} OptionRangeInfo
2541
+ * @property {number} start - recommended range start
2542
+ * @property {number} end - recommended range end
2543
+ * @property {number} step - recommended range step
2544
+ *
2545
+ * @typedef {Object} OptionChoiceInfo
2546
+ * @property {boolean | string} value - boolean for the option that is originally boolean type
2547
+ * @property {string} description
2548
+ * @property {string} [since] - undefined if available since the first version of the option
2549
+ * @property {string} [deprecated] - deprecated since version
2550
+ * @property {OptionValueInfo} [redirect] - redirect deprecated value
2551
+ */
2552
+
2553
+ /** @type {{ [name: string]: OptionInfo }} */
2554
+
2555
+ const options = {
2556
+ cursorOffset: {
2557
+ since: "1.4.0",
2558
+ category: CATEGORY_SPECIAL,
2559
+ type: "int",
2560
+ default: -1,
2561
+ range: {
2562
+ start: -1,
2563
+ end: Number.POSITIVE_INFINITY,
2564
+ step: 1
2565
+ },
2566
+ description: outdent`
2567
+ Print (to stderr) where a cursor at the given position would move to after formatting.
2568
+ This option cannot be used with --range-start and --range-end.
2569
+ `,
2570
+ cliCategory: CATEGORY_EDITOR
2571
+ },
2572
+ endOfLine: {
2573
+ since: "1.15.0",
2574
+ category: CATEGORY_GLOBAL,
2575
+ type: "choice",
2576
+ default: [{
2577
+ since: "1.15.0",
2578
+ value: "auto"
2579
+ }, {
2580
+ since: "2.0.0",
2581
+ value: "lf"
2582
+ }],
2583
+ description: "Which end of line characters to apply.",
2584
+ choices: [{
2585
+ value: "lf",
2586
+ description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
2587
+ }, {
2588
+ value: "crlf",
2589
+ description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
2590
+ }, {
2591
+ value: "cr",
2592
+ description: "Carriage Return character only (\\r), used very rarely"
2593
+ }, {
2594
+ value: "auto",
2595
+ description: outdent`
2596
+ Maintain existing
2597
+ (mixed values within one file are normalised by looking at what's used after the first line)
2598
+ `
2599
+ }]
2600
+ },
2601
+ filepath: {
2602
+ since: "1.4.0",
2603
+ category: CATEGORY_SPECIAL,
2604
+ type: "path",
2605
+ description: "Specify the input filepath. This will be used to do parser inference.",
2606
+ cliName: "stdin-filepath",
2607
+ cliCategory: CATEGORY_OTHER,
2608
+ cliDescription: "Path to the file to pretend that stdin comes from."
2609
+ },
2610
+ insertPragma: {
2611
+ since: "1.8.0",
2612
+ category: CATEGORY_SPECIAL,
2613
+ type: "boolean",
2614
+ default: false,
2615
+ description: "Insert @format pragma into file's first docblock comment.",
2616
+ cliCategory: CATEGORY_OTHER
2617
+ },
2618
+ parser: {
2619
+ since: "0.0.10",
2620
+ category: CATEGORY_GLOBAL,
2621
+ type: "choice",
2622
+ default: [{
2623
+ since: "0.0.10",
2624
+ value: "babylon"
2625
+ }, {
2626
+ since: "1.13.0",
2627
+ value: undefined
2628
+ }],
2629
+ description: "Which parser to use.",
2630
+ exception: value => typeof value === "string" || typeof value === "function",
2631
+ choices: [{
2632
+ value: "flow",
2633
+ description: "Flow"
2634
+ }, {
2635
+ value: "babel",
2636
+ since: "1.16.0",
2637
+ description: "JavaScript"
2638
+ }, {
2639
+ value: "babel-flow",
2640
+ since: "1.16.0",
2641
+ description: "Flow"
2642
+ }, {
2643
+ value: "babel-ts",
2644
+ since: "2.0.0",
2645
+ description: "TypeScript"
2646
+ }, {
2647
+ value: "typescript",
2648
+ since: "1.4.0",
2649
+ description: "TypeScript"
2650
+ }, {
2651
+ value: "espree",
2652
+ since: "2.2.0",
2653
+ description: "JavaScript"
2654
+ }, {
2655
+ value: "meriyah",
2656
+ since: "2.2.0",
2657
+ description: "JavaScript"
2658
+ }, {
2659
+ value: "css",
2660
+ since: "1.7.1",
2661
+ description: "CSS"
2662
+ }, {
2663
+ value: "less",
2664
+ since: "1.7.1",
2665
+ description: "Less"
2666
+ }, {
2667
+ value: "scss",
2668
+ since: "1.7.1",
2669
+ description: "SCSS"
2670
+ }, {
2671
+ value: "json",
2672
+ since: "1.5.0",
2673
+ description: "JSON"
2674
+ }, {
2675
+ value: "json5",
2676
+ since: "1.13.0",
2677
+ description: "JSON5"
2678
+ }, {
2679
+ value: "json-stringify",
2680
+ since: "1.13.0",
2681
+ description: "JSON.stringify"
2682
+ }, {
2683
+ value: "graphql",
2684
+ since: "1.5.0",
2685
+ description: "GraphQL"
2686
+ }, {
2687
+ value: "markdown",
2688
+ since: "1.8.0",
2689
+ description: "Markdown"
2690
+ }, {
2691
+ value: "mdx",
2692
+ since: "1.15.0",
2693
+ description: "MDX"
2694
+ }, {
2695
+ value: "vue",
2696
+ since: "1.10.0",
2697
+ description: "Vue"
2698
+ }, {
2699
+ value: "yaml",
2700
+ since: "1.14.0",
2701
+ description: "YAML"
2702
+ }, {
2703
+ value: "glimmer",
2704
+ since: "2.3.0",
2705
+ description: "Ember / Handlebars"
2706
+ }, {
2707
+ value: "html",
2708
+ since: "1.15.0",
2709
+ description: "HTML"
2710
+ }, {
2711
+ value: "angular",
2712
+ since: "1.15.0",
2713
+ description: "Angular"
2714
+ }, {
2715
+ value: "lwc",
2716
+ since: "1.17.0",
2717
+ description: "Lightning Web Components"
2718
+ }]
2719
+ },
2720
+ plugins: {
2721
+ since: "1.10.0",
2722
+ type: "path",
2723
+ array: true,
2724
+ default: [{
2725
+ value: []
2726
+ }],
2727
+ category: CATEGORY_GLOBAL,
2728
+ description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
2729
+ exception: value => typeof value === "string" || typeof value === "object",
2730
+ cliName: "plugin",
2731
+ cliCategory: CATEGORY_CONFIG
2732
+ },
2733
+ pluginSearchDirs: {
2734
+ since: "1.13.0",
2735
+ type: "path",
2736
+ array: true,
2737
+ default: [{
2738
+ value: []
2739
+ }],
2740
+ category: CATEGORY_GLOBAL,
2741
+ description: outdent`
2742
+ Custom directory that contains prettier plugins in node_modules subdirectory.
2743
+ Overrides default behavior when plugins are searched relatively to the location of Prettier.
2744
+ Multiple values are accepted.
2745
+ `,
2746
+ exception: value => typeof value === "string" || typeof value === "object",
2747
+ cliName: "plugin-search-dir",
2748
+ cliCategory: CATEGORY_CONFIG
2749
+ },
2750
+ printWidth: {
2751
+ since: "0.0.0",
2752
+ category: CATEGORY_GLOBAL,
2753
+ type: "int",
2754
+ default: 80,
2755
+ description: "The line length where Prettier will try wrap.",
2756
+ range: {
2757
+ start: 0,
2758
+ end: Number.POSITIVE_INFINITY,
2759
+ step: 1
2760
+ }
2761
+ },
2762
+ rangeEnd: {
2763
+ since: "1.4.0",
2764
+ category: CATEGORY_SPECIAL,
2765
+ type: "int",
2766
+ default: Number.POSITIVE_INFINITY,
2767
+ range: {
2768
+ start: 0,
2769
+ end: Number.POSITIVE_INFINITY,
2770
+ step: 1
2771
+ },
2772
+ description: outdent`
2773
+ Format code ending at a given character offset (exclusive).
2774
+ The range will extend forwards to the end of the selected statement.
2775
+ This option cannot be used with --cursor-offset.
2776
+ `,
2777
+ cliCategory: CATEGORY_EDITOR
2778
+ },
2779
+ rangeStart: {
2780
+ since: "1.4.0",
2781
+ category: CATEGORY_SPECIAL,
2782
+ type: "int",
2783
+ default: 0,
2784
+ range: {
2785
+ start: 0,
2786
+ end: Number.POSITIVE_INFINITY,
2787
+ step: 1
2788
+ },
2789
+ description: outdent`
2790
+ Format code starting at a given character offset.
2791
+ The range will extend backwards to the start of the first line containing the selected statement.
2792
+ This option cannot be used with --cursor-offset.
2793
+ `,
2794
+ cliCategory: CATEGORY_EDITOR
2795
+ },
2796
+ requirePragma: {
2797
+ since: "1.7.0",
2798
+ category: CATEGORY_SPECIAL,
2799
+ type: "boolean",
2800
+ default: false,
2801
+ description: outdent`
2802
+ Require either '@prettier' or '@format' to be present in the file's first docblock comment
2803
+ in order for it to be formatted.
2804
+ `,
2805
+ cliCategory: CATEGORY_OTHER
2806
+ },
2807
+ tabWidth: {
2808
+ type: "int",
2809
+ category: CATEGORY_GLOBAL,
2810
+ default: 2,
2811
+ description: "Number of spaces per indentation level.",
2812
+ range: {
2813
+ start: 0,
2814
+ end: Number.POSITIVE_INFINITY,
2815
+ step: 1
2816
+ }
2817
+ },
2818
+ useTabs: {
2819
+ since: "1.0.0",
2820
+ category: CATEGORY_GLOBAL,
2821
+ type: "boolean",
2822
+ default: false,
2823
+ description: "Indent with tabs instead of spaces."
2824
+ },
2825
+ embeddedLanguageFormatting: {
2826
+ since: "2.1.0",
2827
+ category: CATEGORY_GLOBAL,
2828
+ type: "choice",
2829
+ default: [{
2830
+ since: "2.1.0",
2831
+ value: "auto"
2832
+ }],
2833
+ description: "Control how Prettier formats quoted code embedded in the file.",
2834
+ choices: [{
2835
+ value: "auto",
2836
+ description: "Format embedded code if Prettier can automatically identify it."
2837
+ }, {
2838
+ value: "off",
2839
+ description: "Never automatically format embedded code."
2840
+ }]
2841
+ }
2842
+ };
2843
+ var coreOptions$1 = {
2844
+ CATEGORY_CONFIG,
2845
+ CATEGORY_EDITOR,
2846
+ CATEGORY_FORMAT,
2847
+ CATEGORY_OTHER,
2848
+ CATEGORY_OUTPUT,
2849
+ CATEGORY_GLOBAL,
2850
+ CATEGORY_SPECIAL,
2851
+ options
2852
+ };
2853
+
2854
+ const _excluded = ["cliName", "cliCategory", "cliDescription"];
2855
+
2856
+ const semver = {
2857
+ compare: compare_1,
2858
+ lt: lt_1,
2859
+ gte: gte_1
2860
+ };
2861
+ const currentVersion = require$$3.version;
2862
+ const coreOptions = coreOptions$1.options;
2863
+ /**
2864
+ * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
2865
+ * of this function created by `withPlugins`. Don't pass them here directly.
2866
+ * @param {object} param0
2867
+ * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
2868
+ * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
2869
+ * @param {boolean=} param0.showUnreleased
2870
+ * @param {boolean=} param0.showDeprecated
2871
+ * @param {boolean=} param0.showInternal
2872
+ */
2873
+
2874
+ function getSupportInfo$1({
2875
+ plugins = [],
2876
+ showUnreleased = false,
2877
+ showDeprecated = false,
2878
+ showInternal = false
2879
+ } = {}) {
2880
+ // pre-release version is smaller than the normal version in semver,
2881
+ // we need to treat it as the normal one so as to test new features.
2882
+ const version = currentVersion.split("-", 1)[0];
2883
+ const languages = plugins.flatMap(plugin => plugin.languages || []).filter(filterSince);
2884
+ const options = arrayify(Object.assign({}, ...plugins.map(({
2885
+ options
2886
+ }) => options), coreOptions), "name").filter(option => filterSince(option) && filterDeprecated(option)).sort((a, b) => a.name === b.name ? 0 : a.name < b.name ? -1 : 1).map(mapInternal).map(option => {
2887
+ option = Object.assign({}, option);
2888
+
2889
+ if (Array.isArray(option.default)) {
2890
+ option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver.compare(info2.since, info1.since))[0].value;
2891
+ }
2892
+
2893
+ if (Array.isArray(option.choices)) {
2894
+ option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
2895
+
2896
+ if (option.name === "parser") {
2897
+ collectParsersFromLanguages(option, languages, plugins);
2898
+ }
2899
+ }
2900
+
2901
+ const pluginDefaults = Object.fromEntries(plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).map(plugin => [plugin.name, plugin.defaultOptions[option.name]]));
2902
+ return Object.assign(Object.assign({}, option), {}, {
2903
+ pluginDefaults
2904
+ });
2905
+ });
2906
+ return {
2907
+ languages,
2908
+ options
2909
+ };
2910
+
2911
+ function filterSince(object) {
2912
+ return showUnreleased || !("since" in object) || object.since && semver.gte(version, object.since);
2913
+ }
2914
+
2915
+ function filterDeprecated(object) {
2916
+ return showDeprecated || !("deprecated" in object) || object.deprecated && semver.lt(version, object.deprecated);
2917
+ }
2918
+
2919
+ function mapInternal(object) {
2920
+ if (showInternal) {
2921
+ return object;
2922
+ }
2923
+
2924
+ const newObject = _objectWithoutProperties(object, _excluded);
2925
+
2926
+ return newObject;
2927
+ }
2928
+ }
2929
+
2930
+ function collectParsersFromLanguages(option, languages, plugins) {
2931
+ const existingValues = new Set(option.choices.map(choice => choice.value));
2932
+
2933
+ for (const language of languages) {
2934
+ if (language.parsers) {
2935
+ for (const value of language.parsers) {
2936
+ if (!existingValues.has(value)) {
2937
+ existingValues.add(value);
2938
+ const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
2939
+ let description = language.name;
2940
+
2941
+ if (plugin && plugin.name) {
2942
+ description += ` (plugin: ${plugin.name})`;
2943
+ }
2944
+
2945
+ option.choices.push({
2946
+ value,
2947
+ description
2948
+ });
2949
+ }
2950
+ }
2951
+ }
2952
+ }
2953
+ }
2954
+
2955
+ var support = {
2956
+ getSupportInfo: getSupportInfo$1
2957
+ };
2958
+
2959
+ const {
2960
+ getSupportInfo
2961
+ } = support;
2962
+ const notAsciiRegex = /[^\x20-\x7F]/;
2963
+
2964
+ const getPenultimate = arr => arr[arr.length - 2];
2965
+ /**
2966
+ * @typedef {{backwards?: boolean}} SkipOptions
2967
+ */
2968
+
2969
+ /**
2970
+ * @param {string | RegExp} chars
2971
+ * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2972
+ */
2973
+
2974
+
2975
+ function skip(chars) {
2976
+ return (text, index, opts) => {
2977
+ const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
2978
+ // to check for failures (did someone say monads?).
2979
+
2980
+ /* istanbul ignore next */
2981
+
2982
+ if (index === false) {
2983
+ return false;
2984
+ }
2985
+
2986
+ const {
2987
+ length
2988
+ } = text;
2989
+ let cursor = index;
2990
+
2991
+ while (cursor >= 0 && cursor < length) {
2992
+ const c = text.charAt(cursor);
2993
+
2994
+ if (chars instanceof RegExp) {
2995
+ if (!chars.test(c)) {
2996
+ return cursor;
2997
+ }
2998
+ } else if (!chars.includes(c)) {
2999
+ return cursor;
3000
+ }
3001
+
3002
+ backwards ? cursor-- : cursor++;
3003
+ }
3004
+
3005
+ if (cursor === -1 || cursor === length) {
3006
+ // If we reached the beginning or end of the file, return the
3007
+ // out-of-bounds cursor. It's up to the caller to handle this
3008
+ // correctly. We don't want to indicate `false` though if it
3009
+ // actually skipped valid characters.
3010
+ return cursor;
3011
+ }
3012
+
3013
+ return false;
3014
+ };
3015
+ }
3016
+ /**
3017
+ * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3018
+ */
3019
+
3020
+
3021
+ const skipWhitespace = skip(/\s/);
3022
+ /**
3023
+ * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3024
+ */
3025
+
3026
+ const skipSpaces = skip(" \t");
3027
+ /**
3028
+ * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3029
+ */
3030
+
3031
+ const skipToLineEnd = skip(",; \t");
3032
+ /**
3033
+ * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
3034
+ */
3035
+
3036
+ const skipEverythingButNewLine = skip(/[^\n\r]/);
3037
+ /**
3038
+ * @param {string} text
3039
+ * @param {number | false} index
3040
+ * @returns {number | false}
3041
+ */
3042
+
3043
+ function skipInlineComment(text, index) {
3044
+ /* istanbul ignore next */
3045
+ if (index === false) {
3046
+ return false;
3047
+ }
3048
+
3049
+ if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
3050
+ for (let i = index + 2; i < text.length; ++i) {
3051
+ if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
3052
+ return i + 2;
3053
+ }
3054
+ }
3055
+ }
3056
+
3057
+ return index;
3058
+ }
3059
+ /**
3060
+ * @param {string} text
3061
+ * @param {number | false} index
3062
+ * @returns {number | false}
3063
+ */
3064
+
3065
+
3066
+ function skipTrailingComment(text, index) {
3067
+ /* istanbul ignore next */
3068
+ if (index === false) {
3069
+ return false;
3070
+ }
3071
+
3072
+ if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
3073
+ return skipEverythingButNewLine(text, index);
3074
+ }
3075
+
3076
+ return index;
3077
+ } // This one doesn't use the above helper function because it wants to
3078
+ // test \r\n in order and `skip` doesn't support ordering and we only
3079
+ // want to skip one newline. It's simple to implement.
3080
+
3081
+ /**
3082
+ * @param {string} text
3083
+ * @param {number | false} index
3084
+ * @param {SkipOptions=} opts
3085
+ * @returns {number | false}
3086
+ */
3087
+
3088
+
3089
+ function skipNewline(text, index, opts) {
3090
+ const backwards = opts && opts.backwards;
3091
+
3092
+ if (index === false) {
3093
+ return false;
3094
+ }
3095
+
3096
+ const atIndex = text.charAt(index);
3097
+
3098
+ if (backwards) {
3099
+ // We already replace `\r\n` with `\n` before parsing
3100
+
3101
+ /* istanbul ignore next */
3102
+ if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
3103
+ return index - 2;
3104
+ }
3105
+
3106
+ if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
3107
+ return index - 1;
3108
+ }
3109
+ } else {
3110
+ // We already replace `\r\n` with `\n` before parsing
3111
+
3112
+ /* istanbul ignore next */
3113
+ if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
3114
+ return index + 2;
3115
+ }
3116
+
3117
+ if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
3118
+ return index + 1;
3119
+ }
3120
+ }
3121
+
3122
+ return index;
3123
+ }
3124
+ /**
3125
+ * @param {string} text
3126
+ * @param {number} index
3127
+ * @param {SkipOptions=} opts
3128
+ * @returns {boolean}
3129
+ */
3130
+
3131
+
3132
+ function hasNewline(text, index, opts = {}) {
3133
+ const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
3134
+ const idx2 = skipNewline(text, idx, opts);
3135
+ return idx !== idx2;
3136
+ }
3137
+ /**
3138
+ * @param {string} text
3139
+ * @param {number} start
3140
+ * @param {number} end
3141
+ * @returns {boolean}
3142
+ */
3143
+
3144
+
3145
+ function hasNewlineInRange(text, start, end) {
3146
+ for (let i = start; i < end; ++i) {
3147
+ if (text.charAt(i) === "\n") {
3148
+ return true;
3149
+ }
3150
+ }
3151
+
3152
+ return false;
3153
+ } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
3154
+
3155
+ /**
3156
+ * @template N
3157
+ * @param {string} text
3158
+ * @param {N} node
3159
+ * @param {(node: N) => number} locStart
3160
+ */
3161
+
3162
+
3163
+ function isPreviousLineEmpty(text, node, locStart) {
3164
+ /** @type {number | false} */
3165
+ let idx = locStart(node) - 1;
3166
+ idx = skipSpaces(text, idx, {
3167
+ backwards: true
3168
+ });
3169
+ idx = skipNewline(text, idx, {
3170
+ backwards: true
3171
+ });
3172
+ idx = skipSpaces(text, idx, {
3173
+ backwards: true
3174
+ });
3175
+ const idx2 = skipNewline(text, idx, {
3176
+ backwards: true
3177
+ });
3178
+ return idx !== idx2;
3179
+ }
3180
+ /**
3181
+ * @param {string} text
3182
+ * @param {number} index
3183
+ * @returns {boolean}
3184
+ */
3185
+
3186
+
3187
+ function isNextLineEmptyAfterIndex(text, index) {
3188
+ /** @type {number | false} */
3189
+ let oldIdx = null;
3190
+ /** @type {number | false} */
3191
+
3192
+ let idx = index;
3193
+
3194
+ while (idx !== oldIdx) {
3195
+ // We need to skip all the potential trailing inline comments
3196
+ oldIdx = idx;
3197
+ idx = skipToLineEnd(text, idx);
3198
+ idx = skipInlineComment(text, idx);
3199
+ idx = skipSpaces(text, idx);
3200
+ }
3201
+
3202
+ idx = skipTrailingComment(text, idx);
3203
+ idx = skipNewline(text, idx);
3204
+ return idx !== false && hasNewline(text, idx);
3205
+ }
3206
+ /**
3207
+ * @template N
3208
+ * @param {string} text
3209
+ * @param {N} node
3210
+ * @param {(node: N) => number} locEnd
3211
+ * @returns {boolean}
3212
+ */
3213
+
3214
+
3215
+ function isNextLineEmpty(text, node, locEnd) {
3216
+ return isNextLineEmptyAfterIndex(text, locEnd(node));
3217
+ }
3218
+ /**
3219
+ * @param {string} text
3220
+ * @param {number} idx
3221
+ * @returns {number | false}
3222
+ */
3223
+
3224
+
3225
+ function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
3226
+ /** @type {number | false} */
3227
+ let oldIdx = null;
3228
+ /** @type {number | false} */
3229
+
3230
+ let nextIdx = idx;
3231
+
3232
+ while (nextIdx !== oldIdx) {
3233
+ oldIdx = nextIdx;
3234
+ nextIdx = skipSpaces(text, nextIdx);
3235
+ nextIdx = skipInlineComment(text, nextIdx);
3236
+ nextIdx = skipTrailingComment(text, nextIdx);
3237
+ nextIdx = skipNewline(text, nextIdx);
3238
+ }
3239
+
3240
+ return nextIdx;
3241
+ }
3242
+ /**
3243
+ * @template N
3244
+ * @param {string} text
3245
+ * @param {N} node
3246
+ * @param {(node: N) => number} locEnd
3247
+ * @returns {number | false}
3248
+ */
3249
+
3250
+
3251
+ function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
3252
+ return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
3253
+ }
3254
+ /**
3255
+ * @template N
3256
+ * @param {string} text
3257
+ * @param {N} node
3258
+ * @param {(node: N) => number} locEnd
3259
+ * @returns {string}
3260
+ */
3261
+
3262
+
3263
+ function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
3264
+ return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback?
3265
+ getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
3266
+ } // Not using, but it's public utils
3267
+
3268
+ /* istanbul ignore next */
3269
+
3270
+ /**
3271
+ * @param {string} text
3272
+ * @param {number} index
3273
+ * @param {SkipOptions=} opts
3274
+ * @returns {boolean}
3275
+ */
3276
+
3277
+
3278
+ function hasSpaces(text, index, opts = {}) {
3279
+ const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
3280
+ return idx !== index;
3281
+ }
3282
+ /**
3283
+ * @param {string} value
3284
+ * @param {number} tabWidth
3285
+ * @param {number=} startIndex
3286
+ * @returns {number}
3287
+ */
3288
+
3289
+
3290
+ function getAlignmentSize(value, tabWidth, startIndex = 0) {
3291
+ let size = 0;
3292
+
3293
+ for (let i = startIndex; i < value.length; ++i) {
3294
+ if (value[i] === "\t") {
3295
+ // Tabs behave in a way that they are aligned to the nearest
3296
+ // multiple of tabWidth:
3297
+ // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
3298
+ // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
3299
+ size = size + tabWidth - size % tabWidth;
3300
+ } else {
3301
+ size++;
3302
+ }
3303
+ }
3304
+
3305
+ return size;
3306
+ }
3307
+ /**
3308
+ * @param {string} value
3309
+ * @param {number} tabWidth
3310
+ * @returns {number}
3311
+ */
3312
+
3313
+
3314
+ function getIndentSize(value, tabWidth) {
3315
+ const lastNewlineIndex = value.lastIndexOf("\n");
3316
+
3317
+ if (lastNewlineIndex === -1) {
3318
+ return 0;
3319
+ }
3320
+
3321
+ return getAlignmentSize( // All the leading whitespaces
3322
+ value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
3323
+ }
3324
+ /**
3325
+ * @typedef {'"' | "'"} Quote
3326
+ */
3327
+
3328
+ /**
3329
+ *
3330
+ * @param {string} raw
3331
+ * @param {Quote} preferredQuote
3332
+ * @returns {Quote}
3333
+ */
3334
+
3335
+
3336
+ function getPreferredQuote(raw, preferredQuote) {
3337
+ // `rawContent` is the string exactly like it appeared in the input source
3338
+ // code, without its enclosing quotes.
3339
+ const rawContent = raw.slice(1, -1);
3340
+ /** @type {{ quote: '"', regex: RegExp }} */
3341
+
3342
+ const double = {
3343
+ quote: '"',
3344
+ regex: /"/g
3345
+ };
3346
+ /** @type {{ quote: "'", regex: RegExp }} */
3347
+
3348
+ const single = {
3349
+ quote: "'",
3350
+ regex: /'/g
3351
+ };
3352
+ const preferred = preferredQuote === "'" ? single : double;
3353
+ const alternate = preferred === single ? double : single;
3354
+ let result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
3355
+ // the string, we might want to enclose with the alternate quote instead, to
3356
+ // minimize the number of escaped quotes.
3357
+
3358
+ if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
3359
+ const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
3360
+ const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
3361
+ result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
3362
+ }
3363
+
3364
+ return result;
3365
+ }
3366
+
3367
+ function printString(raw, options) {
3368
+ // `rawContent` is the string exactly like it appeared in the input source
3369
+ // code, without its enclosing quotes.
3370
+ const rawContent = raw.slice(1, -1);
3371
+ /** @type {Quote} */
3372
+
3373
+ const enclosingQuote = options.parser === "json" || options.parser === "json5" && options.quoteProps === "preserve" && !options.singleQuote ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // It might sound unnecessary to use `makeString` even if the string already
3374
+ // is enclosed with `enclosingQuote`, but it isn't. The string could contain
3375
+ // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
3376
+ // sure that we consistently output the minimum amount of escaped quotes.
3377
+
3378
+ return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.__embeddedInHtml));
3379
+ }
3380
+ /**
3381
+ * @param {string} rawContent
3382
+ * @param {Quote} enclosingQuote
3383
+ * @param {boolean=} unescapeUnnecessaryEscapes
3384
+ * @returns {string}
3385
+ */
3386
+
3387
+
3388
+ function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
3389
+ const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
3390
+
3391
+ const regex = /\\(.)|(["'])/gs; // Escape and unescape single and double quotes as needed to be able to
3392
+ // enclose `rawContent` with `enclosingQuote`.
3393
+
3394
+ const newContent = rawContent.replace(regex, (match, escaped, quote) => {
3395
+ // If we matched an escape, and the escaped character is a quote of the
3396
+ // other type than we intend to enclose the string with, there's no need for
3397
+ // it to be escaped, so return it _without_ the backslash.
3398
+ if (escaped === otherQuote) {
3399
+ return escaped;
3400
+ } // If we matched an unescaped quote and it is of the _same_ type as we
3401
+ // intend to enclose the string with, it must be escaped, so return it with
3402
+ // a backslash.
3403
+
3404
+
3405
+ if (quote === enclosingQuote) {
3406
+ return "\\" + quote;
3407
+ }
3408
+
3409
+ if (quote) {
3410
+ return quote;
3411
+ } // Unescape any unnecessarily escaped character.
3412
+ // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
3413
+
3414
+
3415
+ return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
3416
+ });
3417
+ return enclosingQuote + newContent + enclosingQuote;
3418
+ }
3419
+
3420
+ function printNumber(rawNumber) {
3421
+ return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
3422
+ .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
3423
+ .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
3424
+ .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
3425
+ .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
3426
+ .replace(/\.(?=e|$)/, "");
3427
+ }
3428
+ /**
3429
+ * @param {string} str
3430
+ * @param {string} target
3431
+ * @returns {number}
3432
+ */
3433
+
3434
+
3435
+ function getMaxContinuousCount(str, target) {
3436
+ const results = str.match(new RegExp(`(${escapeStringRegexp(target)})+`, "g"));
3437
+
3438
+ if (results === null) {
3439
+ return 0;
3440
+ }
3441
+
3442
+ return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
3443
+ }
3444
+
3445
+ function getMinNotPresentContinuousCount(str, target) {
3446
+ const matches = str.match(new RegExp(`(${escapeStringRegexp(target)})+`, "g"));
3447
+
3448
+ if (matches === null) {
3449
+ return 0;
3450
+ }
3451
+
3452
+ const countPresent = new Map();
3453
+ let max = 0;
3454
+
3455
+ for (const match of matches) {
3456
+ const count = match.length / target.length;
3457
+ countPresent.set(count, true);
3458
+
3459
+ if (count > max) {
3460
+ max = count;
3461
+ }
3462
+ }
3463
+
3464
+ for (let i = 1; i < max; i++) {
3465
+ if (!countPresent.get(i)) {
3466
+ return i;
3467
+ }
3468
+ }
3469
+
3470
+ return max + 1;
3471
+ }
3472
+ /**
3473
+ * @param {string} text
3474
+ * @returns {number}
3475
+ */
3476
+
3477
+
3478
+ function getStringWidth$1(text) {
3479
+ if (!text) {
3480
+ return 0;
3481
+ } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
3482
+
3483
+
3484
+ if (!notAsciiRegex.test(text)) {
3485
+ return text.length;
3486
+ }
3487
+
3488
+ return stringWidth_1(text);
3489
+ }
3490
+
3491
+ function addCommentHelper(node, comment) {
3492
+ const comments = node.comments || (node.comments = []);
3493
+ comments.push(comment);
3494
+ comment.printed = false;
3495
+ comment.nodeDescription = describeNodeForDebugging(node);
3496
+ }
3497
+
3498
+ function addLeadingComment(node, comment) {
3499
+ comment.leading = true;
3500
+ comment.trailing = false;
3501
+ addCommentHelper(node, comment);
3502
+ }
3503
+
3504
+ function addDanglingComment(node, comment, marker) {
3505
+ comment.leading = false;
3506
+ comment.trailing = false;
3507
+
3508
+ if (marker) {
3509
+ comment.marker = marker;
3510
+ }
3511
+
3512
+ addCommentHelper(node, comment);
3513
+ }
3514
+
3515
+ function addTrailingComment(node, comment) {
3516
+ comment.leading = false;
3517
+ comment.trailing = true;
3518
+ addCommentHelper(node, comment);
3519
+ }
3520
+
3521
+ function inferParserByLanguage(language, options) {
3522
+ const {
3523
+ languages
3524
+ } = getSupportInfo({
3525
+ plugins: options.plugins
3526
+ });
3527
+ const matched = languages.find(({
3528
+ name
3529
+ }) => name.toLowerCase() === language) || languages.find(({
3530
+ aliases
3531
+ }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
3532
+ extensions
3533
+ }) => Array.isArray(extensions) && extensions.includes(`.${language}`));
3534
+ return matched && matched.parsers[0];
3535
+ }
3536
+
3537
+ function isFrontMatterNode(node) {
3538
+ return node && node.type === "front-matter";
3539
+ }
3540
+
3541
+ function getShebang(text) {
3542
+ if (!text.startsWith("#!")) {
3543
+ return "";
3544
+ }
3545
+
3546
+ const index = text.indexOf("\n");
3547
+
3548
+ if (index === -1) {
3549
+ return text;
3550
+ }
3551
+
3552
+ return text.slice(0, index);
3553
+ }
3554
+ /**
3555
+ * @param {any} object
3556
+ * @returns {object is Array<any>}
3557
+ */
3558
+
3559
+
3560
+ function isNonEmptyArray(object) {
3561
+ return Array.isArray(object) && object.length > 0;
3562
+ }
3563
+ /**
3564
+ * @param {string} description
3565
+ * @returns {(node: any) => symbol}
3566
+ */
3567
+
3568
+
3569
+ function createGroupIdMapper(description) {
3570
+ const groupIds = new WeakMap();
3571
+ return function (node) {
3572
+ if (!groupIds.has(node)) {
3573
+ groupIds.set(node, Symbol(description));
3574
+ }
3575
+
3576
+ return groupIds.get(node);
3577
+ };
3578
+ }
3579
+
3580
+ function describeNodeForDebugging(node) {
3581
+ const nodeType = node.type || node.kind || "(unknown type)";
3582
+ let nodeName = String(node.name || node.id && (typeof node.id === "object" ? node.id.name : node.id) || node.key && (typeof node.key === "object" ? node.key.name : node.key) || node.value && (typeof node.value === "object" ? "" : String(node.value)) || node.operator || "");
3583
+
3584
+ if (nodeName.length > 20) {
3585
+ nodeName = nodeName.slice(0, 19) + "…";
3586
+ }
3587
+
3588
+ return nodeType + (nodeName ? " " + nodeName : "");
3589
+ }
3590
+
3591
+ var util = {
3592
+ inferParserByLanguage,
3593
+ getStringWidth: getStringWidth$1,
3594
+ getMaxContinuousCount,
3595
+ getMinNotPresentContinuousCount,
3596
+ getPenultimate,
3597
+ getLast: getLast_1,
3598
+ getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
3599
+ getNextNonSpaceNonCommentCharacterIndex,
3600
+ getNextNonSpaceNonCommentCharacter,
3601
+ skip,
3602
+ skipWhitespace,
3603
+ skipSpaces,
3604
+ skipToLineEnd,
3605
+ skipEverythingButNewLine,
3606
+ skipInlineComment,
3607
+ skipTrailingComment,
3608
+ skipNewline,
3609
+ isNextLineEmptyAfterIndex,
3610
+ isNextLineEmpty,
3611
+ isPreviousLineEmpty,
3612
+ hasNewline,
3613
+ hasNewlineInRange,
3614
+ hasSpaces,
3615
+ getAlignmentSize,
3616
+ getIndentSize,
3617
+ getPreferredQuote,
3618
+ printString,
3619
+ printNumber,
3620
+ makeString,
3621
+ addLeadingComment,
3622
+ addDanglingComment,
3623
+ addTrailingComment,
3624
+ isFrontMatterNode,
3625
+ getShebang,
3626
+ isNonEmptyArray,
3627
+ createGroupIdMapper
3628
+ };
3629
+
3630
+ function guessEndOfLine(text) {
3631
+ const index = text.indexOf("\r");
3632
+
3633
+ if (index >= 0) {
3634
+ return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
3635
+ }
3636
+
3637
+ return "lf";
3638
+ }
3639
+
3640
+ function convertEndOfLineToChars$1(value) {
3641
+ switch (value) {
3642
+ case "cr":
3643
+ return "\r";
3644
+
3645
+ case "crlf":
3646
+ return "\r\n";
3647
+
3648
+ default:
3649
+ return "\n";
3650
+ }
3651
+ }
3652
+
3653
+ function countEndOfLineChars(text, eol) {
3654
+ let regex;
3655
+ /* istanbul ignore else */
3656
+
3657
+ if (eol === "\n") {
3658
+ regex = /\n/g;
3659
+ } else if (eol === "\r") {
3660
+ regex = /\r/g;
3661
+ } else if (eol === "\r\n") {
3662
+ regex = /\r\n/g;
3663
+ } else {
3664
+ throw new Error(`Unexpected "eol" ${JSON.stringify(eol)}.`);
3665
+ }
3666
+
3667
+ const endOfLines = text.match(regex);
3668
+ return endOfLines ? endOfLines.length : 0;
3669
+ }
3670
+
3671
+ function normalizeEndOfLine(text) {
3672
+ return text.replace(/\r\n?/g, "\n");
3673
+ }
3674
+
3675
+ var endOfLine = {
3676
+ guessEndOfLine,
3677
+ convertEndOfLineToChars: convertEndOfLineToChars$1,
3678
+ countEndOfLineChars,
3679
+ normalizeEndOfLine
3680
+ };
3681
+
3682
+ const {
3683
+ literalline,
3684
+ join
3685
+ } = docBuilders;
3686
+
3687
+ const isConcat$2 = doc => Array.isArray(doc) || doc && doc.type === "concat";
3688
+
3689
+ const getDocParts$2 = doc => {
3690
+ if (Array.isArray(doc)) {
3691
+ return doc;
3692
+ }
3693
+ /* istanbul ignore next */
3694
+
3695
+
3696
+ if (doc.type !== "concat" && doc.type !== "fill") {
3697
+ throw new Error("Expect doc type to be `concat` or `fill`.");
3698
+ }
3699
+
3700
+ return doc.parts;
3701
+ }; // Using a unique object to compare by reference.
3702
+
3703
+
3704
+ const traverseDocOnExitStackMarker = {};
3705
+
3706
+ function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
3707
+ const docsStack = [doc];
3708
+
3709
+ while (docsStack.length > 0) {
3710
+ const doc = docsStack.pop();
3711
+
3712
+ if (doc === traverseDocOnExitStackMarker) {
3713
+ onExit(docsStack.pop());
3714
+ continue;
3715
+ }
3716
+
3717
+ if (onExit) {
3718
+ docsStack.push(doc, traverseDocOnExitStackMarker);
3719
+ }
3720
+
3721
+ if ( // Should Recurse
3722
+ !onEnter || onEnter(doc) !== false) {
3723
+ // When there are multiple parts to process,
3724
+ // the parts need to be pushed onto the stack in reverse order,
3725
+ // so that they are processed in the original order
3726
+ // when the stack is popped.
3727
+ if (isConcat$2(doc) || doc.type === "fill") {
3728
+ const parts = getDocParts$2(doc);
3729
+
3730
+ for (let ic = parts.length, i = ic - 1; i >= 0; --i) {
3731
+ docsStack.push(parts[i]);
3732
+ }
3733
+ } else if (doc.type === "if-break") {
3734
+ if (doc.flatContents) {
3735
+ docsStack.push(doc.flatContents);
3736
+ }
3737
+
3738
+ if (doc.breakContents) {
3739
+ docsStack.push(doc.breakContents);
3740
+ }
3741
+ } else if (doc.type === "group" && doc.expandedStates) {
3742
+ if (shouldTraverseConditionalGroups) {
3743
+ for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
3744
+ docsStack.push(doc.expandedStates[i]);
3745
+ }
3746
+ } else {
3747
+ docsStack.push(doc.contents);
3748
+ }
3749
+ } else if (doc.contents) {
3750
+ docsStack.push(doc.contents);
3751
+ }
3752
+ }
3753
+ }
3754
+ }
3755
+
3756
+ function mapDoc(doc, cb) {
3757
+ // Within a doc tree, the same subtrees can be found multiple times.
3758
+ // E.g., often this happens in conditional groups.
3759
+ // As an optimization (those subtrees can be huge) and to maintain the
3760
+ // reference structure of the tree, the mapping results are cached in
3761
+ // a map and reused.
3762
+ const mapped = new Map();
3763
+ return rec(doc);
3764
+
3765
+ function rec(doc) {
3766
+ if (mapped.has(doc)) {
3767
+ return mapped.get(doc);
3768
+ }
3769
+
3770
+ const result = process(doc);
3771
+ mapped.set(doc, result);
3772
+ return result;
3773
+ }
3774
+
3775
+ function process(doc) {
3776
+ if (Array.isArray(doc)) {
3777
+ return cb(doc.map(rec));
3778
+ }
3779
+
3780
+ if (doc.type === "concat" || doc.type === "fill") {
3781
+ const parts = doc.parts.map(rec);
3782
+ return cb(Object.assign(Object.assign({}, doc), {}, {
3783
+ parts
3784
+ }));
3785
+ }
3786
+
3787
+ if (doc.type === "if-break") {
3788
+ const breakContents = doc.breakContents && rec(doc.breakContents);
3789
+ const flatContents = doc.flatContents && rec(doc.flatContents);
3790
+ return cb(Object.assign(Object.assign({}, doc), {}, {
3791
+ breakContents,
3792
+ flatContents
3793
+ }));
3794
+ }
3795
+
3796
+ if (doc.type === "group" && doc.expandedStates) {
3797
+ const expandedStates = doc.expandedStates.map(rec);
3798
+ const contents = expandedStates[0];
3799
+ return cb(Object.assign(Object.assign({}, doc), {}, {
3800
+ contents,
3801
+ expandedStates
3802
+ }));
3803
+ }
3804
+
3805
+ if (doc.contents) {
3806
+ const contents = rec(doc.contents);
3807
+ return cb(Object.assign(Object.assign({}, doc), {}, {
3808
+ contents
3809
+ }));
3810
+ }
3811
+
3812
+ return cb(doc);
3813
+ }
3814
+ }
3815
+
3816
+ function findInDoc(doc, fn, defaultValue) {
3817
+ let result = defaultValue;
3818
+ let hasStopped = false;
3819
+
3820
+ function findInDocOnEnterFn(doc) {
3821
+ const maybeResult = fn(doc);
3822
+
3823
+ if (maybeResult !== undefined) {
3824
+ hasStopped = true;
3825
+ result = maybeResult;
3826
+ }
3827
+
3828
+ if (hasStopped) {
3829
+ return false;
3830
+ }
3831
+ }
3832
+
3833
+ traverseDoc(doc, findInDocOnEnterFn);
3834
+ return result;
3835
+ }
3836
+
3837
+ function willBreakFn(doc) {
3838
+ if (doc.type === "group" && doc.break) {
3839
+ return true;
3840
+ }
3841
+
3842
+ if (doc.type === "line" && doc.hard) {
3843
+ return true;
3844
+ }
3845
+
3846
+ if (doc.type === "break-parent") {
3847
+ return true;
3848
+ }
3849
+ }
3850
+
3851
+ function willBreak(doc) {
3852
+ return findInDoc(doc, willBreakFn, false);
3853
+ }
3854
+
3855
+ function breakParentGroup(groupStack) {
3856
+ if (groupStack.length > 0) {
3857
+ const parentGroup = getLast_1(groupStack); // Breaks are not propagated through conditional groups because
3858
+ // the user is expected to manually handle what breaks.
3859
+
3860
+ if (!parentGroup.expandedStates && !parentGroup.break) {
3861
+ // An alternative truthy value allows to distinguish propagated group breaks
3862
+ // and not to print them as `group(..., { break: true })` in `--debug-print-doc`.
3863
+ parentGroup.break = "propagated";
3864
+ }
3865
+ }
3866
+
3867
+ return null;
3868
+ }
3869
+
3870
+ function propagateBreaks(doc) {
3871
+ const alreadyVisitedSet = new Set();
3872
+ const groupStack = [];
3873
+
3874
+ function propagateBreaksOnEnterFn(doc) {
3875
+ if (doc.type === "break-parent") {
3876
+ breakParentGroup(groupStack);
3877
+ }
3878
+
3879
+ if (doc.type === "group") {
3880
+ groupStack.push(doc);
3881
+
3882
+ if (alreadyVisitedSet.has(doc)) {
3883
+ return false;
3884
+ }
3885
+
3886
+ alreadyVisitedSet.add(doc);
3887
+ }
3888
+ }
3889
+
3890
+ function propagateBreaksOnExitFn(doc) {
3891
+ if (doc.type === "group") {
3892
+ const group = groupStack.pop();
3893
+
3894
+ if (group.break) {
3895
+ breakParentGroup(groupStack);
3896
+ }
3897
+ }
3898
+ }
3899
+
3900
+ traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
3901
+ /* shouldTraverseConditionalGroups */
3902
+ true);
3903
+ }
3904
+
3905
+ function removeLinesFn(doc) {
3906
+ // Force this doc into flat mode by statically converting all
3907
+ // lines into spaces (or soft lines into nothing). Hard lines
3908
+ // should still output because there's too great of a chance
3909
+ // of breaking existing assumptions otherwise.
3910
+ if (doc.type === "line" && !doc.hard) {
3911
+ return doc.soft ? "" : " ";
3912
+ }
3913
+
3914
+ if (doc.type === "if-break") {
3915
+ return doc.flatContents || "";
3916
+ }
3917
+
3918
+ return doc;
3919
+ }
3920
+
3921
+ function removeLines(doc) {
3922
+ return mapDoc(doc, removeLinesFn);
3923
+ }
3924
+
3925
+ const isHardline = (doc, nextDoc) => doc && doc.type === "line" && doc.hard && nextDoc && nextDoc.type === "break-parent";
3926
+
3927
+ function stripDocTrailingHardlineFromDoc(doc) {
3928
+ if (!doc) {
3929
+ return doc;
3930
+ }
3931
+
3932
+ if (isConcat$2(doc) || doc.type === "fill") {
3933
+ const parts = getDocParts$2(doc);
3934
+
3935
+ while (parts.length > 1 && isHardline(...parts.slice(-2))) {
3936
+ parts.length -= 2;
3937
+ }
3938
+
3939
+ if (parts.length > 0) {
3940
+ const lastPart = stripDocTrailingHardlineFromDoc(getLast_1(parts));
3941
+ parts[parts.length - 1] = lastPart;
3942
+ }
3943
+
3944
+ return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
3945
+ parts
3946
+ });
3947
+ }
3948
+
3949
+ switch (doc.type) {
3950
+ case "align":
3951
+ case "indent":
3952
+ case "indent-if-break":
3953
+ case "group":
3954
+ case "line-suffix":
3955
+ case "label":
3956
+ {
3957
+ const contents = stripDocTrailingHardlineFromDoc(doc.contents);
3958
+ return Object.assign(Object.assign({}, doc), {}, {
3959
+ contents
3960
+ });
3961
+ }
3962
+
3963
+ case "if-break":
3964
+ {
3965
+ const breakContents = stripDocTrailingHardlineFromDoc(doc.breakContents);
3966
+ const flatContents = stripDocTrailingHardlineFromDoc(doc.flatContents);
3967
+ return Object.assign(Object.assign({}, doc), {}, {
3968
+ breakContents,
3969
+ flatContents
3970
+ });
3971
+ }
3972
+ }
3973
+
3974
+ return doc;
3975
+ }
3976
+
3977
+ function stripTrailingHardline(doc) {
3978
+ // HACK remove ending hardline, original PR: #1984
3979
+ return stripDocTrailingHardlineFromDoc(cleanDoc(doc));
3980
+ }
3981
+
3982
+ function cleanDocFn(doc) {
3983
+ switch (doc.type) {
3984
+ case "fill":
3985
+ if (doc.parts.length === 0 || doc.parts.every(part => part === "")) {
3986
+ return "";
3987
+ }
3988
+
3989
+ break;
3990
+
3991
+ case "group":
3992
+ if (!doc.contents && !doc.id && !doc.break && !doc.expandedStates) {
3993
+ return "";
3994
+ } // Remove nested only group
3995
+
3996
+
3997
+ if (doc.contents.type === "group" && doc.contents.id === doc.id && doc.contents.break === doc.break && doc.contents.expandedStates === doc.expandedStates) {
3998
+ return doc.contents;
3999
+ }
4000
+
4001
+ break;
4002
+
4003
+ case "align":
4004
+ case "indent":
4005
+ case "indent-if-break":
4006
+ case "line-suffix":
4007
+ if (!doc.contents) {
4008
+ return "";
4009
+ }
4010
+
4011
+ break;
4012
+
4013
+ case "if-break":
4014
+ if (!doc.flatContents && !doc.breakContents) {
4015
+ return "";
4016
+ }
4017
+
4018
+ break;
4019
+ }
4020
+
4021
+ if (!isConcat$2(doc)) {
4022
+ return doc;
4023
+ }
4024
+
4025
+ const parts = [];
4026
+
4027
+ for (const part of getDocParts$2(doc)) {
4028
+ if (!part) {
4029
+ continue;
4030
+ }
4031
+
4032
+ const [currentPart, ...restParts] = isConcat$2(part) ? getDocParts$2(part) : [part];
4033
+
4034
+ if (typeof currentPart === "string" && typeof getLast_1(parts) === "string") {
4035
+ parts[parts.length - 1] += currentPart;
4036
+ } else {
4037
+ parts.push(currentPart);
4038
+ }
4039
+
4040
+ parts.push(...restParts);
4041
+ }
4042
+
4043
+ if (parts.length === 0) {
4044
+ return "";
4045
+ }
4046
+
4047
+ if (parts.length === 1) {
4048
+ return parts[0];
4049
+ }
4050
+
4051
+ return Array.isArray(doc) ? parts : Object.assign(Object.assign({}, doc), {}, {
4052
+ parts
4053
+ });
4054
+ } // A safer version of `normalizeDoc`
4055
+ // - `normalizeDoc` concat strings and flat "concat" in `fill`, while `cleanDoc` don't
4056
+ // - On `concat` object, `normalizeDoc` always return object with `parts`, `cleanDoc` may return strings
4057
+ // - `cleanDoc` also remove nested `group`s and empty `fill`/`align`/`indent`/`line-suffix`/`if-break` if possible
4058
+
4059
+
4060
+ function cleanDoc(doc) {
4061
+ return mapDoc(doc, currentDoc => cleanDocFn(currentDoc));
4062
+ }
4063
+
4064
+ function normalizeParts(parts) {
4065
+ const newParts = [];
4066
+ const restParts = parts.filter(Boolean);
4067
+
4068
+ while (restParts.length > 0) {
4069
+ const part = restParts.shift();
4070
+
4071
+ if (!part) {
4072
+ continue;
4073
+ }
4074
+
4075
+ if (isConcat$2(part)) {
4076
+ restParts.unshift(...getDocParts$2(part));
4077
+ continue;
4078
+ }
4079
+
4080
+ if (newParts.length > 0 && typeof getLast_1(newParts) === "string" && typeof part === "string") {
4081
+ newParts[newParts.length - 1] += part;
4082
+ continue;
4083
+ }
4084
+
4085
+ newParts.push(part);
4086
+ }
4087
+
4088
+ return newParts;
4089
+ }
4090
+
4091
+ function normalizeDoc(doc) {
4092
+ return mapDoc(doc, currentDoc => {
4093
+ if (Array.isArray(currentDoc)) {
4094
+ return normalizeParts(currentDoc);
4095
+ }
4096
+
4097
+ if (!currentDoc.parts) {
4098
+ return currentDoc;
4099
+ }
4100
+
4101
+ return Object.assign(Object.assign({}, currentDoc), {}, {
4102
+ parts: normalizeParts(currentDoc.parts)
4103
+ });
4104
+ });
4105
+ }
4106
+
4107
+ function replaceNewlinesWithLiterallines(doc) {
4108
+ return mapDoc(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? join(literalline, currentDoc.split("\n")) : currentDoc);
4109
+ } // This function need return array
4110
+ // TODO: remove `.parts` when we remove `docBuilders.concat()`
4111
+
4112
+
4113
+ function replaceEndOfLineWith(text, replacement) {
4114
+ return join(replacement, text.split("\n")).parts;
4115
+ }
4116
+
4117
+ var docUtils = {
4118
+ isConcat: isConcat$2,
4119
+ getDocParts: getDocParts$2,
4120
+ willBreak,
4121
+ traverseDoc,
4122
+ findInDoc,
4123
+ mapDoc,
4124
+ propagateBreaks,
4125
+ removeLines,
4126
+ stripTrailingHardline,
4127
+ normalizeParts,
4128
+ normalizeDoc,
4129
+ cleanDoc,
4130
+ replaceEndOfLineWith,
4131
+ replaceNewlinesWithLiterallines
4132
+ };
4133
+
4134
+ const {
4135
+ getStringWidth,
4136
+ getLast
4137
+ } = util;
4138
+ const {
4139
+ convertEndOfLineToChars
4140
+ } = endOfLine;
4141
+ const {
4142
+ fill,
4143
+ cursor,
4144
+ indent
4145
+ } = docBuilders;
4146
+ const {
4147
+ isConcat: isConcat$1,
4148
+ getDocParts: getDocParts$1
4149
+ } = docUtils;
4150
+ /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */
4151
+
4152
+ let groupModeMap;
4153
+ const MODE_BREAK = 1;
4154
+ const MODE_FLAT = 2;
4155
+
4156
+ function rootIndent() {
4157
+ return {
4158
+ value: "",
4159
+ length: 0,
4160
+ queue: []
4161
+ };
4162
+ }
4163
+
4164
+ function makeIndent(ind, options) {
4165
+ return generateInd(ind, {
4166
+ type: "indent"
4167
+ }, options);
4168
+ }
4169
+
4170
+ function makeAlign(indent, widthOrDoc, options) {
4171
+ if (widthOrDoc === Number.NEGATIVE_INFINITY) {
4172
+ return indent.root || rootIndent();
4173
+ }
4174
+
4175
+ if (widthOrDoc < 0) {
4176
+ return generateInd(indent, {
4177
+ type: "dedent"
4178
+ }, options);
4179
+ }
4180
+
4181
+ if (!widthOrDoc) {
4182
+ return indent;
4183
+ }
4184
+
4185
+ if (widthOrDoc.type === "root") {
4186
+ return Object.assign(Object.assign({}, indent), {}, {
4187
+ root: indent
4188
+ });
4189
+ }
4190
+
4191
+ const alignType = typeof widthOrDoc === "string" ? "stringAlign" : "numberAlign";
4192
+ return generateInd(indent, {
4193
+ type: alignType,
4194
+ n: widthOrDoc
4195
+ }, options);
4196
+ }
4197
+
4198
+ function generateInd(ind, newPart, options) {
4199
+ const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : [...ind.queue, newPart];
4200
+ let value = "";
4201
+ let length = 0;
4202
+ let lastTabs = 0;
4203
+ let lastSpaces = 0;
4204
+
4205
+ for (const part of queue) {
4206
+ switch (part.type) {
4207
+ case "indent":
4208
+ flush();
4209
+
4210
+ if (options.useTabs) {
4211
+ addTabs(1);
4212
+ } else {
4213
+ addSpaces(options.tabWidth);
4214
+ }
4215
+
4216
+ break;
4217
+
4218
+ case "stringAlign":
4219
+ flush();
4220
+ value += part.n;
4221
+ length += part.n.length;
4222
+ break;
4223
+
4224
+ case "numberAlign":
4225
+ lastTabs += 1;
4226
+ lastSpaces += part.n;
4227
+ break;
4228
+
4229
+ /* istanbul ignore next */
4230
+
4231
+ default:
4232
+ throw new Error(`Unexpected type '${part.type}'`);
4233
+ }
4234
+ }
4235
+
4236
+ flushSpaces();
4237
+ return Object.assign(Object.assign({}, ind), {}, {
4238
+ value,
4239
+ length,
4240
+ queue
4241
+ });
4242
+
4243
+ function addTabs(count) {
4244
+ value += "\t".repeat(count);
4245
+ length += options.tabWidth * count;
4246
+ }
4247
+
4248
+ function addSpaces(count) {
4249
+ value += " ".repeat(count);
4250
+ length += count;
4251
+ }
4252
+
4253
+ function flush() {
4254
+ if (options.useTabs) {
4255
+ flushTabs();
4256
+ } else {
4257
+ flushSpaces();
4258
+ }
4259
+ }
4260
+
4261
+ function flushTabs() {
4262
+ if (lastTabs > 0) {
4263
+ addTabs(lastTabs);
4264
+ }
4265
+
4266
+ resetLast();
4267
+ }
4268
+
4269
+ function flushSpaces() {
4270
+ if (lastSpaces > 0) {
4271
+ addSpaces(lastSpaces);
4272
+ }
4273
+
4274
+ resetLast();
4275
+ }
4276
+
4277
+ function resetLast() {
4278
+ lastTabs = 0;
4279
+ lastSpaces = 0;
4280
+ }
4281
+ }
4282
+
4283
+ function trim(out) {
4284
+ if (out.length === 0) {
4285
+ return 0;
4286
+ }
4287
+
4288
+ let trimCount = 0; // Trim whitespace at the end of line
4289
+
4290
+ while (out.length > 0 && typeof getLast(out) === "string" && /^[\t ]*$/.test(getLast(out))) {
4291
+ trimCount += out.pop().length;
4292
+ }
4293
+
4294
+ if (out.length > 0 && typeof getLast(out) === "string") {
4295
+ const trimmed = getLast(out).replace(/[\t ]*$/, "");
4296
+ trimCount += getLast(out).length - trimmed.length;
4297
+ out[out.length - 1] = trimmed;
4298
+ }
4299
+
4300
+ return trimCount;
4301
+ }
4302
+
4303
+ function fits(next, restCommands, width, options, hasLineSuffix, mustBeFlat) {
4304
+ let restIdx = restCommands.length;
4305
+ const cmds = [next]; // `out` is only used for width counting because `trim` requires to look
4306
+ // backwards for space characters.
4307
+
4308
+ const out = [];
4309
+
4310
+ while (width >= 0) {
4311
+ if (cmds.length === 0) {
4312
+ if (restIdx === 0) {
4313
+ return true;
4314
+ }
4315
+
4316
+ cmds.push(restCommands[restIdx - 1]);
4317
+ restIdx--;
4318
+ continue;
4319
+ }
4320
+
4321
+ const [ind, mode, doc] = cmds.pop();
4322
+
4323
+ if (typeof doc === "string") {
4324
+ out.push(doc);
4325
+ width -= getStringWidth(doc);
4326
+ } else if (isConcat$1(doc)) {
4327
+ const parts = getDocParts$1(doc);
4328
+
4329
+ for (let i = parts.length - 1; i >= 0; i--) {
4330
+ cmds.push([ind, mode, parts[i]]);
4331
+ }
4332
+ } else {
4333
+ switch (doc.type) {
4334
+ case "indent":
4335
+ cmds.push([makeIndent(ind, options), mode, doc.contents]);
4336
+ break;
4337
+
4338
+ case "align":
4339
+ cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
4340
+ break;
4341
+
4342
+ case "trim":
4343
+ width += trim(out);
4344
+ break;
4345
+
4346
+ case "group":
4347
+ {
4348
+ if (mustBeFlat && doc.break) {
4349
+ return false;
4350
+ }
4351
+
4352
+ const groupMode = doc.break ? MODE_BREAK : mode;
4353
+ cmds.push([ind, groupMode, // The most expanded state takes up the least space on the current line.
4354
+ doc.expandedStates && groupMode === MODE_BREAK ? getLast(doc.expandedStates) : doc.contents]);
4355
+
4356
+ if (doc.id) {
4357
+ groupModeMap[doc.id] = groupMode;
4358
+ }
4359
+
4360
+ break;
4361
+ }
4362
+
4363
+ case "fill":
4364
+ for (let i = doc.parts.length - 1; i >= 0; i--) {
4365
+ cmds.push([ind, mode, doc.parts[i]]);
4366
+ }
4367
+
4368
+ break;
4369
+
4370
+ case "if-break":
4371
+ case "indent-if-break":
4372
+ {
4373
+ const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
4374
+
4375
+ if (groupMode === MODE_BREAK) {
4376
+ const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
4377
+
4378
+ if (breakContents) {
4379
+ cmds.push([ind, mode, breakContents]);
4380
+ }
4381
+ }
4382
+
4383
+ if (groupMode === MODE_FLAT) {
4384
+ const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
4385
+
4386
+ if (flatContents) {
4387
+ cmds.push([ind, mode, flatContents]);
4388
+ }
4389
+ }
4390
+
4391
+ break;
4392
+ }
4393
+
4394
+ case "line":
4395
+ switch (mode) {
4396
+ // fallthrough
4397
+ case MODE_FLAT:
4398
+ if (!doc.hard) {
4399
+ if (!doc.soft) {
4400
+ out.push(" ");
4401
+ width -= 1;
4402
+ }
4403
+
4404
+ break;
4405
+ }
4406
+
4407
+ return true;
4408
+
4409
+ case MODE_BREAK:
4410
+ return true;
4411
+ }
4412
+
4413
+ break;
4414
+
4415
+ case "line-suffix":
4416
+ hasLineSuffix = true;
4417
+ break;
4418
+
4419
+ case "line-suffix-boundary":
4420
+ if (hasLineSuffix) {
4421
+ return false;
4422
+ }
4423
+
4424
+ break;
4425
+
4426
+ case "label":
4427
+ cmds.push([ind, mode, doc.contents]);
4428
+ break;
4429
+ }
4430
+ }
4431
+ }
4432
+
4433
+ return false;
4434
+ }
4435
+
4436
+ function printDocToString(doc, options) {
4437
+ groupModeMap = {};
4438
+ const width = options.printWidth;
4439
+ const newLine = convertEndOfLineToChars(options.endOfLine);
4440
+ let pos = 0; // cmds is basically a stack. We've turned a recursive call into a
4441
+ // while loop which is much faster. The while loop below adds new
4442
+ // cmds to the array instead of recursively calling `print`.
4443
+
4444
+ const cmds = [[rootIndent(), MODE_BREAK, doc]];
4445
+ const out = [];
4446
+ let shouldRemeasure = false;
4447
+ let lineSuffix = [];
4448
+
4449
+ while (cmds.length > 0) {
4450
+ const [ind, mode, doc] = cmds.pop();
4451
+
4452
+ if (typeof doc === "string") {
4453
+ const formatted = newLine !== "\n" ? doc.replace(/\n/g, newLine) : doc;
4454
+ out.push(formatted);
4455
+ pos += getStringWidth(formatted);
4456
+ } else if (isConcat$1(doc)) {
4457
+ const parts = getDocParts$1(doc);
4458
+
4459
+ for (let i = parts.length - 1; i >= 0; i--) {
4460
+ cmds.push([ind, mode, parts[i]]);
4461
+ }
4462
+ } else {
4463
+ switch (doc.type) {
4464
+ case "cursor":
4465
+ out.push(cursor.placeholder);
4466
+ break;
4467
+
4468
+ case "indent":
4469
+ cmds.push([makeIndent(ind, options), mode, doc.contents]);
4470
+ break;
4471
+
4472
+ case "align":
4473
+ cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
4474
+ break;
4475
+
4476
+ case "trim":
4477
+ pos -= trim(out);
4478
+ break;
4479
+
4480
+ case "group":
4481
+ switch (mode) {
4482
+ case MODE_FLAT:
4483
+ if (!shouldRemeasure) {
4484
+ cmds.push([ind, doc.break ? MODE_BREAK : MODE_FLAT, doc.contents]);
4485
+ break;
4486
+ }
4487
+
4488
+ // fallthrough
4489
+
4490
+ case MODE_BREAK:
4491
+ {
4492
+ shouldRemeasure = false;
4493
+ const next = [ind, MODE_FLAT, doc.contents];
4494
+ const rem = width - pos;
4495
+ const hasLineSuffix = lineSuffix.length > 0;
4496
+
4497
+ if (!doc.break && fits(next, cmds, rem, options, hasLineSuffix)) {
4498
+ cmds.push(next);
4499
+ } else {
4500
+ // Expanded states are a rare case where a document
4501
+ // can manually provide multiple representations of
4502
+ // itself. It provides an array of documents
4503
+ // going from the least expanded (most flattened)
4504
+ // representation first to the most expanded. If a
4505
+ // group has these, we need to manually go through
4506
+ // these states and find the first one that fits.
4507
+ if (doc.expandedStates) {
4508
+ const mostExpanded = getLast(doc.expandedStates);
4509
+
4510
+ if (doc.break) {
4511
+ cmds.push([ind, MODE_BREAK, mostExpanded]);
4512
+ break;
4513
+ } else {
4514
+ for (let i = 1; i < doc.expandedStates.length + 1; i++) {
4515
+ if (i >= doc.expandedStates.length) {
4516
+ cmds.push([ind, MODE_BREAK, mostExpanded]);
4517
+ break;
4518
+ } else {
4519
+ const state = doc.expandedStates[i];
4520
+ const cmd = [ind, MODE_FLAT, state];
4521
+
4522
+ if (fits(cmd, cmds, rem, options, hasLineSuffix)) {
4523
+ cmds.push(cmd);
4524
+ break;
4525
+ }
4526
+ }
4527
+ }
4528
+ }
4529
+ } else {
4530
+ cmds.push([ind, MODE_BREAK, doc.contents]);
4531
+ }
4532
+ }
4533
+
4534
+ break;
4535
+ }
4536
+ }
4537
+
4538
+ if (doc.id) {
4539
+ groupModeMap[doc.id] = getLast(cmds)[1];
4540
+ }
4541
+
4542
+ break;
4543
+ // Fills each line with as much code as possible before moving to a new
4544
+ // line with the same indentation.
4545
+ //
4546
+ // Expects doc.parts to be an array of alternating content and
4547
+ // whitespace. The whitespace contains the linebreaks.
4548
+ //
4549
+ // For example:
4550
+ // ["I", line, "love", line, "monkeys"]
4551
+ // or
4552
+ // [{ type: group, ... }, softline, { type: group, ... }]
4553
+ //
4554
+ // It uses this parts structure to handle three main layout cases:
4555
+ // * The first two content items fit on the same line without
4556
+ // breaking
4557
+ // -> output the first content item and the whitespace "flat".
4558
+ // * Only the first content item fits on the line without breaking
4559
+ // -> output the first content item "flat" and the whitespace with
4560
+ // "break".
4561
+ // * Neither content item fits on the line without breaking
4562
+ // -> output the first content item and the whitespace with "break".
4563
+
4564
+ case "fill":
4565
+ {
4566
+ const rem = width - pos;
4567
+ const {
4568
+ parts
4569
+ } = doc;
4570
+
4571
+ if (parts.length === 0) {
4572
+ break;
4573
+ }
4574
+
4575
+ const [content, whitespace] = parts;
4576
+ const contentFlatCmd = [ind, MODE_FLAT, content];
4577
+ const contentBreakCmd = [ind, MODE_BREAK, content];
4578
+ const contentFits = fits(contentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
4579
+
4580
+ if (parts.length === 1) {
4581
+ if (contentFits) {
4582
+ cmds.push(contentFlatCmd);
4583
+ } else {
4584
+ cmds.push(contentBreakCmd);
4585
+ }
4586
+
4587
+ break;
4588
+ }
4589
+
4590
+ const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
4591
+ const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
4592
+
4593
+ if (parts.length === 2) {
4594
+ if (contentFits) {
4595
+ cmds.push(whitespaceFlatCmd, contentFlatCmd);
4596
+ } else {
4597
+ cmds.push(whitespaceBreakCmd, contentBreakCmd);
4598
+ }
4599
+
4600
+ break;
4601
+ } // At this point we've handled the first pair (context, separator)
4602
+ // and will create a new fill doc for the rest of the content.
4603
+ // Ideally we wouldn't mutate the array here but copying all the
4604
+ // elements to a new array would make this algorithm quadratic,
4605
+ // which is unusable for large arrays (e.g. large texts in JSX).
4606
+
4607
+
4608
+ parts.splice(0, 2);
4609
+ const remainingCmd = [ind, mode, fill(parts)];
4610
+ const secondContent = parts[0];
4611
+ const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, [content, whitespace, secondContent]];
4612
+ const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, lineSuffix.length > 0, true);
4613
+
4614
+ if (firstAndSecondContentFits) {
4615
+ cmds.push(remainingCmd, whitespaceFlatCmd, contentFlatCmd);
4616
+ } else if (contentFits) {
4617
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentFlatCmd);
4618
+ } else {
4619
+ cmds.push(remainingCmd, whitespaceBreakCmd, contentBreakCmd);
4620
+ }
4621
+
4622
+ break;
4623
+ }
4624
+
4625
+ case "if-break":
4626
+ case "indent-if-break":
4627
+ {
4628
+ const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
4629
+
4630
+ if (groupMode === MODE_BREAK) {
4631
+ const breakContents = doc.type === "if-break" ? doc.breakContents : doc.negate ? doc.contents : indent(doc.contents);
4632
+
4633
+ if (breakContents) {
4634
+ cmds.push([ind, mode, breakContents]);
4635
+ }
4636
+ }
4637
+
4638
+ if (groupMode === MODE_FLAT) {
4639
+ const flatContents = doc.type === "if-break" ? doc.flatContents : doc.negate ? indent(doc.contents) : doc.contents;
4640
+
4641
+ if (flatContents) {
4642
+ cmds.push([ind, mode, flatContents]);
4643
+ }
4644
+ }
4645
+
4646
+ break;
4647
+ }
4648
+
4649
+ case "line-suffix":
4650
+ lineSuffix.push([ind, mode, doc.contents]);
4651
+ break;
4652
+
4653
+ case "line-suffix-boundary":
4654
+ if (lineSuffix.length > 0) {
4655
+ cmds.push([ind, mode, {
4656
+ type: "line",
4657
+ hard: true
4658
+ }]);
4659
+ }
4660
+
4661
+ break;
4662
+
4663
+ case "line":
4664
+ switch (mode) {
4665
+ case MODE_FLAT:
4666
+ if (!doc.hard) {
4667
+ if (!doc.soft) {
4668
+ out.push(" ");
4669
+ pos += 1;
4670
+ }
4671
+
4672
+ break;
4673
+ } else {
4674
+ // This line was forced into the output even if we
4675
+ // were in flattened mode, so we need to tell the next
4676
+ // group that no matter what, it needs to remeasure
4677
+ // because the previous measurement didn't accurately
4678
+ // capture the entire expression (this is necessary
4679
+ // for nested groups)
4680
+ shouldRemeasure = true;
4681
+ }
4682
+
4683
+ // fallthrough
4684
+
4685
+ case MODE_BREAK:
4686
+ if (lineSuffix.length > 0) {
4687
+ cmds.push([ind, mode, doc], ...lineSuffix.reverse());
4688
+ lineSuffix = [];
4689
+ break;
4690
+ }
4691
+
4692
+ if (doc.literal) {
4693
+ if (ind.root) {
4694
+ out.push(newLine, ind.root.value);
4695
+ pos = ind.root.length;
4696
+ } else {
4697
+ out.push(newLine);
4698
+ pos = 0;
4699
+ }
4700
+ } else {
4701
+ pos -= trim(out);
4702
+ out.push(newLine + ind.value);
4703
+ pos = ind.length;
4704
+ }
4705
+
4706
+ break;
4707
+ }
4708
+
4709
+ break;
4710
+
4711
+ case "label":
4712
+ cmds.push([ind, mode, doc.contents]);
4713
+ break;
4714
+ }
4715
+ } // Flush remaining line-suffix contents at the end of the document, in case
4716
+ // there is no new line after the line-suffix.
4717
+
4718
+
4719
+ if (cmds.length === 0 && lineSuffix.length > 0) {
4720
+ cmds.push(...lineSuffix.reverse());
4721
+ lineSuffix = [];
4722
+ }
4723
+ }
4724
+
4725
+ const cursorPlaceholderIndex = out.indexOf(cursor.placeholder);
4726
+
4727
+ if (cursorPlaceholderIndex !== -1) {
4728
+ const otherCursorPlaceholderIndex = out.indexOf(cursor.placeholder, cursorPlaceholderIndex + 1);
4729
+ const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
4730
+ const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
4731
+ const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
4732
+ return {
4733
+ formatted: beforeCursor + aroundCursor + afterCursor,
4734
+ cursorNodeStart: beforeCursor.length,
4735
+ cursorNodeText: aroundCursor
4736
+ };
4737
+ }
4738
+
4739
+ return {
4740
+ formatted: out.join("")
4741
+ };
4742
+ }
4743
+
4744
+ var docPrinter = {
4745
+ printDocToString
4746
+ };
4747
+
4748
+ const {
4749
+ isConcat,
4750
+ getDocParts
4751
+ } = docUtils;
4752
+
4753
+ function flattenDoc(doc) {
4754
+ if (!doc) {
4755
+ return "";
4756
+ }
4757
+
4758
+ if (isConcat(doc)) {
4759
+ const res = [];
4760
+
4761
+ for (const part of getDocParts(doc)) {
4762
+ if (isConcat(part)) {
4763
+ res.push(...flattenDoc(part).parts);
4764
+ } else {
4765
+ const flattened = flattenDoc(part);
4766
+
4767
+ if (flattened !== "") {
4768
+ res.push(flattened);
4769
+ }
4770
+ }
4771
+ }
4772
+
4773
+ return {
4774
+ type: "concat",
4775
+ parts: res
4776
+ };
4777
+ }
4778
+
4779
+ if (doc.type === "if-break") {
4780
+ return Object.assign(Object.assign({}, doc), {}, {
4781
+ breakContents: flattenDoc(doc.breakContents),
4782
+ flatContents: flattenDoc(doc.flatContents)
4783
+ });
4784
+ }
4785
+
4786
+ if (doc.type === "group") {
4787
+ return Object.assign(Object.assign({}, doc), {}, {
4788
+ contents: flattenDoc(doc.contents),
4789
+ expandedStates: doc.expandedStates && doc.expandedStates.map(flattenDoc)
4790
+ });
4791
+ }
4792
+
4793
+ if (doc.type === "fill") {
4794
+ return {
4795
+ type: "fill",
4796
+ parts: doc.parts.map(flattenDoc)
4797
+ };
4798
+ }
4799
+
4800
+ if (doc.contents) {
4801
+ return Object.assign(Object.assign({}, doc), {}, {
4802
+ contents: flattenDoc(doc.contents)
4803
+ });
4804
+ }
4805
+
4806
+ return doc;
4807
+ }
4808
+
4809
+ function printDocToDebug(doc) {
4810
+ /** @type Record<symbol, string> */
4811
+ const printedSymbols = Object.create(null);
4812
+ /** @type Set<string> */
4813
+
4814
+ const usedKeysForSymbols = new Set();
4815
+ return printDoc(flattenDoc(doc));
4816
+
4817
+ function printDoc(doc, index, parentParts) {
4818
+ if (typeof doc === "string") {
4819
+ return JSON.stringify(doc);
4820
+ }
4821
+
4822
+ if (isConcat(doc)) {
4823
+ const printed = getDocParts(doc).map(printDoc).filter(Boolean);
4824
+ return printed.length === 1 ? printed[0] : `[${printed.join(", ")}]`;
4825
+ }
4826
+
4827
+ if (doc.type === "line") {
4828
+ const withBreakParent = Array.isArray(parentParts) && parentParts[index + 1] && parentParts[index + 1].type === "break-parent";
4829
+
4830
+ if (doc.literal) {
4831
+ return withBreakParent ? "literalline" : "literallineWithoutBreakParent";
4832
+ }
4833
+
4834
+ if (doc.hard) {
4835
+ return withBreakParent ? "hardline" : "hardlineWithoutBreakParent";
4836
+ }
4837
+
4838
+ if (doc.soft) {
4839
+ return "softline";
4840
+ }
4841
+
4842
+ return "line";
4843
+ }
4844
+
4845
+ if (doc.type === "break-parent") {
4846
+ const afterHardline = Array.isArray(parentParts) && parentParts[index - 1] && parentParts[index - 1].type === "line" && parentParts[index - 1].hard;
4847
+ return afterHardline ? undefined : "breakParent";
4848
+ }
4849
+
4850
+ if (doc.type === "trim") {
4851
+ return "trim";
4852
+ }
4853
+
4854
+ if (doc.type === "indent") {
4855
+ return "indent(" + printDoc(doc.contents) + ")";
4856
+ }
4857
+
4858
+ if (doc.type === "align") {
4859
+ return doc.n === Number.NEGATIVE_INFINITY ? "dedentToRoot(" + printDoc(doc.contents) + ")" : doc.n < 0 ? "dedent(" + printDoc(doc.contents) + ")" : doc.n.type === "root" ? "markAsRoot(" + printDoc(doc.contents) + ")" : "align(" + JSON.stringify(doc.n) + ", " + printDoc(doc.contents) + ")";
4860
+ }
4861
+
4862
+ if (doc.type === "if-break") {
4863
+ return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + (doc.groupId ? (!doc.flatContents ? ', ""' : "") + `, { groupId: ${printGroupId(doc.groupId)} }` : "") + ")";
4864
+ }
4865
+
4866
+ if (doc.type === "indent-if-break") {
4867
+ const optionsParts = [];
4868
+
4869
+ if (doc.negate) {
4870
+ optionsParts.push("negate: true");
4871
+ }
4872
+
4873
+ if (doc.groupId) {
4874
+ optionsParts.push(`groupId: ${printGroupId(doc.groupId)}`);
4875
+ }
4876
+
4877
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
4878
+ return `indentIfBreak(${printDoc(doc.contents)}${options})`;
4879
+ }
4880
+
4881
+ if (doc.type === "group") {
4882
+ const optionsParts = [];
4883
+
4884
+ if (doc.break && doc.break !== "propagated") {
4885
+ optionsParts.push("shouldBreak: true");
4886
+ }
4887
+
4888
+ if (doc.id) {
4889
+ optionsParts.push(`id: ${printGroupId(doc.id)}`);
4890
+ }
4891
+
4892
+ const options = optionsParts.length > 0 ? `, { ${optionsParts.join(", ")} }` : "";
4893
+
4894
+ if (doc.expandedStates) {
4895
+ return `conditionalGroup([${doc.expandedStates.map(part => printDoc(part)).join(",")}]${options})`;
4896
+ }
4897
+
4898
+ return `group(${printDoc(doc.contents)}${options})`;
4899
+ }
4900
+
4901
+ if (doc.type === "fill") {
4902
+ return `fill([${doc.parts.map(part => printDoc(part)).join(", ")}])`;
4903
+ }
4904
+
4905
+ if (doc.type === "line-suffix") {
4906
+ return "lineSuffix(" + printDoc(doc.contents) + ")";
4907
+ }
4908
+
4909
+ if (doc.type === "line-suffix-boundary") {
4910
+ return "lineSuffixBoundary";
4911
+ }
4912
+
4913
+ if (doc.type === "label") {
4914
+ return `label(${JSON.stringify(doc.label)}, ${printDoc(doc.contents)})`;
4915
+ }
4916
+
4917
+ throw new Error("Unknown doc type " + doc.type);
4918
+ }
4919
+
4920
+ function printGroupId(id) {
4921
+ if (typeof id !== "symbol") {
4922
+ return JSON.stringify(String(id));
4923
+ }
4924
+
4925
+ if (id in printedSymbols) {
4926
+ return printedSymbols[id];
4927
+ } // TODO: use Symbol.prototype.description instead of slice once Node 10 is dropped
4928
+
4929
+
4930
+ const prefix = String(id).slice(7, -1) || "symbol";
4931
+
4932
+ for (let counter = 0;; counter++) {
4933
+ const key = prefix + (counter > 0 ? ` #${counter}` : "");
4934
+
4935
+ if (!usedKeysForSymbols.has(key)) {
4936
+ usedKeysForSymbols.add(key);
4937
+ return printedSymbols[id] = `Symbol.for(${JSON.stringify(key)})`;
4938
+ }
4939
+ }
4940
+ }
4941
+ }
4942
+
4943
+ var docDebug = {
4944
+ printDocToDebug
4945
+ };
4946
+
4947
+ /**
4948
+ * @typedef {import("./doc-builders").Doc} Doc
4949
+ */
4950
+
4951
+
4952
+ var document = {
4953
+ builders: docBuilders,
4954
+ printer: docPrinter,
4955
+ utils: docUtils,
4956
+ debug: docDebug
4957
+ };
4958
+
4959
+ return document;
4960
+
4961
+ })));