prettier 1.6.0 → 2.0.0.pre.rc3

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