Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / prettier / doc.js
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(contents) {
33
34     return {
35       type: "indent",
36       contents
37     };
38   }
39   /**
40    * @param {number | string} n
41    * @param {Doc} contents
42    * @returns Doc
43    */
44
45
46   function align(n, contents) {
47
48     return {
49       type: "align",
50       contents,
51       n
52     };
53   }
54   /**
55    * @param {Doc} contents
56    * @param {object} [opts] - TBD ???
57    * @returns Doc
58    */
59
60
61   function group(contents, opts) {
62     opts = opts || {};
63
64     return {
65       type: "group",
66       id: opts.id,
67       contents,
68       break: !!opts.shouldBreak,
69       expandedStates: opts.expandedStates
70     };
71   }
72   /**
73    * @param {Doc} contents
74    * @returns Doc
75    */
76
77
78   function dedentToRoot(contents) {
79     return align(-Infinity, contents);
80   }
81   /**
82    * @param {Doc} contents
83    * @returns Doc
84    */
85
86
87   function markAsRoot(contents) {
88     // @ts-ignore - TBD ???:
89     return align({
90       type: "root"
91     }, contents);
92   }
93   /**
94    * @param {Doc} contents
95    * @returns Doc
96    */
97
98
99   function dedent(contents) {
100     return align(-1, contents);
101   }
102   /**
103    * @param {Doc[]} states
104    * @param {object} [opts] - TBD ???
105    * @returns Doc
106    */
107
108
109   function conditionalGroup(states, opts) {
110     return group(states[0], Object.assign({}, opts, {
111       expandedStates: states
112     }));
113   }
114   /**
115    * @param {Doc[]} parts
116    * @returns Doc
117    */
118
119
120   function fill(parts) {
121
122     return {
123       type: "fill",
124       parts
125     };
126   }
127   /**
128    * @param {Doc} [breakContents]
129    * @param {Doc} [flatContents]
130    * @param {object} [opts] - TBD ???
131    * @returns Doc
132    */
133
134
135   function ifBreak(breakContents, flatContents, opts) {
136     opts = opts || {};
137
138     return {
139       type: "if-break",
140       breakContents,
141       flatContents,
142       groupId: opts.groupId
143     };
144   }
145   /**
146    * @param {Doc} contents
147    * @returns Doc
148    */
149
150
151   function lineSuffix(contents) {
152
153     return {
154       type: "line-suffix",
155       contents
156     };
157   }
158
159   const lineSuffixBoundary = {
160     type: "line-suffix-boundary"
161   };
162   const breakParent = {
163     type: "break-parent"
164   };
165   const trim = {
166     type: "trim"
167   };
168   const line = {
169     type: "line"
170   };
171   const softline = {
172     type: "line",
173     soft: true
174   };
175   const hardline = concat([{
176     type: "line",
177     hard: true
178   }, breakParent]);
179   const literalline = concat([{
180     type: "line",
181     hard: true,
182     literal: true
183   }, breakParent]);
184   const cursor = {
185     type: "cursor",
186     placeholder: Symbol("cursor")
187   };
188   /**
189    * @param {Doc} sep
190    * @param {Doc[]} arr
191    * @returns Doc
192    */
193
194   function join(sep, arr) {
195     const res = [];
196
197     for (let i = 0; i < arr.length; i++) {
198       if (i !== 0) {
199         res.push(sep);
200       }
201
202       res.push(arr[i]);
203     }
204
205     return concat(res);
206   }
207   /**
208    * @param {Doc} doc
209    * @param {number} size
210    * @param {number} tabWidth
211    */
212
213
214   function addAlignmentToDoc(doc, size, tabWidth) {
215     let aligned = doc;
216
217     if (size > 0) {
218       // Use indent to add tabs for all the levels of tabs we need
219       for (let i = 0; i < Math.floor(size / tabWidth); ++i) {
220         aligned = indent(aligned);
221       } // Use align for all the spaces that are needed
222
223
224       aligned = align(size % tabWidth, aligned); // size is absolute from 0 and not relative to the current
225       // indentation, so we use -Infinity to reset the indentation to 0
226
227       aligned = align(-Infinity, aligned);
228     }
229
230     return aligned;
231   }
232
233   var docBuilders = {
234     concat,
235     join,
236     line,
237     softline,
238     hardline,
239     literalline,
240     group,
241     conditionalGroup,
242     fill,
243     lineSuffix,
244     lineSuffixBoundary,
245     cursor,
246     breakParent,
247     ifBreak,
248     trim,
249     indent,
250     align,
251     addAlignmentToDoc,
252     markAsRoot,
253     dedentToRoot,
254     dedent
255   };
256
257   var ansiRegex = ({
258     onlyFirst = false
259   } = {}) => {
260     const pattern = ['[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)', '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'].join('|');
261     return new RegExp(pattern, onlyFirst ? undefined : 'g');
262   };
263
264   var stripAnsi = string => typeof string === 'string' ? string.replace(ansiRegex(), '') : string;
265
266   /* eslint-disable yoda */
267
268   const isFullwidthCodePoint = codePoint => {
269     if (Number.isNaN(codePoint)) {
270       return false;
271     } // Code points are derived from:
272     // http://www.unix.org/Public/UNIDATA/EastAsianWidth.txt
273
274
275     if (codePoint >= 0x1100 && (codePoint <= 0x115F || // Hangul Jamo
276     codePoint === 0x2329 || // LEFT-POINTING ANGLE BRACKET
277     codePoint === 0x232A || // RIGHT-POINTING ANGLE BRACKET
278     // CJK Radicals Supplement .. Enclosed CJK Letters and Months
279     0x2E80 <= codePoint && codePoint <= 0x3247 && codePoint !== 0x303F || // Enclosed CJK Letters and Months .. CJK Unified Ideographs Extension A
280     0x3250 <= codePoint && codePoint <= 0x4DBF || // CJK Unified Ideographs .. Yi Radicals
281     0x4E00 <= codePoint && codePoint <= 0xA4C6 || // Hangul Jamo Extended-A
282     0xA960 <= codePoint && codePoint <= 0xA97C || // Hangul Syllables
283     0xAC00 <= codePoint && codePoint <= 0xD7A3 || // CJK Compatibility Ideographs
284     0xF900 <= codePoint && codePoint <= 0xFAFF || // Vertical Forms
285     0xFE10 <= codePoint && codePoint <= 0xFE19 || // CJK Compatibility Forms .. Small Form Variants
286     0xFE30 <= codePoint && codePoint <= 0xFE6B || // Halfwidth and Fullwidth Forms
287     0xFF01 <= codePoint && codePoint <= 0xFF60 || 0xFFE0 <= codePoint && codePoint <= 0xFFE6 || // Kana Supplement
288     0x1B000 <= codePoint && codePoint <= 0x1B001 || // Enclosed Ideographic Supplement
289     0x1F200 <= codePoint && codePoint <= 0x1F251 || // CJK Unified Ideographs Extension B .. Tertiary Ideographic Plane
290     0x20000 <= codePoint && codePoint <= 0x3FFFD)) {
291       return true;
292     }
293
294     return false;
295   };
296
297   var isFullwidthCodePoint_1 = isFullwidthCodePoint;
298   var _default = isFullwidthCodePoint;
299   isFullwidthCodePoint_1.default = _default;
300
301   var emojiRegex = function () {
302     // https://mths.be/emoji
303     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;
304   };
305
306   const stringWidth = string => {
307     string = string.replace(emojiRegex(), '  ');
308
309     if (typeof string !== 'string' || string.length === 0) {
310       return 0;
311     }
312
313     string = stripAnsi(string);
314     let width = 0;
315
316     for (let i = 0; i < string.length; i++) {
317       const code = string.codePointAt(i); // Ignore control characters
318
319       if (code <= 0x1F || code >= 0x7F && code <= 0x9F) {
320         continue;
321       } // Ignore combining characters
322
323
324       if (code >= 0x300 && code <= 0x36F) {
325         continue;
326       } // Surrogates
327
328
329       if (code > 0xFFFF) {
330         i++;
331       }
332
333       width += isFullwidthCodePoint_1(code) ? 2 : 1;
334     }
335
336     return width;
337   };
338
339   var stringWidth_1 = stringWidth; // TODO: remove this in the next major version
340
341   var _default$1 = stringWidth;
342   stringWidth_1.default = _default$1;
343
344   var escapeStringRegexp = string => {
345     if (typeof string !== 'string') {
346       throw new TypeError('Expected a string');
347     } // Escape characters with special meaning either inside or outside character sets.
348     // 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.
349
350
351     return string.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&').replace(/-/g, '\\x2d');
352   };
353
354   var getLast = arr => arr[arr.length - 1];
355
356   function _objectWithoutPropertiesLoose(source, excluded) {
357     if (source == null) return {};
358     var target = {};
359     var sourceKeys = Object.keys(source);
360     var key, i;
361
362     for (i = 0; i < sourceKeys.length; i++) {
363       key = sourceKeys[i];
364       if (excluded.indexOf(key) >= 0) continue;
365       target[key] = source[key];
366     }
367
368     return target;
369   }
370
371   function _taggedTemplateLiteral(strings, raw) {
372     if (!raw) {
373       raw = strings.slice(0);
374     }
375
376     return Object.freeze(Object.defineProperties(strings, {
377       raw: {
378         value: Object.freeze(raw)
379       }
380     }));
381   }
382
383   var global$1 = typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {};
384
385   // based off https://github.com/defunctzombie/node-process/blob/master/browser.js
386
387   function defaultSetTimout() {
388     throw new Error('setTimeout has not been defined');
389   }
390
391   function defaultClearTimeout() {
392     throw new Error('clearTimeout has not been defined');
393   }
394
395   var cachedSetTimeout = defaultSetTimout;
396   var cachedClearTimeout = defaultClearTimeout;
397
398   if (typeof global$1.setTimeout === 'function') {
399     cachedSetTimeout = setTimeout;
400   }
401
402   if (typeof global$1.clearTimeout === 'function') {
403     cachedClearTimeout = clearTimeout;
404   }
405
406   function runTimeout(fun) {
407     if (cachedSetTimeout === setTimeout) {
408       //normal enviroments in sane situations
409       return setTimeout(fun, 0);
410     } // if setTimeout wasn't available but was latter defined
411
412
413     if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
414       cachedSetTimeout = setTimeout;
415       return setTimeout(fun, 0);
416     }
417
418     try {
419       // when when somebody has screwed with setTimeout but no I.E. maddness
420       return cachedSetTimeout(fun, 0);
421     } catch (e) {
422       try {
423         // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
424         return cachedSetTimeout.call(null, fun, 0);
425       } catch (e) {
426         // 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
427         return cachedSetTimeout.call(this, fun, 0);
428       }
429     }
430   }
431
432   function runClearTimeout(marker) {
433     if (cachedClearTimeout === clearTimeout) {
434       //normal enviroments in sane situations
435       return clearTimeout(marker);
436     } // if clearTimeout wasn't available but was latter defined
437
438
439     if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
440       cachedClearTimeout = clearTimeout;
441       return clearTimeout(marker);
442     }
443
444     try {
445       // when when somebody has screwed with setTimeout but no I.E. maddness
446       return cachedClearTimeout(marker);
447     } catch (e) {
448       try {
449         // When we are in I.E. but the script has been evaled so I.E. doesn't  trust the global object when called normally
450         return cachedClearTimeout.call(null, marker);
451       } catch (e) {
452         // 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.
453         // Some versions of I.E. have different rules for clearTimeout vs setTimeout
454         return cachedClearTimeout.call(this, marker);
455       }
456     }
457   }
458
459   var queue = [];
460   var draining = false;
461   var currentQueue;
462   var queueIndex = -1;
463
464   function cleanUpNextTick() {
465     if (!draining || !currentQueue) {
466       return;
467     }
468
469     draining = false;
470
471     if (currentQueue.length) {
472       queue = currentQueue.concat(queue);
473     } else {
474       queueIndex = -1;
475     }
476
477     if (queue.length) {
478       drainQueue();
479     }
480   }
481
482   function drainQueue() {
483     if (draining) {
484       return;
485     }
486
487     var timeout = runTimeout(cleanUpNextTick);
488     draining = true;
489     var len = queue.length;
490
491     while (len) {
492       currentQueue = queue;
493       queue = [];
494
495       while (++queueIndex < len) {
496         if (currentQueue) {
497           currentQueue[queueIndex].run();
498         }
499       }
500
501       queueIndex = -1;
502       len = queue.length;
503     }
504
505     currentQueue = null;
506     draining = false;
507     runClearTimeout(timeout);
508   }
509
510   function nextTick(fun) {
511     var args = new Array(arguments.length - 1);
512
513     if (arguments.length > 1) {
514       for (var i = 1; i < arguments.length; i++) {
515         args[i - 1] = arguments[i];
516       }
517     }
518
519     queue.push(new Item(fun, args));
520
521     if (queue.length === 1 && !draining) {
522       runTimeout(drainQueue);
523     }
524   } // v8 likes predictible objects
525
526   function Item(fun, array) {
527     this.fun = fun;
528     this.array = array;
529   }
530
531   Item.prototype.run = function () {
532     this.fun.apply(null, this.array);
533   };
534
535   var title = 'browser';
536   var platform = 'browser';
537   var browser = true;
538   var env = {};
539   var argv = [];
540   var version = ''; // empty string to avoid regexp issues
541
542   var versions = {};
543   var release = {};
544   var config = {};
545
546   function noop() {}
547
548   var on = noop;
549   var addListener = noop;
550   var once = noop;
551   var off = noop;
552   var removeListener = noop;
553   var removeAllListeners = noop;
554   var emit = noop;
555   function binding(name) {
556     throw new Error('process.binding is not supported');
557   }
558   function cwd() {
559     return '/';
560   }
561   function chdir(dir) {
562     throw new Error('process.chdir is not supported');
563   }
564   function umask() {
565     return 0;
566   } // from https://github.com/kumavis/browser-process-hrtime/blob/master/index.js
567
568   var performance = global$1.performance || {};
569
570   var performanceNow = performance.now || performance.mozNow || performance.msNow || performance.oNow || performance.webkitNow || function () {
571     return new Date().getTime();
572   }; // generate timestamp or delta
573   // see http://nodejs.org/api/process.html#process_process_hrtime
574
575
576   function hrtime(previousTimestamp) {
577     var clocktime = performanceNow.call(performance) * 1e-3;
578     var seconds = Math.floor(clocktime);
579     var nanoseconds = Math.floor(clocktime % 1 * 1e9);
580
581     if (previousTimestamp) {
582       seconds = seconds - previousTimestamp[0];
583       nanoseconds = nanoseconds - previousTimestamp[1];
584
585       if (nanoseconds < 0) {
586         seconds--;
587         nanoseconds += 1e9;
588       }
589     }
590
591     return [seconds, nanoseconds];
592   }
593   var startTime = new Date();
594   function uptime() {
595     var currentTime = new Date();
596     var dif = currentTime - startTime;
597     return dif / 1000;
598   }
599   var process = {
600     nextTick: nextTick,
601     title: title,
602     browser: browser,
603     env: env,
604     argv: argv,
605     version: version,
606     versions: versions,
607     on: on,
608     addListener: addListener,
609     once: once,
610     off: off,
611     removeListener: removeListener,
612     removeAllListeners: removeAllListeners,
613     emit: emit,
614     binding: binding,
615     cwd: cwd,
616     chdir: chdir,
617     umask: umask,
618     hrtime: hrtime,
619     platform: platform,
620     release: release,
621     config: config,
622     uptime: uptime
623   };
624
625   const debug = typeof process === 'object' && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...args) => console.error('SEMVER', ...args) : () => {};
626   var debug_1 = debug;
627
628   // Note: this is the semver.org version of the spec that it implements
629   // Not necessarily the package version of this code.
630   const SEMVER_SPEC_VERSION = '2.0.0';
631   const MAX_LENGTH = 256;
632   const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
633   /* istanbul ignore next */
634   9007199254740991; // Max safe segment length for coercion.
635
636   const MAX_SAFE_COMPONENT_LENGTH = 16;
637   var constants = {
638     SEMVER_SPEC_VERSION,
639     MAX_LENGTH,
640     MAX_SAFE_INTEGER,
641     MAX_SAFE_COMPONENT_LENGTH
642   };
643
644   function createCommonjsModule(fn, basedir, module) {
645         return module = {
646                 path: basedir,
647                 exports: {},
648                 require: function (path, base) {
649                         return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
650                 }
651         }, fn(module, module.exports), module.exports;
652   }
653
654   function commonjsRequire () {
655         throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
656   }
657
658   var re_1 = createCommonjsModule(function (module, exports) {
659     const {
660       MAX_SAFE_COMPONENT_LENGTH
661     } = constants;
662     exports = module.exports = {}; // The actual regexps go on exports.re
663
664     const re = exports.re = [];
665     const src = exports.src = [];
666     const t = exports.t = {};
667     let R = 0;
668
669     const createToken = (name, value, isGlobal) => {
670       const index = R++;
671       debug_1(index, value);
672       t[name] = index;
673       src[index] = value;
674       re[index] = new RegExp(value, isGlobal ? 'g' : undefined);
675     }; // The following Regular Expressions can be used for tokenizing,
676     // validating, and parsing SemVer version strings.
677     // ## Numeric Identifier
678     // A single `0`, or a non-zero digit followed by zero or more digits.
679
680
681     createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*');
682     createToken('NUMERICIDENTIFIERLOOSE', '[0-9]+'); // ## Non-numeric Identifier
683     // Zero or more digits, followed by a letter or hyphen, and then zero or
684     // more letters, digits, or hyphens.
685
686     createToken('NONNUMERICIDENTIFIER', '\\d*[a-zA-Z-][a-zA-Z0-9-]*'); // ## Main Version
687     // Three dot-separated numeric identifiers.
688
689     createToken('MAINVERSION', "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIER], ")"));
690     createToken('MAINVERSIONLOOSE', "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")\\.") + "(".concat(src[t.NUMERICIDENTIFIERLOOSE], ")")); // ## Pre-release Version Identifier
691     // A numeric identifier, or a non-numeric identifier.
692
693     createToken('PRERELEASEIDENTIFIER', "(?:".concat(src[t.NUMERICIDENTIFIER], "|").concat(src[t.NONNUMERICIDENTIFIER], ")"));
694     createToken('PRERELEASEIDENTIFIERLOOSE', "(?:".concat(src[t.NUMERICIDENTIFIERLOOSE], "|").concat(src[t.NONNUMERICIDENTIFIER], ")")); // ## Pre-release Version
695     // Hyphen, followed by one or more dot-separated pre-release version
696     // identifiers.
697
698     createToken('PRERELEASE', "(?:-(".concat(src[t.PRERELEASEIDENTIFIER], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIER], ")*))"));
699     createToken('PRERELEASELOOSE', "(?:-?(".concat(src[t.PRERELEASEIDENTIFIERLOOSE], "(?:\\.").concat(src[t.PRERELEASEIDENTIFIERLOOSE], ")*))")); // ## Build Metadata Identifier
700     // Any combination of digits, letters, or hyphens.
701
702     createToken('BUILDIDENTIFIER', '[0-9A-Za-z-]+'); // ## Build Metadata
703     // Plus sign, followed by one or more period-separated build metadata
704     // identifiers.
705
706     createToken('BUILD', "(?:\\+(".concat(src[t.BUILDIDENTIFIER], "(?:\\.").concat(src[t.BUILDIDENTIFIER], ")*))")); // ## Full Version String
707     // A main version, followed optionally by a pre-release version and
708     // build metadata.
709     // Note that the only major, minor, patch, and pre-release sections of
710     // the version string are capturing groups.  The build metadata is not a
711     // capturing group, because it should not ever be used in version
712     // comparison.
713
714     createToken('FULLPLAIN', "v?".concat(src[t.MAINVERSION]).concat(src[t.PRERELEASE], "?").concat(src[t.BUILD], "?"));
715     createToken('FULL', "^".concat(src[t.FULLPLAIN], "$")); // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
716     // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
717     // common in the npm registry.
718
719     createToken('LOOSEPLAIN', "[v=\\s]*".concat(src[t.MAINVERSIONLOOSE]).concat(src[t.PRERELEASELOOSE], "?").concat(src[t.BUILD], "?"));
720     createToken('LOOSE', "^".concat(src[t.LOOSEPLAIN], "$"));
721     createToken('GTLT', '((?:<|>)?=?)'); // Something like "2.*" or "1.2.x".
722     // Note that "x.x" is a valid xRange identifer, meaning "any version"
723     // Only the first item is strictly required.
724
725     createToken('XRANGEIDENTIFIERLOOSE', "".concat(src[t.NUMERICIDENTIFIERLOOSE], "|x|X|\\*"));
726     createToken('XRANGEIDENTIFIER', "".concat(src[t.NUMERICIDENTIFIER], "|x|X|\\*"));
727     createToken('XRANGEPLAIN', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIER], ")") + "(?:".concat(src[t.PRERELEASE], ")?").concat(src[t.BUILD], "?") + ")?)?");
728     createToken('XRANGEPLAINLOOSE', "[v=\\s]*(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:\\.(".concat(src[t.XRANGEIDENTIFIERLOOSE], ")") + "(?:".concat(src[t.PRERELEASELOOSE], ")?").concat(src[t.BUILD], "?") + ")?)?");
729     createToken('XRANGE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAIN], "$"));
730     createToken('XRANGELOOSE', "^".concat(src[t.GTLT], "\\s*").concat(src[t.XRANGEPLAINLOOSE], "$")); // Coercion.
731     // Extract anything that could conceivably be a part of a valid semver
732
733     createToken('COERCE', "".concat('(^|[^\\d])' + '(\\d{1,').concat(MAX_SAFE_COMPONENT_LENGTH, "})") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:\\.(\\d{1,".concat(MAX_SAFE_COMPONENT_LENGTH, "}))?") + "(?:$|[^\\d])");
734     createToken('COERCERTL', src[t.COERCE], true); // Tilde ranges.
735     // Meaning is "reasonably at or greater than"
736
737     createToken('LONETILDE', '(?:~>?)');
738     createToken('TILDETRIM', "(\\s*)".concat(src[t.LONETILDE], "\\s+"), true);
739     exports.tildeTrimReplace = '$1~';
740     createToken('TILDE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAIN], "$"));
741     createToken('TILDELOOSE', "^".concat(src[t.LONETILDE]).concat(src[t.XRANGEPLAINLOOSE], "$")); // Caret ranges.
742     // Meaning is "at least and backwards compatible with"
743
744     createToken('LONECARET', '(?:\\^)');
745     createToken('CARETTRIM', "(\\s*)".concat(src[t.LONECARET], "\\s+"), true);
746     exports.caretTrimReplace = '$1^';
747     createToken('CARET', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAIN], "$"));
748     createToken('CARETLOOSE', "^".concat(src[t.LONECARET]).concat(src[t.XRANGEPLAINLOOSE], "$")); // A simple gt/lt/eq thing, or just "" to indicate "any version"
749
750     createToken('COMPARATORLOOSE', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], ")$|^$"));
751     createToken('COMPARATOR', "^".concat(src[t.GTLT], "\\s*(").concat(src[t.FULLPLAIN], ")$|^$")); // An expression to strip any whitespace between the gtlt and the thing
752     // it modifies, so that `> 1.2.3` ==> `>1.2.3`
753
754     createToken('COMPARATORTRIM', "(\\s*)".concat(src[t.GTLT], "\\s*(").concat(src[t.LOOSEPLAIN], "|").concat(src[t.XRANGEPLAIN], ")"), true);
755     exports.comparatorTrimReplace = '$1$2$3'; // Something like `1.2.3 - 1.2.4`
756     // Note that these all use the loose form, because they'll be
757     // checked against either the strict or loose comparator form
758     // later.
759
760     createToken('HYPHENRANGE', "^\\s*(".concat(src[t.XRANGEPLAIN], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAIN], ")") + "\\s*$");
761     createToken('HYPHENRANGELOOSE', "^\\s*(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s+-\\s+" + "(".concat(src[t.XRANGEPLAINLOOSE], ")") + "\\s*$"); // Star ranges basically just allow anything at all.
762
763     createToken('STAR', '(<|>)?=?\\s*\\*'); // >=0.0.0 is like a star
764
765     createToken('GTE0', '^\\s*>=\\s*0\.0\.0\\s*$');
766     createToken('GTE0PRE', '^\\s*>=\\s*0\.0\.0-0\\s*$');
767   });
768
769   const numeric = /^[0-9]+$/;
770
771   const compareIdentifiers = (a, b) => {
772     const anum = numeric.test(a);
773     const bnum = numeric.test(b);
774
775     if (anum && bnum) {
776       a = +a;
777       b = +b;
778     }
779
780     return a === b ? 0 : anum && !bnum ? -1 : bnum && !anum ? 1 : a < b ? -1 : 1;
781   };
782
783   const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a);
784
785   var identifiers = {
786     compareIdentifiers,
787     rcompareIdentifiers
788   };
789
790   const {
791     MAX_LENGTH: MAX_LENGTH$1,
792     MAX_SAFE_INTEGER: MAX_SAFE_INTEGER$1
793   } = constants;
794   const {
795     re,
796     t
797   } = re_1;
798   const {
799     compareIdentifiers: compareIdentifiers$1
800   } = identifiers;
801
802   class SemVer {
803     constructor(version, options) {
804       if (!options || typeof options !== 'object') {
805         options = {
806           loose: !!options,
807           includePrerelease: false
808         };
809       }
810
811       if (version instanceof SemVer) {
812         if (version.loose === !!options.loose && version.includePrerelease === !!options.includePrerelease) {
813           return version;
814         } else {
815           version = version.version;
816         }
817       } else if (typeof version !== 'string') {
818         throw new TypeError("Invalid Version: ".concat(version));
819       }
820
821       if (version.length > MAX_LENGTH$1) {
822         throw new TypeError("version is longer than ".concat(MAX_LENGTH$1, " characters"));
823       }
824
825       debug_1('SemVer', version, options);
826       this.options = options;
827       this.loose = !!options.loose; // this isn't actually relevant for versions, but keep it so that we
828       // don't run into trouble passing this.options around.
829
830       this.includePrerelease = !!options.includePrerelease;
831       const m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
832
833       if (!m) {
834         throw new TypeError("Invalid Version: ".concat(version));
835       }
836
837       this.raw = version; // these are actually numbers
838
839       this.major = +m[1];
840       this.minor = +m[2];
841       this.patch = +m[3];
842
843       if (this.major > MAX_SAFE_INTEGER$1 || this.major < 0) {
844         throw new TypeError('Invalid major version');
845       }
846
847       if (this.minor > MAX_SAFE_INTEGER$1 || this.minor < 0) {
848         throw new TypeError('Invalid minor version');
849       }
850
851       if (this.patch > MAX_SAFE_INTEGER$1 || this.patch < 0) {
852         throw new TypeError('Invalid patch version');
853       } // numberify any prerelease numeric ids
854
855
856       if (!m[4]) {
857         this.prerelease = [];
858       } else {
859         this.prerelease = m[4].split('.').map(id => {
860           if (/^[0-9]+$/.test(id)) {
861             const num = +id;
862
863             if (num >= 0 && num < MAX_SAFE_INTEGER$1) {
864               return num;
865             }
866           }
867
868           return id;
869         });
870       }
871
872       this.build = m[5] ? m[5].split('.') : [];
873       this.format();
874     }
875
876     format() {
877       this.version = "".concat(this.major, ".").concat(this.minor, ".").concat(this.patch);
878
879       if (this.prerelease.length) {
880         this.version += "-".concat(this.prerelease.join('.'));
881       }
882
883       return this.version;
884     }
885
886     toString() {
887       return this.version;
888     }
889
890     compare(other) {
891       debug_1('SemVer.compare', this.version, this.options, other);
892
893       if (!(other instanceof SemVer)) {
894         if (typeof other === 'string' && other === this.version) {
895           return 0;
896         }
897
898         other = new SemVer(other, this.options);
899       }
900
901       if (other.version === this.version) {
902         return 0;
903       }
904
905       return this.compareMain(other) || this.comparePre(other);
906     }
907
908     compareMain(other) {
909       if (!(other instanceof SemVer)) {
910         other = new SemVer(other, this.options);
911       }
912
913       return compareIdentifiers$1(this.major, other.major) || compareIdentifiers$1(this.minor, other.minor) || compareIdentifiers$1(this.patch, other.patch);
914     }
915
916     comparePre(other) {
917       if (!(other instanceof SemVer)) {
918         other = new SemVer(other, this.options);
919       } // NOT having a prerelease is > having one
920
921
922       if (this.prerelease.length && !other.prerelease.length) {
923         return -1;
924       } else if (!this.prerelease.length && other.prerelease.length) {
925         return 1;
926       } else if (!this.prerelease.length && !other.prerelease.length) {
927         return 0;
928       }
929
930       let i = 0;
931
932       do {
933         const a = this.prerelease[i];
934         const b = other.prerelease[i];
935         debug_1('prerelease compare', i, a, b);
936
937         if (a === undefined && b === undefined) {
938           return 0;
939         } else if (b === undefined) {
940           return 1;
941         } else if (a === undefined) {
942           return -1;
943         } else if (a === b) {
944           continue;
945         } else {
946           return compareIdentifiers$1(a, b);
947         }
948       } while (++i);
949     }
950
951     compareBuild(other) {
952       if (!(other instanceof SemVer)) {
953         other = new SemVer(other, this.options);
954       }
955
956       let i = 0;
957
958       do {
959         const a = this.build[i];
960         const b = other.build[i];
961         debug_1('prerelease compare', i, a, b);
962
963         if (a === undefined && b === undefined) {
964           return 0;
965         } else if (b === undefined) {
966           return 1;
967         } else if (a === undefined) {
968           return -1;
969         } else if (a === b) {
970           continue;
971         } else {
972           return compareIdentifiers$1(a, b);
973         }
974       } while (++i);
975     } // preminor will bump the version up to the next minor release, and immediately
976     // down to pre-release. premajor and prepatch work the same way.
977
978
979     inc(release, identifier) {
980       switch (release) {
981         case 'premajor':
982           this.prerelease.length = 0;
983           this.patch = 0;
984           this.minor = 0;
985           this.major++;
986           this.inc('pre', identifier);
987           break;
988
989         case 'preminor':
990           this.prerelease.length = 0;
991           this.patch = 0;
992           this.minor++;
993           this.inc('pre', identifier);
994           break;
995
996         case 'prepatch':
997           // If this is already a prerelease, it will bump to the next version
998           // drop any prereleases that might already exist, since they are not
999           // relevant at this point.
1000           this.prerelease.length = 0;
1001           this.inc('patch', identifier);
1002           this.inc('pre', identifier);
1003           break;
1004         // If the input is a non-prerelease version, this acts the same as
1005         // prepatch.
1006
1007         case 'prerelease':
1008           if (this.prerelease.length === 0) {
1009             this.inc('patch', identifier);
1010           }
1011
1012           this.inc('pre', identifier);
1013           break;
1014
1015         case 'major':
1016           // If this is a pre-major version, bump up to the same major version.
1017           // Otherwise increment major.
1018           // 1.0.0-5 bumps to 1.0.0
1019           // 1.1.0 bumps to 2.0.0
1020           if (this.minor !== 0 || this.patch !== 0 || this.prerelease.length === 0) {
1021             this.major++;
1022           }
1023
1024           this.minor = 0;
1025           this.patch = 0;
1026           this.prerelease = [];
1027           break;
1028
1029         case 'minor':
1030           // If this is a pre-minor version, bump up to the same minor version.
1031           // Otherwise increment minor.
1032           // 1.2.0-5 bumps to 1.2.0
1033           // 1.2.1 bumps to 1.3.0
1034           if (this.patch !== 0 || this.prerelease.length === 0) {
1035             this.minor++;
1036           }
1037
1038           this.patch = 0;
1039           this.prerelease = [];
1040           break;
1041
1042         case 'patch':
1043           // If this is not a pre-release version, it will increment the patch.
1044           // If it is a pre-release it will bump up to the same patch version.
1045           // 1.2.0-5 patches to 1.2.0
1046           // 1.2.0 patches to 1.2.1
1047           if (this.prerelease.length === 0) {
1048             this.patch++;
1049           }
1050
1051           this.prerelease = [];
1052           break;
1053         // This probably shouldn't be used publicly.
1054         // 1.0.0 'pre' would become 1.0.0-0 which is the wrong direction.
1055
1056         case 'pre':
1057           if (this.prerelease.length === 0) {
1058             this.prerelease = [0];
1059           } else {
1060             let i = this.prerelease.length;
1061
1062             while (--i >= 0) {
1063               if (typeof this.prerelease[i] === 'number') {
1064                 this.prerelease[i]++;
1065                 i = -2;
1066               }
1067             }
1068
1069             if (i === -1) {
1070               // didn't increment anything
1071               this.prerelease.push(0);
1072             }
1073           }
1074
1075           if (identifier) {
1076             // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
1077             // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
1078             if (this.prerelease[0] === identifier) {
1079               if (isNaN(this.prerelease[1])) {
1080                 this.prerelease = [identifier, 0];
1081               }
1082             } else {
1083               this.prerelease = [identifier, 0];
1084             }
1085           }
1086
1087           break;
1088
1089         default:
1090           throw new Error("invalid increment argument: ".concat(release));
1091       }
1092
1093       this.format();
1094       this.raw = this.version;
1095       return this;
1096     }
1097
1098   }
1099
1100   var semver = SemVer;
1101
1102   const compare = (a, b, loose) => new semver(a, loose).compare(new semver(b, loose));
1103
1104   var compare_1 = compare;
1105
1106   const lt = (a, b, loose) => compare_1(a, b, loose) < 0;
1107
1108   var lt_1 = lt;
1109
1110   const gte = (a, b, loose) => compare_1(a, b, loose) >= 0;
1111
1112   var gte_1 = gte;
1113
1114   var arrayify = (object, keyName) => Object.entries(object).map(([key, value]) => Object.assign({
1115     [keyName]: key
1116   }, value));
1117
1118   var name = "prettier";
1119   var version$1 = "2.2.1";
1120   var description = "Prettier is an opinionated code formatter";
1121   var bin = "./bin/prettier.js";
1122   var repository = "prettier/prettier";
1123   var homepage = "https://prettier.io";
1124   var author = "James Long";
1125   var license = "MIT";
1126   var main = "./index.js";
1127   var browser$1 = "./standalone.js";
1128   var unpkg = "./standalone.js";
1129   var engines = {
1130         node: ">=10.13.0"
1131   };
1132   var files = [
1133         "index.js",
1134         "standalone.js",
1135         "src",
1136         "bin"
1137   ];
1138   var dependencies = {
1139         "@angular/compiler": "10.2.3",
1140         "@babel/code-frame": "7.10.4",
1141         "@babel/parser": "7.12.5",
1142         "@glimmer/syntax": "0.66.0",
1143         "@iarna/toml": "2.2.5",
1144         "@typescript-eslint/typescript-estree": "4.8.1",
1145         "angular-estree-parser": "2.2.1",
1146         "angular-html-parser": "1.7.1",
1147         camelcase: "6.2.0",
1148         chalk: "4.1.0",
1149         "ci-info": "watson/ci-info#f43f6a1cefff47fb361c88cf4b943fdbcaafe540",
1150         "cjk-regex": "2.0.0",
1151         cosmiconfig: "7.0.0",
1152         dashify: "2.0.0",
1153         diff: "5.0.0",
1154         editorconfig: "0.15.3",
1155         "editorconfig-to-prettier": "0.2.0",
1156         "escape-string-regexp": "4.0.0",
1157         espree: "7.3.0",
1158         esutils: "2.0.3",
1159         "fast-glob": "3.2.4",
1160         "fast-json-stable-stringify": "2.1.0",
1161         "find-parent-dir": "0.3.0",
1162         "flow-parser": "0.138.0",
1163         "get-stdin": "8.0.0",
1164         globby: "11.0.1",
1165         graphql: "15.4.0",
1166         "html-element-attributes": "2.3.0",
1167         "html-styles": "1.0.0",
1168         "html-tag-names": "1.1.5",
1169         "html-void-elements": "1.0.5",
1170         ignore: "4.0.6",
1171         "jest-docblock": "26.0.0",
1172         json5: "2.1.3",
1173         leven: "3.1.0",
1174         "lines-and-columns": "1.1.6",
1175         "linguist-languages": "7.12.1",
1176         lodash: "4.17.20",
1177         mem: "8.0.0",
1178         meriyah: "3.1.6",
1179         minimatch: "3.0.4",
1180         minimist: "1.2.5",
1181         "n-readlines": "1.0.1",
1182         outdent: "0.7.1",
1183         "parse-srcset": "ikatyang/parse-srcset#54eb9c1cb21db5c62b4d0e275d7249516df6f0ee",
1184         "please-upgrade-node": "3.2.0",
1185         "postcss-less": "3.1.4",
1186         "postcss-media-query-parser": "0.2.3",
1187         "postcss-scss": "2.1.1",
1188         "postcss-selector-parser": "2.2.3",
1189         "postcss-values-parser": "2.0.1",
1190         "regexp-util": "1.2.2",
1191         "remark-footnotes": "2.0.0",
1192         "remark-math": "3.0.1",
1193         "remark-parse": "8.0.3",
1194         resolve: "1.19.0",
1195         semver: "7.3.2",
1196         "string-width": "4.2.0",
1197         typescript: "4.1.2",
1198         "unicode-regex": "3.0.0",
1199         unified: "9.2.0",
1200         vnopts: "1.0.2",
1201         "yaml-unist-parser": "1.3.1"
1202   };
1203   var devDependencies = {
1204         "@babel/core": "7.12.3",
1205         "@babel/preset-env": "7.12.1",
1206         "@babel/types": "7.12.6",
1207         "@glimmer/reference": "0.66.0",
1208         "@rollup/plugin-alias": "3.1.1",
1209         "@rollup/plugin-babel": "5.2.1",
1210         "@rollup/plugin-commonjs": "16.0.0",
1211         "@rollup/plugin-json": "4.1.0",
1212         "@rollup/plugin-node-resolve": "10.0.0",
1213         "@rollup/plugin-replace": "2.3.4",
1214         "@types/estree": "0.0.45",
1215         "@types/node": "14.14.0",
1216         "@typescript-eslint/types": "4.8.1",
1217         "babel-jest": "26.6.3",
1218         "babel-loader": "8.2.1",
1219         benchmark: "2.1.4",
1220         "builtin-modules": "3.1.0",
1221         "cross-env": "7.0.2",
1222         cspell: "4.2.2",
1223         eslint: "7.13.0",
1224         "eslint-config-prettier": "6.15.0",
1225         "eslint-formatter-friendly": "7.0.0",
1226         "eslint-plugin-import": "2.22.1",
1227         "eslint-plugin-jest": "24.1.3",
1228         "eslint-plugin-prettier-internal-rules": "file:scripts/tools/eslint-plugin-prettier-internal-rules",
1229         "eslint-plugin-react": "7.21.5",
1230         "eslint-plugin-unicorn": "23.0.0",
1231         execa: "4.1.0",
1232         jest: "26.6.3",
1233         "jest-snapshot-serializer-ansi": "1.0.0",
1234         "jest-snapshot-serializer-raw": "1.1.0",
1235         "jest-watch-typeahead": "0.6.1",
1236         "npm-run-all": "4.1.5",
1237         "path-browserify": "1.0.1",
1238         prettier: "2.2.0",
1239         rimraf: "3.0.2",
1240         rollup: "2.33.3",
1241         "rollup-plugin-node-globals": "1.4.0",
1242         "rollup-plugin-terser": "7.0.2",
1243         shelljs: "0.8.4",
1244         "snapshot-diff": "0.8.1",
1245         "strip-ansi": "6.0.0",
1246         "synchronous-promise": "2.0.15",
1247         tempy: "1.0.0",
1248         "terser-webpack-plugin": "5.0.3",
1249         webpack: "5.5.1"
1250   };
1251   var scripts = {
1252         prepublishOnly: "echo \"Error: must publish from dist/\" && exit 1",
1253         "prepare-release": "yarn && yarn build && yarn test:dist",
1254         test: "jest",
1255         "test:dev-package": "cross-env INSTALL_PACKAGE=1 jest",
1256         "test:dist": "cross-env NODE_ENV=production jest",
1257         "test:dist-standalone": "cross-env NODE_ENV=production TEST_STANDALONE=1 jest",
1258         "test:integration": "jest tests_integration",
1259         "perf:repeat": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
1260         "perf:repeat-inspect": "yarn && yarn build && cross-env NODE_ENV=production node --inspect-brk ./dist/bin-prettier.js --debug-repeat ${PERF_REPEAT:-1000} --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
1261         "perf:benchmark": "yarn && yarn build && cross-env NODE_ENV=production node ./dist/bin-prettier.js --debug-benchmark --loglevel debug ${PERF_FILE:-./index.js} > /dev/null",
1262         lint: "run-p lint:*",
1263         "lint:typecheck": "tsc",
1264         "lint:eslint": "cross-env EFF_NO_LINK_RULES=true eslint . --format friendly",
1265         "lint:changelog": "node ./scripts/lint-changelog.js",
1266         "lint:prettier": "prettier . \"!test*\" --check",
1267         "lint:dist": "eslint --no-eslintrc --no-ignore --env=es6,browser --parser-options=ecmaVersion:2018 \"dist/!(bin-prettier|index|third-party).js\"",
1268         "lint:spellcheck": "cspell \"**/*\" \".github/**/*\"",
1269         "lint:deps": "node ./scripts/check-deps.js",
1270         fix: "run-s fix:eslint fix:prettier",
1271         "fix:eslint": "yarn lint:eslint --fix",
1272         "fix:prettier": "yarn lint:prettier --write",
1273         build: "node --max-old-space-size=3072 ./scripts/build/build.js",
1274         "build-docs": "node ./scripts/build-docs.js"
1275   };
1276   var require$$3 = {
1277         name: name,
1278         version: version$1,
1279         description: description,
1280         bin: bin,
1281         repository: repository,
1282         homepage: homepage,
1283         author: author,
1284         license: license,
1285         main: main,
1286         browser: browser$1,
1287         unpkg: unpkg,
1288         engines: engines,
1289         files: files,
1290         dependencies: dependencies,
1291         devDependencies: devDependencies,
1292         scripts: scripts
1293   };
1294
1295   var lib = createCommonjsModule(function (module, exports) {
1296
1297     Object.defineProperty(exports, "__esModule", {
1298       value: true
1299     }); // In the absence of a WeakSet or WeakMap implementation, don't break, but don't cache either.
1300
1301     function noop() {
1302       var args = [];
1303
1304       for (var _i = 0; _i < arguments.length; _i++) {
1305         args[_i] = arguments[_i];
1306       }
1307     }
1308
1309     function createWeakMap() {
1310       if (typeof WeakMap !== 'undefined') {
1311         return new WeakMap();
1312       } else {
1313         return fakeSetOrMap();
1314       }
1315     }
1316     /**
1317      * Creates and returns a no-op implementation of a WeakMap / WeakSet that never stores anything.
1318      */
1319
1320
1321     function fakeSetOrMap() {
1322       return {
1323         add: noop,
1324         delete: noop,
1325         get: noop,
1326         set: noop,
1327         has: function (k) {
1328           return false;
1329         }
1330       };
1331     } // Safe hasOwnProperty
1332
1333
1334     var hop = Object.prototype.hasOwnProperty;
1335
1336     var has = function (obj, prop) {
1337       return hop.call(obj, prop);
1338     }; // Copy all own enumerable properties from source to target
1339
1340
1341     function extend(target, source) {
1342       for (var prop in source) {
1343         if (has(source, prop)) {
1344           target[prop] = source[prop];
1345         }
1346       }
1347
1348       return target;
1349     }
1350
1351     var reLeadingNewline = /^[ \t]*(?:\r\n|\r|\n)/;
1352     var reTrailingNewline = /(?:\r\n|\r|\n)[ \t]*$/;
1353     var reStartsWithNewlineOrIsEmpty = /^(?:[\r\n]|$)/;
1354     var reDetectIndentation = /(?:\r\n|\r|\n)([ \t]*)(?:[^ \t\r\n]|$)/;
1355     var reOnlyWhitespaceWithAtLeastOneNewline = /^[ \t]*[\r\n][ \t\r\n]*$/;
1356
1357     function _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options) {
1358       // If first interpolated value is a reference to outdent,
1359       // determine indentation level from the indentation of the interpolated value.
1360       var indentationLevel = 0;
1361       var match = strings[0].match(reDetectIndentation);
1362
1363       if (match) {
1364         indentationLevel = match[1].length;
1365       }
1366
1367       var reSource = "(\\r\\n|\\r|\\n).{0," + indentationLevel + "}";
1368       var reMatchIndent = new RegExp(reSource, 'g');
1369
1370       if (firstInterpolatedValueSetsIndentationLevel) {
1371         strings = strings.slice(1);
1372       }
1373
1374       var newline = options.newline,
1375           trimLeadingNewline = options.trimLeadingNewline,
1376           trimTrailingNewline = options.trimTrailingNewline;
1377       var normalizeNewlines = typeof newline === 'string';
1378       var l = strings.length;
1379       var outdentedStrings = strings.map(function (v, i) {
1380         // Remove leading indentation from all lines
1381         v = v.replace(reMatchIndent, '$1'); // Trim a leading newline from the first string
1382
1383         if (i === 0 && trimLeadingNewline) {
1384           v = v.replace(reLeadingNewline, '');
1385         } // Trim a trailing newline from the last string
1386
1387
1388         if (i === l - 1 && trimTrailingNewline) {
1389           v = v.replace(reTrailingNewline, '');
1390         } // Normalize newlines
1391
1392
1393         if (normalizeNewlines) {
1394           v = v.replace(/\r\n|\n|\r/g, function (_) {
1395             return newline;
1396           });
1397         }
1398
1399         return v;
1400       });
1401       return outdentedStrings;
1402     }
1403
1404     function concatStringsAndValues(strings, values) {
1405       var ret = '';
1406
1407       for (var i = 0, l = strings.length; i < l; i++) {
1408         ret += strings[i];
1409
1410         if (i < l - 1) {
1411           ret += values[i];
1412         }
1413       }
1414
1415       return ret;
1416     }
1417
1418     function isTemplateStringsArray(v) {
1419       return has(v, 'raw') && has(v, 'length');
1420     }
1421     /**
1422      * It is assumed that opts will not change.  If this is a problem, clone your options object and pass the clone to
1423      * makeInstance
1424      * @param options
1425      * @return {outdent}
1426      */
1427
1428
1429     function createInstance(options) {
1430       /** Cache of pre-processed template literal arrays */
1431       var arrayAutoIndentCache = createWeakMap();
1432       /**
1433        * Cache of pre-processed template literal arrays, where first interpolated value is a reference to outdent,
1434        * before interpolated values are injected.
1435        */
1436
1437       var arrayFirstInterpSetsIndentCache = createWeakMap();
1438
1439       function outdent(stringsOrOptions) {
1440         var values = [];
1441
1442         for (var _i = 1; _i < arguments.length; _i++) {
1443           values[_i - 1] = arguments[_i];
1444         }
1445         /* tslint:enable:no-shadowed-variable */
1446
1447
1448         if (isTemplateStringsArray(stringsOrOptions)) {
1449           var strings = stringsOrOptions; // Is first interpolated value a reference to outdent, alone on its own line, without any preceding non-whitespace?
1450
1451           var firstInterpolatedValueSetsIndentationLevel = (values[0] === outdent || values[0] === defaultOutdent) && reOnlyWhitespaceWithAtLeastOneNewline.test(strings[0]) && reStartsWithNewlineOrIsEmpty.test(strings[1]); // Perform outdentation
1452
1453           var cache = firstInterpolatedValueSetsIndentationLevel ? arrayFirstInterpSetsIndentCache : arrayAutoIndentCache;
1454           var renderedArray = cache.get(strings);
1455
1456           if (!renderedArray) {
1457             renderedArray = _outdentArray(strings, firstInterpolatedValueSetsIndentationLevel, options);
1458             cache.set(strings, renderedArray);
1459           }
1460           /** If no interpolated values, skip concatenation step */
1461
1462
1463           if (values.length === 0) {
1464             return renderedArray[0];
1465           }
1466           /** Concatenate string literals with interpolated values */
1467
1468
1469           var rendered = concatStringsAndValues(renderedArray, firstInterpolatedValueSetsIndentationLevel ? values.slice(1) : values);
1470           return rendered;
1471         } else {
1472           // Create and return a new instance of outdent with the given options
1473           return createInstance(extend(extend({}, options), stringsOrOptions || {}));
1474         }
1475       }
1476
1477       var fullOutdent = extend(outdent, {
1478         string: function (str) {
1479           return _outdentArray([str], false, options)[0];
1480         }
1481       });
1482       return fullOutdent;
1483     }
1484
1485     var defaultOutdent = createInstance({
1486       trimLeadingNewline: true,
1487       trimTrailingNewline: true
1488     });
1489     exports.outdent = defaultOutdent; // Named exports.  Simple and preferred.
1490     // import outdent from 'outdent';
1491
1492     exports.default = defaultOutdent;
1493
1494     {
1495       // In webpack harmony-modules environments, module.exports is read-only,
1496       // so we fail gracefully.
1497       try {
1498         module.exports = defaultOutdent;
1499         Object.defineProperty(defaultOutdent, '__esModule', {
1500           value: true
1501         });
1502         defaultOutdent.default = defaultOutdent;
1503         defaultOutdent.outdent = defaultOutdent;
1504       } catch (e) {}
1505     }
1506   });
1507
1508   function _templateObject6() {
1509     const data = _taggedTemplateLiteral(["\n      Require either '@prettier' or '@format' to be present in the file's first docblock comment\n      in order for it to be formatted.\n    "]);
1510
1511     _templateObject6 = function () {
1512       return data;
1513     };
1514
1515     return data;
1516   }
1517
1518   function _templateObject5() {
1519     const data = _taggedTemplateLiteral(["\n      Format code starting at a given character offset.\n      The range will extend backwards to the start of the first line containing the selected statement.\n      This option cannot be used with --cursor-offset.\n    "]);
1520
1521     _templateObject5 = function () {
1522       return data;
1523     };
1524
1525     return data;
1526   }
1527
1528   function _templateObject4() {
1529     const data = _taggedTemplateLiteral(["\n      Format code ending at a given character offset (exclusive).\n      The range will extend forwards to the end of the selected statement.\n      This option cannot be used with --cursor-offset.\n    "]);
1530
1531     _templateObject4 = function () {
1532       return data;
1533     };
1534
1535     return data;
1536   }
1537
1538   function _templateObject3() {
1539     const data = _taggedTemplateLiteral(["\n      Custom directory that contains prettier plugins in node_modules subdirectory.\n      Overrides default behavior when plugins are searched relatively to the location of Prettier.\n      Multiple values are accepted.\n    "]);
1540
1541     _templateObject3 = function () {
1542       return data;
1543     };
1544
1545     return data;
1546   }
1547
1548   function _templateObject2() {
1549     const data = _taggedTemplateLiteral(["\n          Maintain existing\n          (mixed values within one file are normalised by looking at what's used after the first line)\n        "]);
1550
1551     _templateObject2 = function () {
1552       return data;
1553     };
1554
1555     return data;
1556   }
1557
1558   function _templateObject() {
1559     const data = _taggedTemplateLiteral(["\n      Print (to stderr) where a cursor at the given position would move to after formatting.\n      This option cannot be used with --range-start and --range-end.\n    "]);
1560
1561     _templateObject = function () {
1562       return data;
1563     };
1564
1565     return data;
1566   }
1567
1568   const {
1569     outdent
1570   } = lib;
1571   const CATEGORY_CONFIG = "Config";
1572   const CATEGORY_EDITOR = "Editor";
1573   const CATEGORY_FORMAT = "Format";
1574   const CATEGORY_OTHER = "Other";
1575   const CATEGORY_OUTPUT = "Output";
1576   const CATEGORY_GLOBAL = "Global";
1577   const CATEGORY_SPECIAL = "Special";
1578   /**
1579    * @typedef {Object} OptionInfo
1580    * @property {string} [since] - available since version
1581    * @property {string} category
1582    * @property {'int' | 'boolean' | 'choice' | 'path'} type
1583    * @property {boolean} [array] - indicate it's an array of the specified type
1584    * @property {OptionValueInfo} [default]
1585    * @property {OptionRangeInfo} [range] - for type int
1586    * @property {string} description
1587    * @property {string} [deprecated] - deprecated since version
1588    * @property {OptionRedirectInfo} [redirect] - redirect deprecated option
1589    * @property {(value: any) => boolean} [exception]
1590    * @property {OptionChoiceInfo[]} [choices] - for type choice
1591    * @property {string} [cliName]
1592    * @property {string} [cliCategory]
1593    * @property {string} [cliDescription]
1594    *
1595    * @typedef {number | boolean | string} OptionValue
1596    * @typedef {OptionValue | [{ value: OptionValue[] }] | Array<{ since: string, value: OptionValue}>} OptionValueInfo
1597    *
1598    * @typedef {Object} OptionRedirectInfo
1599    * @property {string} option
1600    * @property {OptionValue} value
1601    *
1602    * @typedef {Object} OptionRangeInfo
1603    * @property {number} start - recommended range start
1604    * @property {number} end - recommended range end
1605    * @property {number} step - recommended range step
1606    *
1607    * @typedef {Object} OptionChoiceInfo
1608    * @property {boolean | string} value - boolean for the option that is originally boolean type
1609    * @property {string} description
1610    * @property {string} [since] - undefined if available since the first version of the option
1611    * @property {string} [deprecated] - deprecated since version
1612    * @property {OptionValueInfo} [redirect] - redirect deprecated value
1613    */
1614
1615   /** @type {{ [name: string]: OptionInfo }} */
1616
1617   const options = {
1618     cursorOffset: {
1619       since: "1.4.0",
1620       category: CATEGORY_SPECIAL,
1621       type: "int",
1622       default: -1,
1623       range: {
1624         start: -1,
1625         end: Infinity,
1626         step: 1
1627       },
1628       description: outdent(_templateObject()),
1629       cliCategory: CATEGORY_EDITOR
1630     },
1631     endOfLine: {
1632       since: "1.15.0",
1633       category: CATEGORY_GLOBAL,
1634       type: "choice",
1635       default: [{
1636         since: "1.15.0",
1637         value: "auto"
1638       }, {
1639         since: "2.0.0",
1640         value: "lf"
1641       }],
1642       description: "Which end of line characters to apply.",
1643       choices: [{
1644         value: "lf",
1645         description: "Line Feed only (\\n), common on Linux and macOS as well as inside git repos"
1646       }, {
1647         value: "crlf",
1648         description: "Carriage Return + Line Feed characters (\\r\\n), common on Windows"
1649       }, {
1650         value: "cr",
1651         description: "Carriage Return character only (\\r), used very rarely"
1652       }, {
1653         value: "auto",
1654         description: outdent(_templateObject2())
1655       }]
1656     },
1657     filepath: {
1658       since: "1.4.0",
1659       category: CATEGORY_SPECIAL,
1660       type: "path",
1661       description: "Specify the input filepath. This will be used to do parser inference.",
1662       cliName: "stdin-filepath",
1663       cliCategory: CATEGORY_OTHER,
1664       cliDescription: "Path to the file to pretend that stdin comes from."
1665     },
1666     insertPragma: {
1667       since: "1.8.0",
1668       category: CATEGORY_SPECIAL,
1669       type: "boolean",
1670       default: false,
1671       description: "Insert @format pragma into file's first docblock comment.",
1672       cliCategory: CATEGORY_OTHER
1673     },
1674     parser: {
1675       since: "0.0.10",
1676       category: CATEGORY_GLOBAL,
1677       type: "choice",
1678       default: [{
1679         since: "0.0.10",
1680         value: "babylon"
1681       }, {
1682         since: "1.13.0",
1683         value: undefined
1684       }],
1685       description: "Which parser to use.",
1686       exception: value => typeof value === "string" || typeof value === "function",
1687       choices: [{
1688         value: "flow",
1689         description: "Flow"
1690       }, {
1691         value: "babel",
1692         since: "1.16.0",
1693         description: "JavaScript"
1694       }, {
1695         value: "babel-flow",
1696         since: "1.16.0",
1697         description: "Flow"
1698       }, {
1699         value: "babel-ts",
1700         since: "2.0.0",
1701         description: "TypeScript"
1702       }, {
1703         value: "typescript",
1704         since: "1.4.0",
1705         description: "TypeScript"
1706       }, {
1707         value: "espree",
1708         since: "2.2.0",
1709         description: "JavaScript"
1710       }, {
1711         value: "meriyah",
1712         since: "2.2.0",
1713         description: "JavaScript"
1714       }, {
1715         value: "css",
1716         since: "1.7.1",
1717         description: "CSS"
1718       }, {
1719         value: "less",
1720         since: "1.7.1",
1721         description: "Less"
1722       }, {
1723         value: "scss",
1724         since: "1.7.1",
1725         description: "SCSS"
1726       }, {
1727         value: "json",
1728         since: "1.5.0",
1729         description: "JSON"
1730       }, {
1731         value: "json5",
1732         since: "1.13.0",
1733         description: "JSON5"
1734       }, {
1735         value: "json-stringify",
1736         since: "1.13.0",
1737         description: "JSON.stringify"
1738       }, {
1739         value: "graphql",
1740         since: "1.5.0",
1741         description: "GraphQL"
1742       }, {
1743         value: "markdown",
1744         since: "1.8.0",
1745         description: "Markdown"
1746       }, {
1747         value: "mdx",
1748         since: "1.15.0",
1749         description: "MDX"
1750       }, {
1751         value: "vue",
1752         since: "1.10.0",
1753         description: "Vue"
1754       }, {
1755         value: "yaml",
1756         since: "1.14.0",
1757         description: "YAML"
1758       }, {
1759         value: "glimmer",
1760         since: null,
1761         description: "Handlebars"
1762       }, {
1763         value: "html",
1764         since: "1.15.0",
1765         description: "HTML"
1766       }, {
1767         value: "angular",
1768         since: "1.15.0",
1769         description: "Angular"
1770       }, {
1771         value: "lwc",
1772         since: "1.17.0",
1773         description: "Lightning Web Components"
1774       }]
1775     },
1776     plugins: {
1777       since: "1.10.0",
1778       type: "path",
1779       array: true,
1780       default: [{
1781         value: []
1782       }],
1783       category: CATEGORY_GLOBAL,
1784       description: "Add a plugin. Multiple plugins can be passed as separate `--plugin`s.",
1785       exception: value => typeof value === "string" || typeof value === "object",
1786       cliName: "plugin",
1787       cliCategory: CATEGORY_CONFIG
1788     },
1789     pluginSearchDirs: {
1790       since: "1.13.0",
1791       type: "path",
1792       array: true,
1793       default: [{
1794         value: []
1795       }],
1796       category: CATEGORY_GLOBAL,
1797       description: outdent(_templateObject3()),
1798       exception: value => typeof value === "string" || typeof value === "object",
1799       cliName: "plugin-search-dir",
1800       cliCategory: CATEGORY_CONFIG
1801     },
1802     printWidth: {
1803       since: "0.0.0",
1804       category: CATEGORY_GLOBAL,
1805       type: "int",
1806       default: 80,
1807       description: "The line length where Prettier will try wrap.",
1808       range: {
1809         start: 0,
1810         end: Infinity,
1811         step: 1
1812       }
1813     },
1814     rangeEnd: {
1815       since: "1.4.0",
1816       category: CATEGORY_SPECIAL,
1817       type: "int",
1818       default: Infinity,
1819       range: {
1820         start: 0,
1821         end: Infinity,
1822         step: 1
1823       },
1824       description: outdent(_templateObject4()),
1825       cliCategory: CATEGORY_EDITOR
1826     },
1827     rangeStart: {
1828       since: "1.4.0",
1829       category: CATEGORY_SPECIAL,
1830       type: "int",
1831       default: 0,
1832       range: {
1833         start: 0,
1834         end: Infinity,
1835         step: 1
1836       },
1837       description: outdent(_templateObject5()),
1838       cliCategory: CATEGORY_EDITOR
1839     },
1840     requirePragma: {
1841       since: "1.7.0",
1842       category: CATEGORY_SPECIAL,
1843       type: "boolean",
1844       default: false,
1845       description: outdent(_templateObject6()),
1846       cliCategory: CATEGORY_OTHER
1847     },
1848     tabWidth: {
1849       type: "int",
1850       category: CATEGORY_GLOBAL,
1851       default: 2,
1852       description: "Number of spaces per indentation level.",
1853       range: {
1854         start: 0,
1855         end: Infinity,
1856         step: 1
1857       }
1858     },
1859     useTabs: {
1860       since: "1.0.0",
1861       category: CATEGORY_GLOBAL,
1862       type: "boolean",
1863       default: false,
1864       description: "Indent with tabs instead of spaces."
1865     },
1866     embeddedLanguageFormatting: {
1867       since: "2.1.0",
1868       category: CATEGORY_GLOBAL,
1869       type: "choice",
1870       default: [{
1871         since: "2.1.0",
1872         value: "auto"
1873       }],
1874       description: "Control how Prettier formats quoted code embedded in the file.",
1875       choices: [{
1876         value: "auto",
1877         description: "Format embedded code if Prettier can automatically identify it."
1878       }, {
1879         value: "off",
1880         description: "Never automatically format embedded code."
1881       }]
1882     }
1883   };
1884   var coreOptions = {
1885     CATEGORY_CONFIG,
1886     CATEGORY_EDITOR,
1887     CATEGORY_FORMAT,
1888     CATEGORY_OTHER,
1889     CATEGORY_OUTPUT,
1890     CATEGORY_GLOBAL,
1891     CATEGORY_SPECIAL,
1892     options
1893   };
1894
1895   const semver$1 = {
1896     compare: compare_1,
1897     lt: lt_1,
1898     gte: gte_1
1899   };
1900   const currentVersion = require$$3.version;
1901   const coreOptions$1 = coreOptions.options;
1902   /**
1903    * Strings in `plugins` and `pluginSearchDirs` are handled by a wrapped version
1904    * of this function created by `withPlugins`. Don't pass them here directly.
1905    * @param {object} param0
1906    * @param {(string | object)[]=} param0.plugins Strings are resolved by `withPlugins`.
1907    * @param {string[]=} param0.pluginSearchDirs Added by `withPlugins`.
1908    * @param {boolean=} param0.showUnreleased
1909    * @param {boolean=} param0.showDeprecated
1910    * @param {boolean=} param0.showInternal
1911    */
1912
1913   function getSupportInfo({
1914     plugins = [],
1915     showUnreleased = false,
1916     showDeprecated = false,
1917     showInternal = false
1918   } = {}) {
1919     // pre-release version is smaller than the normal version in semver,
1920     // we need to treat it as the normal one so as to test new features.
1921     const version = currentVersion.split("-", 1)[0];
1922     const languages = plugins.reduce((all, plugin) => all.concat(plugin.languages || []), []).filter(filterSince);
1923     const options = arrayify(Object.assign({}, ...plugins.map(({
1924       options
1925     }) => options), coreOptions$1), "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 => {
1926       option = Object.assign({}, option);
1927
1928       if (Array.isArray(option.default)) {
1929         option.default = option.default.length === 1 ? option.default[0].value : option.default.filter(filterSince).sort((info1, info2) => semver$1.compare(info2.since, info1.since))[0].value;
1930       }
1931
1932       if (Array.isArray(option.choices)) {
1933         option.choices = option.choices.filter(option => filterSince(option) && filterDeprecated(option));
1934
1935         if (option.name === "parser") {
1936           collectParsersFromLanguages(option, languages, plugins);
1937         }
1938       }
1939
1940       const pluginDefaults = plugins.filter(plugin => plugin.defaultOptions && plugin.defaultOptions[option.name] !== undefined).reduce((reduced, plugin) => {
1941         reduced[plugin.name] = plugin.defaultOptions[option.name];
1942         return reduced;
1943       }, {});
1944       return Object.assign({}, option, {
1945         pluginDefaults
1946       });
1947     });
1948     return {
1949       languages,
1950       options
1951     };
1952
1953     function filterSince(object) {
1954       return showUnreleased || !("since" in object) || object.since && semver$1.gte(version, object.since);
1955     }
1956
1957     function filterDeprecated(object) {
1958       return showDeprecated || !("deprecated" in object) || object.deprecated && semver$1.lt(version, object.deprecated);
1959     }
1960
1961     function mapInternal(object) {
1962       if (showInternal) {
1963         return object;
1964       }
1965
1966       const newObject = _objectWithoutPropertiesLoose(object, ["cliName", "cliCategory", "cliDescription"]);
1967
1968       return newObject;
1969     }
1970   }
1971
1972   function collectParsersFromLanguages(option, languages, plugins) {
1973     const existingValues = new Set(option.choices.map(choice => choice.value));
1974
1975     for (const language of languages) {
1976       if (language.parsers) {
1977         for (const value of language.parsers) {
1978           if (!existingValues.has(value)) {
1979             existingValues.add(value);
1980             const plugin = plugins.find(plugin => plugin.parsers && plugin.parsers[value]);
1981             let description = language.name;
1982
1983             if (plugin && plugin.name) {
1984               description += " (plugin: ".concat(plugin.name, ")");
1985             }
1986
1987             option.choices.push({
1988               value,
1989               description
1990             });
1991           }
1992         }
1993       }
1994     }
1995   }
1996
1997   var support = {
1998     getSupportInfo
1999   };
2000
2001   const {
2002     getSupportInfo: getSupportInfo$1
2003   } = support;
2004   const notAsciiRegex = /[^\x20-\x7F]/;
2005
2006   const getPenultimate = arr => arr[arr.length - 2];
2007   /**
2008    * @typedef {{backwards?: boolean}} SkipOptions
2009    */
2010
2011   /**
2012    * @param {string | RegExp} chars
2013    * @returns {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2014    */
2015
2016
2017   function skip(chars) {
2018     return (text, index, opts) => {
2019       const backwards = opts && opts.backwards; // Allow `skip` functions to be threaded together without having
2020       // to check for failures (did someone say monads?).
2021
2022       /* istanbul ignore next */
2023
2024       if (index === false) {
2025         return false;
2026       }
2027
2028       const {
2029         length
2030       } = text;
2031       let cursor = index;
2032
2033       while (cursor >= 0 && cursor < length) {
2034         const c = text.charAt(cursor);
2035
2036         if (chars instanceof RegExp) {
2037           if (!chars.test(c)) {
2038             return cursor;
2039           }
2040         } else if (!chars.includes(c)) {
2041           return cursor;
2042         }
2043
2044         backwards ? cursor-- : cursor++;
2045       }
2046
2047       if (cursor === -1 || cursor === length) {
2048         // If we reached the beginning or end of the file, return the
2049         // out-of-bounds cursor. It's up to the caller to handle this
2050         // correctly. We don't want to indicate `false` though if it
2051         // actually skipped valid characters.
2052         return cursor;
2053       }
2054
2055       return false;
2056     };
2057   }
2058   /**
2059    * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2060    */
2061
2062
2063   const skipWhitespace = skip(/\s/);
2064   /**
2065    * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2066    */
2067
2068   const skipSpaces = skip(" \t");
2069   /**
2070    * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2071    */
2072
2073   const skipToLineEnd = skip(",; \t");
2074   /**
2075    * @type {(text: string, index: number | false, opts?: SkipOptions) => number | false}
2076    */
2077
2078   const skipEverythingButNewLine = skip(/[^\n\r]/);
2079   /**
2080    * @param {string} text
2081    * @param {number | false} index
2082    * @returns {number | false}
2083    */
2084
2085   function skipInlineComment(text, index) {
2086     /* istanbul ignore next */
2087     if (index === false) {
2088       return false;
2089     }
2090
2091     if (text.charAt(index) === "/" && text.charAt(index + 1) === "*") {
2092       for (let i = index + 2; i < text.length; ++i) {
2093         if (text.charAt(i) === "*" && text.charAt(i + 1) === "/") {
2094           return i + 2;
2095         }
2096       }
2097     }
2098
2099     return index;
2100   }
2101   /**
2102    * @param {string} text
2103    * @param {number | false} index
2104    * @returns {number | false}
2105    */
2106
2107
2108   function skipTrailingComment(text, index) {
2109     /* istanbul ignore next */
2110     if (index === false) {
2111       return false;
2112     }
2113
2114     if (text.charAt(index) === "/" && text.charAt(index + 1) === "/") {
2115       return skipEverythingButNewLine(text, index);
2116     }
2117
2118     return index;
2119   } // This one doesn't use the above helper function because it wants to
2120   // test \r\n in order and `skip` doesn't support ordering and we only
2121   // want to skip one newline. It's simple to implement.
2122
2123   /**
2124    * @param {string} text
2125    * @param {number | false} index
2126    * @param {SkipOptions=} opts
2127    * @returns {number | false}
2128    */
2129
2130
2131   function skipNewline(text, index, opts) {
2132     const backwards = opts && opts.backwards;
2133
2134     if (index === false) {
2135       return false;
2136     }
2137
2138     const atIndex = text.charAt(index);
2139
2140     if (backwards) {
2141       // We already replace `\r\n` with `\n` before parsing
2142
2143       /* istanbul ignore next */
2144       if (text.charAt(index - 1) === "\r" && atIndex === "\n") {
2145         return index - 2;
2146       }
2147
2148       if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
2149         return index - 1;
2150       }
2151     } else {
2152       // We already replace `\r\n` with `\n` before parsing
2153
2154       /* istanbul ignore next */
2155       if (atIndex === "\r" && text.charAt(index + 1) === "\n") {
2156         return index + 2;
2157       }
2158
2159       if (atIndex === "\n" || atIndex === "\r" || atIndex === "\u2028" || atIndex === "\u2029") {
2160         return index + 1;
2161       }
2162     }
2163
2164     return index;
2165   }
2166   /**
2167    * @param {string} text
2168    * @param {number} index
2169    * @param {SkipOptions=} opts
2170    * @returns {boolean}
2171    */
2172
2173
2174   function hasNewline(text, index, opts) {
2175     opts = opts || {};
2176     const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
2177     const idx2 = skipNewline(text, idx, opts);
2178     return idx !== idx2;
2179   }
2180   /**
2181    * @param {string} text
2182    * @param {number} start
2183    * @param {number} end
2184    * @returns {boolean}
2185    */
2186
2187
2188   function hasNewlineInRange(text, start, end) {
2189     for (let i = start; i < end; ++i) {
2190       if (text.charAt(i) === "\n") {
2191         return true;
2192       }
2193     }
2194
2195     return false;
2196   } // Note: this function doesn't ignore leading comments unlike isNextLineEmpty
2197
2198   /**
2199    * @template N
2200    * @param {string} text
2201    * @param {N} node
2202    * @param {(node: N) => number} locStart
2203    */
2204
2205
2206   function isPreviousLineEmpty(text, node, locStart) {
2207     /** @type {number | false} */
2208     let idx = locStart(node) - 1;
2209     idx = skipSpaces(text, idx, {
2210       backwards: true
2211     });
2212     idx = skipNewline(text, idx, {
2213       backwards: true
2214     });
2215     idx = skipSpaces(text, idx, {
2216       backwards: true
2217     });
2218     const idx2 = skipNewline(text, idx, {
2219       backwards: true
2220     });
2221     return idx !== idx2;
2222   }
2223   /**
2224    * @param {string} text
2225    * @param {number} index
2226    * @returns {boolean}
2227    */
2228
2229
2230   function isNextLineEmptyAfterIndex(text, index) {
2231     /** @type {number | false} */
2232     let oldIdx = null;
2233     /** @type {number | false} */
2234
2235     let idx = index;
2236
2237     while (idx !== oldIdx) {
2238       // We need to skip all the potential trailing inline comments
2239       oldIdx = idx;
2240       idx = skipToLineEnd(text, idx);
2241       idx = skipInlineComment(text, idx);
2242       idx = skipSpaces(text, idx);
2243     }
2244
2245     idx = skipTrailingComment(text, idx);
2246     idx = skipNewline(text, idx);
2247     return idx !== false && hasNewline(text, idx);
2248   }
2249   /**
2250    * @template N
2251    * @param {string} text
2252    * @param {N} node
2253    * @param {(node: N) => number} locEnd
2254    * @returns {boolean}
2255    */
2256
2257
2258   function isNextLineEmpty(text, node, locEnd) {
2259     return isNextLineEmptyAfterIndex(text, locEnd(node));
2260   }
2261   /**
2262    * @param {string} text
2263    * @param {number} idx
2264    * @returns {number | false}
2265    */
2266
2267
2268   function getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, idx) {
2269     /** @type {number | false} */
2270     let oldIdx = null;
2271     /** @type {number | false} */
2272
2273     let nextIdx = idx;
2274
2275     while (nextIdx !== oldIdx) {
2276       oldIdx = nextIdx;
2277       nextIdx = skipSpaces(text, nextIdx);
2278       nextIdx = skipInlineComment(text, nextIdx);
2279       nextIdx = skipTrailingComment(text, nextIdx);
2280       nextIdx = skipNewline(text, nextIdx);
2281     }
2282
2283     return nextIdx;
2284   }
2285   /**
2286    * @template N
2287    * @param {string} text
2288    * @param {N} node
2289    * @param {(node: N) => number} locEnd
2290    * @returns {number | false}
2291    */
2292
2293
2294   function getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd) {
2295     return getNextNonSpaceNonCommentCharacterIndexWithStartIndex(text, locEnd(node));
2296   }
2297   /**
2298    * @template N
2299    * @param {string} text
2300    * @param {N} node
2301    * @param {(node: N) => number} locEnd
2302    * @returns {string}
2303    */
2304
2305
2306   function getNextNonSpaceNonCommentCharacter(text, node, locEnd) {
2307     return text.charAt( // @ts-ignore => TBD: can return false, should we define a fallback?
2308     getNextNonSpaceNonCommentCharacterIndex(text, node, locEnd));
2309   } // Not using, but it's public utils
2310
2311   /* istanbul ignore next */
2312
2313   /**
2314    * @param {string} text
2315    * @param {number} index
2316    * @param {SkipOptions=} opts
2317    * @returns {boolean}
2318    */
2319
2320
2321   function hasSpaces(text, index, opts) {
2322     opts = opts || {};
2323     const idx = skipSpaces(text, opts.backwards ? index - 1 : index, opts);
2324     return idx !== index;
2325   }
2326   /**
2327    * @param {string} value
2328    * @param {number} tabWidth
2329    * @param {number=} startIndex
2330    * @returns {number}
2331    */
2332
2333
2334   function getAlignmentSize(value, tabWidth, startIndex) {
2335     startIndex = startIndex || 0;
2336     let size = 0;
2337
2338     for (let i = startIndex; i < value.length; ++i) {
2339       if (value[i] === "\t") {
2340         // Tabs behave in a way that they are aligned to the nearest
2341         // multiple of tabWidth:
2342         // 0 -> 4, 1 -> 4, 2 -> 4, 3 -> 4
2343         // 4 -> 8, 5 -> 8, 6 -> 8, 7 -> 8 ...
2344         size = size + tabWidth - size % tabWidth;
2345       } else {
2346         size++;
2347       }
2348     }
2349
2350     return size;
2351   }
2352   /**
2353    * @param {string} value
2354    * @param {number} tabWidth
2355    * @returns {number}
2356    */
2357
2358
2359   function getIndentSize(value, tabWidth) {
2360     const lastNewlineIndex = value.lastIndexOf("\n");
2361
2362     if (lastNewlineIndex === -1) {
2363       return 0;
2364     }
2365
2366     return getAlignmentSize( // All the leading whitespaces
2367     value.slice(lastNewlineIndex + 1).match(/^[\t ]*/)[0], tabWidth);
2368   }
2369   /**
2370    * @typedef {'"' | "'"} Quote
2371    */
2372
2373   /**
2374    *
2375    * @param {string} raw
2376    * @param {Quote} preferredQuote
2377    * @returns {Quote}
2378    */
2379
2380
2381   function getPreferredQuote(raw, preferredQuote) {
2382     // `rawContent` is the string exactly like it appeared in the input source
2383     // code, without its enclosing quotes.
2384     const rawContent = raw.slice(1, -1);
2385     /** @type {{ quote: '"', regex: RegExp }} */
2386
2387     const double = {
2388       quote: '"',
2389       regex: /"/g
2390     };
2391     /** @type {{ quote: "'", regex: RegExp }} */
2392
2393     const single = {
2394       quote: "'",
2395       regex: /'/g
2396     };
2397     const preferred = preferredQuote === "'" ? single : double;
2398     const alternate = preferred === single ? double : single;
2399     let result = preferred.quote; // If `rawContent` contains at least one of the quote preferred for enclosing
2400     // the string, we might want to enclose with the alternate quote instead, to
2401     // minimize the number of escaped quotes.
2402
2403     if (rawContent.includes(preferred.quote) || rawContent.includes(alternate.quote)) {
2404       const numPreferredQuotes = (rawContent.match(preferred.regex) || []).length;
2405       const numAlternateQuotes = (rawContent.match(alternate.regex) || []).length;
2406       result = numPreferredQuotes > numAlternateQuotes ? alternate.quote : preferred.quote;
2407     }
2408
2409     return result;
2410   }
2411
2412   function printString(raw, options, isDirectiveLiteral) {
2413     // `rawContent` is the string exactly like it appeared in the input source
2414     // code, without its enclosing quotes.
2415     const rawContent = raw.slice(1, -1); // Check for the alternate quote, to determine if we're allowed to swap
2416     // the quotes on a DirectiveLiteral.
2417
2418     const canChangeDirectiveQuotes = !rawContent.includes('"') && !rawContent.includes("'");
2419     /** @type {Quote} */
2420
2421     const enclosingQuote = options.parser === "json" ? '"' : options.__isInHtmlAttribute ? "'" : getPreferredQuote(raw, options.singleQuote ? "'" : '"'); // Directives are exact code unit sequences, which means that you can't
2422     // change the escape sequences they use.
2423     // See https://github.com/prettier/prettier/issues/1555
2424     // and https://tc39.github.io/ecma262/#directive-prologue
2425
2426     if (isDirectiveLiteral) {
2427       if (canChangeDirectiveQuotes) {
2428         return enclosingQuote + rawContent + enclosingQuote;
2429       }
2430
2431       return raw;
2432     } // It might sound unnecessary to use `makeString` even if the string already
2433     // is enclosed with `enclosingQuote`, but it isn't. The string could contain
2434     // unnecessary escapes (such as in `"\'"`). Always using `makeString` makes
2435     // sure that we consistently output the minimum amount of escaped quotes.
2436
2437
2438     return makeString(rawContent, enclosingQuote, !(options.parser === "css" || options.parser === "less" || options.parser === "scss" || options.embeddedInHtml));
2439   }
2440   /**
2441    * @param {string} rawContent
2442    * @param {Quote} enclosingQuote
2443    * @param {boolean=} unescapeUnnecessaryEscapes
2444    * @returns {string}
2445    */
2446
2447
2448   function makeString(rawContent, enclosingQuote, unescapeUnnecessaryEscapes) {
2449     const otherQuote = enclosingQuote === '"' ? "'" : '"'; // Matches _any_ escape and unescaped quotes (both single and double).
2450
2451     const regex = /\\([\S\s])|(["'])/g; // Escape and unescape single and double quotes as needed to be able to
2452     // enclose `rawContent` with `enclosingQuote`.
2453
2454     const newContent = rawContent.replace(regex, (match, escaped, quote) => {
2455       // If we matched an escape, and the escaped character is a quote of the
2456       // other type than we intend to enclose the string with, there's no need for
2457       // it to be escaped, so return it _without_ the backslash.
2458       if (escaped === otherQuote) {
2459         return escaped;
2460       } // If we matched an unescaped quote and it is of the _same_ type as we
2461       // intend to enclose the string with, it must be escaped, so return it with
2462       // a backslash.
2463
2464
2465       if (quote === enclosingQuote) {
2466         return "\\" + quote;
2467       }
2468
2469       if (quote) {
2470         return quote;
2471       } // Unescape any unnecessarily escaped character.
2472       // Adapted from https://github.com/eslint/eslint/blob/de0b4ad7bd820ade41b1f606008bea68683dc11a/lib/rules/no-useless-escape.js#L27
2473
2474
2475       return unescapeUnnecessaryEscapes && /^[^\n\r"'0-7\\bfnrt-vx\u2028\u2029]$/.test(escaped) ? escaped : "\\" + escaped;
2476     });
2477     return enclosingQuote + newContent + enclosingQuote;
2478   }
2479
2480   function printNumber(rawNumber) {
2481     return rawNumber.toLowerCase() // Remove unnecessary plus and zeroes from scientific notation.
2482     .replace(/^([+-]?[\d.]+e)(?:\+|(-))?0*(\d)/, "$1$2$3") // Remove unnecessary scientific notation (1e0).
2483     .replace(/^([+-]?[\d.]+)e[+-]?0+$/, "$1") // Make sure numbers always start with a digit.
2484     .replace(/^([+-])?\./, "$10.") // Remove extraneous trailing decimal zeroes.
2485     .replace(/(\.\d+?)0+(?=e|$)/, "$1") // Remove trailing dot.
2486     .replace(/\.(?=e|$)/, "");
2487   }
2488   /**
2489    * @param {string} str
2490    * @param {string} target
2491    * @returns {number}
2492    */
2493
2494
2495   function getMaxContinuousCount(str, target) {
2496     const results = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
2497
2498     if (results === null) {
2499       return 0;
2500     }
2501
2502     return results.reduce((maxCount, result) => Math.max(maxCount, result.length / target.length), 0);
2503   }
2504
2505   function getMinNotPresentContinuousCount(str, target) {
2506     const matches = str.match(new RegExp("(".concat(escapeStringRegexp(target), ")+"), "g"));
2507
2508     if (matches === null) {
2509       return 0;
2510     }
2511
2512     const countPresent = new Map();
2513     let max = 0;
2514
2515     for (const match of matches) {
2516       const count = match.length / target.length;
2517       countPresent.set(count, true);
2518
2519       if (count > max) {
2520         max = count;
2521       }
2522     }
2523
2524     for (let i = 1; i < max; i++) {
2525       if (!countPresent.get(i)) {
2526         return i;
2527       }
2528     }
2529
2530     return max + 1;
2531   }
2532   /**
2533    * @param {string} text
2534    * @returns {number}
2535    */
2536
2537
2538   function getStringWidth(text) {
2539     if (!text) {
2540       return 0;
2541     } // shortcut to avoid needless string `RegExp`s, replacements, and allocations within `string-width`
2542
2543
2544     if (!notAsciiRegex.test(text)) {
2545       return text.length;
2546     }
2547
2548     return stringWidth_1(text);
2549   }
2550
2551   function isNodeIgnoreComment(comment) {
2552     return comment.value.trim() === "prettier-ignore";
2553   }
2554
2555   function addCommentHelper(node, comment) {
2556     const comments = node.comments || (node.comments = []);
2557     comments.push(comment);
2558     comment.printed = false; // For some reason, TypeScript parses `// x` inside of JSXText as a comment
2559     // We already "print" it via the raw text, we don't need to re-print it as a
2560     // comment
2561
2562     /* istanbul ignore next */
2563
2564     if (node.type === "JSXText") {
2565       comment.printed = true;
2566     }
2567   }
2568
2569   function addLeadingComment(node, comment) {
2570     comment.leading = true;
2571     comment.trailing = false;
2572     addCommentHelper(node, comment);
2573   }
2574
2575   function addDanglingComment(node, comment, marker) {
2576     comment.leading = false;
2577     comment.trailing = false;
2578
2579     if (marker) {
2580       comment.marker = marker;
2581     }
2582
2583     addCommentHelper(node, comment);
2584   }
2585
2586   function addTrailingComment(node, comment) {
2587     comment.leading = false;
2588     comment.trailing = true;
2589     addCommentHelper(node, comment);
2590   }
2591
2592   function replaceEndOfLineWith(text, replacement) {
2593     const parts = [];
2594
2595     for (const part of text.split("\n")) {
2596       if (parts.length !== 0) {
2597         parts.push(replacement);
2598       }
2599
2600       parts.push(part);
2601     }
2602
2603     return parts;
2604   }
2605
2606   function inferParserByLanguage(language, options) {
2607     const {
2608       languages
2609     } = getSupportInfo$1({
2610       plugins: options.plugins
2611     });
2612     const matched = languages.find(({
2613       name
2614     }) => name.toLowerCase() === language) || languages.find(({
2615       aliases
2616     }) => Array.isArray(aliases) && aliases.includes(language)) || languages.find(({
2617       extensions
2618     }) => Array.isArray(extensions) && extensions.includes(".".concat(language)));
2619     return matched && matched.parsers[0];
2620   }
2621
2622   function isFrontMatterNode(node) {
2623     return node && node.type === "front-matter";
2624   }
2625
2626   function getShebang(text) {
2627     if (!text.startsWith("#!")) {
2628       return "";
2629     }
2630
2631     const index = text.indexOf("\n");
2632
2633     if (index === -1) {
2634       return text;
2635     }
2636
2637     return text.slice(0, index);
2638   }
2639
2640   var util = {
2641     inferParserByLanguage,
2642     replaceEndOfLineWith,
2643     getStringWidth,
2644     getMaxContinuousCount,
2645     getMinNotPresentContinuousCount,
2646     getPenultimate,
2647     getLast,
2648     getNextNonSpaceNonCommentCharacterIndexWithStartIndex,
2649     getNextNonSpaceNonCommentCharacterIndex,
2650     getNextNonSpaceNonCommentCharacter,
2651     skip,
2652     skipWhitespace,
2653     skipSpaces,
2654     skipToLineEnd,
2655     skipEverythingButNewLine,
2656     skipInlineComment,
2657     skipTrailingComment,
2658     skipNewline,
2659     isNextLineEmptyAfterIndex,
2660     isNextLineEmpty,
2661     isPreviousLineEmpty,
2662     hasNewline,
2663     hasNewlineInRange,
2664     hasSpaces,
2665     getAlignmentSize,
2666     getIndentSize,
2667     getPreferredQuote,
2668     printString,
2669     printNumber,
2670     isNodeIgnoreComment,
2671     makeString,
2672     addLeadingComment,
2673     addDanglingComment,
2674     addTrailingComment,
2675     isFrontMatterNode,
2676     getShebang
2677   };
2678
2679   function guessEndOfLine(text) {
2680     const index = text.indexOf("\r");
2681
2682     if (index >= 0) {
2683       return text.charAt(index + 1) === "\n" ? "crlf" : "cr";
2684     }
2685
2686     return "lf";
2687   }
2688
2689   function convertEndOfLineToChars(value) {
2690     switch (value) {
2691       case "cr":
2692         return "\r";
2693
2694       case "crlf":
2695         return "\r\n";
2696
2697       default:
2698         return "\n";
2699     }
2700   }
2701
2702   function countEndOfLineChars(text, eol) {
2703     let regex;
2704     /* istanbul ignore else */
2705
2706     if (eol === "\n") {
2707       regex = /\n/g;
2708     } else if (eol === "\r") {
2709       regex = /\r/g;
2710     } else if (eol === "\r\n") {
2711       regex = /\r\n/g;
2712     } else {
2713       throw new Error("Unexpected \"eol\" ".concat(JSON.stringify(eol), "."));
2714     }
2715
2716     const endOfLines = text.match(regex);
2717     return endOfLines ? endOfLines.length : 0;
2718   }
2719
2720   function normalizeEndOfLine(text) {
2721     return text.replace(/\r\n?/g, "\n");
2722   }
2723
2724   var endOfLine = {
2725     guessEndOfLine,
2726     convertEndOfLineToChars,
2727     countEndOfLineChars,
2728     normalizeEndOfLine
2729   };
2730
2731   const {
2732     getStringWidth: getStringWidth$1
2733   } = util;
2734   const {
2735     convertEndOfLineToChars: convertEndOfLineToChars$1
2736   } = endOfLine;
2737   const {
2738     concat: concat$1,
2739     fill: fill$1,
2740     cursor: cursor$1
2741   } = docBuilders;
2742   /** @type {Record<symbol, typeof MODE_BREAK | typeof MODE_FLAT>} */
2743
2744   let groupModeMap;
2745   const MODE_BREAK = 1;
2746   const MODE_FLAT = 2;
2747
2748   function rootIndent() {
2749     return {
2750       value: "",
2751       length: 0,
2752       queue: []
2753     };
2754   }
2755
2756   function makeIndent(ind, options) {
2757     return generateInd(ind, {
2758       type: "indent"
2759     }, options);
2760   }
2761
2762   function makeAlign(indent, n, options) {
2763     if (n === -Infinity) {
2764       return indent.root || rootIndent();
2765     }
2766
2767     if (n < 0) {
2768       return generateInd(indent, {
2769         type: "dedent"
2770       }, options);
2771     }
2772
2773     if (!n) {
2774       return indent;
2775     }
2776
2777     if (n.type === "root") {
2778       return Object.assign({}, indent, {
2779         root: indent
2780       });
2781     }
2782
2783     const alignType = typeof n === "string" ? "stringAlign" : "numberAlign";
2784     return generateInd(indent, {
2785       type: alignType,
2786       n
2787     }, options);
2788   }
2789
2790   function generateInd(ind, newPart, options) {
2791     const queue = newPart.type === "dedent" ? ind.queue.slice(0, -1) : ind.queue.concat(newPart);
2792     let value = "";
2793     let length = 0;
2794     let lastTabs = 0;
2795     let lastSpaces = 0;
2796
2797     for (const part of queue) {
2798       switch (part.type) {
2799         case "indent":
2800           flush();
2801
2802           if (options.useTabs) {
2803             addTabs(1);
2804           } else {
2805             addSpaces(options.tabWidth);
2806           }
2807
2808           break;
2809
2810         case "stringAlign":
2811           flush();
2812           value += part.n;
2813           length += part.n.length;
2814           break;
2815
2816         case "numberAlign":
2817           lastTabs += 1;
2818           lastSpaces += part.n;
2819           break;
2820
2821         /* istanbul ignore next */
2822
2823         default:
2824           throw new Error("Unexpected type '".concat(part.type, "'"));
2825       }
2826     }
2827
2828     flushSpaces();
2829     return Object.assign({}, ind, {
2830       value,
2831       length,
2832       queue
2833     });
2834
2835     function addTabs(count) {
2836       value += "\t".repeat(count);
2837       length += options.tabWidth * count;
2838     }
2839
2840     function addSpaces(count) {
2841       value += " ".repeat(count);
2842       length += count;
2843     }
2844
2845     function flush() {
2846       if (options.useTabs) {
2847         flushTabs();
2848       } else {
2849         flushSpaces();
2850       }
2851     }
2852
2853     function flushTabs() {
2854       if (lastTabs > 0) {
2855         addTabs(lastTabs);
2856       }
2857
2858       resetLast();
2859     }
2860
2861     function flushSpaces() {
2862       if (lastSpaces > 0) {
2863         addSpaces(lastSpaces);
2864       }
2865
2866       resetLast();
2867     }
2868
2869     function resetLast() {
2870       lastTabs = 0;
2871       lastSpaces = 0;
2872     }
2873   }
2874
2875   function trim$1(out) {
2876     if (out.length === 0) {
2877       return 0;
2878     }
2879
2880     let trimCount = 0; // Trim whitespace at the end of line
2881
2882     while (out.length > 0 && typeof out[out.length - 1] === "string" && out[out.length - 1].match(/^[\t ]*$/)) {
2883       trimCount += out.pop().length;
2884     }
2885
2886     if (out.length && typeof out[out.length - 1] === "string") {
2887       const trimmed = out[out.length - 1].replace(/[\t ]*$/, "");
2888       trimCount += out[out.length - 1].length - trimmed.length;
2889       out[out.length - 1] = trimmed;
2890     }
2891
2892     return trimCount;
2893   }
2894
2895   function fits(next, restCommands, width, options, mustBeFlat) {
2896     let restIdx = restCommands.length;
2897     const cmds = [next]; // `out` is only used for width counting because `trim` requires to look
2898     // backwards for space characters.
2899
2900     const out = [];
2901
2902     while (width >= 0) {
2903       if (cmds.length === 0) {
2904         if (restIdx === 0) {
2905           return true;
2906         }
2907
2908         cmds.push(restCommands[restIdx - 1]);
2909         restIdx--;
2910         continue;
2911       }
2912
2913       const [ind, mode, doc] = cmds.pop();
2914
2915       if (typeof doc === "string") {
2916         out.push(doc);
2917         width -= getStringWidth$1(doc);
2918       } else {
2919         switch (doc.type) {
2920           case "concat":
2921             for (let i = doc.parts.length - 1; i >= 0; i--) {
2922               cmds.push([ind, mode, doc.parts[i]]);
2923             }
2924
2925             break;
2926
2927           case "indent":
2928             cmds.push([makeIndent(ind, options), mode, doc.contents]);
2929             break;
2930
2931           case "align":
2932             cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
2933             break;
2934
2935           case "trim":
2936             width += trim$1(out);
2937             break;
2938
2939           case "group":
2940             if (mustBeFlat && doc.break) {
2941               return false;
2942             }
2943
2944             cmds.push([ind, doc.break ? MODE_BREAK : mode, doc.contents]);
2945
2946             if (doc.id) {
2947               groupModeMap[doc.id] = cmds[cmds.length - 1][1];
2948             }
2949
2950             break;
2951
2952           case "fill":
2953             for (let i = doc.parts.length - 1; i >= 0; i--) {
2954               cmds.push([ind, mode, doc.parts[i]]);
2955             }
2956
2957             break;
2958
2959           case "if-break":
2960             {
2961               const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
2962
2963               if (groupMode === MODE_BREAK) {
2964                 if (doc.breakContents) {
2965                   cmds.push([ind, mode, doc.breakContents]);
2966                 }
2967               }
2968
2969               if (groupMode === MODE_FLAT) {
2970                 if (doc.flatContents) {
2971                   cmds.push([ind, mode, doc.flatContents]);
2972                 }
2973               }
2974
2975               break;
2976             }
2977
2978           case "line":
2979             switch (mode) {
2980               // fallthrough
2981               case MODE_FLAT:
2982                 if (!doc.hard) {
2983                   if (!doc.soft) {
2984                     out.push(" ");
2985                     width -= 1;
2986                   }
2987
2988                   break;
2989                 }
2990
2991                 return true;
2992
2993               case MODE_BREAK:
2994                 return true;
2995             }
2996
2997             break;
2998         }
2999       }
3000     }
3001
3002     return false;
3003   }
3004
3005   function printDocToString(doc, options) {
3006     groupModeMap = {};
3007     const width = options.printWidth;
3008     const newLine = convertEndOfLineToChars$1(options.endOfLine);
3009     let pos = 0; // cmds is basically a stack. We've turned a recursive call into a
3010     // while loop which is much faster. The while loop below adds new
3011     // cmds to the array instead of recursively calling `print`.
3012
3013     const cmds = [[rootIndent(), MODE_BREAK, doc]];
3014     const out = [];
3015     let shouldRemeasure = false;
3016     let lineSuffix = [];
3017
3018     while (cmds.length !== 0) {
3019       const [ind, mode, doc] = cmds.pop();
3020
3021       if (typeof doc === "string") {
3022         const formatted = newLine !== "\n" && doc.includes("\n") ? doc.replace(/\n/g, newLine) : doc;
3023         out.push(formatted);
3024         pos += getStringWidth$1(formatted);
3025       } else {
3026         switch (doc.type) {
3027           case "cursor":
3028             out.push(cursor$1.placeholder);
3029             break;
3030
3031           case "concat":
3032             for (let i = doc.parts.length - 1; i >= 0; i--) {
3033               cmds.push([ind, mode, doc.parts[i]]);
3034             }
3035
3036             break;
3037
3038           case "indent":
3039             cmds.push([makeIndent(ind, options), mode, doc.contents]);
3040             break;
3041
3042           case "align":
3043             cmds.push([makeAlign(ind, doc.n, options), mode, doc.contents]);
3044             break;
3045
3046           case "trim":
3047             pos -= trim$1(out);
3048             break;
3049
3050           case "group":
3051             switch (mode) {
3052               case MODE_FLAT:
3053                 if (!shouldRemeasure) {
3054                   cmds.push([ind, doc.break ? MODE_BREAK : MODE_FLAT, doc.contents]);
3055                   break;
3056                 }
3057
3058               // fallthrough
3059
3060               case MODE_BREAK:
3061                 {
3062                   shouldRemeasure = false;
3063                   const next = [ind, MODE_FLAT, doc.contents];
3064                   const rem = width - pos;
3065
3066                   if (!doc.break && fits(next, cmds, rem, options)) {
3067                     cmds.push(next);
3068                   } else {
3069                     // Expanded states are a rare case where a document
3070                     // can manually provide multiple representations of
3071                     // itself. It provides an array of documents
3072                     // going from the least expanded (most flattened)
3073                     // representation first to the most expanded. If a
3074                     // group has these, we need to manually go through
3075                     // these states and find the first one that fits.
3076                     if (doc.expandedStates) {
3077                       const mostExpanded = doc.expandedStates[doc.expandedStates.length - 1];
3078
3079                       if (doc.break) {
3080                         cmds.push([ind, MODE_BREAK, mostExpanded]);
3081                         break;
3082                       } else {
3083                         for (let i = 1; i < doc.expandedStates.length + 1; i++) {
3084                           if (i >= doc.expandedStates.length) {
3085                             cmds.push([ind, MODE_BREAK, mostExpanded]);
3086                             break;
3087                           } else {
3088                             const state = doc.expandedStates[i];
3089                             const cmd = [ind, MODE_FLAT, state];
3090
3091                             if (fits(cmd, cmds, rem, options)) {
3092                               cmds.push(cmd);
3093                               break;
3094                             }
3095                           }
3096                         }
3097                       }
3098                     } else {
3099                       cmds.push([ind, MODE_BREAK, doc.contents]);
3100                     }
3101                   }
3102
3103                   break;
3104                 }
3105             }
3106
3107             if (doc.id) {
3108               groupModeMap[doc.id] = cmds[cmds.length - 1][1];
3109             }
3110
3111             break;
3112           // Fills each line with as much code as possible before moving to a new
3113           // line with the same indentation.
3114           //
3115           // Expects doc.parts to be an array of alternating content and
3116           // whitespace. The whitespace contains the linebreaks.
3117           //
3118           // For example:
3119           //   ["I", line, "love", line, "monkeys"]
3120           // or
3121           //   [{ type: group, ... }, softline, { type: group, ... }]
3122           //
3123           // It uses this parts structure to handle three main layout cases:
3124           // * The first two content items fit on the same line without
3125           //   breaking
3126           //   -> output the first content item and the whitespace "flat".
3127           // * Only the first content item fits on the line without breaking
3128           //   -> output the first content item "flat" and the whitespace with
3129           //   "break".
3130           // * Neither content item fits on the line without breaking
3131           //   -> output the first content item and the whitespace with "break".
3132
3133           case "fill":
3134             {
3135               const rem = width - pos;
3136               const {
3137                 parts
3138               } = doc;
3139
3140               if (parts.length === 0) {
3141                 break;
3142               }
3143
3144               const [content, whitespace] = parts;
3145               const contentFlatCmd = [ind, MODE_FLAT, content];
3146               const contentBreakCmd = [ind, MODE_BREAK, content];
3147               const contentFits = fits(contentFlatCmd, [], rem, options, true);
3148
3149               if (parts.length === 1) {
3150                 if (contentFits) {
3151                   cmds.push(contentFlatCmd);
3152                 } else {
3153                   cmds.push(contentBreakCmd);
3154                 }
3155
3156                 break;
3157               }
3158
3159               const whitespaceFlatCmd = [ind, MODE_FLAT, whitespace];
3160               const whitespaceBreakCmd = [ind, MODE_BREAK, whitespace];
3161
3162               if (parts.length === 2) {
3163                 if (contentFits) {
3164                   cmds.push(whitespaceFlatCmd);
3165                   cmds.push(contentFlatCmd);
3166                 } else {
3167                   cmds.push(whitespaceBreakCmd);
3168                   cmds.push(contentBreakCmd);
3169                 }
3170
3171                 break;
3172               } // At this point we've handled the first pair (context, separator)
3173               // and will create a new fill doc for the rest of the content.
3174               // Ideally we wouldn't mutate the array here but copying all the
3175               // elements to a new array would make this algorithm quadratic,
3176               // which is unusable for large arrays (e.g. large texts in JSX).
3177
3178
3179               parts.splice(0, 2);
3180               const remainingCmd = [ind, mode, fill$1(parts)];
3181               const secondContent = parts[0];
3182               const firstAndSecondContentFlatCmd = [ind, MODE_FLAT, concat$1([content, whitespace, secondContent])];
3183               const firstAndSecondContentFits = fits(firstAndSecondContentFlatCmd, [], rem, options, true);
3184
3185               if (firstAndSecondContentFits) {
3186                 cmds.push(remainingCmd);
3187                 cmds.push(whitespaceFlatCmd);
3188                 cmds.push(contentFlatCmd);
3189               } else if (contentFits) {
3190                 cmds.push(remainingCmd);
3191                 cmds.push(whitespaceBreakCmd);
3192                 cmds.push(contentFlatCmd);
3193               } else {
3194                 cmds.push(remainingCmd);
3195                 cmds.push(whitespaceBreakCmd);
3196                 cmds.push(contentBreakCmd);
3197               }
3198
3199               break;
3200             }
3201
3202           case "if-break":
3203             {
3204               const groupMode = doc.groupId ? groupModeMap[doc.groupId] : mode;
3205
3206               if (groupMode === MODE_BREAK) {
3207                 if (doc.breakContents) {
3208                   cmds.push([ind, mode, doc.breakContents]);
3209                 }
3210               }
3211
3212               if (groupMode === MODE_FLAT) {
3213                 if (doc.flatContents) {
3214                   cmds.push([ind, mode, doc.flatContents]);
3215                 }
3216               }
3217
3218               break;
3219             }
3220
3221           case "line-suffix":
3222             lineSuffix.push([ind, mode, doc.contents]);
3223             break;
3224
3225           case "line-suffix-boundary":
3226             if (lineSuffix.length > 0) {
3227               cmds.push([ind, mode, {
3228                 type: "line",
3229                 hard: true
3230               }]);
3231             }
3232
3233             break;
3234
3235           case "line":
3236             switch (mode) {
3237               case MODE_FLAT:
3238                 if (!doc.hard) {
3239                   if (!doc.soft) {
3240                     out.push(" ");
3241                     pos += 1;
3242                   }
3243
3244                   break;
3245                 } else {
3246                   // This line was forced into the output even if we
3247                   // were in flattened mode, so we need to tell the next
3248                   // group that no matter what, it needs to remeasure
3249                   // because the previous measurement didn't accurately
3250                   // capture the entire expression (this is necessary
3251                   // for nested groups)
3252                   shouldRemeasure = true;
3253                 }
3254
3255               // fallthrough
3256
3257               case MODE_BREAK:
3258                 if (lineSuffix.length) {
3259                   cmds.push([ind, mode, doc]);
3260                   cmds.push(...lineSuffix.reverse());
3261                   lineSuffix = [];
3262                   break;
3263                 }
3264
3265                 if (doc.literal) {
3266                   if (ind.root) {
3267                     out.push(newLine, ind.root.value);
3268                     pos = ind.root.length;
3269                   } else {
3270                     out.push(newLine);
3271                     pos = 0;
3272                   }
3273                 } else {
3274                   pos -= trim$1(out);
3275                   out.push(newLine + ind.value);
3276                   pos = ind.length;
3277                 }
3278
3279                 break;
3280             }
3281
3282             break;
3283         }
3284       } // Flush remaining line-suffix contents at the end of the document, in case
3285       // there is no new line after the line-suffix.
3286
3287
3288       if (cmds.length === 0 && lineSuffix.length) {
3289         cmds.push(...lineSuffix.reverse());
3290         lineSuffix = [];
3291       }
3292     }
3293
3294     const cursorPlaceholderIndex = out.indexOf(cursor$1.placeholder);
3295
3296     if (cursorPlaceholderIndex !== -1) {
3297       const otherCursorPlaceholderIndex = out.indexOf(cursor$1.placeholder, cursorPlaceholderIndex + 1);
3298       const beforeCursor = out.slice(0, cursorPlaceholderIndex).join("");
3299       const aroundCursor = out.slice(cursorPlaceholderIndex + 1, otherCursorPlaceholderIndex).join("");
3300       const afterCursor = out.slice(otherCursorPlaceholderIndex + 1).join("");
3301       return {
3302         formatted: beforeCursor + aroundCursor + afterCursor,
3303         cursorNodeStart: beforeCursor.length,
3304         cursorNodeText: aroundCursor
3305       };
3306     }
3307
3308     return {
3309       formatted: out.join("")
3310     };
3311   }
3312
3313   var docPrinter = {
3314     printDocToString
3315   };
3316
3317   const {
3318     literalline: literalline$1,
3319     concat: concat$2
3320   } = docBuilders; // Using a unique object to compare by reference.
3321
3322   const traverseDocOnExitStackMarker = {};
3323
3324   function traverseDoc(doc, onEnter, onExit, shouldTraverseConditionalGroups) {
3325     const docsStack = [doc];
3326
3327     while (docsStack.length !== 0) {
3328       const doc = docsStack.pop();
3329
3330       if (doc === traverseDocOnExitStackMarker) {
3331         onExit(docsStack.pop());
3332         continue;
3333       }
3334
3335       if (onExit) {
3336         docsStack.push(doc, traverseDocOnExitStackMarker);
3337       }
3338
3339       if ( // Should Recurse
3340       !onEnter || onEnter(doc) !== false) {
3341         // When there are multiple parts to process,
3342         // the parts need to be pushed onto the stack in reverse order,
3343         // so that they are processed in the original order
3344         // when the stack is popped.
3345         if (doc.type === "concat" || doc.type === "fill") {
3346           for (let ic = doc.parts.length, i = ic - 1; i >= 0; --i) {
3347             docsStack.push(doc.parts[i]);
3348           }
3349         } else if (doc.type === "if-break") {
3350           if (doc.flatContents) {
3351             docsStack.push(doc.flatContents);
3352           }
3353
3354           if (doc.breakContents) {
3355             docsStack.push(doc.breakContents);
3356           }
3357         } else if (doc.type === "group" && doc.expandedStates) {
3358           if (shouldTraverseConditionalGroups) {
3359             for (let ic = doc.expandedStates.length, i = ic - 1; i >= 0; --i) {
3360               docsStack.push(doc.expandedStates[i]);
3361             }
3362           } else {
3363             docsStack.push(doc.contents);
3364           }
3365         } else if (doc.contents) {
3366           docsStack.push(doc.contents);
3367         }
3368       }
3369     }
3370   }
3371
3372   function mapDoc(doc, cb) {
3373     if (doc.type === "concat" || doc.type === "fill") {
3374       const parts = doc.parts.map(part => mapDoc(part, cb));
3375       return cb(Object.assign({}, doc, {
3376         parts
3377       }));
3378     } else if (doc.type === "if-break") {
3379       const breakContents = doc.breakContents && mapDoc(doc.breakContents, cb);
3380       const flatContents = doc.flatContents && mapDoc(doc.flatContents, cb);
3381       return cb(Object.assign({}, doc, {
3382         breakContents,
3383         flatContents
3384       }));
3385     } else if (doc.contents) {
3386       const contents = mapDoc(doc.contents, cb);
3387       return cb(Object.assign({}, doc, {
3388         contents
3389       }));
3390     }
3391
3392     return cb(doc);
3393   }
3394
3395   function findInDoc(doc, fn, defaultValue) {
3396     let result = defaultValue;
3397     let hasStopped = false;
3398
3399     function findInDocOnEnterFn(doc) {
3400       const maybeResult = fn(doc);
3401
3402       if (maybeResult !== undefined) {
3403         hasStopped = true;
3404         result = maybeResult;
3405       }
3406
3407       if (hasStopped) {
3408         return false;
3409       }
3410     }
3411
3412     traverseDoc(doc, findInDocOnEnterFn);
3413     return result;
3414   }
3415
3416   function isEmpty(n) {
3417     return typeof n === "string" && n.length === 0;
3418   }
3419
3420   function isLineNextFn(doc) {
3421     if (typeof doc === "string") {
3422       return false;
3423     }
3424
3425     if (doc.type === "line") {
3426       return true;
3427     }
3428   }
3429
3430   function isLineNext(doc) {
3431     return findInDoc(doc, isLineNextFn, false);
3432   }
3433
3434   function willBreakFn(doc) {
3435     if (doc.type === "group" && doc.break) {
3436       return true;
3437     }
3438
3439     if (doc.type === "line" && doc.hard) {
3440       return true;
3441     }
3442
3443     if (doc.type === "break-parent") {
3444       return true;
3445     }
3446   }
3447
3448   function willBreak(doc) {
3449     return findInDoc(doc, willBreakFn, false);
3450   }
3451
3452   function breakParentGroup(groupStack) {
3453     if (groupStack.length > 0) {
3454       const parentGroup = groupStack[groupStack.length - 1]; // Breaks are not propagated through conditional groups because
3455       // the user is expected to manually handle what breaks.
3456
3457       if (!parentGroup.expandedStates) {
3458         parentGroup.break = true;
3459       }
3460     }
3461
3462     return null;
3463   }
3464
3465   function propagateBreaks(doc) {
3466     const alreadyVisitedSet = new Set();
3467     const groupStack = [];
3468
3469     function propagateBreaksOnEnterFn(doc) {
3470       if (doc.type === "break-parent") {
3471         breakParentGroup(groupStack);
3472       }
3473
3474       if (doc.type === "group") {
3475         groupStack.push(doc);
3476
3477         if (alreadyVisitedSet.has(doc)) {
3478           return false;
3479         }
3480
3481         alreadyVisitedSet.add(doc);
3482       }
3483     }
3484
3485     function propagateBreaksOnExitFn(doc) {
3486       if (doc.type === "group") {
3487         const group = groupStack.pop();
3488
3489         if (group.break) {
3490           breakParentGroup(groupStack);
3491         }
3492       }
3493     }
3494
3495     traverseDoc(doc, propagateBreaksOnEnterFn, propagateBreaksOnExitFn,
3496     /* shouldTraverseConditionalGroups */
3497     true);
3498   }
3499
3500   function removeLinesFn(doc) {
3501     // Force this doc into flat mode by statically converting all
3502     // lines into spaces (or soft lines into nothing). Hard lines
3503     // should still output because there's too great of a chance
3504     // of breaking existing assumptions otherwise.
3505     if (doc.type === "line" && !doc.hard) {
3506       return doc.soft ? "" : " ";
3507     } else if (doc.type === "if-break") {
3508       return doc.flatContents || "";
3509     }
3510
3511     return doc;
3512   }
3513
3514   function removeLines(doc) {
3515     return mapDoc(doc, removeLinesFn);
3516   }
3517
3518   function getInnerParts(doc) {
3519     let {
3520       parts
3521     } = doc;
3522     let lastPart; // Avoid a falsy element like ""
3523
3524     for (let i = doc.parts.length; i > 0 && !lastPart; i--) {
3525       lastPart = parts[i - 1];
3526     }
3527
3528     if (lastPart.type === "group") {
3529       parts = lastPart.contents.parts;
3530     }
3531
3532     return parts;
3533   }
3534
3535   function stripTrailingHardline(doc, withInnerParts = false) {
3536     // HACK remove ending hardline, original PR: #1984
3537     if (doc.type === "concat" && doc.parts.length !== 0) {
3538       const parts = withInnerParts ? getInnerParts(doc) : doc.parts;
3539       const lastPart = parts[parts.length - 1];
3540
3541       if (lastPart.type === "concat") {
3542         if (lastPart.parts.length === 2 && lastPart.parts[0].hard && lastPart.parts[1].type === "break-parent") {
3543           return {
3544             type: "concat",
3545             parts: parts.slice(0, -1)
3546           };
3547         }
3548
3549         return {
3550           type: "concat",
3551           parts: doc.parts.slice(0, -1).concat(stripTrailingHardline(lastPart))
3552         };
3553       }
3554     }
3555
3556     return doc;
3557   }
3558
3559   function normalizeParts(parts) {
3560     const newParts = [];
3561     const restParts = parts.filter(Boolean);
3562
3563     while (restParts.length !== 0) {
3564       const part = restParts.shift();
3565
3566       if (!part) {
3567         continue;
3568       }
3569
3570       if (part.type === "concat") {
3571         restParts.unshift(...part.parts);
3572         continue;
3573       }
3574
3575       if (newParts.length !== 0 && typeof newParts[newParts.length - 1] === "string" && typeof part === "string") {
3576         newParts[newParts.length - 1] += part;
3577         continue;
3578       }
3579
3580       newParts.push(part);
3581     }
3582
3583     return newParts;
3584   }
3585
3586   function normalizeDoc(doc) {
3587     return mapDoc(doc, currentDoc => {
3588       if (!currentDoc.parts) {
3589         return currentDoc;
3590       }
3591
3592       return Object.assign({}, currentDoc, {
3593         parts: normalizeParts(currentDoc.parts)
3594       });
3595     });
3596   }
3597
3598   function replaceNewlinesWithLiterallines(doc) {
3599     return mapDoc(doc, currentDoc => typeof currentDoc === "string" && currentDoc.includes("\n") ? concat$2(currentDoc.split(/(\n)/g).map((v, i) => i % 2 === 0 ? v : literalline$1)) : currentDoc);
3600   }
3601
3602   var docUtils = {
3603     isEmpty,
3604     willBreak,
3605     isLineNext,
3606     traverseDoc,
3607     findInDoc,
3608     mapDoc,
3609     propagateBreaks,
3610     removeLines,
3611     stripTrailingHardline,
3612     normalizeParts,
3613     normalizeDoc,
3614     replaceNewlinesWithLiterallines
3615   };
3616
3617   function flattenDoc(doc) {
3618     if (doc.type === "concat") {
3619       const res = [];
3620
3621       for (let i = 0; i < doc.parts.length; ++i) {
3622         const doc2 = doc.parts[i];
3623
3624         if (typeof doc2 !== "string" && doc2.type === "concat") {
3625           res.push(...flattenDoc(doc2).parts);
3626         } else {
3627           const flattened = flattenDoc(doc2);
3628
3629           if (flattened !== "") {
3630             res.push(flattened);
3631           }
3632         }
3633       }
3634
3635       return Object.assign({}, doc, {
3636         parts: res
3637       });
3638     } else if (doc.type === "if-break") {
3639       return Object.assign({}, doc, {
3640         breakContents: doc.breakContents != null ? flattenDoc(doc.breakContents) : null,
3641         flatContents: doc.flatContents != null ? flattenDoc(doc.flatContents) : null
3642       });
3643     } else if (doc.type === "group") {
3644       return Object.assign({}, doc, {
3645         contents: flattenDoc(doc.contents),
3646         expandedStates: doc.expandedStates ? doc.expandedStates.map(flattenDoc) : doc.expandedStates
3647       });
3648     } else if (doc.contents) {
3649       return Object.assign({}, doc, {
3650         contents: flattenDoc(doc.contents)
3651       });
3652     }
3653
3654     return doc;
3655   }
3656
3657   function printDoc(doc) {
3658     if (typeof doc === "string") {
3659       return JSON.stringify(doc);
3660     }
3661
3662     if (doc.type === "line") {
3663       if (doc.literal) {
3664         return "literalline";
3665       }
3666
3667       if (doc.hard) {
3668         return "hardline";
3669       }
3670
3671       if (doc.soft) {
3672         return "softline";
3673       }
3674
3675       return "line";
3676     }
3677
3678     if (doc.type === "break-parent") {
3679       return "breakParent";
3680     }
3681
3682     if (doc.type === "trim") {
3683       return "trim";
3684     }
3685
3686     if (doc.type === "concat") {
3687       return "[" + doc.parts.map(printDoc).join(", ") + "]";
3688     }
3689
3690     if (doc.type === "indent") {
3691       return "indent(" + printDoc(doc.contents) + ")";
3692     }
3693
3694     if (doc.type === "align") {
3695       return doc.n === -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) + ")";
3696     }
3697
3698     if (doc.type === "if-break") {
3699       return "ifBreak(" + printDoc(doc.breakContents) + (doc.flatContents ? ", " + printDoc(doc.flatContents) : "") + ")";
3700     }
3701
3702     if (doc.type === "group") {
3703       if (doc.expandedStates) {
3704         return "conditionalGroup(" + "[" + doc.expandedStates.map(printDoc).join(",") + "])";
3705       }
3706
3707       return (doc.break ? "wrappedGroup" : "group") + "(" + printDoc(doc.contents) + ")";
3708     }
3709
3710     if (doc.type === "fill") {
3711       return "fill" + "(" + doc.parts.map(printDoc).join(", ") + ")";
3712     }
3713
3714     if (doc.type === "line-suffix") {
3715       return "lineSuffix(" + printDoc(doc.contents) + ")";
3716     }
3717
3718     if (doc.type === "line-suffix-boundary") {
3719       return "lineSuffixBoundary";
3720     }
3721
3722     throw new Error("Unknown doc type " + doc.type);
3723   }
3724
3725   var docDebug = {
3726     printDocToDebug(doc) {
3727       return printDoc(flattenDoc(doc));
3728     }
3729
3730   };
3731
3732   /**
3733    * @typedef {import("./doc-builders").Doc} Doc
3734    */
3735
3736
3737   var document = {
3738     builders: docBuilders,
3739     printer: docPrinter,
3740     utils: docUtils,
3741     debug: docDebug
3742   };
3743
3744   return document;
3745
3746 })));