.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / esquery / dist / esquery.lite.js
1 (function (global, factory) {
2   typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('estraverse')) :
3   typeof define === 'function' && define.amd ? define(['estraverse'], factory) :
4   (global = global || self, global.esquery = factory(global.estraverse));
5 }(this, (function (estraverse) { 'use strict';
6
7   estraverse = estraverse && Object.prototype.hasOwnProperty.call(estraverse, 'default') ? estraverse['default'] : estraverse;
8
9   function _typeof(obj) {
10     "@babel/helpers - typeof";
11
12     if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
13       _typeof = function (obj) {
14         return typeof obj;
15       };
16     } else {
17       _typeof = function (obj) {
18         return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
19       };
20     }
21
22     return _typeof(obj);
23   }
24
25   function _slicedToArray(arr, i) {
26     return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
27   }
28
29   function _toConsumableArray(arr) {
30     return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
31   }
32
33   function _arrayWithoutHoles(arr) {
34     if (Array.isArray(arr)) return _arrayLikeToArray(arr);
35   }
36
37   function _arrayWithHoles(arr) {
38     if (Array.isArray(arr)) return arr;
39   }
40
41   function _iterableToArray(iter) {
42     if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
43   }
44
45   function _iterableToArrayLimit(arr, i) {
46     if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
47     var _arr = [];
48     var _n = true;
49     var _d = false;
50     var _e = undefined;
51
52     try {
53       for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
54         _arr.push(_s.value);
55
56         if (i && _arr.length === i) break;
57       }
58     } catch (err) {
59       _d = true;
60       _e = err;
61     } finally {
62       try {
63         if (!_n && _i["return"] != null) _i["return"]();
64       } finally {
65         if (_d) throw _e;
66       }
67     }
68
69     return _arr;
70   }
71
72   function _unsupportedIterableToArray(o, minLen) {
73     if (!o) return;
74     if (typeof o === "string") return _arrayLikeToArray(o, minLen);
75     var n = Object.prototype.toString.call(o).slice(8, -1);
76     if (n === "Object" && o.constructor) n = o.constructor.name;
77     if (n === "Map" || n === "Set") return Array.from(o);
78     if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
79   }
80
81   function _arrayLikeToArray(arr, len) {
82     if (len == null || len > arr.length) len = arr.length;
83
84     for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
85
86     return arr2;
87   }
88
89   function _nonIterableSpread() {
90     throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
91   }
92
93   function _nonIterableRest() {
94     throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
95   }
96
97   function _createForOfIteratorHelper(o, allowArrayLike) {
98     var it;
99
100     if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
101       if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
102         if (it) o = it;
103         var i = 0;
104
105         var F = function () {};
106
107         return {
108           s: F,
109           n: function () {
110             if (i >= o.length) return {
111               done: true
112             };
113             return {
114               done: false,
115               value: o[i++]
116             };
117           },
118           e: function (e) {
119             throw e;
120           },
121           f: F
122         };
123       }
124
125       throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
126     }
127
128     var normalCompletion = true,
129         didErr = false,
130         err;
131     return {
132       s: function () {
133         it = o[Symbol.iterator]();
134       },
135       n: function () {
136         var step = it.next();
137         normalCompletion = step.done;
138         return step;
139       },
140       e: function (e) {
141         didErr = true;
142         err = e;
143       },
144       f: function () {
145         try {
146           if (!normalCompletion && it.return != null) it.return();
147         } finally {
148           if (didErr) throw err;
149         }
150       }
151     };
152   }
153
154   var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
155
156   function createCommonjsModule(fn, module) {
157         return module = { exports: {} }, fn(module, module.exports), module.exports;
158   }
159
160   var parser = createCommonjsModule(function (module) {
161     /*
162      * Generated by PEG.js 0.10.0.
163      *
164      * http://pegjs.org/
165      */
166     (function (root, factory) {
167       if ( module.exports) {
168         module.exports = factory();
169       }
170     })(commonjsGlobal, function () {
171
172       function peg$subclass(child, parent) {
173         function ctor() {
174           this.constructor = child;
175         }
176
177         ctor.prototype = parent.prototype;
178         child.prototype = new ctor();
179       }
180
181       function peg$SyntaxError(message, expected, found, location) {
182         this.message = message;
183         this.expected = expected;
184         this.found = found;
185         this.location = location;
186         this.name = "SyntaxError";
187
188         if (typeof Error.captureStackTrace === "function") {
189           Error.captureStackTrace(this, peg$SyntaxError);
190         }
191       }
192
193       peg$subclass(peg$SyntaxError, Error);
194
195       peg$SyntaxError.buildMessage = function (expected, found) {
196         var DESCRIBE_EXPECTATION_FNS = {
197           literal: function literal(expectation) {
198             return "\"" + literalEscape(expectation.text) + "\"";
199           },
200           "class": function _class(expectation) {
201             var escapedParts = "",
202                 i;
203
204             for (i = 0; i < expectation.parts.length; i++) {
205               escapedParts += expectation.parts[i] instanceof Array ? classEscape(expectation.parts[i][0]) + "-" + classEscape(expectation.parts[i][1]) : classEscape(expectation.parts[i]);
206             }
207
208             return "[" + (expectation.inverted ? "^" : "") + escapedParts + "]";
209           },
210           any: function any(expectation) {
211             return "any character";
212           },
213           end: function end(expectation) {
214             return "end of input";
215           },
216           other: function other(expectation) {
217             return expectation.description;
218           }
219         };
220
221         function hex(ch) {
222           return ch.charCodeAt(0).toString(16).toUpperCase();
223         }
224
225         function literalEscape(s) {
226           return s.replace(/\\/g, '\\\\').replace(/"/g, '\\"').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
227             return '\\x0' + hex(ch);
228           }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
229             return '\\x' + hex(ch);
230           });
231         }
232
233         function classEscape(s) {
234           return s.replace(/\\/g, '\\\\').replace(/\]/g, '\\]').replace(/\^/g, '\\^').replace(/-/g, '\\-').replace(/\0/g, '\\0').replace(/\t/g, '\\t').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/[\x00-\x0F]/g, function (ch) {
235             return '\\x0' + hex(ch);
236           }).replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) {
237             return '\\x' + hex(ch);
238           });
239         }
240
241         function describeExpectation(expectation) {
242           return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);
243         }
244
245         function describeExpected(expected) {
246           var descriptions = new Array(expected.length),
247               i,
248               j;
249
250           for (i = 0; i < expected.length; i++) {
251             descriptions[i] = describeExpectation(expected[i]);
252           }
253
254           descriptions.sort();
255
256           if (descriptions.length > 0) {
257             for (i = 1, j = 1; i < descriptions.length; i++) {
258               if (descriptions[i - 1] !== descriptions[i]) {
259                 descriptions[j] = descriptions[i];
260                 j++;
261               }
262             }
263
264             descriptions.length = j;
265           }
266
267           switch (descriptions.length) {
268             case 1:
269               return descriptions[0];
270
271             case 2:
272               return descriptions[0] + " or " + descriptions[1];
273
274             default:
275               return descriptions.slice(0, -1).join(", ") + ", or " + descriptions[descriptions.length - 1];
276           }
277         }
278
279         function describeFound(found) {
280           return found ? "\"" + literalEscape(found) + "\"" : "end of input";
281         }
282
283         return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";
284       };
285
286       function peg$parse(input, options) {
287         options = options !== void 0 ? options : {};
288
289         var peg$FAILED = {},
290             peg$startRuleFunctions = {
291           start: peg$parsestart
292         },
293             peg$startRuleFunction = peg$parsestart,
294             peg$c0 = function peg$c0(ss) {
295           return ss.length === 1 ? ss[0] : {
296             type: 'matches',
297             selectors: ss
298           };
299         },
300             peg$c1 = function peg$c1() {
301           return void 0;
302         },
303             peg$c2 = " ",
304             peg$c3 = peg$literalExpectation(" ", false),
305             peg$c4 = /^[^ [\],():#!=><~+.]/,
306             peg$c5 = peg$classExpectation([" ", "[", "]", ",", "(", ")", ":", "#", "!", "=", ">", "<", "~", "+", "."], true, false),
307             peg$c6 = function peg$c6(i) {
308           return i.join('');
309         },
310             peg$c7 = ">",
311             peg$c8 = peg$literalExpectation(">", false),
312             peg$c9 = function peg$c9() {
313           return 'child';
314         },
315             peg$c10 = "~",
316             peg$c11 = peg$literalExpectation("~", false),
317             peg$c12 = function peg$c12() {
318           return 'sibling';
319         },
320             peg$c13 = "+",
321             peg$c14 = peg$literalExpectation("+", false),
322             peg$c15 = function peg$c15() {
323           return 'adjacent';
324         },
325             peg$c16 = function peg$c16() {
326           return 'descendant';
327         },
328             peg$c17 = ",",
329             peg$c18 = peg$literalExpectation(",", false),
330             peg$c19 = function peg$c19(s, ss) {
331           return [s].concat(ss.map(function (s) {
332             return s[3];
333           }));
334         },
335             peg$c20 = function peg$c20(a, ops) {
336           return ops.reduce(function (memo, rhs) {
337             return {
338               type: rhs[0],
339               left: memo,
340               right: rhs[1]
341             };
342           }, a);
343         },
344             peg$c21 = "!",
345             peg$c22 = peg$literalExpectation("!", false),
346             peg$c23 = function peg$c23(subject, as) {
347           var b = as.length === 1 ? as[0] : {
348             type: 'compound',
349             selectors: as
350           };
351           if (subject) b.subject = true;
352           return b;
353         },
354             peg$c24 = "*",
355             peg$c25 = peg$literalExpectation("*", false),
356             peg$c26 = function peg$c26(a) {
357           return {
358             type: 'wildcard',
359             value: a
360           };
361         },
362             peg$c27 = "#",
363             peg$c28 = peg$literalExpectation("#", false),
364             peg$c29 = function peg$c29(i) {
365           return {
366             type: 'identifier',
367             value: i
368           };
369         },
370             peg$c30 = "[",
371             peg$c31 = peg$literalExpectation("[", false),
372             peg$c32 = "]",
373             peg$c33 = peg$literalExpectation("]", false),
374             peg$c34 = function peg$c34(v) {
375           return v;
376         },
377             peg$c35 = /^[><!]/,
378             peg$c36 = peg$classExpectation([">", "<", "!"], false, false),
379             peg$c37 = "=",
380             peg$c38 = peg$literalExpectation("=", false),
381             peg$c39 = function peg$c39(a) {
382           return (a || '') + '=';
383         },
384             peg$c40 = /^[><]/,
385             peg$c41 = peg$classExpectation([">", "<"], false, false),
386             peg$c42 = ".",
387             peg$c43 = peg$literalExpectation(".", false),
388             peg$c44 = function peg$c44(a, as) {
389           return [].concat.apply([a], as).join('');
390         },
391             peg$c45 = function peg$c45(name, op, value) {
392           return {
393             type: 'attribute',
394             name: name,
395             operator: op,
396             value: value
397           };
398         },
399             peg$c46 = function peg$c46(name) {
400           return {
401             type: 'attribute',
402             name: name
403           };
404         },
405             peg$c47 = "\"",
406             peg$c48 = peg$literalExpectation("\"", false),
407             peg$c49 = /^[^\\"]/,
408             peg$c50 = peg$classExpectation(["\\", "\""], true, false),
409             peg$c51 = "\\",
410             peg$c52 = peg$literalExpectation("\\", false),
411             peg$c53 = peg$anyExpectation(),
412             peg$c54 = function peg$c54(a, b) {
413           return a + b;
414         },
415             peg$c55 = function peg$c55(d) {
416           return {
417             type: 'literal',
418             value: strUnescape(d.join(''))
419           };
420         },
421             peg$c56 = "'",
422             peg$c57 = peg$literalExpectation("'", false),
423             peg$c58 = /^[^\\']/,
424             peg$c59 = peg$classExpectation(["\\", "'"], true, false),
425             peg$c60 = /^[0-9]/,
426             peg$c61 = peg$classExpectation([["0", "9"]], false, false),
427             peg$c62 = function peg$c62(a, b) {
428           // Can use `a.flat().join('')` once supported
429           var leadingDecimals = a ? [].concat.apply([], a).join('') : '';
430           return {
431             type: 'literal',
432             value: parseFloat(leadingDecimals + b.join(''))
433           };
434         },
435             peg$c63 = function peg$c63(i) {
436           return {
437             type: 'literal',
438             value: i
439           };
440         },
441             peg$c64 = "type(",
442             peg$c65 = peg$literalExpectation("type(", false),
443             peg$c66 = /^[^ )]/,
444             peg$c67 = peg$classExpectation([" ", ")"], true, false),
445             peg$c68 = ")",
446             peg$c69 = peg$literalExpectation(")", false),
447             peg$c70 = function peg$c70(t) {
448           return {
449             type: 'type',
450             value: t.join('')
451           };
452         },
453             peg$c71 = /^[imsu]/,
454             peg$c72 = peg$classExpectation(["i", "m", "s", "u"], false, false),
455             peg$c73 = "/",
456             peg$c74 = peg$literalExpectation("/", false),
457             peg$c75 = /^[^\/]/,
458             peg$c76 = peg$classExpectation(["/"], true, false),
459             peg$c77 = function peg$c77(d, flgs) {
460           return {
461             type: 'regexp',
462             value: new RegExp(d.join(''), flgs ? flgs.join('') : '')
463           };
464         },
465             peg$c78 = function peg$c78(i, is) {
466           return {
467             type: 'field',
468             name: is.reduce(function (memo, p) {
469               return memo + p[0] + p[1];
470             }, i)
471           };
472         },
473             peg$c79 = ":not(",
474             peg$c80 = peg$literalExpectation(":not(", false),
475             peg$c81 = function peg$c81(ss) {
476           return {
477             type: 'not',
478             selectors: ss
479           };
480         },
481             peg$c82 = ":matches(",
482             peg$c83 = peg$literalExpectation(":matches(", false),
483             peg$c84 = function peg$c84(ss) {
484           return {
485             type: 'matches',
486             selectors: ss
487           };
488         },
489             peg$c85 = ":has(",
490             peg$c86 = peg$literalExpectation(":has(", false),
491             peg$c87 = function peg$c87(ss) {
492           return {
493             type: 'has',
494             selectors: ss
495           };
496         },
497             peg$c88 = ":first-child",
498             peg$c89 = peg$literalExpectation(":first-child", false),
499             peg$c90 = function peg$c90() {
500           return nth(1);
501         },
502             peg$c91 = ":last-child",
503             peg$c92 = peg$literalExpectation(":last-child", false),
504             peg$c93 = function peg$c93() {
505           return nthLast(1);
506         },
507             peg$c94 = ":nth-child(",
508             peg$c95 = peg$literalExpectation(":nth-child(", false),
509             peg$c96 = function peg$c96(n) {
510           return nth(parseInt(n.join(''), 10));
511         },
512             peg$c97 = ":nth-last-child(",
513             peg$c98 = peg$literalExpectation(":nth-last-child(", false),
514             peg$c99 = function peg$c99(n) {
515           return nthLast(parseInt(n.join(''), 10));
516         },
517             peg$c100 = ":",
518             peg$c101 = peg$literalExpectation(":", false),
519             peg$c102 = "statement",
520             peg$c103 = peg$literalExpectation("statement", true),
521             peg$c104 = "expression",
522             peg$c105 = peg$literalExpectation("expression", true),
523             peg$c106 = "declaration",
524             peg$c107 = peg$literalExpectation("declaration", true),
525             peg$c108 = "function",
526             peg$c109 = peg$literalExpectation("function", true),
527             peg$c110 = "pattern",
528             peg$c111 = peg$literalExpectation("pattern", true),
529             peg$c112 = function peg$c112(c) {
530           return {
531             type: 'class',
532             name: c
533           };
534         },
535             peg$currPos = 0,
536             peg$posDetailsCache = [{
537           line: 1,
538           column: 1
539         }],
540             peg$maxFailPos = 0,
541             peg$maxFailExpected = [],
542             peg$resultsCache = {},
543             peg$result;
544
545         if ("startRule" in options) {
546           if (!(options.startRule in peg$startRuleFunctions)) {
547             throw new Error("Can't start parsing from rule \"" + options.startRule + "\".");
548           }
549
550           peg$startRuleFunction = peg$startRuleFunctions[options.startRule];
551         }
552
553         function peg$literalExpectation(text, ignoreCase) {
554           return {
555             type: "literal",
556             text: text,
557             ignoreCase: ignoreCase
558           };
559         }
560
561         function peg$classExpectation(parts, inverted, ignoreCase) {
562           return {
563             type: "class",
564             parts: parts,
565             inverted: inverted,
566             ignoreCase: ignoreCase
567           };
568         }
569
570         function peg$anyExpectation() {
571           return {
572             type: "any"
573           };
574         }
575
576         function peg$endExpectation() {
577           return {
578             type: "end"
579           };
580         }
581
582         function peg$computePosDetails(pos) {
583           var details = peg$posDetailsCache[pos],
584               p;
585
586           if (details) {
587             return details;
588           } else {
589             p = pos - 1;
590
591             while (!peg$posDetailsCache[p]) {
592               p--;
593             }
594
595             details = peg$posDetailsCache[p];
596             details = {
597               line: details.line,
598               column: details.column
599             };
600
601             while (p < pos) {
602               if (input.charCodeAt(p) === 10) {
603                 details.line++;
604                 details.column = 1;
605               } else {
606                 details.column++;
607               }
608
609               p++;
610             }
611
612             peg$posDetailsCache[pos] = details;
613             return details;
614           }
615         }
616
617         function peg$computeLocation(startPos, endPos) {
618           var startPosDetails = peg$computePosDetails(startPos),
619               endPosDetails = peg$computePosDetails(endPos);
620           return {
621             start: {
622               offset: startPos,
623               line: startPosDetails.line,
624               column: startPosDetails.column
625             },
626             end: {
627               offset: endPos,
628               line: endPosDetails.line,
629               column: endPosDetails.column
630             }
631           };
632         }
633
634         function peg$fail(expected) {
635           if (peg$currPos < peg$maxFailPos) {
636             return;
637           }
638
639           if (peg$currPos > peg$maxFailPos) {
640             peg$maxFailPos = peg$currPos;
641             peg$maxFailExpected = [];
642           }
643
644           peg$maxFailExpected.push(expected);
645         }
646
647         function peg$buildStructuredError(expected, found, location) {
648           return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location);
649         }
650
651         function peg$parsestart() {
652           var s0, s1, s2, s3;
653           var key = peg$currPos * 30 + 0,
654               cached = peg$resultsCache[key];
655
656           if (cached) {
657             peg$currPos = cached.nextPos;
658             return cached.result;
659           }
660
661           s0 = peg$currPos;
662           s1 = peg$parse_();
663
664           if (s1 !== peg$FAILED) {
665             s2 = peg$parseselectors();
666
667             if (s2 !== peg$FAILED) {
668               s3 = peg$parse_();
669
670               if (s3 !== peg$FAILED) {
671                 s1 = peg$c0(s2);
672                 s0 = s1;
673               } else {
674                 peg$currPos = s0;
675                 s0 = peg$FAILED;
676               }
677             } else {
678               peg$currPos = s0;
679               s0 = peg$FAILED;
680             }
681           } else {
682             peg$currPos = s0;
683             s0 = peg$FAILED;
684           }
685
686           if (s0 === peg$FAILED) {
687             s0 = peg$currPos;
688             s1 = peg$parse_();
689
690             if (s1 !== peg$FAILED) {
691               s1 = peg$c1();
692             }
693
694             s0 = s1;
695           }
696
697           peg$resultsCache[key] = {
698             nextPos: peg$currPos,
699             result: s0
700           };
701           return s0;
702         }
703
704         function peg$parse_() {
705           var s0, s1;
706           var key = peg$currPos * 30 + 1,
707               cached = peg$resultsCache[key];
708
709           if (cached) {
710             peg$currPos = cached.nextPos;
711             return cached.result;
712           }
713
714           s0 = [];
715
716           if (input.charCodeAt(peg$currPos) === 32) {
717             s1 = peg$c2;
718             peg$currPos++;
719           } else {
720             s1 = peg$FAILED;
721
722             {
723               peg$fail(peg$c3);
724             }
725           }
726
727           while (s1 !== peg$FAILED) {
728             s0.push(s1);
729
730             if (input.charCodeAt(peg$currPos) === 32) {
731               s1 = peg$c2;
732               peg$currPos++;
733             } else {
734               s1 = peg$FAILED;
735
736               {
737                 peg$fail(peg$c3);
738               }
739             }
740           }
741
742           peg$resultsCache[key] = {
743             nextPos: peg$currPos,
744             result: s0
745           };
746           return s0;
747         }
748
749         function peg$parseidentifierName() {
750           var s0, s1, s2;
751           var key = peg$currPos * 30 + 2,
752               cached = peg$resultsCache[key];
753
754           if (cached) {
755             peg$currPos = cached.nextPos;
756             return cached.result;
757           }
758
759           s0 = peg$currPos;
760           s1 = [];
761
762           if (peg$c4.test(input.charAt(peg$currPos))) {
763             s2 = input.charAt(peg$currPos);
764             peg$currPos++;
765           } else {
766             s2 = peg$FAILED;
767
768             {
769               peg$fail(peg$c5);
770             }
771           }
772
773           if (s2 !== peg$FAILED) {
774             while (s2 !== peg$FAILED) {
775               s1.push(s2);
776
777               if (peg$c4.test(input.charAt(peg$currPos))) {
778                 s2 = input.charAt(peg$currPos);
779                 peg$currPos++;
780               } else {
781                 s2 = peg$FAILED;
782
783                 {
784                   peg$fail(peg$c5);
785                 }
786               }
787             }
788           } else {
789             s1 = peg$FAILED;
790           }
791
792           if (s1 !== peg$FAILED) {
793             s1 = peg$c6(s1);
794           }
795
796           s0 = s1;
797           peg$resultsCache[key] = {
798             nextPos: peg$currPos,
799             result: s0
800           };
801           return s0;
802         }
803
804         function peg$parsebinaryOp() {
805           var s0, s1, s2, s3;
806           var key = peg$currPos * 30 + 3,
807               cached = peg$resultsCache[key];
808
809           if (cached) {
810             peg$currPos = cached.nextPos;
811             return cached.result;
812           }
813
814           s0 = peg$currPos;
815           s1 = peg$parse_();
816
817           if (s1 !== peg$FAILED) {
818             if (input.charCodeAt(peg$currPos) === 62) {
819               s2 = peg$c7;
820               peg$currPos++;
821             } else {
822               s2 = peg$FAILED;
823
824               {
825                 peg$fail(peg$c8);
826               }
827             }
828
829             if (s2 !== peg$FAILED) {
830               s3 = peg$parse_();
831
832               if (s3 !== peg$FAILED) {
833                 s1 = peg$c9();
834                 s0 = s1;
835               } else {
836                 peg$currPos = s0;
837                 s0 = peg$FAILED;
838               }
839             } else {
840               peg$currPos = s0;
841               s0 = peg$FAILED;
842             }
843           } else {
844             peg$currPos = s0;
845             s0 = peg$FAILED;
846           }
847
848           if (s0 === peg$FAILED) {
849             s0 = peg$currPos;
850             s1 = peg$parse_();
851
852             if (s1 !== peg$FAILED) {
853               if (input.charCodeAt(peg$currPos) === 126) {
854                 s2 = peg$c10;
855                 peg$currPos++;
856               } else {
857                 s2 = peg$FAILED;
858
859                 {
860                   peg$fail(peg$c11);
861                 }
862               }
863
864               if (s2 !== peg$FAILED) {
865                 s3 = peg$parse_();
866
867                 if (s3 !== peg$FAILED) {
868                   s1 = peg$c12();
869                   s0 = s1;
870                 } else {
871                   peg$currPos = s0;
872                   s0 = peg$FAILED;
873                 }
874               } else {
875                 peg$currPos = s0;
876                 s0 = peg$FAILED;
877               }
878             } else {
879               peg$currPos = s0;
880               s0 = peg$FAILED;
881             }
882
883             if (s0 === peg$FAILED) {
884               s0 = peg$currPos;
885               s1 = peg$parse_();
886
887               if (s1 !== peg$FAILED) {
888                 if (input.charCodeAt(peg$currPos) === 43) {
889                   s2 = peg$c13;
890                   peg$currPos++;
891                 } else {
892                   s2 = peg$FAILED;
893
894                   {
895                     peg$fail(peg$c14);
896                   }
897                 }
898
899                 if (s2 !== peg$FAILED) {
900                   s3 = peg$parse_();
901
902                   if (s3 !== peg$FAILED) {
903                     s1 = peg$c15();
904                     s0 = s1;
905                   } else {
906                     peg$currPos = s0;
907                     s0 = peg$FAILED;
908                   }
909                 } else {
910                   peg$currPos = s0;
911                   s0 = peg$FAILED;
912                 }
913               } else {
914                 peg$currPos = s0;
915                 s0 = peg$FAILED;
916               }
917
918               if (s0 === peg$FAILED) {
919                 s0 = peg$currPos;
920
921                 if (input.charCodeAt(peg$currPos) === 32) {
922                   s1 = peg$c2;
923                   peg$currPos++;
924                 } else {
925                   s1 = peg$FAILED;
926
927                   {
928                     peg$fail(peg$c3);
929                   }
930                 }
931
932                 if (s1 !== peg$FAILED) {
933                   s2 = peg$parse_();
934
935                   if (s2 !== peg$FAILED) {
936                     s1 = peg$c16();
937                     s0 = s1;
938                   } else {
939                     peg$currPos = s0;
940                     s0 = peg$FAILED;
941                   }
942                 } else {
943                   peg$currPos = s0;
944                   s0 = peg$FAILED;
945                 }
946               }
947             }
948           }
949
950           peg$resultsCache[key] = {
951             nextPos: peg$currPos,
952             result: s0
953           };
954           return s0;
955         }
956
957         function peg$parseselectors() {
958           var s0, s1, s2, s3, s4, s5, s6, s7;
959           var key = peg$currPos * 30 + 4,
960               cached = peg$resultsCache[key];
961
962           if (cached) {
963             peg$currPos = cached.nextPos;
964             return cached.result;
965           }
966
967           s0 = peg$currPos;
968           s1 = peg$parseselector();
969
970           if (s1 !== peg$FAILED) {
971             s2 = [];
972             s3 = peg$currPos;
973             s4 = peg$parse_();
974
975             if (s4 !== peg$FAILED) {
976               if (input.charCodeAt(peg$currPos) === 44) {
977                 s5 = peg$c17;
978                 peg$currPos++;
979               } else {
980                 s5 = peg$FAILED;
981
982                 {
983                   peg$fail(peg$c18);
984                 }
985               }
986
987               if (s5 !== peg$FAILED) {
988                 s6 = peg$parse_();
989
990                 if (s6 !== peg$FAILED) {
991                   s7 = peg$parseselector();
992
993                   if (s7 !== peg$FAILED) {
994                     s4 = [s4, s5, s6, s7];
995                     s3 = s4;
996                   } else {
997                     peg$currPos = s3;
998                     s3 = peg$FAILED;
999                   }
1000                 } else {
1001                   peg$currPos = s3;
1002                   s3 = peg$FAILED;
1003                 }
1004               } else {
1005                 peg$currPos = s3;
1006                 s3 = peg$FAILED;
1007               }
1008             } else {
1009               peg$currPos = s3;
1010               s3 = peg$FAILED;
1011             }
1012
1013             while (s3 !== peg$FAILED) {
1014               s2.push(s3);
1015               s3 = peg$currPos;
1016               s4 = peg$parse_();
1017
1018               if (s4 !== peg$FAILED) {
1019                 if (input.charCodeAt(peg$currPos) === 44) {
1020                   s5 = peg$c17;
1021                   peg$currPos++;
1022                 } else {
1023                   s5 = peg$FAILED;
1024
1025                   {
1026                     peg$fail(peg$c18);
1027                   }
1028                 }
1029
1030                 if (s5 !== peg$FAILED) {
1031                   s6 = peg$parse_();
1032
1033                   if (s6 !== peg$FAILED) {
1034                     s7 = peg$parseselector();
1035
1036                     if (s7 !== peg$FAILED) {
1037                       s4 = [s4, s5, s6, s7];
1038                       s3 = s4;
1039                     } else {
1040                       peg$currPos = s3;
1041                       s3 = peg$FAILED;
1042                     }
1043                   } else {
1044                     peg$currPos = s3;
1045                     s3 = peg$FAILED;
1046                   }
1047                 } else {
1048                   peg$currPos = s3;
1049                   s3 = peg$FAILED;
1050                 }
1051               } else {
1052                 peg$currPos = s3;
1053                 s3 = peg$FAILED;
1054               }
1055             }
1056
1057             if (s2 !== peg$FAILED) {
1058               s1 = peg$c19(s1, s2);
1059               s0 = s1;
1060             } else {
1061               peg$currPos = s0;
1062               s0 = peg$FAILED;
1063             }
1064           } else {
1065             peg$currPos = s0;
1066             s0 = peg$FAILED;
1067           }
1068
1069           peg$resultsCache[key] = {
1070             nextPos: peg$currPos,
1071             result: s0
1072           };
1073           return s0;
1074         }
1075
1076         function peg$parseselector() {
1077           var s0, s1, s2, s3, s4, s5;
1078           var key = peg$currPos * 30 + 5,
1079               cached = peg$resultsCache[key];
1080
1081           if (cached) {
1082             peg$currPos = cached.nextPos;
1083             return cached.result;
1084           }
1085
1086           s0 = peg$currPos;
1087           s1 = peg$parsesequence();
1088
1089           if (s1 !== peg$FAILED) {
1090             s2 = [];
1091             s3 = peg$currPos;
1092             s4 = peg$parsebinaryOp();
1093
1094             if (s4 !== peg$FAILED) {
1095               s5 = peg$parsesequence();
1096
1097               if (s5 !== peg$FAILED) {
1098                 s4 = [s4, s5];
1099                 s3 = s4;
1100               } else {
1101                 peg$currPos = s3;
1102                 s3 = peg$FAILED;
1103               }
1104             } else {
1105               peg$currPos = s3;
1106               s3 = peg$FAILED;
1107             }
1108
1109             while (s3 !== peg$FAILED) {
1110               s2.push(s3);
1111               s3 = peg$currPos;
1112               s4 = peg$parsebinaryOp();
1113
1114               if (s4 !== peg$FAILED) {
1115                 s5 = peg$parsesequence();
1116
1117                 if (s5 !== peg$FAILED) {
1118                   s4 = [s4, s5];
1119                   s3 = s4;
1120                 } else {
1121                   peg$currPos = s3;
1122                   s3 = peg$FAILED;
1123                 }
1124               } else {
1125                 peg$currPos = s3;
1126                 s3 = peg$FAILED;
1127               }
1128             }
1129
1130             if (s2 !== peg$FAILED) {
1131               s1 = peg$c20(s1, s2);
1132               s0 = s1;
1133             } else {
1134               peg$currPos = s0;
1135               s0 = peg$FAILED;
1136             }
1137           } else {
1138             peg$currPos = s0;
1139             s0 = peg$FAILED;
1140           }
1141
1142           peg$resultsCache[key] = {
1143             nextPos: peg$currPos,
1144             result: s0
1145           };
1146           return s0;
1147         }
1148
1149         function peg$parsesequence() {
1150           var s0, s1, s2, s3;
1151           var key = peg$currPos * 30 + 6,
1152               cached = peg$resultsCache[key];
1153
1154           if (cached) {
1155             peg$currPos = cached.nextPos;
1156             return cached.result;
1157           }
1158
1159           s0 = peg$currPos;
1160
1161           if (input.charCodeAt(peg$currPos) === 33) {
1162             s1 = peg$c21;
1163             peg$currPos++;
1164           } else {
1165             s1 = peg$FAILED;
1166
1167             {
1168               peg$fail(peg$c22);
1169             }
1170           }
1171
1172           if (s1 === peg$FAILED) {
1173             s1 = null;
1174           }
1175
1176           if (s1 !== peg$FAILED) {
1177             s2 = [];
1178             s3 = peg$parseatom();
1179
1180             if (s3 !== peg$FAILED) {
1181               while (s3 !== peg$FAILED) {
1182                 s2.push(s3);
1183                 s3 = peg$parseatom();
1184               }
1185             } else {
1186               s2 = peg$FAILED;
1187             }
1188
1189             if (s2 !== peg$FAILED) {
1190               s1 = peg$c23(s1, s2);
1191               s0 = s1;
1192             } else {
1193               peg$currPos = s0;
1194               s0 = peg$FAILED;
1195             }
1196           } else {
1197             peg$currPos = s0;
1198             s0 = peg$FAILED;
1199           }
1200
1201           peg$resultsCache[key] = {
1202             nextPos: peg$currPos,
1203             result: s0
1204           };
1205           return s0;
1206         }
1207
1208         function peg$parseatom() {
1209           var s0;
1210           var key = peg$currPos * 30 + 7,
1211               cached = peg$resultsCache[key];
1212
1213           if (cached) {
1214             peg$currPos = cached.nextPos;
1215             return cached.result;
1216           }
1217
1218           s0 = peg$parsewildcard();
1219
1220           if (s0 === peg$FAILED) {
1221             s0 = peg$parseidentifier();
1222
1223             if (s0 === peg$FAILED) {
1224               s0 = peg$parseattr();
1225
1226               if (s0 === peg$FAILED) {
1227                 s0 = peg$parsefield();
1228
1229                 if (s0 === peg$FAILED) {
1230                   s0 = peg$parsenegation();
1231
1232                   if (s0 === peg$FAILED) {
1233                     s0 = peg$parsematches();
1234
1235                     if (s0 === peg$FAILED) {
1236                       s0 = peg$parsehas();
1237
1238                       if (s0 === peg$FAILED) {
1239                         s0 = peg$parsefirstChild();
1240
1241                         if (s0 === peg$FAILED) {
1242                           s0 = peg$parselastChild();
1243
1244                           if (s0 === peg$FAILED) {
1245                             s0 = peg$parsenthChild();
1246
1247                             if (s0 === peg$FAILED) {
1248                               s0 = peg$parsenthLastChild();
1249
1250                               if (s0 === peg$FAILED) {
1251                                 s0 = peg$parseclass();
1252                               }
1253                             }
1254                           }
1255                         }
1256                       }
1257                     }
1258                   }
1259                 }
1260               }
1261             }
1262           }
1263
1264           peg$resultsCache[key] = {
1265             nextPos: peg$currPos,
1266             result: s0
1267           };
1268           return s0;
1269         }
1270
1271         function peg$parsewildcard() {
1272           var s0, s1;
1273           var key = peg$currPos * 30 + 8,
1274               cached = peg$resultsCache[key];
1275
1276           if (cached) {
1277             peg$currPos = cached.nextPos;
1278             return cached.result;
1279           }
1280
1281           s0 = peg$currPos;
1282
1283           if (input.charCodeAt(peg$currPos) === 42) {
1284             s1 = peg$c24;
1285             peg$currPos++;
1286           } else {
1287             s1 = peg$FAILED;
1288
1289             {
1290               peg$fail(peg$c25);
1291             }
1292           }
1293
1294           if (s1 !== peg$FAILED) {
1295             s1 = peg$c26(s1);
1296           }
1297
1298           s0 = s1;
1299           peg$resultsCache[key] = {
1300             nextPos: peg$currPos,
1301             result: s0
1302           };
1303           return s0;
1304         }
1305
1306         function peg$parseidentifier() {
1307           var s0, s1, s2;
1308           var key = peg$currPos * 30 + 9,
1309               cached = peg$resultsCache[key];
1310
1311           if (cached) {
1312             peg$currPos = cached.nextPos;
1313             return cached.result;
1314           }
1315
1316           s0 = peg$currPos;
1317
1318           if (input.charCodeAt(peg$currPos) === 35) {
1319             s1 = peg$c27;
1320             peg$currPos++;
1321           } else {
1322             s1 = peg$FAILED;
1323
1324             {
1325               peg$fail(peg$c28);
1326             }
1327           }
1328
1329           if (s1 === peg$FAILED) {
1330             s1 = null;
1331           }
1332
1333           if (s1 !== peg$FAILED) {
1334             s2 = peg$parseidentifierName();
1335
1336             if (s2 !== peg$FAILED) {
1337               s1 = peg$c29(s2);
1338               s0 = s1;
1339             } else {
1340               peg$currPos = s0;
1341               s0 = peg$FAILED;
1342             }
1343           } else {
1344             peg$currPos = s0;
1345             s0 = peg$FAILED;
1346           }
1347
1348           peg$resultsCache[key] = {
1349             nextPos: peg$currPos,
1350             result: s0
1351           };
1352           return s0;
1353         }
1354
1355         function peg$parseattr() {
1356           var s0, s1, s2, s3, s4, s5;
1357           var key = peg$currPos * 30 + 10,
1358               cached = peg$resultsCache[key];
1359
1360           if (cached) {
1361             peg$currPos = cached.nextPos;
1362             return cached.result;
1363           }
1364
1365           s0 = peg$currPos;
1366
1367           if (input.charCodeAt(peg$currPos) === 91) {
1368             s1 = peg$c30;
1369             peg$currPos++;
1370           } else {
1371             s1 = peg$FAILED;
1372
1373             {
1374               peg$fail(peg$c31);
1375             }
1376           }
1377
1378           if (s1 !== peg$FAILED) {
1379             s2 = peg$parse_();
1380
1381             if (s2 !== peg$FAILED) {
1382               s3 = peg$parseattrValue();
1383
1384               if (s3 !== peg$FAILED) {
1385                 s4 = peg$parse_();
1386
1387                 if (s4 !== peg$FAILED) {
1388                   if (input.charCodeAt(peg$currPos) === 93) {
1389                     s5 = peg$c32;
1390                     peg$currPos++;
1391                   } else {
1392                     s5 = peg$FAILED;
1393
1394                     {
1395                       peg$fail(peg$c33);
1396                     }
1397                   }
1398
1399                   if (s5 !== peg$FAILED) {
1400                     s1 = peg$c34(s3);
1401                     s0 = s1;
1402                   } else {
1403                     peg$currPos = s0;
1404                     s0 = peg$FAILED;
1405                   }
1406                 } else {
1407                   peg$currPos = s0;
1408                   s0 = peg$FAILED;
1409                 }
1410               } else {
1411                 peg$currPos = s0;
1412                 s0 = peg$FAILED;
1413               }
1414             } else {
1415               peg$currPos = s0;
1416               s0 = peg$FAILED;
1417             }
1418           } else {
1419             peg$currPos = s0;
1420             s0 = peg$FAILED;
1421           }
1422
1423           peg$resultsCache[key] = {
1424             nextPos: peg$currPos,
1425             result: s0
1426           };
1427           return s0;
1428         }
1429
1430         function peg$parseattrOps() {
1431           var s0, s1, s2;
1432           var key = peg$currPos * 30 + 11,
1433               cached = peg$resultsCache[key];
1434
1435           if (cached) {
1436             peg$currPos = cached.nextPos;
1437             return cached.result;
1438           }
1439
1440           s0 = peg$currPos;
1441
1442           if (peg$c35.test(input.charAt(peg$currPos))) {
1443             s1 = input.charAt(peg$currPos);
1444             peg$currPos++;
1445           } else {
1446             s1 = peg$FAILED;
1447
1448             {
1449               peg$fail(peg$c36);
1450             }
1451           }
1452
1453           if (s1 === peg$FAILED) {
1454             s1 = null;
1455           }
1456
1457           if (s1 !== peg$FAILED) {
1458             if (input.charCodeAt(peg$currPos) === 61) {
1459               s2 = peg$c37;
1460               peg$currPos++;
1461             } else {
1462               s2 = peg$FAILED;
1463
1464               {
1465                 peg$fail(peg$c38);
1466               }
1467             }
1468
1469             if (s2 !== peg$FAILED) {
1470               s1 = peg$c39(s1);
1471               s0 = s1;
1472             } else {
1473               peg$currPos = s0;
1474               s0 = peg$FAILED;
1475             }
1476           } else {
1477             peg$currPos = s0;
1478             s0 = peg$FAILED;
1479           }
1480
1481           if (s0 === peg$FAILED) {
1482             if (peg$c40.test(input.charAt(peg$currPos))) {
1483               s0 = input.charAt(peg$currPos);
1484               peg$currPos++;
1485             } else {
1486               s0 = peg$FAILED;
1487
1488               {
1489                 peg$fail(peg$c41);
1490               }
1491             }
1492           }
1493
1494           peg$resultsCache[key] = {
1495             nextPos: peg$currPos,
1496             result: s0
1497           };
1498           return s0;
1499         }
1500
1501         function peg$parseattrEqOps() {
1502           var s0, s1, s2;
1503           var key = peg$currPos * 30 + 12,
1504               cached = peg$resultsCache[key];
1505
1506           if (cached) {
1507             peg$currPos = cached.nextPos;
1508             return cached.result;
1509           }
1510
1511           s0 = peg$currPos;
1512
1513           if (input.charCodeAt(peg$currPos) === 33) {
1514             s1 = peg$c21;
1515             peg$currPos++;
1516           } else {
1517             s1 = peg$FAILED;
1518
1519             {
1520               peg$fail(peg$c22);
1521             }
1522           }
1523
1524           if (s1 === peg$FAILED) {
1525             s1 = null;
1526           }
1527
1528           if (s1 !== peg$FAILED) {
1529             if (input.charCodeAt(peg$currPos) === 61) {
1530               s2 = peg$c37;
1531               peg$currPos++;
1532             } else {
1533               s2 = peg$FAILED;
1534
1535               {
1536                 peg$fail(peg$c38);
1537               }
1538             }
1539
1540             if (s2 !== peg$FAILED) {
1541               s1 = peg$c39(s1);
1542               s0 = s1;
1543             } else {
1544               peg$currPos = s0;
1545               s0 = peg$FAILED;
1546             }
1547           } else {
1548             peg$currPos = s0;
1549             s0 = peg$FAILED;
1550           }
1551
1552           peg$resultsCache[key] = {
1553             nextPos: peg$currPos,
1554             result: s0
1555           };
1556           return s0;
1557         }
1558
1559         function peg$parseattrName() {
1560           var s0, s1, s2, s3, s4, s5;
1561           var key = peg$currPos * 30 + 13,
1562               cached = peg$resultsCache[key];
1563
1564           if (cached) {
1565             peg$currPos = cached.nextPos;
1566             return cached.result;
1567           }
1568
1569           s0 = peg$currPos;
1570           s1 = peg$parseidentifierName();
1571
1572           if (s1 !== peg$FAILED) {
1573             s2 = [];
1574             s3 = peg$currPos;
1575
1576             if (input.charCodeAt(peg$currPos) === 46) {
1577               s4 = peg$c42;
1578               peg$currPos++;
1579             } else {
1580               s4 = peg$FAILED;
1581
1582               {
1583                 peg$fail(peg$c43);
1584               }
1585             }
1586
1587             if (s4 !== peg$FAILED) {
1588               s5 = peg$parseidentifierName();
1589
1590               if (s5 !== peg$FAILED) {
1591                 s4 = [s4, s5];
1592                 s3 = s4;
1593               } else {
1594                 peg$currPos = s3;
1595                 s3 = peg$FAILED;
1596               }
1597             } else {
1598               peg$currPos = s3;
1599               s3 = peg$FAILED;
1600             }
1601
1602             while (s3 !== peg$FAILED) {
1603               s2.push(s3);
1604               s3 = peg$currPos;
1605
1606               if (input.charCodeAt(peg$currPos) === 46) {
1607                 s4 = peg$c42;
1608                 peg$currPos++;
1609               } else {
1610                 s4 = peg$FAILED;
1611
1612                 {
1613                   peg$fail(peg$c43);
1614                 }
1615               }
1616
1617               if (s4 !== peg$FAILED) {
1618                 s5 = peg$parseidentifierName();
1619
1620                 if (s5 !== peg$FAILED) {
1621                   s4 = [s4, s5];
1622                   s3 = s4;
1623                 } else {
1624                   peg$currPos = s3;
1625                   s3 = peg$FAILED;
1626                 }
1627               } else {
1628                 peg$currPos = s3;
1629                 s3 = peg$FAILED;
1630               }
1631             }
1632
1633             if (s2 !== peg$FAILED) {
1634               s1 = peg$c44(s1, s2);
1635               s0 = s1;
1636             } else {
1637               peg$currPos = s0;
1638               s0 = peg$FAILED;
1639             }
1640           } else {
1641             peg$currPos = s0;
1642             s0 = peg$FAILED;
1643           }
1644
1645           peg$resultsCache[key] = {
1646             nextPos: peg$currPos,
1647             result: s0
1648           };
1649           return s0;
1650         }
1651
1652         function peg$parseattrValue() {
1653           var s0, s1, s2, s3, s4, s5;
1654           var key = peg$currPos * 30 + 14,
1655               cached = peg$resultsCache[key];
1656
1657           if (cached) {
1658             peg$currPos = cached.nextPos;
1659             return cached.result;
1660           }
1661
1662           s0 = peg$currPos;
1663           s1 = peg$parseattrName();
1664
1665           if (s1 !== peg$FAILED) {
1666             s2 = peg$parse_();
1667
1668             if (s2 !== peg$FAILED) {
1669               s3 = peg$parseattrEqOps();
1670
1671               if (s3 !== peg$FAILED) {
1672                 s4 = peg$parse_();
1673
1674                 if (s4 !== peg$FAILED) {
1675                   s5 = peg$parsetype();
1676
1677                   if (s5 === peg$FAILED) {
1678                     s5 = peg$parseregex();
1679                   }
1680
1681                   if (s5 !== peg$FAILED) {
1682                     s1 = peg$c45(s1, s3, s5);
1683                     s0 = s1;
1684                   } else {
1685                     peg$currPos = s0;
1686                     s0 = peg$FAILED;
1687                   }
1688                 } else {
1689                   peg$currPos = s0;
1690                   s0 = peg$FAILED;
1691                 }
1692               } else {
1693                 peg$currPos = s0;
1694                 s0 = peg$FAILED;
1695               }
1696             } else {
1697               peg$currPos = s0;
1698               s0 = peg$FAILED;
1699             }
1700           } else {
1701             peg$currPos = s0;
1702             s0 = peg$FAILED;
1703           }
1704
1705           if (s0 === peg$FAILED) {
1706             s0 = peg$currPos;
1707             s1 = peg$parseattrName();
1708
1709             if (s1 !== peg$FAILED) {
1710               s2 = peg$parse_();
1711
1712               if (s2 !== peg$FAILED) {
1713                 s3 = peg$parseattrOps();
1714
1715                 if (s3 !== peg$FAILED) {
1716                   s4 = peg$parse_();
1717
1718                   if (s4 !== peg$FAILED) {
1719                     s5 = peg$parsestring();
1720
1721                     if (s5 === peg$FAILED) {
1722                       s5 = peg$parsenumber();
1723
1724                       if (s5 === peg$FAILED) {
1725                         s5 = peg$parsepath();
1726                       }
1727                     }
1728
1729                     if (s5 !== peg$FAILED) {
1730                       s1 = peg$c45(s1, s3, s5);
1731                       s0 = s1;
1732                     } else {
1733                       peg$currPos = s0;
1734                       s0 = peg$FAILED;
1735                     }
1736                   } else {
1737                     peg$currPos = s0;
1738                     s0 = peg$FAILED;
1739                   }
1740                 } else {
1741                   peg$currPos = s0;
1742                   s0 = peg$FAILED;
1743                 }
1744               } else {
1745                 peg$currPos = s0;
1746                 s0 = peg$FAILED;
1747               }
1748             } else {
1749               peg$currPos = s0;
1750               s0 = peg$FAILED;
1751             }
1752
1753             if (s0 === peg$FAILED) {
1754               s0 = peg$currPos;
1755               s1 = peg$parseattrName();
1756
1757               if (s1 !== peg$FAILED) {
1758                 s1 = peg$c46(s1);
1759               }
1760
1761               s0 = s1;
1762             }
1763           }
1764
1765           peg$resultsCache[key] = {
1766             nextPos: peg$currPos,
1767             result: s0
1768           };
1769           return s0;
1770         }
1771
1772         function peg$parsestring() {
1773           var s0, s1, s2, s3, s4, s5;
1774           var key = peg$currPos * 30 + 15,
1775               cached = peg$resultsCache[key];
1776
1777           if (cached) {
1778             peg$currPos = cached.nextPos;
1779             return cached.result;
1780           }
1781
1782           s0 = peg$currPos;
1783
1784           if (input.charCodeAt(peg$currPos) === 34) {
1785             s1 = peg$c47;
1786             peg$currPos++;
1787           } else {
1788             s1 = peg$FAILED;
1789
1790             {
1791               peg$fail(peg$c48);
1792             }
1793           }
1794
1795           if (s1 !== peg$FAILED) {
1796             s2 = [];
1797
1798             if (peg$c49.test(input.charAt(peg$currPos))) {
1799               s3 = input.charAt(peg$currPos);
1800               peg$currPos++;
1801             } else {
1802               s3 = peg$FAILED;
1803
1804               {
1805                 peg$fail(peg$c50);
1806               }
1807             }
1808
1809             if (s3 === peg$FAILED) {
1810               s3 = peg$currPos;
1811
1812               if (input.charCodeAt(peg$currPos) === 92) {
1813                 s4 = peg$c51;
1814                 peg$currPos++;
1815               } else {
1816                 s4 = peg$FAILED;
1817
1818                 {
1819                   peg$fail(peg$c52);
1820                 }
1821               }
1822
1823               if (s4 !== peg$FAILED) {
1824                 if (input.length > peg$currPos) {
1825                   s5 = input.charAt(peg$currPos);
1826                   peg$currPos++;
1827                 } else {
1828                   s5 = peg$FAILED;
1829
1830                   {
1831                     peg$fail(peg$c53);
1832                   }
1833                 }
1834
1835                 if (s5 !== peg$FAILED) {
1836                   s4 = peg$c54(s4, s5);
1837                   s3 = s4;
1838                 } else {
1839                   peg$currPos = s3;
1840                   s3 = peg$FAILED;
1841                 }
1842               } else {
1843                 peg$currPos = s3;
1844                 s3 = peg$FAILED;
1845               }
1846             }
1847
1848             while (s3 !== peg$FAILED) {
1849               s2.push(s3);
1850
1851               if (peg$c49.test(input.charAt(peg$currPos))) {
1852                 s3 = input.charAt(peg$currPos);
1853                 peg$currPos++;
1854               } else {
1855                 s3 = peg$FAILED;
1856
1857                 {
1858                   peg$fail(peg$c50);
1859                 }
1860               }
1861
1862               if (s3 === peg$FAILED) {
1863                 s3 = peg$currPos;
1864
1865                 if (input.charCodeAt(peg$currPos) === 92) {
1866                   s4 = peg$c51;
1867                   peg$currPos++;
1868                 } else {
1869                   s4 = peg$FAILED;
1870
1871                   {
1872                     peg$fail(peg$c52);
1873                   }
1874                 }
1875
1876                 if (s4 !== peg$FAILED) {
1877                   if (input.length > peg$currPos) {
1878                     s5 = input.charAt(peg$currPos);
1879                     peg$currPos++;
1880                   } else {
1881                     s5 = peg$FAILED;
1882
1883                     {
1884                       peg$fail(peg$c53);
1885                     }
1886                   }
1887
1888                   if (s5 !== peg$FAILED) {
1889                     s4 = peg$c54(s4, s5);
1890                     s3 = s4;
1891                   } else {
1892                     peg$currPos = s3;
1893                     s3 = peg$FAILED;
1894                   }
1895                 } else {
1896                   peg$currPos = s3;
1897                   s3 = peg$FAILED;
1898                 }
1899               }
1900             }
1901
1902             if (s2 !== peg$FAILED) {
1903               if (input.charCodeAt(peg$currPos) === 34) {
1904                 s3 = peg$c47;
1905                 peg$currPos++;
1906               } else {
1907                 s3 = peg$FAILED;
1908
1909                 {
1910                   peg$fail(peg$c48);
1911                 }
1912               }
1913
1914               if (s3 !== peg$FAILED) {
1915                 s1 = peg$c55(s2);
1916                 s0 = s1;
1917               } else {
1918                 peg$currPos = s0;
1919                 s0 = peg$FAILED;
1920               }
1921             } else {
1922               peg$currPos = s0;
1923               s0 = peg$FAILED;
1924             }
1925           } else {
1926             peg$currPos = s0;
1927             s0 = peg$FAILED;
1928           }
1929
1930           if (s0 === peg$FAILED) {
1931             s0 = peg$currPos;
1932
1933             if (input.charCodeAt(peg$currPos) === 39) {
1934               s1 = peg$c56;
1935               peg$currPos++;
1936             } else {
1937               s1 = peg$FAILED;
1938
1939               {
1940                 peg$fail(peg$c57);
1941               }
1942             }
1943
1944             if (s1 !== peg$FAILED) {
1945               s2 = [];
1946
1947               if (peg$c58.test(input.charAt(peg$currPos))) {
1948                 s3 = input.charAt(peg$currPos);
1949                 peg$currPos++;
1950               } else {
1951                 s3 = peg$FAILED;
1952
1953                 {
1954                   peg$fail(peg$c59);
1955                 }
1956               }
1957
1958               if (s3 === peg$FAILED) {
1959                 s3 = peg$currPos;
1960
1961                 if (input.charCodeAt(peg$currPos) === 92) {
1962                   s4 = peg$c51;
1963                   peg$currPos++;
1964                 } else {
1965                   s4 = peg$FAILED;
1966
1967                   {
1968                     peg$fail(peg$c52);
1969                   }
1970                 }
1971
1972                 if (s4 !== peg$FAILED) {
1973                   if (input.length > peg$currPos) {
1974                     s5 = input.charAt(peg$currPos);
1975                     peg$currPos++;
1976                   } else {
1977                     s5 = peg$FAILED;
1978
1979                     {
1980                       peg$fail(peg$c53);
1981                     }
1982                   }
1983
1984                   if (s5 !== peg$FAILED) {
1985                     s4 = peg$c54(s4, s5);
1986                     s3 = s4;
1987                   } else {
1988                     peg$currPos = s3;
1989                     s3 = peg$FAILED;
1990                   }
1991                 } else {
1992                   peg$currPos = s3;
1993                   s3 = peg$FAILED;
1994                 }
1995               }
1996
1997               while (s3 !== peg$FAILED) {
1998                 s2.push(s3);
1999
2000                 if (peg$c58.test(input.charAt(peg$currPos))) {
2001                   s3 = input.charAt(peg$currPos);
2002                   peg$currPos++;
2003                 } else {
2004                   s3 = peg$FAILED;
2005
2006                   {
2007                     peg$fail(peg$c59);
2008                   }
2009                 }
2010
2011                 if (s3 === peg$FAILED) {
2012                   s3 = peg$currPos;
2013
2014                   if (input.charCodeAt(peg$currPos) === 92) {
2015                     s4 = peg$c51;
2016                     peg$currPos++;
2017                   } else {
2018                     s4 = peg$FAILED;
2019
2020                     {
2021                       peg$fail(peg$c52);
2022                     }
2023                   }
2024
2025                   if (s4 !== peg$FAILED) {
2026                     if (input.length > peg$currPos) {
2027                       s5 = input.charAt(peg$currPos);
2028                       peg$currPos++;
2029                     } else {
2030                       s5 = peg$FAILED;
2031
2032                       {
2033                         peg$fail(peg$c53);
2034                       }
2035                     }
2036
2037                     if (s5 !== peg$FAILED) {
2038                       s4 = peg$c54(s4, s5);
2039                       s3 = s4;
2040                     } else {
2041                       peg$currPos = s3;
2042                       s3 = peg$FAILED;
2043                     }
2044                   } else {
2045                     peg$currPos = s3;
2046                     s3 = peg$FAILED;
2047                   }
2048                 }
2049               }
2050
2051               if (s2 !== peg$FAILED) {
2052                 if (input.charCodeAt(peg$currPos) === 39) {
2053                   s3 = peg$c56;
2054                   peg$currPos++;
2055                 } else {
2056                   s3 = peg$FAILED;
2057
2058                   {
2059                     peg$fail(peg$c57);
2060                   }
2061                 }
2062
2063                 if (s3 !== peg$FAILED) {
2064                   s1 = peg$c55(s2);
2065                   s0 = s1;
2066                 } else {
2067                   peg$currPos = s0;
2068                   s0 = peg$FAILED;
2069                 }
2070               } else {
2071                 peg$currPos = s0;
2072                 s0 = peg$FAILED;
2073               }
2074             } else {
2075               peg$currPos = s0;
2076               s0 = peg$FAILED;
2077             }
2078           }
2079
2080           peg$resultsCache[key] = {
2081             nextPos: peg$currPos,
2082             result: s0
2083           };
2084           return s0;
2085         }
2086
2087         function peg$parsenumber() {
2088           var s0, s1, s2, s3;
2089           var key = peg$currPos * 30 + 16,
2090               cached = peg$resultsCache[key];
2091
2092           if (cached) {
2093             peg$currPos = cached.nextPos;
2094             return cached.result;
2095           }
2096
2097           s0 = peg$currPos;
2098           s1 = peg$currPos;
2099           s2 = [];
2100
2101           if (peg$c60.test(input.charAt(peg$currPos))) {
2102             s3 = input.charAt(peg$currPos);
2103             peg$currPos++;
2104           } else {
2105             s3 = peg$FAILED;
2106
2107             {
2108               peg$fail(peg$c61);
2109             }
2110           }
2111
2112           while (s3 !== peg$FAILED) {
2113             s2.push(s3);
2114
2115             if (peg$c60.test(input.charAt(peg$currPos))) {
2116               s3 = input.charAt(peg$currPos);
2117               peg$currPos++;
2118             } else {
2119               s3 = peg$FAILED;
2120
2121               {
2122                 peg$fail(peg$c61);
2123               }
2124             }
2125           }
2126
2127           if (s2 !== peg$FAILED) {
2128             if (input.charCodeAt(peg$currPos) === 46) {
2129               s3 = peg$c42;
2130               peg$currPos++;
2131             } else {
2132               s3 = peg$FAILED;
2133
2134               {
2135                 peg$fail(peg$c43);
2136               }
2137             }
2138
2139             if (s3 !== peg$FAILED) {
2140               s2 = [s2, s3];
2141               s1 = s2;
2142             } else {
2143               peg$currPos = s1;
2144               s1 = peg$FAILED;
2145             }
2146           } else {
2147             peg$currPos = s1;
2148             s1 = peg$FAILED;
2149           }
2150
2151           if (s1 === peg$FAILED) {
2152             s1 = null;
2153           }
2154
2155           if (s1 !== peg$FAILED) {
2156             s2 = [];
2157
2158             if (peg$c60.test(input.charAt(peg$currPos))) {
2159               s3 = input.charAt(peg$currPos);
2160               peg$currPos++;
2161             } else {
2162               s3 = peg$FAILED;
2163
2164               {
2165                 peg$fail(peg$c61);
2166               }
2167             }
2168
2169             if (s3 !== peg$FAILED) {
2170               while (s3 !== peg$FAILED) {
2171                 s2.push(s3);
2172
2173                 if (peg$c60.test(input.charAt(peg$currPos))) {
2174                   s3 = input.charAt(peg$currPos);
2175                   peg$currPos++;
2176                 } else {
2177                   s3 = peg$FAILED;
2178
2179                   {
2180                     peg$fail(peg$c61);
2181                   }
2182                 }
2183               }
2184             } else {
2185               s2 = peg$FAILED;
2186             }
2187
2188             if (s2 !== peg$FAILED) {
2189               s1 = peg$c62(s1, s2);
2190               s0 = s1;
2191             } else {
2192               peg$currPos = s0;
2193               s0 = peg$FAILED;
2194             }
2195           } else {
2196             peg$currPos = s0;
2197             s0 = peg$FAILED;
2198           }
2199
2200           peg$resultsCache[key] = {
2201             nextPos: peg$currPos,
2202             result: s0
2203           };
2204           return s0;
2205         }
2206
2207         function peg$parsepath() {
2208           var s0, s1;
2209           var key = peg$currPos * 30 + 17,
2210               cached = peg$resultsCache[key];
2211
2212           if (cached) {
2213             peg$currPos = cached.nextPos;
2214             return cached.result;
2215           }
2216
2217           s0 = peg$currPos;
2218           s1 = peg$parseidentifierName();
2219
2220           if (s1 !== peg$FAILED) {
2221             s1 = peg$c63(s1);
2222           }
2223
2224           s0 = s1;
2225           peg$resultsCache[key] = {
2226             nextPos: peg$currPos,
2227             result: s0
2228           };
2229           return s0;
2230         }
2231
2232         function peg$parsetype() {
2233           var s0, s1, s2, s3, s4, s5;
2234           var key = peg$currPos * 30 + 18,
2235               cached = peg$resultsCache[key];
2236
2237           if (cached) {
2238             peg$currPos = cached.nextPos;
2239             return cached.result;
2240           }
2241
2242           s0 = peg$currPos;
2243
2244           if (input.substr(peg$currPos, 5) === peg$c64) {
2245             s1 = peg$c64;
2246             peg$currPos += 5;
2247           } else {
2248             s1 = peg$FAILED;
2249
2250             {
2251               peg$fail(peg$c65);
2252             }
2253           }
2254
2255           if (s1 !== peg$FAILED) {
2256             s2 = peg$parse_();
2257
2258             if (s2 !== peg$FAILED) {
2259               s3 = [];
2260
2261               if (peg$c66.test(input.charAt(peg$currPos))) {
2262                 s4 = input.charAt(peg$currPos);
2263                 peg$currPos++;
2264               } else {
2265                 s4 = peg$FAILED;
2266
2267                 {
2268                   peg$fail(peg$c67);
2269                 }
2270               }
2271
2272               if (s4 !== peg$FAILED) {
2273                 while (s4 !== peg$FAILED) {
2274                   s3.push(s4);
2275
2276                   if (peg$c66.test(input.charAt(peg$currPos))) {
2277                     s4 = input.charAt(peg$currPos);
2278                     peg$currPos++;
2279                   } else {
2280                     s4 = peg$FAILED;
2281
2282                     {
2283                       peg$fail(peg$c67);
2284                     }
2285                   }
2286                 }
2287               } else {
2288                 s3 = peg$FAILED;
2289               }
2290
2291               if (s3 !== peg$FAILED) {
2292                 s4 = peg$parse_();
2293
2294                 if (s4 !== peg$FAILED) {
2295                   if (input.charCodeAt(peg$currPos) === 41) {
2296                     s5 = peg$c68;
2297                     peg$currPos++;
2298                   } else {
2299                     s5 = peg$FAILED;
2300
2301                     {
2302                       peg$fail(peg$c69);
2303                     }
2304                   }
2305
2306                   if (s5 !== peg$FAILED) {
2307                     s1 = peg$c70(s3);
2308                     s0 = s1;
2309                   } else {
2310                     peg$currPos = s0;
2311                     s0 = peg$FAILED;
2312                   }
2313                 } else {
2314                   peg$currPos = s0;
2315                   s0 = peg$FAILED;
2316                 }
2317               } else {
2318                 peg$currPos = s0;
2319                 s0 = peg$FAILED;
2320               }
2321             } else {
2322               peg$currPos = s0;
2323               s0 = peg$FAILED;
2324             }
2325           } else {
2326             peg$currPos = s0;
2327             s0 = peg$FAILED;
2328           }
2329
2330           peg$resultsCache[key] = {
2331             nextPos: peg$currPos,
2332             result: s0
2333           };
2334           return s0;
2335         }
2336
2337         function peg$parseflags() {
2338           var s0, s1;
2339           var key = peg$currPos * 30 + 19,
2340               cached = peg$resultsCache[key];
2341
2342           if (cached) {
2343             peg$currPos = cached.nextPos;
2344             return cached.result;
2345           }
2346
2347           s0 = [];
2348
2349           if (peg$c71.test(input.charAt(peg$currPos))) {
2350             s1 = input.charAt(peg$currPos);
2351             peg$currPos++;
2352           } else {
2353             s1 = peg$FAILED;
2354
2355             {
2356               peg$fail(peg$c72);
2357             }
2358           }
2359
2360           if (s1 !== peg$FAILED) {
2361             while (s1 !== peg$FAILED) {
2362               s0.push(s1);
2363
2364               if (peg$c71.test(input.charAt(peg$currPos))) {
2365                 s1 = input.charAt(peg$currPos);
2366                 peg$currPos++;
2367               } else {
2368                 s1 = peg$FAILED;
2369
2370                 {
2371                   peg$fail(peg$c72);
2372                 }
2373               }
2374             }
2375           } else {
2376             s0 = peg$FAILED;
2377           }
2378
2379           peg$resultsCache[key] = {
2380             nextPos: peg$currPos,
2381             result: s0
2382           };
2383           return s0;
2384         }
2385
2386         function peg$parseregex() {
2387           var s0, s1, s2, s3, s4;
2388           var key = peg$currPos * 30 + 20,
2389               cached = peg$resultsCache[key];
2390
2391           if (cached) {
2392             peg$currPos = cached.nextPos;
2393             return cached.result;
2394           }
2395
2396           s0 = peg$currPos;
2397
2398           if (input.charCodeAt(peg$currPos) === 47) {
2399             s1 = peg$c73;
2400             peg$currPos++;
2401           } else {
2402             s1 = peg$FAILED;
2403
2404             {
2405               peg$fail(peg$c74);
2406             }
2407           }
2408
2409           if (s1 !== peg$FAILED) {
2410             s2 = [];
2411
2412             if (peg$c75.test(input.charAt(peg$currPos))) {
2413               s3 = input.charAt(peg$currPos);
2414               peg$currPos++;
2415             } else {
2416               s3 = peg$FAILED;
2417
2418               {
2419                 peg$fail(peg$c76);
2420               }
2421             }
2422
2423             if (s3 !== peg$FAILED) {
2424               while (s3 !== peg$FAILED) {
2425                 s2.push(s3);
2426
2427                 if (peg$c75.test(input.charAt(peg$currPos))) {
2428                   s3 = input.charAt(peg$currPos);
2429                   peg$currPos++;
2430                 } else {
2431                   s3 = peg$FAILED;
2432
2433                   {
2434                     peg$fail(peg$c76);
2435                   }
2436                 }
2437               }
2438             } else {
2439               s2 = peg$FAILED;
2440             }
2441
2442             if (s2 !== peg$FAILED) {
2443               if (input.charCodeAt(peg$currPos) === 47) {
2444                 s3 = peg$c73;
2445                 peg$currPos++;
2446               } else {
2447                 s3 = peg$FAILED;
2448
2449                 {
2450                   peg$fail(peg$c74);
2451                 }
2452               }
2453
2454               if (s3 !== peg$FAILED) {
2455                 s4 = peg$parseflags();
2456
2457                 if (s4 === peg$FAILED) {
2458                   s4 = null;
2459                 }
2460
2461                 if (s4 !== peg$FAILED) {
2462                   s1 = peg$c77(s2, s4);
2463                   s0 = s1;
2464                 } else {
2465                   peg$currPos = s0;
2466                   s0 = peg$FAILED;
2467                 }
2468               } else {
2469                 peg$currPos = s0;
2470                 s0 = peg$FAILED;
2471               }
2472             } else {
2473               peg$currPos = s0;
2474               s0 = peg$FAILED;
2475             }
2476           } else {
2477             peg$currPos = s0;
2478             s0 = peg$FAILED;
2479           }
2480
2481           peg$resultsCache[key] = {
2482             nextPos: peg$currPos,
2483             result: s0
2484           };
2485           return s0;
2486         }
2487
2488         function peg$parsefield() {
2489           var s0, s1, s2, s3, s4, s5, s6;
2490           var key = peg$currPos * 30 + 21,
2491               cached = peg$resultsCache[key];
2492
2493           if (cached) {
2494             peg$currPos = cached.nextPos;
2495             return cached.result;
2496           }
2497
2498           s0 = peg$currPos;
2499
2500           if (input.charCodeAt(peg$currPos) === 46) {
2501             s1 = peg$c42;
2502             peg$currPos++;
2503           } else {
2504             s1 = peg$FAILED;
2505
2506             {
2507               peg$fail(peg$c43);
2508             }
2509           }
2510
2511           if (s1 !== peg$FAILED) {
2512             s2 = peg$parseidentifierName();
2513
2514             if (s2 !== peg$FAILED) {
2515               s3 = [];
2516               s4 = peg$currPos;
2517
2518               if (input.charCodeAt(peg$currPos) === 46) {
2519                 s5 = peg$c42;
2520                 peg$currPos++;
2521               } else {
2522                 s5 = peg$FAILED;
2523
2524                 {
2525                   peg$fail(peg$c43);
2526                 }
2527               }
2528
2529               if (s5 !== peg$FAILED) {
2530                 s6 = peg$parseidentifierName();
2531
2532                 if (s6 !== peg$FAILED) {
2533                   s5 = [s5, s6];
2534                   s4 = s5;
2535                 } else {
2536                   peg$currPos = s4;
2537                   s4 = peg$FAILED;
2538                 }
2539               } else {
2540                 peg$currPos = s4;
2541                 s4 = peg$FAILED;
2542               }
2543
2544               while (s4 !== peg$FAILED) {
2545                 s3.push(s4);
2546                 s4 = peg$currPos;
2547
2548                 if (input.charCodeAt(peg$currPos) === 46) {
2549                   s5 = peg$c42;
2550                   peg$currPos++;
2551                 } else {
2552                   s5 = peg$FAILED;
2553
2554                   {
2555                     peg$fail(peg$c43);
2556                   }
2557                 }
2558
2559                 if (s5 !== peg$FAILED) {
2560                   s6 = peg$parseidentifierName();
2561
2562                   if (s6 !== peg$FAILED) {
2563                     s5 = [s5, s6];
2564                     s4 = s5;
2565                   } else {
2566                     peg$currPos = s4;
2567                     s4 = peg$FAILED;
2568                   }
2569                 } else {
2570                   peg$currPos = s4;
2571                   s4 = peg$FAILED;
2572                 }
2573               }
2574
2575               if (s3 !== peg$FAILED) {
2576                 s1 = peg$c78(s2, s3);
2577                 s0 = s1;
2578               } else {
2579                 peg$currPos = s0;
2580                 s0 = peg$FAILED;
2581               }
2582             } else {
2583               peg$currPos = s0;
2584               s0 = peg$FAILED;
2585             }
2586           } else {
2587             peg$currPos = s0;
2588             s0 = peg$FAILED;
2589           }
2590
2591           peg$resultsCache[key] = {
2592             nextPos: peg$currPos,
2593             result: s0
2594           };
2595           return s0;
2596         }
2597
2598         function peg$parsenegation() {
2599           var s0, s1, s2, s3, s4, s5;
2600           var key = peg$currPos * 30 + 22,
2601               cached = peg$resultsCache[key];
2602
2603           if (cached) {
2604             peg$currPos = cached.nextPos;
2605             return cached.result;
2606           }
2607
2608           s0 = peg$currPos;
2609
2610           if (input.substr(peg$currPos, 5) === peg$c79) {
2611             s1 = peg$c79;
2612             peg$currPos += 5;
2613           } else {
2614             s1 = peg$FAILED;
2615
2616             {
2617               peg$fail(peg$c80);
2618             }
2619           }
2620
2621           if (s1 !== peg$FAILED) {
2622             s2 = peg$parse_();
2623
2624             if (s2 !== peg$FAILED) {
2625               s3 = peg$parseselectors();
2626
2627               if (s3 !== peg$FAILED) {
2628                 s4 = peg$parse_();
2629
2630                 if (s4 !== peg$FAILED) {
2631                   if (input.charCodeAt(peg$currPos) === 41) {
2632                     s5 = peg$c68;
2633                     peg$currPos++;
2634                   } else {
2635                     s5 = peg$FAILED;
2636
2637                     {
2638                       peg$fail(peg$c69);
2639                     }
2640                   }
2641
2642                   if (s5 !== peg$FAILED) {
2643                     s1 = peg$c81(s3);
2644                     s0 = s1;
2645                   } else {
2646                     peg$currPos = s0;
2647                     s0 = peg$FAILED;
2648                   }
2649                 } else {
2650                   peg$currPos = s0;
2651                   s0 = peg$FAILED;
2652                 }
2653               } else {
2654                 peg$currPos = s0;
2655                 s0 = peg$FAILED;
2656               }
2657             } else {
2658               peg$currPos = s0;
2659               s0 = peg$FAILED;
2660             }
2661           } else {
2662             peg$currPos = s0;
2663             s0 = peg$FAILED;
2664           }
2665
2666           peg$resultsCache[key] = {
2667             nextPos: peg$currPos,
2668             result: s0
2669           };
2670           return s0;
2671         }
2672
2673         function peg$parsematches() {
2674           var s0, s1, s2, s3, s4, s5;
2675           var key = peg$currPos * 30 + 23,
2676               cached = peg$resultsCache[key];
2677
2678           if (cached) {
2679             peg$currPos = cached.nextPos;
2680             return cached.result;
2681           }
2682
2683           s0 = peg$currPos;
2684
2685           if (input.substr(peg$currPos, 9) === peg$c82) {
2686             s1 = peg$c82;
2687             peg$currPos += 9;
2688           } else {
2689             s1 = peg$FAILED;
2690
2691             {
2692               peg$fail(peg$c83);
2693             }
2694           }
2695
2696           if (s1 !== peg$FAILED) {
2697             s2 = peg$parse_();
2698
2699             if (s2 !== peg$FAILED) {
2700               s3 = peg$parseselectors();
2701
2702               if (s3 !== peg$FAILED) {
2703                 s4 = peg$parse_();
2704
2705                 if (s4 !== peg$FAILED) {
2706                   if (input.charCodeAt(peg$currPos) === 41) {
2707                     s5 = peg$c68;
2708                     peg$currPos++;
2709                   } else {
2710                     s5 = peg$FAILED;
2711
2712                     {
2713                       peg$fail(peg$c69);
2714                     }
2715                   }
2716
2717                   if (s5 !== peg$FAILED) {
2718                     s1 = peg$c84(s3);
2719                     s0 = s1;
2720                   } else {
2721                     peg$currPos = s0;
2722                     s0 = peg$FAILED;
2723                   }
2724                 } else {
2725                   peg$currPos = s0;
2726                   s0 = peg$FAILED;
2727                 }
2728               } else {
2729                 peg$currPos = s0;
2730                 s0 = peg$FAILED;
2731               }
2732             } else {
2733               peg$currPos = s0;
2734               s0 = peg$FAILED;
2735             }
2736           } else {
2737             peg$currPos = s0;
2738             s0 = peg$FAILED;
2739           }
2740
2741           peg$resultsCache[key] = {
2742             nextPos: peg$currPos,
2743             result: s0
2744           };
2745           return s0;
2746         }
2747
2748         function peg$parsehas() {
2749           var s0, s1, s2, s3, s4, s5;
2750           var key = peg$currPos * 30 + 24,
2751               cached = peg$resultsCache[key];
2752
2753           if (cached) {
2754             peg$currPos = cached.nextPos;
2755             return cached.result;
2756           }
2757
2758           s0 = peg$currPos;
2759
2760           if (input.substr(peg$currPos, 5) === peg$c85) {
2761             s1 = peg$c85;
2762             peg$currPos += 5;
2763           } else {
2764             s1 = peg$FAILED;
2765
2766             {
2767               peg$fail(peg$c86);
2768             }
2769           }
2770
2771           if (s1 !== peg$FAILED) {
2772             s2 = peg$parse_();
2773
2774             if (s2 !== peg$FAILED) {
2775               s3 = peg$parseselectors();
2776
2777               if (s3 !== peg$FAILED) {
2778                 s4 = peg$parse_();
2779
2780                 if (s4 !== peg$FAILED) {
2781                   if (input.charCodeAt(peg$currPos) === 41) {
2782                     s5 = peg$c68;
2783                     peg$currPos++;
2784                   } else {
2785                     s5 = peg$FAILED;
2786
2787                     {
2788                       peg$fail(peg$c69);
2789                     }
2790                   }
2791
2792                   if (s5 !== peg$FAILED) {
2793                     s1 = peg$c87(s3);
2794                     s0 = s1;
2795                   } else {
2796                     peg$currPos = s0;
2797                     s0 = peg$FAILED;
2798                   }
2799                 } else {
2800                   peg$currPos = s0;
2801                   s0 = peg$FAILED;
2802                 }
2803               } else {
2804                 peg$currPos = s0;
2805                 s0 = peg$FAILED;
2806               }
2807             } else {
2808               peg$currPos = s0;
2809               s0 = peg$FAILED;
2810             }
2811           } else {
2812             peg$currPos = s0;
2813             s0 = peg$FAILED;
2814           }
2815
2816           peg$resultsCache[key] = {
2817             nextPos: peg$currPos,
2818             result: s0
2819           };
2820           return s0;
2821         }
2822
2823         function peg$parsefirstChild() {
2824           var s0, s1;
2825           var key = peg$currPos * 30 + 25,
2826               cached = peg$resultsCache[key];
2827
2828           if (cached) {
2829             peg$currPos = cached.nextPos;
2830             return cached.result;
2831           }
2832
2833           s0 = peg$currPos;
2834
2835           if (input.substr(peg$currPos, 12) === peg$c88) {
2836             s1 = peg$c88;
2837             peg$currPos += 12;
2838           } else {
2839             s1 = peg$FAILED;
2840
2841             {
2842               peg$fail(peg$c89);
2843             }
2844           }
2845
2846           if (s1 !== peg$FAILED) {
2847             s1 = peg$c90();
2848           }
2849
2850           s0 = s1;
2851           peg$resultsCache[key] = {
2852             nextPos: peg$currPos,
2853             result: s0
2854           };
2855           return s0;
2856         }
2857
2858         function peg$parselastChild() {
2859           var s0, s1;
2860           var key = peg$currPos * 30 + 26,
2861               cached = peg$resultsCache[key];
2862
2863           if (cached) {
2864             peg$currPos = cached.nextPos;
2865             return cached.result;
2866           }
2867
2868           s0 = peg$currPos;
2869
2870           if (input.substr(peg$currPos, 11) === peg$c91) {
2871             s1 = peg$c91;
2872             peg$currPos += 11;
2873           } else {
2874             s1 = peg$FAILED;
2875
2876             {
2877               peg$fail(peg$c92);
2878             }
2879           }
2880
2881           if (s1 !== peg$FAILED) {
2882             s1 = peg$c93();
2883           }
2884
2885           s0 = s1;
2886           peg$resultsCache[key] = {
2887             nextPos: peg$currPos,
2888             result: s0
2889           };
2890           return s0;
2891         }
2892
2893         function peg$parsenthChild() {
2894           var s0, s1, s2, s3, s4, s5;
2895           var key = peg$currPos * 30 + 27,
2896               cached = peg$resultsCache[key];
2897
2898           if (cached) {
2899             peg$currPos = cached.nextPos;
2900             return cached.result;
2901           }
2902
2903           s0 = peg$currPos;
2904
2905           if (input.substr(peg$currPos, 11) === peg$c94) {
2906             s1 = peg$c94;
2907             peg$currPos += 11;
2908           } else {
2909             s1 = peg$FAILED;
2910
2911             {
2912               peg$fail(peg$c95);
2913             }
2914           }
2915
2916           if (s1 !== peg$FAILED) {
2917             s2 = peg$parse_();
2918
2919             if (s2 !== peg$FAILED) {
2920               s3 = [];
2921
2922               if (peg$c60.test(input.charAt(peg$currPos))) {
2923                 s4 = input.charAt(peg$currPos);
2924                 peg$currPos++;
2925               } else {
2926                 s4 = peg$FAILED;
2927
2928                 {
2929                   peg$fail(peg$c61);
2930                 }
2931               }
2932
2933               if (s4 !== peg$FAILED) {
2934                 while (s4 !== peg$FAILED) {
2935                   s3.push(s4);
2936
2937                   if (peg$c60.test(input.charAt(peg$currPos))) {
2938                     s4 = input.charAt(peg$currPos);
2939                     peg$currPos++;
2940                   } else {
2941                     s4 = peg$FAILED;
2942
2943                     {
2944                       peg$fail(peg$c61);
2945                     }
2946                   }
2947                 }
2948               } else {
2949                 s3 = peg$FAILED;
2950               }
2951
2952               if (s3 !== peg$FAILED) {
2953                 s4 = peg$parse_();
2954
2955                 if (s4 !== peg$FAILED) {
2956                   if (input.charCodeAt(peg$currPos) === 41) {
2957                     s5 = peg$c68;
2958                     peg$currPos++;
2959                   } else {
2960                     s5 = peg$FAILED;
2961
2962                     {
2963                       peg$fail(peg$c69);
2964                     }
2965                   }
2966
2967                   if (s5 !== peg$FAILED) {
2968                     s1 = peg$c96(s3);
2969                     s0 = s1;
2970                   } else {
2971                     peg$currPos = s0;
2972                     s0 = peg$FAILED;
2973                   }
2974                 } else {
2975                   peg$currPos = s0;
2976                   s0 = peg$FAILED;
2977                 }
2978               } else {
2979                 peg$currPos = s0;
2980                 s0 = peg$FAILED;
2981               }
2982             } else {
2983               peg$currPos = s0;
2984               s0 = peg$FAILED;
2985             }
2986           } else {
2987             peg$currPos = s0;
2988             s0 = peg$FAILED;
2989           }
2990
2991           peg$resultsCache[key] = {
2992             nextPos: peg$currPos,
2993             result: s0
2994           };
2995           return s0;
2996         }
2997
2998         function peg$parsenthLastChild() {
2999           var s0, s1, s2, s3, s4, s5;
3000           var key = peg$currPos * 30 + 28,
3001               cached = peg$resultsCache[key];
3002
3003           if (cached) {
3004             peg$currPos = cached.nextPos;
3005             return cached.result;
3006           }
3007
3008           s0 = peg$currPos;
3009
3010           if (input.substr(peg$currPos, 16) === peg$c97) {
3011             s1 = peg$c97;
3012             peg$currPos += 16;
3013           } else {
3014             s1 = peg$FAILED;
3015
3016             {
3017               peg$fail(peg$c98);
3018             }
3019           }
3020
3021           if (s1 !== peg$FAILED) {
3022             s2 = peg$parse_();
3023
3024             if (s2 !== peg$FAILED) {
3025               s3 = [];
3026
3027               if (peg$c60.test(input.charAt(peg$currPos))) {
3028                 s4 = input.charAt(peg$currPos);
3029                 peg$currPos++;
3030               } else {
3031                 s4 = peg$FAILED;
3032
3033                 {
3034                   peg$fail(peg$c61);
3035                 }
3036               }
3037
3038               if (s4 !== peg$FAILED) {
3039                 while (s4 !== peg$FAILED) {
3040                   s3.push(s4);
3041
3042                   if (peg$c60.test(input.charAt(peg$currPos))) {
3043                     s4 = input.charAt(peg$currPos);
3044                     peg$currPos++;
3045                   } else {
3046                     s4 = peg$FAILED;
3047
3048                     {
3049                       peg$fail(peg$c61);
3050                     }
3051                   }
3052                 }
3053               } else {
3054                 s3 = peg$FAILED;
3055               }
3056
3057               if (s3 !== peg$FAILED) {
3058                 s4 = peg$parse_();
3059
3060                 if (s4 !== peg$FAILED) {
3061                   if (input.charCodeAt(peg$currPos) === 41) {
3062                     s5 = peg$c68;
3063                     peg$currPos++;
3064                   } else {
3065                     s5 = peg$FAILED;
3066
3067                     {
3068                       peg$fail(peg$c69);
3069                     }
3070                   }
3071
3072                   if (s5 !== peg$FAILED) {
3073                     s1 = peg$c99(s3);
3074                     s0 = s1;
3075                   } else {
3076                     peg$currPos = s0;
3077                     s0 = peg$FAILED;
3078                   }
3079                 } else {
3080                   peg$currPos = s0;
3081                   s0 = peg$FAILED;
3082                 }
3083               } else {
3084                 peg$currPos = s0;
3085                 s0 = peg$FAILED;
3086               }
3087             } else {
3088               peg$currPos = s0;
3089               s0 = peg$FAILED;
3090             }
3091           } else {
3092             peg$currPos = s0;
3093             s0 = peg$FAILED;
3094           }
3095
3096           peg$resultsCache[key] = {
3097             nextPos: peg$currPos,
3098             result: s0
3099           };
3100           return s0;
3101         }
3102
3103         function peg$parseclass() {
3104           var s0, s1, s2;
3105           var key = peg$currPos * 30 + 29,
3106               cached = peg$resultsCache[key];
3107
3108           if (cached) {
3109             peg$currPos = cached.nextPos;
3110             return cached.result;
3111           }
3112
3113           s0 = peg$currPos;
3114
3115           if (input.charCodeAt(peg$currPos) === 58) {
3116             s1 = peg$c100;
3117             peg$currPos++;
3118           } else {
3119             s1 = peg$FAILED;
3120
3121             {
3122               peg$fail(peg$c101);
3123             }
3124           }
3125
3126           if (s1 !== peg$FAILED) {
3127             if (input.substr(peg$currPos, 9).toLowerCase() === peg$c102) {
3128               s2 = input.substr(peg$currPos, 9);
3129               peg$currPos += 9;
3130             } else {
3131               s2 = peg$FAILED;
3132
3133               {
3134                 peg$fail(peg$c103);
3135               }
3136             }
3137
3138             if (s2 === peg$FAILED) {
3139               if (input.substr(peg$currPos, 10).toLowerCase() === peg$c104) {
3140                 s2 = input.substr(peg$currPos, 10);
3141                 peg$currPos += 10;
3142               } else {
3143                 s2 = peg$FAILED;
3144
3145                 {
3146                   peg$fail(peg$c105);
3147                 }
3148               }
3149
3150               if (s2 === peg$FAILED) {
3151                 if (input.substr(peg$currPos, 11).toLowerCase() === peg$c106) {
3152                   s2 = input.substr(peg$currPos, 11);
3153                   peg$currPos += 11;
3154                 } else {
3155                   s2 = peg$FAILED;
3156
3157                   {
3158                     peg$fail(peg$c107);
3159                   }
3160                 }
3161
3162                 if (s2 === peg$FAILED) {
3163                   if (input.substr(peg$currPos, 8).toLowerCase() === peg$c108) {
3164                     s2 = input.substr(peg$currPos, 8);
3165                     peg$currPos += 8;
3166                   } else {
3167                     s2 = peg$FAILED;
3168
3169                     {
3170                       peg$fail(peg$c109);
3171                     }
3172                   }
3173
3174                   if (s2 === peg$FAILED) {
3175                     if (input.substr(peg$currPos, 7).toLowerCase() === peg$c110) {
3176                       s2 = input.substr(peg$currPos, 7);
3177                       peg$currPos += 7;
3178                     } else {
3179                       s2 = peg$FAILED;
3180
3181                       {
3182                         peg$fail(peg$c111);
3183                       }
3184                     }
3185                   }
3186                 }
3187               }
3188             }
3189
3190             if (s2 !== peg$FAILED) {
3191               s1 = peg$c112(s2);
3192               s0 = s1;
3193             } else {
3194               peg$currPos = s0;
3195               s0 = peg$FAILED;
3196             }
3197           } else {
3198             peg$currPos = s0;
3199             s0 = peg$FAILED;
3200           }
3201
3202           peg$resultsCache[key] = {
3203             nextPos: peg$currPos,
3204             result: s0
3205           };
3206           return s0;
3207         }
3208
3209         function nth(n) {
3210           return {
3211             type: 'nth-child',
3212             index: {
3213               type: 'literal',
3214               value: n
3215             }
3216           };
3217         }
3218
3219         function nthLast(n) {
3220           return {
3221             type: 'nth-last-child',
3222             index: {
3223               type: 'literal',
3224               value: n
3225             }
3226           };
3227         }
3228
3229         function strUnescape(s) {
3230           return s.replace(/\\(.)/g, function (match, ch) {
3231             switch (ch) {
3232               case 'b':
3233                 return '\b';
3234
3235               case 'f':
3236                 return '\f';
3237
3238               case 'n':
3239                 return '\n';
3240
3241               case 'r':
3242                 return '\r';
3243
3244               case 't':
3245                 return '\t';
3246
3247               case 'v':
3248                 return '\v';
3249
3250               default:
3251                 return ch;
3252             }
3253           });
3254         }
3255
3256         peg$result = peg$startRuleFunction();
3257
3258         if (peg$result !== peg$FAILED && peg$currPos === input.length) {
3259           return peg$result;
3260         } else {
3261           if (peg$result !== peg$FAILED && peg$currPos < input.length) {
3262             peg$fail(peg$endExpectation());
3263           }
3264
3265           throw peg$buildStructuredError(peg$maxFailExpected, peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, peg$maxFailPos < input.length ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) : peg$computeLocation(peg$maxFailPos, peg$maxFailPos));
3266         }
3267       }
3268
3269       return {
3270         SyntaxError: peg$SyntaxError,
3271         parse: peg$parse
3272       };
3273     });
3274   });
3275
3276   function _objectEntries(obj) {
3277     var entries = [];
3278     var keys = Object.keys(obj);
3279
3280     for (var k = 0; k < keys.length; k++) entries.push([keys[k], obj[keys[k]]]);
3281
3282     return entries;
3283   }
3284   /**
3285   * @typedef {"LEFT_SIDE"|"RIGHT_SIDE"} Side
3286   */
3287
3288   var LEFT_SIDE = 'LEFT_SIDE';
3289   var RIGHT_SIDE = 'RIGHT_SIDE';
3290   /**
3291    * @external AST
3292    * @see https://esprima.readthedocs.io/en/latest/syntax-tree-format.html
3293    */
3294
3295   /**
3296    * One of the rules of `grammar.pegjs`
3297    * @typedef {PlainObject} SelectorAST
3298    * @see grammar.pegjs
3299   */
3300
3301   /**
3302    * The `sequence` production of `grammar.pegjs`
3303    * @typedef {PlainObject} SelectorSequenceAST
3304   */
3305
3306   /**
3307    * Get the value of a property which may be multiple levels down
3308    * in the object.
3309    * @param {?PlainObject} obj
3310    * @param {string} key
3311    * @returns {undefined|boolean|string|number|external:AST}
3312    */
3313
3314   function getPath(obj, key) {
3315     var keys = key.split('.');
3316
3317     var _iterator = _createForOfIteratorHelper(keys),
3318         _step;
3319
3320     try {
3321       for (_iterator.s(); !(_step = _iterator.n()).done;) {
3322         var _key = _step.value;
3323
3324         if (obj == null) {
3325           return obj;
3326         }
3327
3328         obj = obj[_key];
3329       }
3330     } catch (err) {
3331       _iterator.e(err);
3332     } finally {
3333       _iterator.f();
3334     }
3335
3336     return obj;
3337   }
3338   /**
3339    * Determine whether `node` can be reached by following `path`,
3340    * starting at `ancestor`.
3341    * @param {?external:AST} node
3342    * @param {?external:AST} ancestor
3343    * @param {string[]} path
3344    * @returns {boolean}
3345    */
3346
3347
3348   function inPath(node, ancestor, path) {
3349     if (path.length === 0) {
3350       return node === ancestor;
3351     }
3352
3353     if (ancestor == null) {
3354       return false;
3355     }
3356
3357     var field = ancestor[path[0]];
3358     var remainingPath = path.slice(1);
3359
3360     if (Array.isArray(field)) {
3361       var _iterator2 = _createForOfIteratorHelper(field),
3362           _step2;
3363
3364       try {
3365         for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
3366           var component = _step2.value;
3367
3368           if (inPath(node, component, remainingPath)) {
3369             return true;
3370           }
3371         }
3372       } catch (err) {
3373         _iterator2.e(err);
3374       } finally {
3375         _iterator2.f();
3376       }
3377
3378       return false;
3379     } else {
3380       return inPath(node, field, remainingPath);
3381     }
3382   }
3383   /**
3384    * @callback TraverseOptionFallback
3385    * @param {external:AST} node The given node.
3386    * @returns {string[]} An array of visitor keys for the given node.
3387    */
3388
3389   /**
3390    * @typedef {object} ESQueryOptions
3391    * @property { { [nodeType: string]: string[] } } [visitorKeys] By passing `visitorKeys` mapping, we can extend the properties of the nodes that traverse the node.
3392    * @property {TraverseOptionFallback} [fallback] By passing `fallback` option, we can control the properties of traversing nodes when encountering unknown nodes.
3393    */
3394
3395   /**
3396    * Given a `node` and its ancestors, determine if `node` is matched
3397    * by `selector`.
3398    * @param {?external:AST} node
3399    * @param {?SelectorAST} selector
3400    * @param {external:AST[]} [ancestry=[]]
3401    * @param {ESQueryOptions} [options]
3402    * @throws {Error} Unknowns (operator, class name, selector type, or
3403    * selector value type)
3404    * @returns {boolean}
3405    */
3406
3407
3408   function matches(node, selector, ancestry, options) {
3409     if (!selector) {
3410       return true;
3411     }
3412
3413     if (!node) {
3414       return false;
3415     }
3416
3417     if (!ancestry) {
3418       ancestry = [];
3419     }
3420
3421     switch (selector.type) {
3422       case 'wildcard':
3423         return true;
3424
3425       case 'identifier':
3426         return selector.value.toLowerCase() === node.type.toLowerCase();
3427
3428       case 'field':
3429         {
3430           var path = selector.name.split('.');
3431           var ancestor = ancestry[path.length - 1];
3432           return inPath(node, ancestor, path);
3433         }
3434
3435       case 'matches':
3436         var _iterator3 = _createForOfIteratorHelper(selector.selectors),
3437             _step3;
3438
3439         try {
3440           for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
3441             var sel = _step3.value;
3442
3443             if (matches(node, sel, ancestry, options)) {
3444               return true;
3445             }
3446           }
3447         } catch (err) {
3448           _iterator3.e(err);
3449         } finally {
3450           _iterator3.f();
3451         }
3452
3453         return false;
3454
3455       case 'compound':
3456         var _iterator4 = _createForOfIteratorHelper(selector.selectors),
3457             _step4;
3458
3459         try {
3460           for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
3461             var _sel = _step4.value;
3462
3463             if (!matches(node, _sel, ancestry, options)) {
3464               return false;
3465             }
3466           }
3467         } catch (err) {
3468           _iterator4.e(err);
3469         } finally {
3470           _iterator4.f();
3471         }
3472
3473         return true;
3474
3475       case 'not':
3476         var _iterator5 = _createForOfIteratorHelper(selector.selectors),
3477             _step5;
3478
3479         try {
3480           for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
3481             var _sel2 = _step5.value;
3482
3483             if (matches(node, _sel2, ancestry, options)) {
3484               return false;
3485             }
3486           }
3487         } catch (err) {
3488           _iterator5.e(err);
3489         } finally {
3490           _iterator5.f();
3491         }
3492
3493         return true;
3494
3495       case 'has':
3496         {
3497           var _ret = function () {
3498             var collector = [];
3499
3500             var _iterator6 = _createForOfIteratorHelper(selector.selectors),
3501                 _step6;
3502
3503             try {
3504               var _loop = function _loop() {
3505                 var sel = _step6.value;
3506                 var a = [];
3507                 estraverse.traverse(node, {
3508                   enter: function enter(node, parent) {
3509                     if (parent != null) {
3510                       a.unshift(parent);
3511                     }
3512
3513                     if (matches(node, sel, a, options)) {
3514                       collector.push(node);
3515                     }
3516                   },
3517                   leave: function leave() {
3518                     a.shift();
3519                   },
3520                   keys: options && options.visitorKeys,
3521                   fallback: options && options.fallback || 'iteration'
3522                 });
3523               };
3524
3525               for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
3526                 _loop();
3527               }
3528             } catch (err) {
3529               _iterator6.e(err);
3530             } finally {
3531               _iterator6.f();
3532             }
3533
3534             return {
3535               v: collector.length !== 0
3536             };
3537           }();
3538
3539           if (_typeof(_ret) === "object") return _ret.v;
3540         }
3541
3542       case 'child':
3543         if (matches(node, selector.right, ancestry, options)) {
3544           return matches(ancestry[0], selector.left, ancestry.slice(1), options);
3545         }
3546
3547         return false;
3548
3549       case 'descendant':
3550         if (matches(node, selector.right, ancestry, options)) {
3551           for (var i = 0, l = ancestry.length; i < l; ++i) {
3552             if (matches(ancestry[i], selector.left, ancestry.slice(i + 1), options)) {
3553               return true;
3554             }
3555           }
3556         }
3557
3558         return false;
3559
3560       case 'attribute':
3561         {
3562           var p = getPath(node, selector.name);
3563
3564           switch (selector.operator) {
3565             case void 0:
3566               return p != null;
3567
3568             case '=':
3569               switch (selector.value.type) {
3570                 case 'regexp':
3571                   return typeof p === 'string' && selector.value.value.test(p);
3572
3573                 case 'literal':
3574                   return "".concat(selector.value.value) === "".concat(p);
3575
3576                 case 'type':
3577                   return selector.value.value === _typeof(p);
3578               }
3579
3580               throw new Error("Unknown selector value type: ".concat(selector.value.type));
3581
3582             case '!=':
3583               switch (selector.value.type) {
3584                 case 'regexp':
3585                   return !selector.value.value.test(p);
3586
3587                 case 'literal':
3588                   return "".concat(selector.value.value) !== "".concat(p);
3589
3590                 case 'type':
3591                   return selector.value.value !== _typeof(p);
3592               }
3593
3594               throw new Error("Unknown selector value type: ".concat(selector.value.type));
3595
3596             case '<=':
3597               return p <= selector.value.value;
3598
3599             case '<':
3600               return p < selector.value.value;
3601
3602             case '>':
3603               return p > selector.value.value;
3604
3605             case '>=':
3606               return p >= selector.value.value;
3607           }
3608
3609           throw new Error("Unknown operator: ".concat(selector.operator));
3610         }
3611
3612       case 'sibling':
3613         return matches(node, selector.right, ancestry, options) && sibling(node, selector.left, ancestry, LEFT_SIDE, options) || selector.left.subject && matches(node, selector.left, ancestry, options) && sibling(node, selector.right, ancestry, RIGHT_SIDE, options);
3614
3615       case 'adjacent':
3616         return matches(node, selector.right, ancestry, options) && adjacent(node, selector.left, ancestry, LEFT_SIDE, options) || selector.right.subject && matches(node, selector.left, ancestry, options) && adjacent(node, selector.right, ancestry, RIGHT_SIDE, options);
3617
3618       case 'nth-child':
3619         return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function () {
3620           return selector.index.value - 1;
3621         }, options);
3622
3623       case 'nth-last-child':
3624         return matches(node, selector.right, ancestry, options) && nthChild(node, ancestry, function (length) {
3625           return length - selector.index.value;
3626         }, options);
3627
3628       case 'class':
3629         switch (selector.name.toLowerCase()) {
3630           case 'statement':
3631             if (node.type.slice(-9) === 'Statement') return true;
3632           // fallthrough: interface Declaration <: Statement { }
3633
3634           case 'declaration':
3635             return node.type.slice(-11) === 'Declaration';
3636
3637           case 'pattern':
3638             if (node.type.slice(-7) === 'Pattern') return true;
3639           // fallthrough: interface Expression <: Node, Pattern { }
3640
3641           case 'expression':
3642             return node.type.slice(-10) === 'Expression' || node.type.slice(-7) === 'Literal' || node.type === 'Identifier' && (ancestry.length === 0 || ancestry[0].type !== 'MetaProperty') || node.type === 'MetaProperty';
3643
3644           case 'function':
3645             return node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression';
3646         }
3647
3648         throw new Error("Unknown class name: ".concat(selector.name));
3649     }
3650
3651     throw new Error("Unknown selector type: ".concat(selector.type));
3652   }
3653   /**
3654    * Get visitor keys of a given node.
3655    * @param {external:AST} node The AST node to get keys.
3656    * @param {ESQueryOptions|undefined} options
3657    * @returns {string[]} Visitor keys of the node.
3658    */
3659
3660
3661   function getVisitorKeys(node, options) {
3662     var nodeType = node.type;
3663
3664     if (options && options.visitorKeys && options.visitorKeys[nodeType]) {
3665       return options.visitorKeys[nodeType];
3666     }
3667
3668     if (estraverse.VisitorKeys[nodeType]) {
3669       return estraverse.VisitorKeys[nodeType];
3670     }
3671
3672     if (options && typeof options.fallback === 'function') {
3673       return options.fallback(node);
3674     } // 'iteration' fallback
3675
3676
3677     return Object.keys(node).filter(function (key) {
3678       return key !== 'type';
3679     });
3680   }
3681   /**
3682    * Check whether the given value is an ASTNode or not.
3683    * @param {any} node The value to check.
3684    * @returns {boolean} `true` if the value is an ASTNode.
3685    */
3686
3687
3688   function isNode(node) {
3689     return node !== null && _typeof(node) === 'object' && typeof node.type === 'string';
3690   }
3691   /**
3692    * Determines if the given node has a sibling that matches the
3693    * given selector.
3694    * @param {external:AST} node
3695    * @param {SelectorSequenceAST} selector
3696    * @param {external:AST[]} ancestry
3697    * @param {Side} side
3698    * @param {ESQueryOptions|undefined} options
3699    * @returns {boolean}
3700    */
3701
3702
3703   function sibling(node, selector, ancestry, side, options) {
3704     var _ancestry = _slicedToArray(ancestry, 1),
3705         parent = _ancestry[0];
3706
3707     if (!parent) {
3708       return false;
3709     }
3710
3711     var keys = getVisitorKeys(parent, options);
3712
3713     var _iterator7 = _createForOfIteratorHelper(keys),
3714         _step7;
3715
3716     try {
3717       for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
3718         var key = _step7.value;
3719         var listProp = parent[key];
3720
3721         if (Array.isArray(listProp)) {
3722           var startIndex = listProp.indexOf(node);
3723
3724           if (startIndex < 0) {
3725             continue;
3726           }
3727
3728           var lowerBound = void 0,
3729               upperBound = void 0;
3730
3731           if (side === LEFT_SIDE) {
3732             lowerBound = 0;
3733             upperBound = startIndex;
3734           } else {
3735             lowerBound = startIndex + 1;
3736             upperBound = listProp.length;
3737           }
3738
3739           for (var k = lowerBound; k < upperBound; ++k) {
3740             if (isNode(listProp[k]) && matches(listProp[k], selector, ancestry, options)) {
3741               return true;
3742             }
3743           }
3744         }
3745       }
3746     } catch (err) {
3747       _iterator7.e(err);
3748     } finally {
3749       _iterator7.f();
3750     }
3751
3752     return false;
3753   }
3754   /**
3755    * Determines if the given node has an adjacent sibling that matches
3756    * the given selector.
3757    * @param {external:AST} node
3758    * @param {SelectorSequenceAST} selector
3759    * @param {external:AST[]} ancestry
3760    * @param {Side} side
3761    * @param {ESQueryOptions|undefined} options
3762    * @returns {boolean}
3763    */
3764
3765
3766   function adjacent(node, selector, ancestry, side, options) {
3767     var _ancestry2 = _slicedToArray(ancestry, 1),
3768         parent = _ancestry2[0];
3769
3770     if (!parent) {
3771       return false;
3772     }
3773
3774     var keys = getVisitorKeys(parent, options);
3775
3776     var _iterator8 = _createForOfIteratorHelper(keys),
3777         _step8;
3778
3779     try {
3780       for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
3781         var key = _step8.value;
3782         var listProp = parent[key];
3783
3784         if (Array.isArray(listProp)) {
3785           var idx = listProp.indexOf(node);
3786
3787           if (idx < 0) {
3788             continue;
3789           }
3790
3791           if (side === LEFT_SIDE && idx > 0 && isNode(listProp[idx - 1]) && matches(listProp[idx - 1], selector, ancestry, options)) {
3792             return true;
3793           }
3794
3795           if (side === RIGHT_SIDE && idx < listProp.length - 1 && isNode(listProp[idx + 1]) && matches(listProp[idx + 1], selector, ancestry, options)) {
3796             return true;
3797           }
3798         }
3799       }
3800     } catch (err) {
3801       _iterator8.e(err);
3802     } finally {
3803       _iterator8.f();
3804     }
3805
3806     return false;
3807   }
3808   /**
3809   * @callback IndexFunction
3810   * @param {Integer} len Containing list's length
3811   * @returns {Integer}
3812   */
3813
3814   /**
3815    * Determines if the given node is the nth child, determined by
3816    * `idxFn`, which is given the containing list's length.
3817    * @param {external:AST} node
3818    * @param {external:AST[]} ancestry
3819    * @param {IndexFunction} idxFn
3820    * @param {ESQueryOptions|undefined} options
3821    * @returns {boolean}
3822    */
3823
3824
3825   function nthChild(node, ancestry, idxFn, options) {
3826     var _ancestry3 = _slicedToArray(ancestry, 1),
3827         parent = _ancestry3[0];
3828
3829     if (!parent) {
3830       return false;
3831     }
3832
3833     var keys = getVisitorKeys(parent, options);
3834
3835     var _iterator9 = _createForOfIteratorHelper(keys),
3836         _step9;
3837
3838     try {
3839       for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
3840         var key = _step9.value;
3841         var listProp = parent[key];
3842
3843         if (Array.isArray(listProp)) {
3844           var idx = listProp.indexOf(node);
3845
3846           if (idx >= 0 && idx === idxFn(listProp.length)) {
3847             return true;
3848           }
3849         }
3850       }
3851     } catch (err) {
3852       _iterator9.e(err);
3853     } finally {
3854       _iterator9.f();
3855     }
3856
3857     return false;
3858   }
3859   /**
3860    * For each selector node marked as a subject, find the portion of the
3861    * selector that the subject must match.
3862    * @param {SelectorAST} selector
3863    * @param {SelectorAST} [ancestor] Defaults to `selector`
3864    * @returns {SelectorAST[]}
3865    */
3866
3867
3868   function subjects(selector, ancestor) {
3869     if (selector == null || _typeof(selector) != 'object') {
3870       return [];
3871     }
3872
3873     if (ancestor == null) {
3874       ancestor = selector;
3875     }
3876
3877     var results = selector.subject ? [ancestor] : [];
3878
3879     for (var _i = 0, _Object$entries = _objectEntries(selector); _i < _Object$entries.length; _i++) {
3880       var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
3881           p = _Object$entries$_i[0],
3882           sel = _Object$entries$_i[1];
3883
3884       results.push.apply(results, _toConsumableArray(subjects(sel, p === 'left' ? sel : ancestor)));
3885     }
3886
3887     return results;
3888   }
3889   /**
3890   * @callback TraverseVisitor
3891   * @param {?external:AST} node
3892   * @param {?external:AST} parent
3893   * @param {external:AST[]} ancestry
3894   */
3895
3896   /**
3897    * From a JS AST and a selector AST, collect all JS AST nodes that
3898    * match the selector.
3899    * @param {external:AST} ast
3900    * @param {?SelectorAST} selector
3901    * @param {TraverseVisitor} visitor
3902    * @param {ESQueryOptions} [options]
3903    * @returns {external:AST[]}
3904    */
3905
3906
3907   function traverse(ast, selector, visitor, options) {
3908     if (!selector) {
3909       return;
3910     }
3911
3912     var ancestry = [];
3913     var altSubjects = subjects(selector);
3914     estraverse.traverse(ast, {
3915       enter: function enter(node, parent) {
3916         if (parent != null) {
3917           ancestry.unshift(parent);
3918         }
3919
3920         if (matches(node, selector, ancestry, options)) {
3921           if (altSubjects.length) {
3922             for (var i = 0, l = altSubjects.length; i < l; ++i) {
3923               if (matches(node, altSubjects[i], ancestry, options)) {
3924                 visitor(node, parent, ancestry);
3925               }
3926
3927               for (var k = 0, m = ancestry.length; k < m; ++k) {
3928                 var succeedingAncestry = ancestry.slice(k + 1);
3929
3930                 if (matches(ancestry[k], altSubjects[i], succeedingAncestry, options)) {
3931                   visitor(ancestry[k], parent, succeedingAncestry);
3932                 }
3933               }
3934             }
3935           } else {
3936             visitor(node, parent, ancestry);
3937           }
3938         }
3939       },
3940       leave: function leave() {
3941         ancestry.shift();
3942       },
3943       keys: options && options.visitorKeys,
3944       fallback: options && options.fallback || 'iteration'
3945     });
3946   }
3947   /**
3948    * From a JS AST and a selector AST, collect all JS AST nodes that
3949    * match the selector.
3950    * @param {external:AST} ast
3951    * @param {?SelectorAST} selector
3952    * @param {ESQueryOptions} [options]
3953    * @returns {external:AST[]}
3954    */
3955
3956
3957   function match(ast, selector, options) {
3958     var results = [];
3959     traverse(ast, selector, function (node) {
3960       results.push(node);
3961     }, options);
3962     return results;
3963   }
3964   /**
3965    * Parse a selector string and return its AST.
3966    * @param {string} selector
3967    * @returns {SelectorAST}
3968    */
3969
3970
3971   function parse(selector) {
3972     return parser.parse(selector);
3973   }
3974   /**
3975    * Query the code AST using the selector string.
3976    * @param {external:AST} ast
3977    * @param {string} selector
3978    * @param {ESQueryOptions} [options]
3979    * @returns {external:AST[]}
3980    */
3981
3982
3983   function query(ast, selector, options) {
3984     return match(ast, parse(selector), options);
3985   }
3986
3987   query.parse = parse;
3988   query.match = match;
3989   query.traverse = traverse;
3990   query.matches = matches;
3991   query.query = query;
3992
3993   return query;
3994
3995 })));