UNPKG

434 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('vue-template-compiler')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'vue', 'vue-template-compiler'], factory) :
4 (global = global || self, factory(global.VueTestUtils = {}, global.Vue, global.VueTemplateCompiler));
5}(this, (function (exports, Vue, vueTemplateCompiler) { 'use strict';
6
7 Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue;
8
9 //
10
11 function createVNodes(vm, slotValue, name) {
12 var el = vueTemplateCompiler.compileToFunctions(
13 ("<div><template slot=" + name + ">" + slotValue + "</template></div>")
14 );
15 var _staticRenderFns = vm._renderProxy.$options.staticRenderFns;
16 var _staticTrees = vm._renderProxy._staticTrees;
17 vm._renderProxy._staticTrees = [];
18 vm._renderProxy.$options.staticRenderFns = el.staticRenderFns;
19 var vnode = el.render.call(vm._renderProxy, vm.$createElement);
20 vm._renderProxy.$options.staticRenderFns = _staticRenderFns;
21 vm._renderProxy._staticTrees = _staticTrees;
22 return vnode.children[0]
23 }
24
25 function createVNodesForSlot(
26 vm,
27 slotValue,
28 name
29 ) {
30 if (typeof slotValue === 'string') {
31 return createVNodes(vm, slotValue, name)
32 }
33 var vnode = vm.$createElement(slotValue)
34 ;(vnode.data || (vnode.data = {})).slot = name;
35 return vnode
36 }
37
38 function createSlotVNodes(
39 vm,
40 slots
41 ) {
42 return Object.keys(slots).reduce(function (acc, key) {
43 var content = slots[key];
44 if (Array.isArray(content)) {
45 var nodes = content.map(function (slotDef) { return createVNodesForSlot(vm, slotDef, key); }
46 );
47 return acc.concat(nodes)
48 }
49
50 return acc.concat(createVNodesForSlot(vm, content, key))
51 }, [])
52 }
53
54 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
55
56 function createCommonjsModule(fn, module) {
57 return module = { exports: {} }, fn(module, module.exports), module.exports;
58 }
59
60 function getCjsExportFromNamespace (n) {
61 return n && n['default'] || n;
62 }
63
64 var semver = createCommonjsModule(function (module, exports) {
65 exports = module.exports = SemVer;
66
67 var debug;
68 /* istanbul ignore next */
69 if (typeof process === 'object' &&
70 process.env &&
71 process.env.NODE_DEBUG &&
72 /\bsemver\b/i.test(process.env.NODE_DEBUG)) {
73 debug = function () {
74 var args = Array.prototype.slice.call(arguments, 0);
75 args.unshift('SEMVER');
76 console.log.apply(console, args);
77 };
78 } else {
79 debug = function () {};
80 }
81
82 // Note: this is the semver.org version of the spec that it implements
83 // Not necessarily the package version of this code.
84 exports.SEMVER_SPEC_VERSION = '2.0.0';
85
86 var MAX_LENGTH = 256;
87 var MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
88 /* istanbul ignore next */ 9007199254740991;
89
90 // Max safe segment length for coercion.
91 var MAX_SAFE_COMPONENT_LENGTH = 16;
92
93 // The actual regexps go on exports.re
94 var re = exports.re = [];
95 var src = exports.src = [];
96 var t = exports.tokens = {};
97 var R = 0;
98
99 function tok (n) {
100 t[n] = R++;
101 }
102
103 // The following Regular Expressions can be used for tokenizing,
104 // validating, and parsing SemVer version strings.
105
106 // ## Numeric Identifier
107 // A single `0`, or a non-zero digit followed by zero or more digits.
108
109 tok('NUMERICIDENTIFIER');
110 src[t.NUMERICIDENTIFIER] = '0|[1-9]\\d*';
111 tok('NUMERICIDENTIFIERLOOSE');
112 src[t.NUMERICIDENTIFIERLOOSE] = '[0-9]+';
113
114 // ## Non-numeric Identifier
115 // Zero or more digits, followed by a letter or hyphen, and then zero or
116 // more letters, digits, or hyphens.
117
118 tok('NONNUMERICIDENTIFIER');
119 src[t.NONNUMERICIDENTIFIER] = '\\d*[a-zA-Z-][a-zA-Z0-9-]*';
120
121 // ## Main Version
122 // Three dot-separated numeric identifiers.
123
124 tok('MAINVERSION');
125 src[t.MAINVERSION] = '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
126 '(' + src[t.NUMERICIDENTIFIER] + ')\\.' +
127 '(' + src[t.NUMERICIDENTIFIER] + ')';
128
129 tok('MAINVERSIONLOOSE');
130 src[t.MAINVERSIONLOOSE] = '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
131 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')\\.' +
132 '(' + src[t.NUMERICIDENTIFIERLOOSE] + ')';
133
134 // ## Pre-release Version Identifier
135 // A numeric identifier, or a non-numeric identifier.
136
137 tok('PRERELEASEIDENTIFIER');
138 src[t.PRERELEASEIDENTIFIER] = '(?:' + src[t.NUMERICIDENTIFIER] +
139 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
140
141 tok('PRERELEASEIDENTIFIERLOOSE');
142 src[t.PRERELEASEIDENTIFIERLOOSE] = '(?:' + src[t.NUMERICIDENTIFIERLOOSE] +
143 '|' + src[t.NONNUMERICIDENTIFIER] + ')';
144
145 // ## Pre-release Version
146 // Hyphen, followed by one or more dot-separated pre-release version
147 // identifiers.
148
149 tok('PRERELEASE');
150 src[t.PRERELEASE] = '(?:-(' + src[t.PRERELEASEIDENTIFIER] +
151 '(?:\\.' + src[t.PRERELEASEIDENTIFIER] + ')*))';
152
153 tok('PRERELEASELOOSE');
154 src[t.PRERELEASELOOSE] = '(?:-?(' + src[t.PRERELEASEIDENTIFIERLOOSE] +
155 '(?:\\.' + src[t.PRERELEASEIDENTIFIERLOOSE] + ')*))';
156
157 // ## Build Metadata Identifier
158 // Any combination of digits, letters, or hyphens.
159
160 tok('BUILDIDENTIFIER');
161 src[t.BUILDIDENTIFIER] = '[0-9A-Za-z-]+';
162
163 // ## Build Metadata
164 // Plus sign, followed by one or more period-separated build metadata
165 // identifiers.
166
167 tok('BUILD');
168 src[t.BUILD] = '(?:\\+(' + src[t.BUILDIDENTIFIER] +
169 '(?:\\.' + src[t.BUILDIDENTIFIER] + ')*))';
170
171 // ## Full Version String
172 // A main version, followed optionally by a pre-release version and
173 // build metadata.
174
175 // Note that the only major, minor, patch, and pre-release sections of
176 // the version string are capturing groups. The build metadata is not a
177 // capturing group, because it should not ever be used in version
178 // comparison.
179
180 tok('FULL');
181 tok('FULLPLAIN');
182 src[t.FULLPLAIN] = 'v?' + src[t.MAINVERSION] +
183 src[t.PRERELEASE] + '?' +
184 src[t.BUILD] + '?';
185
186 src[t.FULL] = '^' + src[t.FULLPLAIN] + '$';
187
188 // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
189 // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
190 // common in the npm registry.
191 tok('LOOSEPLAIN');
192 src[t.LOOSEPLAIN] = '[v=\\s]*' + src[t.MAINVERSIONLOOSE] +
193 src[t.PRERELEASELOOSE] + '?' +
194 src[t.BUILD] + '?';
195
196 tok('LOOSE');
197 src[t.LOOSE] = '^' + src[t.LOOSEPLAIN] + '$';
198
199 tok('GTLT');
200 src[t.GTLT] = '((?:<|>)?=?)';
201
202 // Something like "2.*" or "1.2.x".
203 // Note that "x.x" is a valid xRange identifer, meaning "any version"
204 // Only the first item is strictly required.
205 tok('XRANGEIDENTIFIERLOOSE');
206 src[t.XRANGEIDENTIFIERLOOSE] = src[t.NUMERICIDENTIFIERLOOSE] + '|x|X|\\*';
207 tok('XRANGEIDENTIFIER');
208 src[t.XRANGEIDENTIFIER] = src[t.NUMERICIDENTIFIER] + '|x|X|\\*';
209
210 tok('XRANGEPLAIN');
211 src[t.XRANGEPLAIN] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIER] + ')' +
212 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
213 '(?:\\.(' + src[t.XRANGEIDENTIFIER] + ')' +
214 '(?:' + src[t.PRERELEASE] + ')?' +
215 src[t.BUILD] + '?' +
216 ')?)?';
217
218 tok('XRANGEPLAINLOOSE');
219 src[t.XRANGEPLAINLOOSE] = '[v=\\s]*(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
220 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
221 '(?:\\.(' + src[t.XRANGEIDENTIFIERLOOSE] + ')' +
222 '(?:' + src[t.PRERELEASELOOSE] + ')?' +
223 src[t.BUILD] + '?' +
224 ')?)?';
225
226 tok('XRANGE');
227 src[t.XRANGE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAIN] + '$';
228 tok('XRANGELOOSE');
229 src[t.XRANGELOOSE] = '^' + src[t.GTLT] + '\\s*' + src[t.XRANGEPLAINLOOSE] + '$';
230
231 // Coercion.
232 // Extract anything that could conceivably be a part of a valid semver
233 tok('COERCE');
234 src[t.COERCE] = '(^|[^\\d])' +
235 '(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '})' +
236 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
237 '(?:\\.(\\d{1,' + MAX_SAFE_COMPONENT_LENGTH + '}))?' +
238 '(?:$|[^\\d])';
239 tok('COERCERTL');
240 re[t.COERCERTL] = new RegExp(src[t.COERCE], 'g');
241
242 // Tilde ranges.
243 // Meaning is "reasonably at or greater than"
244 tok('LONETILDE');
245 src[t.LONETILDE] = '(?:~>?)';
246
247 tok('TILDETRIM');
248 src[t.TILDETRIM] = '(\\s*)' + src[t.LONETILDE] + '\\s+';
249 re[t.TILDETRIM] = new RegExp(src[t.TILDETRIM], 'g');
250 var tildeTrimReplace = '$1~';
251
252 tok('TILDE');
253 src[t.TILDE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAIN] + '$';
254 tok('TILDELOOSE');
255 src[t.TILDELOOSE] = '^' + src[t.LONETILDE] + src[t.XRANGEPLAINLOOSE] + '$';
256
257 // Caret ranges.
258 // Meaning is "at least and backwards compatible with"
259 tok('LONECARET');
260 src[t.LONECARET] = '(?:\\^)';
261
262 tok('CARETTRIM');
263 src[t.CARETTRIM] = '(\\s*)' + src[t.LONECARET] + '\\s+';
264 re[t.CARETTRIM] = new RegExp(src[t.CARETTRIM], 'g');
265 var caretTrimReplace = '$1^';
266
267 tok('CARET');
268 src[t.CARET] = '^' + src[t.LONECARET] + src[t.XRANGEPLAIN] + '$';
269 tok('CARETLOOSE');
270 src[t.CARETLOOSE] = '^' + src[t.LONECARET] + src[t.XRANGEPLAINLOOSE] + '$';
271
272 // A simple gt/lt/eq thing, or just "" to indicate "any version"
273 tok('COMPARATORLOOSE');
274 src[t.COMPARATORLOOSE] = '^' + src[t.GTLT] + '\\s*(' + src[t.LOOSEPLAIN] + ')$|^$';
275 tok('COMPARATOR');
276 src[t.COMPARATOR] = '^' + src[t.GTLT] + '\\s*(' + src[t.FULLPLAIN] + ')$|^$';
277
278 // An expression to strip any whitespace between the gtlt and the thing
279 // it modifies, so that `> 1.2.3` ==> `>1.2.3`
280 tok('COMPARATORTRIM');
281 src[t.COMPARATORTRIM] = '(\\s*)' + src[t.GTLT] +
282 '\\s*(' + src[t.LOOSEPLAIN] + '|' + src[t.XRANGEPLAIN] + ')';
283
284 // this one has to use the /g flag
285 re[t.COMPARATORTRIM] = new RegExp(src[t.COMPARATORTRIM], 'g');
286 var comparatorTrimReplace = '$1$2$3';
287
288 // Something like `1.2.3 - 1.2.4`
289 // Note that these all use the loose form, because they'll be
290 // checked against either the strict or loose comparator form
291 // later.
292 tok('HYPHENRANGE');
293 src[t.HYPHENRANGE] = '^\\s*(' + src[t.XRANGEPLAIN] + ')' +
294 '\\s+-\\s+' +
295 '(' + src[t.XRANGEPLAIN] + ')' +
296 '\\s*$';
297
298 tok('HYPHENRANGELOOSE');
299 src[t.HYPHENRANGELOOSE] = '^\\s*(' + src[t.XRANGEPLAINLOOSE] + ')' +
300 '\\s+-\\s+' +
301 '(' + src[t.XRANGEPLAINLOOSE] + ')' +
302 '\\s*$';
303
304 // Star ranges basically just allow anything at all.
305 tok('STAR');
306 src[t.STAR] = '(<|>)?=?\\s*\\*';
307
308 // Compile to actual regexp objects.
309 // All are flag-free, unless they were created above with a flag.
310 for (var i = 0; i < R; i++) {
311 debug(i, src[i]);
312 if (!re[i]) {
313 re[i] = new RegExp(src[i]);
314 }
315 }
316
317 exports.parse = parse;
318 function parse (version, options) {
319 if (!options || typeof options !== 'object') {
320 options = {
321 loose: !!options,
322 includePrerelease: false
323 };
324 }
325
326 if (version instanceof SemVer) {
327 return version
328 }
329
330 if (typeof version !== 'string') {
331 return null
332 }
333
334 if (version.length > MAX_LENGTH) {
335 return null
336 }
337
338 var r = options.loose ? re[t.LOOSE] : re[t.FULL];
339 if (!r.test(version)) {
340 return null
341 }
342
343 try {
344 return new SemVer(version, options)
345 } catch (er) {
346 return null
347 }
348 }
349
350 exports.valid = valid;
351 function valid (version, options) {
352 var v = parse(version, options);
353 return v ? v.version : null
354 }
355
356 exports.clean = clean;
357 function clean (version, options) {
358 var s = parse(version.trim().replace(/^[=v]+/, ''), options);
359 return s ? s.version : null
360 }
361
362 exports.SemVer = SemVer;
363
364 function SemVer (version, options) {
365 if (!options || typeof options !== 'object') {
366 options = {
367 loose: !!options,
368 includePrerelease: false
369 };
370 }
371 if (version instanceof SemVer) {
372 if (version.loose === options.loose) {
373 return version
374 } else {
375 version = version.version;
376 }
377 } else if (typeof version !== 'string') {
378 throw new TypeError('Invalid Version: ' + version)
379 }
380
381 if (version.length > MAX_LENGTH) {
382 throw new TypeError('version is longer than ' + MAX_LENGTH + ' characters')
383 }
384
385 if (!(this instanceof SemVer)) {
386 return new SemVer(version, options)
387 }
388
389 debug('SemVer', version, options);
390 this.options = options;
391 this.loose = !!options.loose;
392
393 var m = version.trim().match(options.loose ? re[t.LOOSE] : re[t.FULL]);
394
395 if (!m) {
396 throw new TypeError('Invalid Version: ' + version)
397 }
398
399 this.raw = version;
400
401 // these are actually numbers
402 this.major = +m[1];
403 this.minor = +m[2];
404 this.patch = +m[3];
405
406 if (this.major > MAX_SAFE_INTEGER || this.major < 0) {
407 throw new TypeError('Invalid major version')
408 }
409
410 if (this.minor > MAX_SAFE_INTEGER || this.minor < 0) {
411 throw new TypeError('Invalid minor version')
412 }
413
414 if (this.patch > MAX_SAFE_INTEGER || this.patch < 0) {
415 throw new TypeError('Invalid patch version')
416 }
417
418 // numberify any prerelease numeric ids
419 if (!m[4]) {
420 this.prerelease = [];
421 } else {
422 this.prerelease = m[4].split('.').map(function (id) {
423 if (/^[0-9]+$/.test(id)) {
424 var num = +id;
425 if (num >= 0 && num < MAX_SAFE_INTEGER) {
426 return num
427 }
428 }
429 return id
430 });
431 }
432
433 this.build = m[5] ? m[5].split('.') : [];
434 this.format();
435 }
436
437 SemVer.prototype.format = function () {
438 this.version = this.major + '.' + this.minor + '.' + this.patch;
439 if (this.prerelease.length) {
440 this.version += '-' + this.prerelease.join('.');
441 }
442 return this.version
443 };
444
445 SemVer.prototype.toString = function () {
446 return this.version
447 };
448
449 SemVer.prototype.compare = function (other) {
450 debug('SemVer.compare', this.version, this.options, other);
451 if (!(other instanceof SemVer)) {
452 other = new SemVer(other, this.options);
453 }
454
455 return this.compareMain(other) || this.comparePre(other)
456 };
457
458 SemVer.prototype.compareMain = function (other) {
459 if (!(other instanceof SemVer)) {
460 other = new SemVer(other, this.options);
461 }
462
463 return compareIdentifiers(this.major, other.major) ||
464 compareIdentifiers(this.minor, other.minor) ||
465 compareIdentifiers(this.patch, other.patch)
466 };
467
468 SemVer.prototype.comparePre = function (other) {
469 if (!(other instanceof SemVer)) {
470 other = new SemVer(other, this.options);
471 }
472
473 // NOT having a prerelease is > having one
474 if (this.prerelease.length && !other.prerelease.length) {
475 return -1
476 } else if (!this.prerelease.length && other.prerelease.length) {
477 return 1
478 } else if (!this.prerelease.length && !other.prerelease.length) {
479 return 0
480 }
481
482 var i = 0;
483 do {
484 var a = this.prerelease[i];
485 var b = other.prerelease[i];
486 debug('prerelease compare', i, a, b);
487 if (a === undefined && b === undefined) {
488 return 0
489 } else if (b === undefined) {
490 return 1
491 } else if (a === undefined) {
492 return -1
493 } else if (a === b) {
494 continue
495 } else {
496 return compareIdentifiers(a, b)
497 }
498 } while (++i)
499 };
500
501 SemVer.prototype.compareBuild = function (other) {
502 if (!(other instanceof SemVer)) {
503 other = new SemVer(other, this.options);
504 }
505
506 var i = 0;
507 do {
508 var a = this.build[i];
509 var b = other.build[i];
510 debug('prerelease compare', i, a, b);
511 if (a === undefined && b === undefined) {
512 return 0
513 } else if (b === undefined) {
514 return 1
515 } else if (a === undefined) {
516 return -1
517 } else if (a === b) {
518 continue
519 } else {
520 return compareIdentifiers(a, b)
521 }
522 } while (++i)
523 };
524
525 // preminor will bump the version up to the next minor release, and immediately
526 // down to pre-release. premajor and prepatch work the same way.
527 SemVer.prototype.inc = function (release, identifier) {
528 switch (release) {
529 case 'premajor':
530 this.prerelease.length = 0;
531 this.patch = 0;
532 this.minor = 0;
533 this.major++;
534 this.inc('pre', identifier);
535 break
536 case 'preminor':
537 this.prerelease.length = 0;
538 this.patch = 0;
539 this.minor++;
540 this.inc('pre', identifier);
541 break
542 case 'prepatch':
543 // If this is already a prerelease, it will bump to the next version
544 // drop any prereleases that might already exist, since they are not
545 // relevant at this point.
546 this.prerelease.length = 0;
547 this.inc('patch', identifier);
548 this.inc('pre', identifier);
549 break
550 // If the input is a non-prerelease version, this acts the same as
551 // prepatch.
552 case 'prerelease':
553 if (this.prerelease.length === 0) {
554 this.inc('patch', identifier);
555 }
556 this.inc('pre', identifier);
557 break
558
559 case 'major':
560 // If this is a pre-major version, bump up to the same major version.
561 // Otherwise increment major.
562 // 1.0.0-5 bumps to 1.0.0
563 // 1.1.0 bumps to 2.0.0
564 if (this.minor !== 0 ||
565 this.patch !== 0 ||
566 this.prerelease.length === 0) {
567 this.major++;
568 }
569 this.minor = 0;
570 this.patch = 0;
571 this.prerelease = [];
572 break
573 case 'minor':
574 // If this is a pre-minor version, bump up to the same minor version.
575 // Otherwise increment minor.
576 // 1.2.0-5 bumps to 1.2.0
577 // 1.2.1 bumps to 1.3.0
578 if (this.patch !== 0 || this.prerelease.length === 0) {
579 this.minor++;
580 }
581 this.patch = 0;
582 this.prerelease = [];
583 break
584 case 'patch':
585 // If this is not a pre-release version, it will increment the patch.
586 // If it is a pre-release it will bump up to the same patch version.
587 // 1.2.0-5 patches to 1.2.0
588 // 1.2.0 patches to 1.2.1
589 if (this.prerelease.length === 0) {
590 this.patch++;
591 }
592 this.prerelease = [];
593 break
594 // This probably shouldn't be used publicly.
595 // 1.0.0 "pre" would become 1.0.0-0 which is the wrong direction.
596 case 'pre':
597 if (this.prerelease.length === 0) {
598 this.prerelease = [0];
599 } else {
600 var i = this.prerelease.length;
601 while (--i >= 0) {
602 if (typeof this.prerelease[i] === 'number') {
603 this.prerelease[i]++;
604 i = -2;
605 }
606 }
607 if (i === -1) {
608 // didn't increment anything
609 this.prerelease.push(0);
610 }
611 }
612 if (identifier) {
613 // 1.2.0-beta.1 bumps to 1.2.0-beta.2,
614 // 1.2.0-beta.fooblz or 1.2.0-beta bumps to 1.2.0-beta.0
615 if (this.prerelease[0] === identifier) {
616 if (isNaN(this.prerelease[1])) {
617 this.prerelease = [identifier, 0];
618 }
619 } else {
620 this.prerelease = [identifier, 0];
621 }
622 }
623 break
624
625 default:
626 throw new Error('invalid increment argument: ' + release)
627 }
628 this.format();
629 this.raw = this.version;
630 return this
631 };
632
633 exports.inc = inc;
634 function inc (version, release, loose, identifier) {
635 if (typeof (loose) === 'string') {
636 identifier = loose;
637 loose = undefined;
638 }
639
640 try {
641 return new SemVer(version, loose).inc(release, identifier).version
642 } catch (er) {
643 return null
644 }
645 }
646
647 exports.diff = diff;
648 function diff (version1, version2) {
649 if (eq(version1, version2)) {
650 return null
651 } else {
652 var v1 = parse(version1);
653 var v2 = parse(version2);
654 var prefix = '';
655 if (v1.prerelease.length || v2.prerelease.length) {
656 prefix = 'pre';
657 var defaultResult = 'prerelease';
658 }
659 for (var key in v1) {
660 if (key === 'major' || key === 'minor' || key === 'patch') {
661 if (v1[key] !== v2[key]) {
662 return prefix + key
663 }
664 }
665 }
666 return defaultResult // may be undefined
667 }
668 }
669
670 exports.compareIdentifiers = compareIdentifiers;
671
672 var numeric = /^[0-9]+$/;
673 function compareIdentifiers (a, b) {
674 var anum = numeric.test(a);
675 var bnum = numeric.test(b);
676
677 if (anum && bnum) {
678 a = +a;
679 b = +b;
680 }
681
682 return a === b ? 0
683 : (anum && !bnum) ? -1
684 : (bnum && !anum) ? 1
685 : a < b ? -1
686 : 1
687 }
688
689 exports.rcompareIdentifiers = rcompareIdentifiers;
690 function rcompareIdentifiers (a, b) {
691 return compareIdentifiers(b, a)
692 }
693
694 exports.major = major;
695 function major (a, loose) {
696 return new SemVer(a, loose).major
697 }
698
699 exports.minor = minor;
700 function minor (a, loose) {
701 return new SemVer(a, loose).minor
702 }
703
704 exports.patch = patch;
705 function patch (a, loose) {
706 return new SemVer(a, loose).patch
707 }
708
709 exports.compare = compare;
710 function compare (a, b, loose) {
711 return new SemVer(a, loose).compare(new SemVer(b, loose))
712 }
713
714 exports.compareLoose = compareLoose;
715 function compareLoose (a, b) {
716 return compare(a, b, true)
717 }
718
719 exports.compareBuild = compareBuild;
720 function compareBuild (a, b, loose) {
721 var versionA = new SemVer(a, loose);
722 var versionB = new SemVer(b, loose);
723 return versionA.compare(versionB) || versionA.compareBuild(versionB)
724 }
725
726 exports.rcompare = rcompare;
727 function rcompare (a, b, loose) {
728 return compare(b, a, loose)
729 }
730
731 exports.sort = sort;
732 function sort (list, loose) {
733 return list.sort(function (a, b) {
734 return exports.compareBuild(a, b, loose)
735 })
736 }
737
738 exports.rsort = rsort;
739 function rsort (list, loose) {
740 return list.sort(function (a, b) {
741 return exports.compareBuild(b, a, loose)
742 })
743 }
744
745 exports.gt = gt;
746 function gt (a, b, loose) {
747 return compare(a, b, loose) > 0
748 }
749
750 exports.lt = lt;
751 function lt (a, b, loose) {
752 return compare(a, b, loose) < 0
753 }
754
755 exports.eq = eq;
756 function eq (a, b, loose) {
757 return compare(a, b, loose) === 0
758 }
759
760 exports.neq = neq;
761 function neq (a, b, loose) {
762 return compare(a, b, loose) !== 0
763 }
764
765 exports.gte = gte;
766 function gte (a, b, loose) {
767 return compare(a, b, loose) >= 0
768 }
769
770 exports.lte = lte;
771 function lte (a, b, loose) {
772 return compare(a, b, loose) <= 0
773 }
774
775 exports.cmp = cmp;
776 function cmp (a, op, b, loose) {
777 switch (op) {
778 case '===':
779 if (typeof a === 'object')
780 { a = a.version; }
781 if (typeof b === 'object')
782 { b = b.version; }
783 return a === b
784
785 case '!==':
786 if (typeof a === 'object')
787 { a = a.version; }
788 if (typeof b === 'object')
789 { b = b.version; }
790 return a !== b
791
792 case '':
793 case '=':
794 case '==':
795 return eq(a, b, loose)
796
797 case '!=':
798 return neq(a, b, loose)
799
800 case '>':
801 return gt(a, b, loose)
802
803 case '>=':
804 return gte(a, b, loose)
805
806 case '<':
807 return lt(a, b, loose)
808
809 case '<=':
810 return lte(a, b, loose)
811
812 default:
813 throw new TypeError('Invalid operator: ' + op)
814 }
815 }
816
817 exports.Comparator = Comparator;
818 function Comparator (comp, options) {
819 if (!options || typeof options !== 'object') {
820 options = {
821 loose: !!options,
822 includePrerelease: false
823 };
824 }
825
826 if (comp instanceof Comparator) {
827 if (comp.loose === !!options.loose) {
828 return comp
829 } else {
830 comp = comp.value;
831 }
832 }
833
834 if (!(this instanceof Comparator)) {
835 return new Comparator(comp, options)
836 }
837
838 debug('comparator', comp, options);
839 this.options = options;
840 this.loose = !!options.loose;
841 this.parse(comp);
842
843 if (this.semver === ANY) {
844 this.value = '';
845 } else {
846 this.value = this.operator + this.semver.version;
847 }
848
849 debug('comp', this);
850 }
851
852 var ANY = {};
853 Comparator.prototype.parse = function (comp) {
854 var r = this.options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
855 var m = comp.match(r);
856
857 if (!m) {
858 throw new TypeError('Invalid comparator: ' + comp)
859 }
860
861 this.operator = m[1] !== undefined ? m[1] : '';
862 if (this.operator === '=') {
863 this.operator = '';
864 }
865
866 // if it literally is just '>' or '' then allow anything.
867 if (!m[2]) {
868 this.semver = ANY;
869 } else {
870 this.semver = new SemVer(m[2], this.options.loose);
871 }
872 };
873
874 Comparator.prototype.toString = function () {
875 return this.value
876 };
877
878 Comparator.prototype.test = function (version) {
879 debug('Comparator.test', version, this.options.loose);
880
881 if (this.semver === ANY || version === ANY) {
882 return true
883 }
884
885 if (typeof version === 'string') {
886 try {
887 version = new SemVer(version, this.options);
888 } catch (er) {
889 return false
890 }
891 }
892
893 return cmp(version, this.operator, this.semver, this.options)
894 };
895
896 Comparator.prototype.intersects = function (comp, options) {
897 if (!(comp instanceof Comparator)) {
898 throw new TypeError('a Comparator is required')
899 }
900
901 if (!options || typeof options !== 'object') {
902 options = {
903 loose: !!options,
904 includePrerelease: false
905 };
906 }
907
908 var rangeTmp;
909
910 if (this.operator === '') {
911 if (this.value === '') {
912 return true
913 }
914 rangeTmp = new Range(comp.value, options);
915 return satisfies(this.value, rangeTmp, options)
916 } else if (comp.operator === '') {
917 if (comp.value === '') {
918 return true
919 }
920 rangeTmp = new Range(this.value, options);
921 return satisfies(comp.semver, rangeTmp, options)
922 }
923
924 var sameDirectionIncreasing =
925 (this.operator === '>=' || this.operator === '>') &&
926 (comp.operator === '>=' || comp.operator === '>');
927 var sameDirectionDecreasing =
928 (this.operator === '<=' || this.operator === '<') &&
929 (comp.operator === '<=' || comp.operator === '<');
930 var sameSemVer = this.semver.version === comp.semver.version;
931 var differentDirectionsInclusive =
932 (this.operator === '>=' || this.operator === '<=') &&
933 (comp.operator === '>=' || comp.operator === '<=');
934 var oppositeDirectionsLessThan =
935 cmp(this.semver, '<', comp.semver, options) &&
936 ((this.operator === '>=' || this.operator === '>') &&
937 (comp.operator === '<=' || comp.operator === '<'));
938 var oppositeDirectionsGreaterThan =
939 cmp(this.semver, '>', comp.semver, options) &&
940 ((this.operator === '<=' || this.operator === '<') &&
941 (comp.operator === '>=' || comp.operator === '>'));
942
943 return sameDirectionIncreasing || sameDirectionDecreasing ||
944 (sameSemVer && differentDirectionsInclusive) ||
945 oppositeDirectionsLessThan || oppositeDirectionsGreaterThan
946 };
947
948 exports.Range = Range;
949 function Range (range, options) {
950 if (!options || typeof options !== 'object') {
951 options = {
952 loose: !!options,
953 includePrerelease: false
954 };
955 }
956
957 if (range instanceof Range) {
958 if (range.loose === !!options.loose &&
959 range.includePrerelease === !!options.includePrerelease) {
960 return range
961 } else {
962 return new Range(range.raw, options)
963 }
964 }
965
966 if (range instanceof Comparator) {
967 return new Range(range.value, options)
968 }
969
970 if (!(this instanceof Range)) {
971 return new Range(range, options)
972 }
973
974 this.options = options;
975 this.loose = !!options.loose;
976 this.includePrerelease = !!options.includePrerelease;
977
978 // First, split based on boolean or ||
979 this.raw = range;
980 this.set = range.split(/\s*\|\|\s*/).map(function (range) {
981 return this.parseRange(range.trim())
982 }, this).filter(function (c) {
983 // throw out any that are not relevant for whatever reason
984 return c.length
985 });
986
987 if (!this.set.length) {
988 throw new TypeError('Invalid SemVer Range: ' + range)
989 }
990
991 this.format();
992 }
993
994 Range.prototype.format = function () {
995 this.range = this.set.map(function (comps) {
996 return comps.join(' ').trim()
997 }).join('||').trim();
998 return this.range
999 };
1000
1001 Range.prototype.toString = function () {
1002 return this.range
1003 };
1004
1005 Range.prototype.parseRange = function (range) {
1006 var loose = this.options.loose;
1007 range = range.trim();
1008 // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
1009 var hr = loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE];
1010 range = range.replace(hr, hyphenReplace);
1011 debug('hyphen replace', range);
1012 // `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`
1013 range = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace);
1014 debug('comparator trim', range, re[t.COMPARATORTRIM]);
1015
1016 // `~ 1.2.3` => `~1.2.3`
1017 range = range.replace(re[t.TILDETRIM], tildeTrimReplace);
1018
1019 // `^ 1.2.3` => `^1.2.3`
1020 range = range.replace(re[t.CARETTRIM], caretTrimReplace);
1021
1022 // normalize spaces
1023 range = range.split(/\s+/).join(' ');
1024
1025 // At this point, the range is completely trimmed and
1026 // ready to be split into comparators.
1027
1028 var compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1029 var set = range.split(' ').map(function (comp) {
1030 return parseComparator(comp, this.options)
1031 }, this).join(' ').split(/\s+/);
1032 if (this.options.loose) {
1033 // in loose mode, throw out any that are not valid comparators
1034 set = set.filter(function (comp) {
1035 return !!comp.match(compRe)
1036 });
1037 }
1038 set = set.map(function (comp) {
1039 return new Comparator(comp, this.options)
1040 }, this);
1041
1042 return set
1043 };
1044
1045 Range.prototype.intersects = function (range, options) {
1046 if (!(range instanceof Range)) {
1047 throw new TypeError('a Range is required')
1048 }
1049
1050 return this.set.some(function (thisComparators) {
1051 return (
1052 isSatisfiable(thisComparators, options) &&
1053 range.set.some(function (rangeComparators) {
1054 return (
1055 isSatisfiable(rangeComparators, options) &&
1056 thisComparators.every(function (thisComparator) {
1057 return rangeComparators.every(function (rangeComparator) {
1058 return thisComparator.intersects(rangeComparator, options)
1059 })
1060 })
1061 )
1062 })
1063 )
1064 })
1065 };
1066
1067 // take a set of comparators and determine whether there
1068 // exists a version which can satisfy it
1069 function isSatisfiable (comparators, options) {
1070 var result = true;
1071 var remainingComparators = comparators.slice();
1072 var testComparator = remainingComparators.pop();
1073
1074 while (result && remainingComparators.length) {
1075 result = remainingComparators.every(function (otherComparator) {
1076 return testComparator.intersects(otherComparator, options)
1077 });
1078
1079 testComparator = remainingComparators.pop();
1080 }
1081
1082 return result
1083 }
1084
1085 // Mostly just for testing and legacy API reasons
1086 exports.toComparators = toComparators;
1087 function toComparators (range, options) {
1088 return new Range(range, options).set.map(function (comp) {
1089 return comp.map(function (c) {
1090 return c.value
1091 }).join(' ').trim().split(' ')
1092 })
1093 }
1094
1095 // comprised of xranges, tildes, stars, and gtlt's at this point.
1096 // already replaced the hyphen ranges
1097 // turn into a set of JUST comparators.
1098 function parseComparator (comp, options) {
1099 debug('comp', comp, options);
1100 comp = replaceCarets(comp, options);
1101 debug('caret', comp);
1102 comp = replaceTildes(comp, options);
1103 debug('tildes', comp);
1104 comp = replaceXRanges(comp, options);
1105 debug('xrange', comp);
1106 comp = replaceStars(comp, options);
1107 debug('stars', comp);
1108 return comp
1109 }
1110
1111 function isX (id) {
1112 return !id || id.toLowerCase() === 'x' || id === '*'
1113 }
1114
1115 // ~, ~> --> * (any, kinda silly)
1116 // ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0
1117 // ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0
1118 // ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0
1119 // ~1.2.3, ~>1.2.3 --> >=1.2.3 <1.3.0
1120 // ~1.2.0, ~>1.2.0 --> >=1.2.0 <1.3.0
1121 function replaceTildes (comp, options) {
1122 return comp.trim().split(/\s+/).map(function (comp) {
1123 return replaceTilde(comp, options)
1124 }).join(' ')
1125 }
1126
1127 function replaceTilde (comp, options) {
1128 var r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE];
1129 return comp.replace(r, function (_, M, m, p, pr) {
1130 debug('tilde', comp, _, M, m, p, pr);
1131 var ret;
1132
1133 if (isX(M)) {
1134 ret = '';
1135 } else if (isX(m)) {
1136 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1137 } else if (isX(p)) {
1138 // ~1.2 == >=1.2.0 <1.3.0
1139 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1140 } else if (pr) {
1141 debug('replaceTilde pr', pr);
1142 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1143 ' <' + M + '.' + (+m + 1) + '.0';
1144 } else {
1145 // ~1.2.3 == >=1.2.3 <1.3.0
1146 ret = '>=' + M + '.' + m + '.' + p +
1147 ' <' + M + '.' + (+m + 1) + '.0';
1148 }
1149
1150 debug('tilde return', ret);
1151 return ret
1152 })
1153 }
1154
1155 // ^ --> * (any, kinda silly)
1156 // ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0
1157 // ^2.0, ^2.0.x --> >=2.0.0 <3.0.0
1158 // ^1.2, ^1.2.x --> >=1.2.0 <2.0.0
1159 // ^1.2.3 --> >=1.2.3 <2.0.0
1160 // ^1.2.0 --> >=1.2.0 <2.0.0
1161 function replaceCarets (comp, options) {
1162 return comp.trim().split(/\s+/).map(function (comp) {
1163 return replaceCaret(comp, options)
1164 }).join(' ')
1165 }
1166
1167 function replaceCaret (comp, options) {
1168 debug('caret', comp, options);
1169 var r = options.loose ? re[t.CARETLOOSE] : re[t.CARET];
1170 return comp.replace(r, function (_, M, m, p, pr) {
1171 debug('caret', comp, _, M, m, p, pr);
1172 var ret;
1173
1174 if (isX(M)) {
1175 ret = '';
1176 } else if (isX(m)) {
1177 ret = '>=' + M + '.0.0 <' + (+M + 1) + '.0.0';
1178 } else if (isX(p)) {
1179 if (M === '0') {
1180 ret = '>=' + M + '.' + m + '.0 <' + M + '.' + (+m + 1) + '.0';
1181 } else {
1182 ret = '>=' + M + '.' + m + '.0 <' + (+M + 1) + '.0.0';
1183 }
1184 } else if (pr) {
1185 debug('replaceCaret pr', pr);
1186 if (M === '0') {
1187 if (m === '0') {
1188 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1189 ' <' + M + '.' + m + '.' + (+p + 1);
1190 } else {
1191 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1192 ' <' + M + '.' + (+m + 1) + '.0';
1193 }
1194 } else {
1195 ret = '>=' + M + '.' + m + '.' + p + '-' + pr +
1196 ' <' + (+M + 1) + '.0.0';
1197 }
1198 } else {
1199 debug('no pr');
1200 if (M === '0') {
1201 if (m === '0') {
1202 ret = '>=' + M + '.' + m + '.' + p +
1203 ' <' + M + '.' + m + '.' + (+p + 1);
1204 } else {
1205 ret = '>=' + M + '.' + m + '.' + p +
1206 ' <' + M + '.' + (+m + 1) + '.0';
1207 }
1208 } else {
1209 ret = '>=' + M + '.' + m + '.' + p +
1210 ' <' + (+M + 1) + '.0.0';
1211 }
1212 }
1213
1214 debug('caret return', ret);
1215 return ret
1216 })
1217 }
1218
1219 function replaceXRanges (comp, options) {
1220 debug('replaceXRanges', comp, options);
1221 return comp.split(/\s+/).map(function (comp) {
1222 return replaceXRange(comp, options)
1223 }).join(' ')
1224 }
1225
1226 function replaceXRange (comp, options) {
1227 comp = comp.trim();
1228 var r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE];
1229 return comp.replace(r, function (ret, gtlt, M, m, p, pr) {
1230 debug('xRange', comp, ret, gtlt, M, m, p, pr);
1231 var xM = isX(M);
1232 var xm = xM || isX(m);
1233 var xp = xm || isX(p);
1234 var anyX = xp;
1235
1236 if (gtlt === '=' && anyX) {
1237 gtlt = '';
1238 }
1239
1240 // if we're including prereleases in the match, then we need
1241 // to fix this to -0, the lowest possible prerelease value
1242 pr = options.includePrerelease ? '-0' : '';
1243
1244 if (xM) {
1245 if (gtlt === '>' || gtlt === '<') {
1246 // nothing is allowed
1247 ret = '<0.0.0-0';
1248 } else {
1249 // nothing is forbidden
1250 ret = '*';
1251 }
1252 } else if (gtlt && anyX) {
1253 // we know patch is an x, because we have any x at all.
1254 // replace X with 0
1255 if (xm) {
1256 m = 0;
1257 }
1258 p = 0;
1259
1260 if (gtlt === '>') {
1261 // >1 => >=2.0.0
1262 // >1.2 => >=1.3.0
1263 // >1.2.3 => >= 1.2.4
1264 gtlt = '>=';
1265 if (xm) {
1266 M = +M + 1;
1267 m = 0;
1268 p = 0;
1269 } else {
1270 m = +m + 1;
1271 p = 0;
1272 }
1273 } else if (gtlt === '<=') {
1274 // <=0.7.x is actually <0.8.0, since any 0.7.x should
1275 // pass. Similarly, <=7.x is actually <8.0.0, etc.
1276 gtlt = '<';
1277 if (xm) {
1278 M = +M + 1;
1279 } else {
1280 m = +m + 1;
1281 }
1282 }
1283
1284 ret = gtlt + M + '.' + m + '.' + p + pr;
1285 } else if (xm) {
1286 ret = '>=' + M + '.0.0' + pr + ' <' + (+M + 1) + '.0.0' + pr;
1287 } else if (xp) {
1288 ret = '>=' + M + '.' + m + '.0' + pr +
1289 ' <' + M + '.' + (+m + 1) + '.0' + pr;
1290 }
1291
1292 debug('xRange return', ret);
1293
1294 return ret
1295 })
1296 }
1297
1298 // Because * is AND-ed with everything else in the comparator,
1299 // and '' means "any version", just remove the *s entirely.
1300 function replaceStars (comp, options) {
1301 debug('replaceStars', comp, options);
1302 // Looseness is ignored here. star is always as loose as it gets!
1303 return comp.trim().replace(re[t.STAR], '')
1304 }
1305
1306 // This function is passed to string.replace(re[t.HYPHENRANGE])
1307 // M, m, patch, prerelease, build
1308 // 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
1309 // 1.2.3 - 3.4 => >=1.2.0 <3.5.0 Any 3.4.x will do
1310 // 1.2 - 3.4 => >=1.2.0 <3.5.0
1311 function hyphenReplace ($0,
1312 from, fM, fm, fp, fpr, fb,
1313 to, tM, tm, tp, tpr, tb) {
1314 if (isX(fM)) {
1315 from = '';
1316 } else if (isX(fm)) {
1317 from = '>=' + fM + '.0.0';
1318 } else if (isX(fp)) {
1319 from = '>=' + fM + '.' + fm + '.0';
1320 } else {
1321 from = '>=' + from;
1322 }
1323
1324 if (isX(tM)) {
1325 to = '';
1326 } else if (isX(tm)) {
1327 to = '<' + (+tM + 1) + '.0.0';
1328 } else if (isX(tp)) {
1329 to = '<' + tM + '.' + (+tm + 1) + '.0';
1330 } else if (tpr) {
1331 to = '<=' + tM + '.' + tm + '.' + tp + '-' + tpr;
1332 } else {
1333 to = '<=' + to;
1334 }
1335
1336 return (from + ' ' + to).trim()
1337 }
1338
1339 // if ANY of the sets match ALL of its comparators, then pass
1340 Range.prototype.test = function (version) {
1341 if (!version) {
1342 return false
1343 }
1344
1345 if (typeof version === 'string') {
1346 try {
1347 version = new SemVer(version, this.options);
1348 } catch (er) {
1349 return false
1350 }
1351 }
1352
1353 for (var i = 0; i < this.set.length; i++) {
1354 if (testSet(this.set[i], version, this.options)) {
1355 return true
1356 }
1357 }
1358 return false
1359 };
1360
1361 function testSet (set, version, options) {
1362 for (var i = 0; i < set.length; i++) {
1363 if (!set[i].test(version)) {
1364 return false
1365 }
1366 }
1367
1368 if (version.prerelease.length && !options.includePrerelease) {
1369 // Find the set of versions that are allowed to have prereleases
1370 // For example, ^1.2.3-pr.1 desugars to >=1.2.3-pr.1 <2.0.0
1371 // That should allow `1.2.3-pr.2` to pass.
1372 // However, `1.2.4-alpha.notready` should NOT be allowed,
1373 // even though it's within the range set by the comparators.
1374 for (i = 0; i < set.length; i++) {
1375 debug(set[i].semver);
1376 if (set[i].semver === ANY) {
1377 continue
1378 }
1379
1380 if (set[i].semver.prerelease.length > 0) {
1381 var allowed = set[i].semver;
1382 if (allowed.major === version.major &&
1383 allowed.minor === version.minor &&
1384 allowed.patch === version.patch) {
1385 return true
1386 }
1387 }
1388 }
1389
1390 // Version has a -pre, but it's not one of the ones we like.
1391 return false
1392 }
1393
1394 return true
1395 }
1396
1397 exports.satisfies = satisfies;
1398 function satisfies (version, range, options) {
1399 try {
1400 range = new Range(range, options);
1401 } catch (er) {
1402 return false
1403 }
1404 return range.test(version)
1405 }
1406
1407 exports.maxSatisfying = maxSatisfying;
1408 function maxSatisfying (versions, range, options) {
1409 var max = null;
1410 var maxSV = null;
1411 try {
1412 var rangeObj = new Range(range, options);
1413 } catch (er) {
1414 return null
1415 }
1416 versions.forEach(function (v) {
1417 if (rangeObj.test(v)) {
1418 // satisfies(v, range, options)
1419 if (!max || maxSV.compare(v) === -1) {
1420 // compare(max, v, true)
1421 max = v;
1422 maxSV = new SemVer(max, options);
1423 }
1424 }
1425 });
1426 return max
1427 }
1428
1429 exports.minSatisfying = minSatisfying;
1430 function minSatisfying (versions, range, options) {
1431 var min = null;
1432 var minSV = null;
1433 try {
1434 var rangeObj = new Range(range, options);
1435 } catch (er) {
1436 return null
1437 }
1438 versions.forEach(function (v) {
1439 if (rangeObj.test(v)) {
1440 // satisfies(v, range, options)
1441 if (!min || minSV.compare(v) === 1) {
1442 // compare(min, v, true)
1443 min = v;
1444 minSV = new SemVer(min, options);
1445 }
1446 }
1447 });
1448 return min
1449 }
1450
1451 exports.minVersion = minVersion;
1452 function minVersion (range, loose) {
1453 range = new Range(range, loose);
1454
1455 var minver = new SemVer('0.0.0');
1456 if (range.test(minver)) {
1457 return minver
1458 }
1459
1460 minver = new SemVer('0.0.0-0');
1461 if (range.test(minver)) {
1462 return minver
1463 }
1464
1465 minver = null;
1466 for (var i = 0; i < range.set.length; ++i) {
1467 var comparators = range.set[i];
1468
1469 comparators.forEach(function (comparator) {
1470 // Clone to avoid manipulating the comparator's semver object.
1471 var compver = new SemVer(comparator.semver.version);
1472 switch (comparator.operator) {
1473 case '>':
1474 if (compver.prerelease.length === 0) {
1475 compver.patch++;
1476 } else {
1477 compver.prerelease.push(0);
1478 }
1479 compver.raw = compver.format();
1480 /* fallthrough */
1481 case '':
1482 case '>=':
1483 if (!minver || gt(minver, compver)) {
1484 minver = compver;
1485 }
1486 break
1487 case '<':
1488 case '<=':
1489 /* Ignore maximum versions */
1490 break
1491 /* istanbul ignore next */
1492 default:
1493 throw new Error('Unexpected operation: ' + comparator.operator)
1494 }
1495 });
1496 }
1497
1498 if (minver && range.test(minver)) {
1499 return minver
1500 }
1501
1502 return null
1503 }
1504
1505 exports.validRange = validRange;
1506 function validRange (range, options) {
1507 try {
1508 // Return '*' instead of '' so that truthiness works.
1509 // This will throw if it's invalid anyway
1510 return new Range(range, options).range || '*'
1511 } catch (er) {
1512 return null
1513 }
1514 }
1515
1516 // Determine if version is less than all the versions possible in the range
1517 exports.ltr = ltr;
1518 function ltr (version, range, options) {
1519 return outside(version, range, '<', options)
1520 }
1521
1522 // Determine if version is greater than all the versions possible in the range.
1523 exports.gtr = gtr;
1524 function gtr (version, range, options) {
1525 return outside(version, range, '>', options)
1526 }
1527
1528 exports.outside = outside;
1529 function outside (version, range, hilo, options) {
1530 version = new SemVer(version, options);
1531 range = new Range(range, options);
1532
1533 var gtfn, ltefn, ltfn, comp, ecomp;
1534 switch (hilo) {
1535 case '>':
1536 gtfn = gt;
1537 ltefn = lte;
1538 ltfn = lt;
1539 comp = '>';
1540 ecomp = '>=';
1541 break
1542 case '<':
1543 gtfn = lt;
1544 ltefn = gte;
1545 ltfn = gt;
1546 comp = '<';
1547 ecomp = '<=';
1548 break
1549 default:
1550 throw new TypeError('Must provide a hilo val of "<" or ">"')
1551 }
1552
1553 // If it satisifes the range it is not outside
1554 if (satisfies(version, range, options)) {
1555 return false
1556 }
1557
1558 // From now on, variable terms are as if we're in "gtr" mode.
1559 // but note that everything is flipped for the "ltr" function.
1560
1561 for (var i = 0; i < range.set.length; ++i) {
1562 var comparators = range.set[i];
1563
1564 var high = null;
1565 var low = null;
1566
1567 comparators.forEach(function (comparator) {
1568 if (comparator.semver === ANY) {
1569 comparator = new Comparator('>=0.0.0');
1570 }
1571 high = high || comparator;
1572 low = low || comparator;
1573 if (gtfn(comparator.semver, high.semver, options)) {
1574 high = comparator;
1575 } else if (ltfn(comparator.semver, low.semver, options)) {
1576 low = comparator;
1577 }
1578 });
1579
1580 // If the edge version comparator has a operator then our version
1581 // isn't outside it
1582 if (high.operator === comp || high.operator === ecomp) {
1583 return false
1584 }
1585
1586 // If the lowest version comparator has an operator and our version
1587 // is less than it then it isn't higher than the range
1588 if ((!low.operator || low.operator === comp) &&
1589 ltefn(version, low.semver)) {
1590 return false
1591 } else if (low.operator === ecomp && ltfn(version, low.semver)) {
1592 return false
1593 }
1594 }
1595 return true
1596 }
1597
1598 exports.prerelease = prerelease;
1599 function prerelease (version, options) {
1600 var parsed = parse(version, options);
1601 return (parsed && parsed.prerelease.length) ? parsed.prerelease : null
1602 }
1603
1604 exports.intersects = intersects;
1605 function intersects (r1, r2, options) {
1606 r1 = new Range(r1, options);
1607 r2 = new Range(r2, options);
1608 return r1.intersects(r2)
1609 }
1610
1611 exports.coerce = coerce;
1612 function coerce (version, options) {
1613 if (version instanceof SemVer) {
1614 return version
1615 }
1616
1617 if (typeof version === 'number') {
1618 version = String(version);
1619 }
1620
1621 if (typeof version !== 'string') {
1622 return null
1623 }
1624
1625 options = options || {};
1626
1627 var match = null;
1628 if (!options.rtl) {
1629 match = version.match(re[t.COERCE]);
1630 } else {
1631 // Find the right-most coercible string that does not share
1632 // a terminus with a more left-ward coercible string.
1633 // Eg, '1.2.3.4' wants to coerce '2.3.4', not '3.4' or '4'
1634 //
1635 // Walk through the string checking with a /g regexp
1636 // Manually set the index so as to pick up overlapping matches.
1637 // Stop when we get a match that ends at the string end, since no
1638 // coercible string can be more right-ward without the same terminus.
1639 var next;
1640 while ((next = re[t.COERCERTL].exec(version)) &&
1641 (!match || match.index + match[0].length !== version.length)
1642 ) {
1643 if (!match ||
1644 next.index + next[0].length !== match.index + match[0].length) {
1645 match = next;
1646 }
1647 re[t.COERCERTL].lastIndex = next.index + next[1].length + next[2].length;
1648 }
1649 // leave it in a clean state
1650 re[t.COERCERTL].lastIndex = -1;
1651 }
1652
1653 if (match === null) {
1654 return null
1655 }
1656
1657 return parse(match[2] +
1658 '.' + (match[3] || '0') +
1659 '.' + (match[4] || '0'), options)
1660 }
1661 });
1662 var semver_1 = semver.SEMVER_SPEC_VERSION;
1663 var semver_2 = semver.re;
1664 var semver_3 = semver.src;
1665 var semver_4 = semver.tokens;
1666 var semver_5 = semver.parse;
1667 var semver_6 = semver.valid;
1668 var semver_7 = semver.clean;
1669 var semver_8 = semver.SemVer;
1670 var semver_9 = semver.inc;
1671 var semver_10 = semver.diff;
1672 var semver_11 = semver.compareIdentifiers;
1673 var semver_12 = semver.rcompareIdentifiers;
1674 var semver_13 = semver.major;
1675 var semver_14 = semver.minor;
1676 var semver_15 = semver.patch;
1677 var semver_16 = semver.compare;
1678 var semver_17 = semver.compareLoose;
1679 var semver_18 = semver.compareBuild;
1680 var semver_19 = semver.rcompare;
1681 var semver_20 = semver.sort;
1682 var semver_21 = semver.rsort;
1683 var semver_22 = semver.gt;
1684 var semver_23 = semver.lt;
1685 var semver_24 = semver.eq;
1686 var semver_25 = semver.neq;
1687 var semver_26 = semver.gte;
1688 var semver_27 = semver.lte;
1689 var semver_28 = semver.cmp;
1690 var semver_29 = semver.Comparator;
1691 var semver_30 = semver.Range;
1692 var semver_31 = semver.toComparators;
1693 var semver_32 = semver.satisfies;
1694 var semver_33 = semver.maxSatisfying;
1695 var semver_34 = semver.minSatisfying;
1696 var semver_35 = semver.minVersion;
1697 var semver_36 = semver.validRange;
1698 var semver_37 = semver.ltr;
1699 var semver_38 = semver.gtr;
1700 var semver_39 = semver.outside;
1701 var semver_40 = semver.prerelease;
1702 var semver_41 = semver.intersects;
1703 var semver_42 = semver.coerce;
1704
1705 var NAME_SELECTOR = 'NAME_SELECTOR';
1706 var COMPONENT_SELECTOR = 'COMPONENT_SELECTOR';
1707 var REF_SELECTOR = 'REF_SELECTOR';
1708 var DOM_SELECTOR = 'DOM_SELECTOR';
1709 var INVALID_SELECTOR = 'INVALID_SELECTOR';
1710
1711 var VUE_VERSION = Number(
1712 ((Vue.version.split('.')[0]) + "." + (Vue.version.split('.')[1]))
1713 );
1714
1715 var FUNCTIONAL_OPTIONS =
1716 VUE_VERSION >= 2.5 ? 'fnOptions' : 'functionalOptions';
1717
1718 var BEFORE_RENDER_LIFECYCLE_HOOK = semver.gt(Vue.version, '2.1.8')
1719 ? 'beforeCreate'
1720 : 'beforeMount';
1721
1722 var CREATE_ELEMENT_ALIAS = semver.gt(Vue.version, '2.1.5')
1723 ? '_c'
1724 : '_h';
1725
1726 //
1727
1728 function throwError(msg) {
1729 throw new Error(("[vue-test-utils]: " + msg))
1730 }
1731
1732 function warn(msg) {
1733 console.error(("[vue-test-utils]: " + msg));
1734 }
1735
1736 var camelizeRE = /-(\w)/g;
1737
1738 var camelize = function (str) {
1739 var camelizedStr = str.replace(camelizeRE, function (_, c) { return c ? c.toUpperCase() : ''; }
1740 );
1741 return camelizedStr.charAt(0).toLowerCase() + camelizedStr.slice(1)
1742 };
1743
1744 /**
1745 * Capitalize a string.
1746 */
1747 var capitalize = function (str) { return str.charAt(0).toUpperCase() + str.slice(1); };
1748
1749 /**
1750 * Hyphenate a camelCase string.
1751 */
1752 var hyphenateRE = /\B([A-Z])/g;
1753 var hyphenate = function (str) { return str.replace(hyphenateRE, '-$1').toLowerCase(); };
1754
1755 function hasOwnProperty(obj, prop) {
1756 return Object.prototype.hasOwnProperty.call(obj, prop)
1757 }
1758
1759 function keys(obj) {
1760 return Object.keys(obj)
1761 }
1762
1763 function resolveComponent(id, components) {
1764 if (typeof id !== 'string') {
1765 return
1766 }
1767 // check local registration variations first
1768 if (hasOwnProperty(components, id)) {
1769 return components[id]
1770 }
1771 var camelizedId = camelize(id);
1772 if (hasOwnProperty(components, camelizedId)) {
1773 return components[camelizedId]
1774 }
1775 var PascalCaseId = capitalize(camelizedId);
1776 if (hasOwnProperty(components, PascalCaseId)) {
1777 return components[PascalCaseId]
1778 }
1779 // fallback to prototype chain
1780 return components[id] || components[camelizedId] || components[PascalCaseId]
1781 }
1782
1783 var UA =
1784 typeof window !== 'undefined' &&
1785 'navigator' in window &&
1786 navigator.userAgent.toLowerCase();
1787
1788 var isPhantomJS = UA && UA.includes && UA.match(/phantomjs/i);
1789
1790 var isEdge = UA && UA.indexOf('edge/') > 0;
1791 var isChrome = UA && /chrome\/\d+/.test(UA) && !isEdge;
1792
1793 // get the event used to trigger v-model handler that updates bound data
1794 function getCheckedEvent() {
1795 var version = Vue.version;
1796
1797 if (semver.satisfies(version, '2.1.9 - 2.1.10')) {
1798 return 'click'
1799 }
1800
1801 if (semver.satisfies(version, '2.2 - 2.4')) {
1802 return isChrome ? 'click' : 'change'
1803 }
1804
1805 // change is handler for version 2.0 - 2.1.8, and 2.5+
1806 return 'change'
1807 }
1808
1809 /**
1810 * Normalize nextTick to return a promise for all Vue 2 versions.
1811 * Vue < 2.1 does not return a Promise from nextTick
1812 * @return {Promise<R>}
1813 */
1814 function nextTick() {
1815 if (VUE_VERSION > 2) { return Vue.nextTick() }
1816 return new Promise(function (resolve) {
1817 Vue.nextTick(resolve);
1818 })
1819 }
1820
1821 function warnDeprecated(method, fallback) {
1822 if ( fallback === void 0 ) fallback = '';
1823
1824 if (!config.showDeprecationWarnings) { return }
1825 var msg = method + " is deprecated and will be removed in the next major version.";
1826 if (fallback) { msg += " " + fallback + "."; }
1827 warn(msg);
1828 }
1829
1830 //
1831
1832 function addMocks(
1833 _Vue,
1834 mockedProperties
1835 ) {
1836 if ( mockedProperties === void 0 ) mockedProperties = {};
1837
1838 if (mockedProperties === false) {
1839 return
1840 }
1841 Object.keys(mockedProperties).forEach(function (key) {
1842 try {
1843 // $FlowIgnore
1844 _Vue.prototype[key] = mockedProperties[key];
1845 } catch (e) {
1846 warn(
1847 "could not overwrite property " + key + ", this is " +
1848 "usually caused by a plugin that has added " +
1849 "the property as a read-only value"
1850 );
1851 }
1852 // $FlowIgnore
1853 Vue.util.defineReactive(_Vue, key, mockedProperties[key]);
1854 });
1855 }
1856
1857 //
1858
1859 function logEvents(
1860 vm,
1861 emitted,
1862 emittedByOrder
1863 ) {
1864 var emit = vm.$emit;
1865 vm.$emit = function (name) {
1866 var args = [], len = arguments.length - 1;
1867 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
1868 (emitted[name] || (emitted[name] = [])).push(args);
1869 emittedByOrder.push({ name: name, args: args });
1870 return emit.call.apply(emit, [ vm, name ].concat( args ))
1871 };
1872 }
1873
1874 function addEventLogger(_Vue) {
1875 _Vue.mixin({
1876 beforeCreate: function() {
1877 this.__emitted = Object.create(null);
1878 this.__emittedByOrder = [];
1879 logEvents(this, this.__emitted, this.__emittedByOrder);
1880 }
1881 });
1882 }
1883
1884 function addStubs(_Vue, stubComponents) {
1885 var obj;
1886
1887 function addStubComponentsMixin() {
1888 Object.assign(this.$options.components, stubComponents);
1889 }
1890
1891 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = addStubComponentsMixin, obj ));
1892 }
1893
1894 //
1895
1896 function isDomSelector(selector) {
1897 if (typeof selector !== 'string') {
1898 return false
1899 }
1900
1901 try {
1902 if (typeof document === 'undefined') {
1903 throwError(
1904 "mount must be run in a browser environment like " +
1905 "PhantomJS, jsdom or chrome"
1906 );
1907 }
1908 } catch (error) {
1909 throwError(
1910 "mount must be run in a browser environment like " +
1911 "PhantomJS, jsdom or chrome"
1912 );
1913 }
1914
1915 try {
1916 document.querySelector(selector);
1917 return true
1918 } catch (error) {
1919 return false
1920 }
1921 }
1922
1923 function isVueComponent(c) {
1924 if (isConstructor(c)) {
1925 return true
1926 }
1927
1928 if (c === null || typeof c !== 'object') {
1929 return false
1930 }
1931
1932 if (c.extends || c._Ctor) {
1933 return true
1934 }
1935
1936 if (typeof c.template === 'string') {
1937 return true
1938 }
1939
1940 return typeof c.render === 'function'
1941 }
1942
1943 function componentNeedsCompiling(component) {
1944 return (
1945 component &&
1946 !component.render &&
1947 (component.template || component.extends || component.extendOptions) &&
1948 !component.functional
1949 )
1950 }
1951
1952 function isRefSelector(refOptionsObject) {
1953 if (
1954 typeof refOptionsObject !== 'object' ||
1955 Object.keys(refOptionsObject || {}).length !== 1
1956 ) {
1957 return false
1958 }
1959
1960 return typeof refOptionsObject.ref === 'string'
1961 }
1962
1963 function isNameSelector(nameOptionsObject) {
1964 if (typeof nameOptionsObject !== 'object' || nameOptionsObject === null) {
1965 return false
1966 }
1967
1968 return !!nameOptionsObject.name
1969 }
1970
1971 function isConstructor(c) {
1972 return typeof c === 'function' && c.cid
1973 }
1974
1975 function isDynamicComponent(c) {
1976 return typeof c === 'function' && !c.cid
1977 }
1978
1979 function isComponentOptions(c) {
1980 return typeof c === 'object' && (c.template || c.render)
1981 }
1982
1983 function isFunctionalComponent(c) {
1984 if (!isVueComponent(c)) {
1985 return false
1986 }
1987 if (isConstructor(c)) {
1988 return c.options.functional
1989 }
1990 return c.functional
1991 }
1992
1993 function templateContainsComponent(
1994 template,
1995 name
1996 ) {
1997 return [capitalize, camelize, hyphenate].some(function (format) {
1998 var re = new RegExp(("<" + (format(name)) + "\\s*(\\s|>|(/>))"), 'g');
1999 return re.test(template)
2000 })
2001 }
2002
2003 function isPlainObject(c) {
2004 return Object.prototype.toString.call(c) === '[object Object]'
2005 }
2006
2007 function isHTMLElement(c) {
2008 if (typeof HTMLElement === 'undefined') {
2009 return false
2010 }
2011 // eslint-disable-next-line no-undef
2012 return c instanceof HTMLElement
2013 }
2014
2015 function makeMap(str, expectsLowerCase) {
2016 var map = Object.create(null);
2017 var list = str.split(',');
2018 for (var i = 0; i < list.length; i++) {
2019 map[list[i]] = true;
2020 }
2021 return expectsLowerCase
2022 ? function(val) {
2023 return map[val.toLowerCase()]
2024 }
2025 : function(val) {
2026 return map[val]
2027 }
2028 }
2029
2030 var isHTMLTag = makeMap(
2031 'html,body,base,head,link,meta,style,title,' +
2032 'address,article,aside,footer,header,h1,h2,h3,h4,h5,h6,hgroup,nav,section,' +
2033 'div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,' +
2034 'a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,rtc,ruby,' +
2035 's,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,' +
2036 'embed,object,param,source,canvas,script,noscript,del,ins,' +
2037 'caption,col,colgroup,table,thead,tbody,td,th,tr,video,' +
2038 'button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,' +
2039 'output,progress,select,textarea,' +
2040 'details,dialog,menu,menuitem,summary,' +
2041 'content,element,shadow,template,blockquote,iframe,tfoot'
2042 );
2043
2044 // this map is intentionally selective, only covering SVG elements that may
2045 // contain child elements.
2046 var isSVG = makeMap(
2047 'svg,animate,circle,clippath,cursor,defs,desc,ellipse,filter,font-face,' +
2048 'foreignObject,g,glyph,image,line,marker,mask,missing-glyph,path,pattern,' +
2049 'polygon,polyline,rect,switch,symbol,text,textpath,tspan,use,view',
2050 true
2051 );
2052
2053 var isReservedTag = function (tag) { return isHTMLTag(tag) || isSVG(tag); };
2054
2055 //
2056
2057 function compileTemplate(component) {
2058 if (component.template) {
2059 if (!vueTemplateCompiler.compileToFunctions) {
2060 throwError(
2061 "vueTemplateCompiler is undefined, you must pass " +
2062 "precompiled components if vue-template-compiler is " +
2063 "undefined"
2064 );
2065 }
2066
2067 if (component.template.charAt('#') === '#') {
2068 var el = document.querySelector(component.template);
2069 if (!el) {
2070 throwError('Cannot find element' + component.template);
2071
2072 el = document.createElement('div');
2073 }
2074 component.template = el.innerHTML;
2075 }
2076
2077 Object.assign(component, Object.assign({}, vueTemplateCompiler.compileToFunctions(component.template),
2078 {name: component.name}));
2079 }
2080
2081 if (component.components) {
2082 Object.keys(component.components).forEach(function (c) {
2083 var cmp = component.components[c];
2084 if (!cmp.render) {
2085 compileTemplate(cmp);
2086 }
2087 });
2088 }
2089
2090 if (component.extends) {
2091 compileTemplate(component.extends);
2092 }
2093
2094 if (component.extendOptions && !component.options.render) {
2095 compileTemplate(component.options);
2096 }
2097 }
2098
2099 function compileTemplateForSlots(slots) {
2100 Object.keys(slots).forEach(function (key) {
2101 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
2102 slot.forEach(function (slotValue) {
2103 if (componentNeedsCompiling(slotValue)) {
2104 compileTemplate(slotValue);
2105 }
2106 });
2107 });
2108 }
2109
2110 //
2111
2112 var MOUNTING_OPTIONS = [
2113 'attachToDocument',
2114 'mocks',
2115 'slots',
2116 'localVue',
2117 'stubs',
2118 'context',
2119 'clone',
2120 'attrs',
2121 'listeners',
2122 'propsData',
2123 'shouldProxy'
2124 ];
2125
2126 function extractInstanceOptions(options) {
2127 var instanceOptions = Object.assign({}, options);
2128 MOUNTING_OPTIONS.forEach(function (mountingOption) {
2129 delete instanceOptions[mountingOption];
2130 });
2131 return instanceOptions
2132 }
2133
2134 //
2135
2136 function isDestructuringSlotScope(slotScope) {
2137 return /^{.*}$/.test(slotScope)
2138 }
2139
2140 function getVueTemplateCompilerHelpers(
2141 _Vue
2142 ) {
2143 // $FlowIgnore
2144 var vue = new _Vue();
2145 var helpers = {};
2146 var names = [
2147 '_c',
2148 '_o',
2149 '_n',
2150 '_s',
2151 '_l',
2152 '_t',
2153 '_q',
2154 '_i',
2155 '_m',
2156 '_f',
2157 '_k',
2158 '_b',
2159 '_v',
2160 '_e',
2161 '_u',
2162 '_g'
2163 ];
2164 names.forEach(function (name) {
2165 helpers[name] = vue._renderProxy[name];
2166 });
2167 helpers.$createElement = vue._renderProxy.$createElement;
2168 helpers.$set = vue._renderProxy.$set;
2169 return helpers
2170 }
2171
2172 function validateEnvironment() {
2173 if (VUE_VERSION < 2.1) {
2174 throwError("the scopedSlots option is only supported in vue@2.1+.");
2175 }
2176 }
2177
2178 function isScopedSlot(slot) {
2179 if (typeof slot === 'function') { return { match: null, slot: slot } }
2180
2181 var slotScopeRe = /<[^>]+ slot-scope="(.+)"/;
2182 var vSlotRe = /<template v-slot(?::.+)?="(.+)"/;
2183 var shortVSlotRe = /<template #.*="(.+)"/;
2184
2185 var hasOldSlotScope = slot.match(slotScopeRe);
2186 var hasVSlotScopeAttr = slot.match(vSlotRe);
2187 var hasShortVSlotScopeAttr = slot.match(shortVSlotRe);
2188
2189 if (hasOldSlotScope) {
2190 return { slot: slot, match: hasOldSlotScope }
2191 } else if (hasVSlotScopeAttr || hasShortVSlotScopeAttr) {
2192 // Strip v-slot and #slot attributes from `template` tag. compileToFunctions leaves empty `template` tag otherwise.
2193 var sanitizedSlot = slot.replace(
2194 /(<template)([^>]+)(>.+<\/template>)/,
2195 '$1$3'
2196 );
2197 return {
2198 slot: sanitizedSlot,
2199 match: hasVSlotScopeAttr || hasShortVSlotScopeAttr
2200 }
2201 }
2202 // we have no matches, so we just return
2203 return {
2204 slot: slot,
2205 match: null
2206 }
2207 }
2208
2209 // Hide warning about <template> disallowed as root element
2210 function customWarn(msg) {
2211 if (msg.indexOf('Cannot use <template> as component root element') === -1) {
2212 console.error(msg);
2213 }
2214 }
2215
2216 function createScopedSlots(
2217 scopedSlotsOption,
2218 _Vue
2219 ) {
2220 var scopedSlots = {};
2221 if (!scopedSlotsOption) {
2222 return scopedSlots
2223 }
2224 validateEnvironment();
2225 var helpers = getVueTemplateCompilerHelpers(_Vue);
2226 var loop = function ( scopedSlotName ) {
2227 var slot = scopedSlotsOption[scopedSlotName];
2228 var isFn = typeof slot === 'function';
2229
2230 var scopedSlotMatches = isScopedSlot(slot);
2231
2232 // Type check to silence flow (can't use isFn)
2233 var renderFn =
2234 typeof slot === 'function'
2235 ? slot
2236 : vueTemplateCompiler.compileToFunctions(scopedSlotMatches.slot, { warn: customWarn })
2237 .render;
2238
2239 var slotScope = scopedSlotMatches.match && scopedSlotMatches.match[1];
2240
2241 scopedSlots[scopedSlotName] = function(props) {
2242 var obj;
2243
2244 var res;
2245 if (isFn) {
2246 res = renderFn.call(Object.assign({}, helpers), props);
2247 } else if (slotScope && !isDestructuringSlotScope(slotScope)) {
2248 res = renderFn.call(Object.assign({}, helpers, ( obj = {}, obj[slotScope] = props, obj )));
2249 } else if (slotScope && isDestructuringSlotScope(slotScope)) {
2250 res = renderFn.call(Object.assign({}, helpers, props));
2251 } else {
2252 res = renderFn.call(Object.assign({}, helpers, {props: props}));
2253 }
2254 // res is Array if <template> is a root element
2255 return Array.isArray(res) ? res[0] : res
2256 };
2257 };
2258
2259 for (var scopedSlotName in scopedSlotsOption) loop( scopedSlotName );
2260 return scopedSlots
2261 }
2262
2263 //
2264
2265 function isVueComponentStub(comp) {
2266 return (comp && comp.template) || isVueComponent(comp)
2267 }
2268
2269 function isValidStub(stub) {
2270 return (
2271 typeof stub === 'boolean' ||
2272 (!!stub && typeof stub === 'string') ||
2273 isVueComponentStub(stub)
2274 )
2275 }
2276
2277 function resolveComponent$1(obj, component) {
2278 return (
2279 obj[component] ||
2280 obj[hyphenate(component)] ||
2281 obj[camelize(component)] ||
2282 obj[capitalize(camelize(component))] ||
2283 obj[capitalize(component)] ||
2284 {}
2285 )
2286 }
2287
2288 function getCoreProperties(componentOptions) {
2289 return {
2290 attrs: componentOptions.attrs,
2291 name: componentOptions.name,
2292 model: componentOptions.model,
2293 props: componentOptions.props,
2294 on: componentOptions.on,
2295 key: componentOptions.key,
2296 domProps: componentOptions.domProps,
2297 class: componentOptions.class,
2298 staticClass: componentOptions.staticClass,
2299 staticStyle: componentOptions.staticStyle,
2300 style: componentOptions.style,
2301 normalizedStyle: componentOptions.normalizedStyle,
2302 nativeOn: componentOptions.nativeOn,
2303 functional: componentOptions.functional
2304 }
2305 }
2306
2307 function createClassString(staticClass, dynamicClass) {
2308 // :class="someComputedObject" can return a string, object or undefined
2309 // if it is a string, we don't need to do anything special.
2310 var evaluatedDynamicClass = dynamicClass;
2311
2312 // if it is an object, eg { 'foo': true }, we need to evaluate it.
2313 // see https://github.com/vuejs/vue-test-utils/issues/1474 for more context.
2314 if (typeof dynamicClass === 'object') {
2315 evaluatedDynamicClass = Object.keys(dynamicClass).reduce(function (acc, key) {
2316 if (dynamicClass[key]) {
2317 return acc + ' ' + key
2318 }
2319 return acc
2320 }, '');
2321 }
2322
2323 if (staticClass && evaluatedDynamicClass) {
2324 return staticClass + ' ' + evaluatedDynamicClass
2325 }
2326 return staticClass || evaluatedDynamicClass
2327 }
2328
2329 function resolveOptions(component, _Vue) {
2330 if (isDynamicComponent(component)) {
2331 return {}
2332 }
2333
2334 return isConstructor(component)
2335 ? component.options
2336 : _Vue.extend(component).options
2337 }
2338
2339 function getScopedSlotRenderFunctions(ctx) {
2340 // In Vue 2.6+ a new v-slot syntax was introduced
2341 // scopedSlots are now saved in parent._vnode.data.scopedSlots
2342 // We filter out the _normalized and $stable key
2343 if (
2344 ctx &&
2345 ctx.$options &&
2346 ctx.$options.parent &&
2347 ctx.$options.parent._vnode &&
2348 ctx.$options.parent._vnode.data &&
2349 ctx.$options.parent._vnode.data.scopedSlots
2350 ) {
2351 var slotKeys = ctx.$options.parent._vnode.data.scopedSlots;
2352 return keys(slotKeys).filter(function (x) { return x !== '_normalized' && x !== '$stable'; })
2353 }
2354
2355 return []
2356 }
2357
2358 function createStubFromComponent(
2359 originalComponent,
2360 name,
2361 _Vue
2362 ) {
2363 var componentOptions = resolveOptions(originalComponent, _Vue);
2364 var tagName = (name || 'anonymous') + "-stub";
2365
2366 // ignoreElements does not exist in Vue 2.0.x
2367 if (Vue.config.ignoredElements) {
2368 Vue.config.ignoredElements.push(tagName);
2369 }
2370
2371 return Object.assign({}, getCoreProperties(componentOptions),
2372 {$_vueTestUtils_original: originalComponent,
2373 $_doNotStubChildren: true,
2374 render: function render(h, context) {
2375 var this$1 = this;
2376
2377 return h(
2378 tagName,
2379 {
2380 ref: componentOptions.functional ? context.data.ref : undefined,
2381 attrs: componentOptions.functional
2382 ? Object.assign({}, context.props,
2383 context.data.attrs,
2384 {class: createClassString(
2385 context.data.staticClass,
2386 context.data.class
2387 )})
2388 : Object.assign({}, this.$props)
2389 },
2390 context
2391 ? context.children
2392 : this.$options._renderChildren ||
2393 getScopedSlotRenderFunctions(this).map(function (x) { return this$1.$options.parent._vnode.data.scopedSlots[x](); }
2394 )
2395 )
2396 }})
2397 }
2398
2399 // DEPRECATED: converts string stub to template stub.
2400 function createStubFromString(templateString, name) {
2401 warnDeprecated('Using a string for stubs');
2402
2403 if (templateContainsComponent(templateString, name)) {
2404 throwError('options.stub cannot contain a circular reference');
2405 }
2406
2407 return {
2408 template: templateString,
2409 $_doNotStubChildren: true
2410 }
2411 }
2412
2413 function setStubComponentName(
2414 stub,
2415 originalComponent,
2416 _Vue
2417 ) {
2418 if ( originalComponent === void 0 ) originalComponent = {};
2419
2420 if (stub.name) { return }
2421
2422 var componentOptions = resolveOptions(originalComponent, _Vue);
2423 stub.name = getCoreProperties(componentOptions).name;
2424 }
2425
2426 function validateStub(stub) {
2427 if (!isValidStub(stub)) {
2428 throwError("options.stub values must be passed a string or " + "component");
2429 }
2430 }
2431
2432 function createStubsFromStubsObject(
2433 originalComponents,
2434 stubs,
2435 _Vue
2436 ) {
2437 if ( originalComponents === void 0 ) originalComponents = {};
2438
2439 return Object.keys(stubs || {}).reduce(function (acc, stubName) {
2440 var stub = stubs[stubName];
2441
2442 validateStub(stub);
2443
2444 if (stub === false) {
2445 return acc
2446 }
2447
2448 var component = resolveComponent$1(originalComponents, stubName);
2449
2450 if (stub === true) {
2451 acc[stubName] = createStubFromComponent(component, stubName, _Vue);
2452 return acc
2453 }
2454
2455 if (typeof stub === 'string') {
2456 stub = createStubFromString(stub, stubName);
2457 stubs[stubName];
2458 }
2459
2460 setStubComponentName(stub, component, _Vue);
2461 if (componentNeedsCompiling(stub)) {
2462 compileTemplate(stub);
2463 }
2464
2465 acc[stubName] = stub;
2466 stub._Ctor = {};
2467
2468 return acc
2469 }, {})
2470 }
2471
2472 var isAllowlisted = function (el, allowlist) { return resolveComponent(el, allowlist); };
2473 var isAlreadyStubbed = function (el, stubs) { return stubs.has(el); };
2474
2475 function shouldExtend(component, _Vue) {
2476 return isConstructor(component) || (component && component.extends)
2477 }
2478
2479 function extend(component, _Vue) {
2480 var componentOptions = component.options ? component.options : component;
2481 var stub = _Vue.extend(componentOptions);
2482 stub.options.$_vueTestUtils_original = component;
2483 stub.options._base = _Vue;
2484 return stub
2485 }
2486
2487 function createStubIfNeeded(shouldStub, component, _Vue, el) {
2488 if (shouldStub) {
2489 return createStubFromComponent(component || {}, el, _Vue)
2490 }
2491
2492 if (shouldExtend(component)) {
2493 return extend(component, _Vue)
2494 }
2495 }
2496
2497 function shouldNotBeStubbed(el, allowlist, modifiedComponents) {
2498 return (
2499 (typeof el === 'string' && isReservedTag(el)) ||
2500 isAllowlisted(el, allowlist) ||
2501 isAlreadyStubbed(el, modifiedComponents)
2502 )
2503 }
2504
2505 function patchCreateElement(_Vue, stubs, stubAllComponents) {
2506 var obj;
2507
2508 // This mixin patches vm.$createElement so that we can stub all components
2509 // before they are rendered in shallow mode. We also need to ensure that
2510 // component constructors were created from the _Vue constructor. If not,
2511 // we must replace them with components created from the _Vue constructor
2512 // before calling the original $createElement. This ensures that components
2513 // have the correct instance properties and stubs when they are rendered.
2514 function patchCreateElementMixin() {
2515 var vm = this;
2516
2517 if (vm.$options.$_doNotStubChildren || vm.$options._isFunctionalContainer) {
2518 return
2519 }
2520
2521 var modifiedComponents = new Set();
2522 var originalCreateElement = vm.$createElement;
2523 var originalComponents = vm.$options.components;
2524
2525 var createElement = function (el) {
2526 var obj;
2527
2528 var args = [], len = arguments.length - 1;
2529 while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ];
2530 if (shouldNotBeStubbed(el, stubs, modifiedComponents)) {
2531 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2532 }
2533
2534 if (isConstructor(el) || isComponentOptions(el)) {
2535 if (stubAllComponents) {
2536 var stub = createStubFromComponent(el, el.name || 'anonymous', _Vue);
2537 return originalCreateElement.apply(void 0, [ stub ].concat( args ))
2538 }
2539 var Constructor = shouldExtend(el) ? extend(el, _Vue) : el;
2540
2541 return originalCreateElement.apply(void 0, [ Constructor ].concat( args ))
2542 }
2543
2544 if (typeof el === 'string') {
2545 var original = resolveComponent(el, originalComponents);
2546
2547 if (!original) {
2548 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2549 }
2550
2551 if (isDynamicComponent(original)) {
2552 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2553 }
2554
2555 var stub$1 = createStubIfNeeded(stubAllComponents, original, _Vue, el);
2556
2557 if (stub$1) {
2558 Object.assign(vm.$options.components, ( obj = {}, obj[el] = stub$1, obj ));
2559 modifiedComponents.add(el);
2560 }
2561 }
2562
2563 return originalCreateElement.apply(void 0, [ el ].concat( args ))
2564 };
2565
2566 vm[CREATE_ELEMENT_ALIAS] = createElement;
2567 vm.$createElement = createElement;
2568 }
2569
2570 _Vue.mixin(( obj = {}, obj[BEFORE_RENDER_LIFECYCLE_HOOK] = patchCreateElementMixin, obj ));
2571 }
2572
2573 //
2574
2575 function createContext(options, scopedSlots) {
2576 var on = Object.assign({}, (options.context && options.context.on),
2577 options.listeners);
2578 return Object.assign({}, {attrs: Object.assign({}, options.attrs,
2579 // pass as attrs so that inheritAttrs works correctly
2580 // propsData should take precedence over attrs
2581 options.propsData)},
2582 (options.context || {}),
2583 {on: on,
2584 scopedSlots: scopedSlots})
2585 }
2586
2587 function createChildren(vm, h, ref) {
2588 var slots = ref.slots;
2589 var context = ref.context;
2590
2591 var slotVNodes = slots ? createSlotVNodes(vm, slots) : undefined;
2592 return (
2593 (context &&
2594 context.children &&
2595 context.children.map(function (x) { return (typeof x === 'function' ? x(h) : x); })) ||
2596 slotVNodes
2597 )
2598 }
2599
2600 function getValuesFromCallableOption(optionValue) {
2601 if (typeof optionValue === 'function') {
2602 return optionValue.call(this)
2603 }
2604 return optionValue
2605 }
2606
2607 function createInstance(
2608 component,
2609 options,
2610 _Vue
2611 ) {
2612 var componentOptions = isConstructor(component)
2613 ? component.options
2614 : component;
2615
2616 // instance options are options that are passed to the
2617 // root instance when it's instantiated
2618 var instanceOptions = extractInstanceOptions(options);
2619
2620 var globalComponents = _Vue.options.components || {};
2621 var componentsToStub = Object.assign(
2622 Object.create(globalComponents),
2623 componentOptions.components
2624 );
2625
2626 var stubComponentsObject = createStubsFromStubsObject(
2627 componentsToStub,
2628 // $FlowIgnore
2629 options.stubs,
2630 _Vue
2631 );
2632
2633 addEventLogger(_Vue);
2634 addMocks(_Vue, options.mocks);
2635 addStubs(_Vue, stubComponentsObject);
2636 patchCreateElement(_Vue, stubComponentsObject, options.shouldProxy);
2637
2638 if (componentNeedsCompiling(componentOptions)) {
2639 compileTemplate(componentOptions);
2640 }
2641
2642 // used to identify extended component using constructor
2643 componentOptions.$_vueTestUtils_original = component;
2644
2645 // watchers provided in mounting options should override preexisting ones
2646 if (componentOptions.watch && instanceOptions.watch) {
2647 var componentWatchers = Object.keys(componentOptions.watch);
2648 var instanceWatchers = Object.keys(instanceOptions.watch);
2649
2650 for (var i = 0; i < instanceWatchers.length; i++) {
2651 var k = instanceWatchers[i];
2652 // override the componentOptions with the one provided in mounting options
2653 if (componentWatchers.includes(k)) {
2654 componentOptions.watch[k] = instanceOptions.watch[k];
2655 }
2656 }
2657 }
2658
2659 // make sure all extends are based on this instance
2660 var Constructor = _Vue.extend(componentOptions).extend(instanceOptions);
2661 Constructor.options._base = _Vue;
2662
2663 var scopedSlots = createScopedSlots(options.scopedSlots, _Vue);
2664
2665 var parentComponentOptions = options.parentComponent || {};
2666
2667 var originalParentComponentProvide = parentComponentOptions.provide;
2668 parentComponentOptions.provide = function() {
2669 return Object.assign({}, getValuesFromCallableOption.call(this, originalParentComponentProvide),
2670 getValuesFromCallableOption.call(this, options.provide))
2671 };
2672
2673 parentComponentOptions.$_doNotStubChildren = true;
2674 parentComponentOptions._isFunctionalContainer = componentOptions.functional;
2675 parentComponentOptions.render = function(h) {
2676 return h(
2677 Constructor,
2678 createContext(options, scopedSlots),
2679 createChildren(this, h, options)
2680 )
2681 };
2682 var Parent = _Vue.extend(parentComponentOptions);
2683
2684 return new Parent()
2685 }
2686
2687 //
2688
2689 function createElement() {
2690 if (document) {
2691 var elem = document.createElement('div');
2692
2693 if (document.body) {
2694 document.body.appendChild(elem);
2695 }
2696 return elem
2697 }
2698 }
2699
2700 //
2701
2702 function findDOMNodes(
2703 element,
2704 selector
2705 ) {
2706 var nodes = [];
2707 if (!element || !element.querySelectorAll || !element.matches) {
2708 return nodes
2709 }
2710
2711 if (element.matches(selector)) {
2712 nodes.push(element);
2713 }
2714 // $FlowIgnore
2715 return nodes.concat([].slice.call(element.querySelectorAll(selector)))
2716 }
2717
2718 function vmMatchesName(vm, name) {
2719 // We want to mirror how Vue resolves component names in SFCs:
2720 // For example, <test-component />, <TestComponent /> and `<testComponent />
2721 // all resolve to the same component
2722 var componentName = (vm.$options && vm.$options.name) || '';
2723 return (
2724 !!name &&
2725 (componentName === name ||
2726 // testComponent -> TestComponent
2727 componentName === capitalize(name) ||
2728 // test-component -> TestComponent
2729 componentName === capitalize(camelize(name)) ||
2730 // same match as above, but the component name vs query
2731 capitalize(camelize(componentName)) === name)
2732 )
2733 }
2734
2735 function vmCtorMatches(vm, component) {
2736 if (
2737 (vm.$options && vm.$options.$_vueTestUtils_original === component) ||
2738 vm.$_vueTestUtils_original === component
2739 ) {
2740 return true
2741 }
2742
2743 var Ctor = isConstructor(component)
2744 ? component.options._Ctor
2745 : component._Ctor;
2746
2747 if (!Ctor) {
2748 return false
2749 }
2750
2751 if (vm.constructor.extendOptions === component) {
2752 return true
2753 }
2754
2755 if (component.functional) {
2756 return Object.keys(vm._Ctor || {}).some(function (c) {
2757 return component === vm._Ctor[c].extendOptions
2758 })
2759 }
2760 }
2761
2762 function matches(node, selector) {
2763 if (selector.type === DOM_SELECTOR) {
2764 var element = node instanceof Element ? node : node.elm;
2765 return element && element.matches && element.matches(selector.value)
2766 }
2767
2768 var isFunctionalSelector = isConstructor(selector.value)
2769 ? selector.value.options.functional
2770 : selector.value.functional;
2771
2772 var componentInstance = isFunctionalSelector
2773 ? node[FUNCTIONAL_OPTIONS]
2774 : node.child;
2775
2776 if (!componentInstance) {
2777 return false
2778 }
2779
2780 if (selector.type === COMPONENT_SELECTOR) {
2781 if (vmCtorMatches(componentInstance, selector.value)) {
2782 return true
2783 }
2784 }
2785
2786 // Fallback to name selector for COMPONENT_SELECTOR for Vue < 2.1
2787 var nameSelector = isConstructor(selector.value)
2788 ? selector.value.extendOptions.name
2789 : selector.value.name;
2790 return vmMatchesName(componentInstance, nameSelector)
2791 }
2792
2793 //
2794
2795 function findAllInstances(rootVm) {
2796 var instances = [rootVm];
2797 var i = 0;
2798 while (i < instances.length) {
2799 var vm = instances[i]
2800 ;(vm.$children || []).forEach(function (child) {
2801 instances.push(child);
2802 });
2803 i++;
2804 }
2805 return instances
2806 }
2807
2808 function findAllVNodes(vnode, selector) {
2809 var matchingNodes = [];
2810 var nodes = [vnode];
2811 while (nodes.length) {
2812 var node = nodes.shift();
2813 if (node.children) {
2814 var children = [].concat( node.children ).reverse();
2815 children.forEach(function (n) {
2816 nodes.unshift(n);
2817 });
2818 }
2819 if (node.child) {
2820 nodes.unshift(node.child._vnode);
2821 }
2822 if (matches(node, selector)) {
2823 matchingNodes.push(node);
2824 }
2825 }
2826
2827 return matchingNodes
2828 }
2829
2830 function removeDuplicateNodes(vNodes) {
2831 var vNodeElms = vNodes.map(function (vNode) { return vNode.elm; });
2832 return vNodes.filter(function (vNode, index) { return index === vNodeElms.indexOf(vNode.elm); })
2833 }
2834
2835 function find(
2836 root,
2837 vm,
2838 selector
2839 ) {
2840 if (root instanceof Element && selector.type !== DOM_SELECTOR) {
2841 throwError(
2842 "cannot find a Vue instance on a DOM node. The node " +
2843 "you are calling find on does not exist in the " +
2844 "VDom. Are you adding the node as innerHTML?"
2845 );
2846 }
2847
2848 if (
2849 selector.type === COMPONENT_SELECTOR &&
2850 (selector.value.functional ||
2851 (selector.value.options && selector.value.options.functional)) &&
2852 VUE_VERSION < 2.3
2853 ) {
2854 throwError(
2855 "find for functional components is not supported " + "in Vue < 2.3"
2856 );
2857 }
2858
2859 if (root instanceof Element) {
2860 return findDOMNodes(root, selector.value)
2861 }
2862
2863 if (!root && selector.type !== DOM_SELECTOR) {
2864 throwError(
2865 "cannot find a Vue instance on a DOM node. The node " +
2866 "you are calling find on does not exist in the " +
2867 "VDom. Are you adding the node as innerHTML?"
2868 );
2869 }
2870
2871 if (!vm && selector.type === REF_SELECTOR) {
2872 throwError("$ref selectors can only be used on Vue component " + "wrappers");
2873 }
2874
2875 if (vm && vm.$refs && selector.value.ref in vm.$refs) {
2876 var refs = vm.$refs[selector.value.ref];
2877 return Array.isArray(refs) ? refs : [refs]
2878 }
2879
2880 var nodes = findAllVNodes(root, selector);
2881 var dedupedNodes = removeDuplicateNodes(nodes);
2882
2883 if (nodes.length > 0 || selector.type !== DOM_SELECTOR) {
2884 return dedupedNodes
2885 }
2886
2887 // Fallback in case element exists in HTML, but not in vnode tree
2888 // (e.g. if innerHTML is set as a domProp)
2889 return findDOMNodes(root.elm, selector.value)
2890 }
2891
2892 function errorHandler(errorOrString, vm) {
2893 var error =
2894 typeof errorOrString === 'object' ? errorOrString : new Error(errorOrString);
2895
2896 vm._error = error;
2897 throw error
2898 }
2899
2900 function throwIfInstancesThrew(vm) {
2901 var instancesWithError = findAllInstances(vm).filter(function (_vm) { return _vm._error; });
2902
2903 if (instancesWithError.length > 0) {
2904 throw instancesWithError[0]._error
2905 }
2906 }
2907
2908 var hasWarned = false;
2909
2910 // Vue swallows errors thrown by instances, even if the global error handler
2911 // throws. In order to throw in the test, we add an _error property to an
2912 // instance when it throws. Then we loop through the instances with
2913 // throwIfInstancesThrew and throw an error in the test context if any
2914 // instances threw.
2915 function addGlobalErrorHandler(_Vue) {
2916 var existingErrorHandler = _Vue.config.errorHandler;
2917
2918 if (existingErrorHandler === errorHandler) {
2919 return
2920 }
2921
2922 if (_Vue.config.errorHandler && !hasWarned) {
2923 warn(
2924 "Global error handler detected (Vue.config.errorHandler). \n" +
2925 "Vue Test Utils sets a custom error handler to throw errors " +
2926 "thrown by instances. If you want this behavior in " +
2927 "your tests, you must remove the global error handler."
2928 );
2929 hasWarned = true;
2930 } else {
2931 _Vue.config.errorHandler = errorHandler;
2932 }
2933 }
2934
2935 function normalizeStubs(stubs) {
2936 if ( stubs === void 0 ) stubs = {};
2937
2938 if (stubs === false) {
2939 return false
2940 }
2941 if (isPlainObject(stubs)) {
2942 return stubs
2943 }
2944 if (Array.isArray(stubs)) {
2945 return stubs.reduce(function (acc, stub) {
2946 if (typeof stub !== 'string') {
2947 throwError('each item in an options.stubs array must be a string');
2948 }
2949 acc[stub] = true;
2950 return acc
2951 }, {})
2952 }
2953 throwError('options.stubs must be an object or an Array');
2954 }
2955
2956 function normalizeProvide(provide) {
2957 // Objects are not resolved in extended components in Vue < 2.5
2958 // https://github.com/vuejs/vue/issues/6436
2959 if (typeof provide === 'object' && VUE_VERSION < 2.5) {
2960 var obj = Object.assign({}, provide);
2961 return function () { return obj; }
2962 }
2963 return provide
2964 }
2965
2966 //
2967
2968 function getOption(option, config) {
2969 if (option === false) {
2970 return false
2971 }
2972 if (option || (config && Object.keys(config).length > 0)) {
2973 if (option instanceof Function) {
2974 return option
2975 }
2976 if (config instanceof Function) {
2977 throw new Error("Config can't be a Function.")
2978 }
2979 return Object.assign({}, config,
2980 option)
2981 }
2982 }
2983
2984 function getStubs(stubs, configStubs) {
2985 var normalizedStubs = normalizeStubs(stubs);
2986 var normalizedConfigStubs = normalizeStubs(configStubs);
2987 return getOption(normalizedStubs, normalizedConfigStubs)
2988 }
2989
2990 function mergeOptions(
2991 options,
2992 config
2993 ) {
2994 var mocks = (getOption(options.mocks, config.mocks));
2995 var methods = (getOption(options.methods, config.methods));
2996 if (methods && Object.keys(methods).length) {
2997 warnDeprecated(
2998 'overwriting methods via the `methods` property',
2999 'There is no clear migration path for the `methods` property - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests'
3000 );
3001 }
3002
3003 var provide = (getOption(options.provide, config.provide));
3004 var stubs = (getStubs(options.stubs, config.stubs));
3005 // $FlowIgnore
3006 return Object.assign({}, options,
3007 {provide: normalizeProvide(provide),
3008 stubs: stubs,
3009 mocks: mocks,
3010 methods: methods})
3011 }
3012
3013 var config = {
3014 stubs: {
3015 transition: true,
3016 'transition-group': true
3017 },
3018 mocks: {},
3019 methods: {},
3020 provide: {},
3021 silent: true,
3022 showDeprecationWarnings:
3023 true
3024 };
3025
3026 //
3027
3028 function warnIfNoWindow() {
3029 if (typeof window === 'undefined') {
3030 throwError(
3031 "window is undefined, vue-test-utils needs to be " +
3032 "run in a browser environment. \n" +
3033 "You can run the tests in node using jsdom \n" +
3034 "See https://vue-test-utils.vuejs.org/guides/#browser-environment " +
3035 "for more details."
3036 );
3037 }
3038 }
3039
3040 function polyfill() {
3041 // Polyfill `Element.matches()` for IE and older versions of Chrome:
3042 // https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill
3043 if (!Element.prototype.matches) {
3044 Element.prototype.matches =
3045 Element.prototype.msMatchesSelector ||
3046 Element.prototype.webkitMatchesSelector;
3047 }
3048 }
3049
3050 /*jshint node:true */
3051
3052 function OutputLine(parent) {
3053 this.__parent = parent;
3054 this.__character_count = 0;
3055 // use indent_count as a marker for this.__lines that have preserved indentation
3056 this.__indent_count = -1;
3057 this.__alignment_count = 0;
3058 this.__wrap_point_index = 0;
3059 this.__wrap_point_character_count = 0;
3060 this.__wrap_point_indent_count = -1;
3061 this.__wrap_point_alignment_count = 0;
3062
3063 this.__items = [];
3064 }
3065
3066 OutputLine.prototype.clone_empty = function() {
3067 var line = new OutputLine(this.__parent);
3068 line.set_indent(this.__indent_count, this.__alignment_count);
3069 return line;
3070 };
3071
3072 OutputLine.prototype.item = function(index) {
3073 if (index < 0) {
3074 return this.__items[this.__items.length + index];
3075 } else {
3076 return this.__items[index];
3077 }
3078 };
3079
3080 OutputLine.prototype.has_match = function(pattern) {
3081 for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
3082 if (this.__items[lastCheckedOutput].match(pattern)) {
3083 return true;
3084 }
3085 }
3086 return false;
3087 };
3088
3089 OutputLine.prototype.set_indent = function(indent, alignment) {
3090 if (this.is_empty()) {
3091 this.__indent_count = indent || 0;
3092 this.__alignment_count = alignment || 0;
3093 this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
3094 }
3095 };
3096
3097 OutputLine.prototype._set_wrap_point = function() {
3098 if (this.__parent.wrap_line_length) {
3099 this.__wrap_point_index = this.__items.length;
3100 this.__wrap_point_character_count = this.__character_count;
3101 this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
3102 this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
3103 }
3104 };
3105
3106 OutputLine.prototype._should_wrap = function() {
3107 return this.__wrap_point_index &&
3108 this.__character_count > this.__parent.wrap_line_length &&
3109 this.__wrap_point_character_count > this.__parent.next_line.__character_count;
3110 };
3111
3112 OutputLine.prototype._allow_wrap = function() {
3113 if (this._should_wrap()) {
3114 this.__parent.add_new_line();
3115 var next = this.__parent.current_line;
3116 next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
3117 next.__items = this.__items.slice(this.__wrap_point_index);
3118 this.__items = this.__items.slice(0, this.__wrap_point_index);
3119
3120 next.__character_count += this.__character_count - this.__wrap_point_character_count;
3121 this.__character_count = this.__wrap_point_character_count;
3122
3123 if (next.__items[0] === " ") {
3124 next.__items.splice(0, 1);
3125 next.__character_count -= 1;
3126 }
3127 return true;
3128 }
3129 return false;
3130 };
3131
3132 OutputLine.prototype.is_empty = function() {
3133 return this.__items.length === 0;
3134 };
3135
3136 OutputLine.prototype.last = function() {
3137 if (!this.is_empty()) {
3138 return this.__items[this.__items.length - 1];
3139 } else {
3140 return null;
3141 }
3142 };
3143
3144 OutputLine.prototype.push = function(item) {
3145 this.__items.push(item);
3146 var last_newline_index = item.lastIndexOf('\n');
3147 if (last_newline_index !== -1) {
3148 this.__character_count = item.length - last_newline_index;
3149 } else {
3150 this.__character_count += item.length;
3151 }
3152 };
3153
3154 OutputLine.prototype.pop = function() {
3155 var item = null;
3156 if (!this.is_empty()) {
3157 item = this.__items.pop();
3158 this.__character_count -= item.length;
3159 }
3160 return item;
3161 };
3162
3163
3164 OutputLine.prototype._remove_indent = function() {
3165 if (this.__indent_count > 0) {
3166 this.__indent_count -= 1;
3167 this.__character_count -= this.__parent.indent_size;
3168 }
3169 };
3170
3171 OutputLine.prototype._remove_wrap_indent = function() {
3172 if (this.__wrap_point_indent_count > 0) {
3173 this.__wrap_point_indent_count -= 1;
3174 }
3175 };
3176 OutputLine.prototype.trim = function() {
3177 while (this.last() === ' ') {
3178 this.__items.pop();
3179 this.__character_count -= 1;
3180 }
3181 };
3182
3183 OutputLine.prototype.toString = function() {
3184 var result = '';
3185 if (this.is_empty()) {
3186 if (this.__parent.indent_empty_lines) {
3187 result = this.__parent.get_indent_string(this.__indent_count);
3188 }
3189 } else {
3190 result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
3191 result += this.__items.join('');
3192 }
3193 return result;
3194 };
3195
3196 function IndentStringCache(options, baseIndentString) {
3197 this.__cache = [''];
3198 this.__indent_size = options.indent_size;
3199 this.__indent_string = options.indent_char;
3200 if (!options.indent_with_tabs) {
3201 this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
3202 }
3203
3204 // Set to null to continue support for auto detection of base indent
3205 baseIndentString = baseIndentString || '';
3206 if (options.indent_level > 0) {
3207 baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
3208 }
3209
3210 this.__base_string = baseIndentString;
3211 this.__base_string_length = baseIndentString.length;
3212 }
3213
3214 IndentStringCache.prototype.get_indent_size = function(indent, column) {
3215 var result = this.__base_string_length;
3216 column = column || 0;
3217 if (indent < 0) {
3218 result = 0;
3219 }
3220 result += indent * this.__indent_size;
3221 result += column;
3222 return result;
3223 };
3224
3225 IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
3226 var result = this.__base_string;
3227 column = column || 0;
3228 if (indent_level < 0) {
3229 indent_level = 0;
3230 result = '';
3231 }
3232 column += indent_level * this.__indent_size;
3233 this.__ensure_cache(column);
3234 result += this.__cache[column];
3235 return result;
3236 };
3237
3238 IndentStringCache.prototype.__ensure_cache = function(column) {
3239 while (column >= this.__cache.length) {
3240 this.__add_column();
3241 }
3242 };
3243
3244 IndentStringCache.prototype.__add_column = function() {
3245 var column = this.__cache.length;
3246 var indent = 0;
3247 var result = '';
3248 if (this.__indent_size && column >= this.__indent_size) {
3249 indent = Math.floor(column / this.__indent_size);
3250 column -= indent * this.__indent_size;
3251 result = new Array(indent + 1).join(this.__indent_string);
3252 }
3253 if (column) {
3254 result += new Array(column + 1).join(' ');
3255 }
3256
3257 this.__cache.push(result);
3258 };
3259
3260 function Output(options, baseIndentString) {
3261 this.__indent_cache = new IndentStringCache(options, baseIndentString);
3262 this.raw = false;
3263 this._end_with_newline = options.end_with_newline;
3264 this.indent_size = options.indent_size;
3265 this.wrap_line_length = options.wrap_line_length;
3266 this.indent_empty_lines = options.indent_empty_lines;
3267 this.__lines = [];
3268 this.previous_line = null;
3269 this.current_line = null;
3270 this.next_line = new OutputLine(this);
3271 this.space_before_token = false;
3272 this.non_breaking_space = false;
3273 this.previous_token_wrapped = false;
3274 // initialize
3275 this.__add_outputline();
3276 }
3277
3278 Output.prototype.__add_outputline = function() {
3279 this.previous_line = this.current_line;
3280 this.current_line = this.next_line.clone_empty();
3281 this.__lines.push(this.current_line);
3282 };
3283
3284 Output.prototype.get_line_number = function() {
3285 return this.__lines.length;
3286 };
3287
3288 Output.prototype.get_indent_string = function(indent, column) {
3289 return this.__indent_cache.get_indent_string(indent, column);
3290 };
3291
3292 Output.prototype.get_indent_size = function(indent, column) {
3293 return this.__indent_cache.get_indent_size(indent, column);
3294 };
3295
3296 Output.prototype.is_empty = function() {
3297 return !this.previous_line && this.current_line.is_empty();
3298 };
3299
3300 Output.prototype.add_new_line = function(force_newline) {
3301 // never newline at the start of file
3302 // otherwise, newline only if we didn't just add one or we're forced
3303 if (this.is_empty() ||
3304 (!force_newline && this.just_added_newline())) {
3305 return false;
3306 }
3307
3308 // if raw output is enabled, don't print additional newlines,
3309 // but still return True as though you had
3310 if (!this.raw) {
3311 this.__add_outputline();
3312 }
3313 return true;
3314 };
3315
3316 Output.prototype.get_code = function(eol) {
3317 this.trim(true);
3318
3319 // handle some edge cases where the last tokens
3320 // has text that ends with newline(s)
3321 var last_item = this.current_line.pop();
3322 if (last_item) {
3323 if (last_item[last_item.length - 1] === '\n') {
3324 last_item = last_item.replace(/\n+$/g, '');
3325 }
3326 this.current_line.push(last_item);
3327 }
3328
3329 if (this._end_with_newline) {
3330 this.__add_outputline();
3331 }
3332
3333 var sweet_code = this.__lines.join('\n');
3334
3335 if (eol !== '\n') {
3336 sweet_code = sweet_code.replace(/[\n]/g, eol);
3337 }
3338 return sweet_code;
3339 };
3340
3341 Output.prototype.set_wrap_point = function() {
3342 this.current_line._set_wrap_point();
3343 };
3344
3345 Output.prototype.set_indent = function(indent, alignment) {
3346 indent = indent || 0;
3347 alignment = alignment || 0;
3348
3349 // Next line stores alignment values
3350 this.next_line.set_indent(indent, alignment);
3351
3352 // Never indent your first output indent at the start of the file
3353 if (this.__lines.length > 1) {
3354 this.current_line.set_indent(indent, alignment);
3355 return true;
3356 }
3357
3358 this.current_line.set_indent();
3359 return false;
3360 };
3361
3362 Output.prototype.add_raw_token = function(token) {
3363 for (var x = 0; x < token.newlines; x++) {
3364 this.__add_outputline();
3365 }
3366 this.current_line.set_indent(-1);
3367 this.current_line.push(token.whitespace_before);
3368 this.current_line.push(token.text);
3369 this.space_before_token = false;
3370 this.non_breaking_space = false;
3371 this.previous_token_wrapped = false;
3372 };
3373
3374 Output.prototype.add_token = function(printable_token) {
3375 this.__add_space_before_token();
3376 this.current_line.push(printable_token);
3377 this.space_before_token = false;
3378 this.non_breaking_space = false;
3379 this.previous_token_wrapped = this.current_line._allow_wrap();
3380 };
3381
3382 Output.prototype.__add_space_before_token = function() {
3383 if (this.space_before_token && !this.just_added_newline()) {
3384 if (!this.non_breaking_space) {
3385 this.set_wrap_point();
3386 }
3387 this.current_line.push(' ');
3388 }
3389 };
3390
3391 Output.prototype.remove_indent = function(index) {
3392 var output_length = this.__lines.length;
3393 while (index < output_length) {
3394 this.__lines[index]._remove_indent();
3395 index++;
3396 }
3397 this.current_line._remove_wrap_indent();
3398 };
3399
3400 Output.prototype.trim = function(eat_newlines) {
3401 eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
3402
3403 this.current_line.trim();
3404
3405 while (eat_newlines && this.__lines.length > 1 &&
3406 this.current_line.is_empty()) {
3407 this.__lines.pop();
3408 this.current_line = this.__lines[this.__lines.length - 1];
3409 this.current_line.trim();
3410 }
3411
3412 this.previous_line = this.__lines.length > 1 ?
3413 this.__lines[this.__lines.length - 2] : null;
3414 };
3415
3416 Output.prototype.just_added_newline = function() {
3417 return this.current_line.is_empty();
3418 };
3419
3420 Output.prototype.just_added_blankline = function() {
3421 return this.is_empty() ||
3422 (this.current_line.is_empty() && this.previous_line.is_empty());
3423 };
3424
3425 Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
3426 var index = this.__lines.length - 2;
3427 while (index >= 0) {
3428 var potentialEmptyLine = this.__lines[index];
3429 if (potentialEmptyLine.is_empty()) {
3430 break;
3431 } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
3432 potentialEmptyLine.item(-1) !== ends_with) {
3433 this.__lines.splice(index + 1, 0, new OutputLine(this));
3434 this.previous_line = this.__lines[this.__lines.length - 2];
3435 break;
3436 }
3437 index--;
3438 }
3439 };
3440
3441 var Output_1 = Output;
3442
3443 var output = {
3444 Output: Output_1
3445 };
3446
3447 /*jshint node:true */
3448
3449 function Token(type, text, newlines, whitespace_before) {
3450 this.type = type;
3451 this.text = text;
3452
3453 // comments_before are
3454 // comments that have a new line before them
3455 // and may or may not have a newline after
3456 // this is a set of comments before
3457 this.comments_before = null; /* inline comment*/
3458
3459
3460 // this.comments_after = new TokenStream(); // no new line before and newline after
3461 this.newlines = newlines || 0;
3462 this.whitespace_before = whitespace_before || '';
3463 this.parent = null;
3464 this.next = null;
3465 this.previous = null;
3466 this.opened = null;
3467 this.closed = null;
3468 this.directives = null;
3469 }
3470
3471
3472 var Token_1 = Token;
3473
3474 var token = {
3475 Token: Token_1
3476 };
3477
3478 var acorn = createCommonjsModule(function (module, exports) {
3479
3480 // acorn used char codes to squeeze the last bit of performance out
3481 // Beautifier is okay without that, so we're using regex
3482 // permit $ (36) and @ (64). @ is used in ES7 decorators.
3483 // 65 through 91 are uppercase letters.
3484 // permit _ (95).
3485 // 97 through 123 are lowercase letters.
3486 var baseASCIIidentifierStartChars = "\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
3487
3488 // inside an identifier @ is not allowed but 0-9 are.
3489 var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
3490
3491 // Big ugly regular expressions that match characters in the
3492 // whitespace, identifier, and identifier-start categories. These
3493 // are only applied when a character is found to actually have a
3494 // code point above 128.
3495 var nonASCIIidentifierStartChars = "\\xaa\\xb5\\xba\\xc0-\\xd6\\xd8-\\xf6\\xf8-\\u02c1\\u02c6-\\u02d1\\u02e0-\\u02e4\\u02ec\\u02ee\\u0370-\\u0374\\u0376\\u0377\\u037a-\\u037d\\u0386\\u0388-\\u038a\\u038c\\u038e-\\u03a1\\u03a3-\\u03f5\\u03f7-\\u0481\\u048a-\\u0527\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05d0-\\u05ea\\u05f0-\\u05f2\\u0620-\\u064a\\u066e\\u066f\\u0671-\\u06d3\\u06d5\\u06e5\\u06e6\\u06ee\\u06ef\\u06fa-\\u06fc\\u06ff\\u0710\\u0712-\\u072f\\u074d-\\u07a5\\u07b1\\u07ca-\\u07ea\\u07f4\\u07f5\\u07fa\\u0800-\\u0815\\u081a\\u0824\\u0828\\u0840-\\u0858\\u08a0\\u08a2-\\u08ac\\u0904-\\u0939\\u093d\\u0950\\u0958-\\u0961\\u0971-\\u0977\\u0979-\\u097f\\u0985-\\u098c\\u098f\\u0990\\u0993-\\u09a8\\u09aa-\\u09b0\\u09b2\\u09b6-\\u09b9\\u09bd\\u09ce\\u09dc\\u09dd\\u09df-\\u09e1\\u09f0\\u09f1\\u0a05-\\u0a0a\\u0a0f\\u0a10\\u0a13-\\u0a28\\u0a2a-\\u0a30\\u0a32\\u0a33\\u0a35\\u0a36\\u0a38\\u0a39\\u0a59-\\u0a5c\\u0a5e\\u0a72-\\u0a74\\u0a85-\\u0a8d\\u0a8f-\\u0a91\\u0a93-\\u0aa8\\u0aaa-\\u0ab0\\u0ab2\\u0ab3\\u0ab5-\\u0ab9\\u0abd\\u0ad0\\u0ae0\\u0ae1\\u0b05-\\u0b0c\\u0b0f\\u0b10\\u0b13-\\u0b28\\u0b2a-\\u0b30\\u0b32\\u0b33\\u0b35-\\u0b39\\u0b3d\\u0b5c\\u0b5d\\u0b5f-\\u0b61\\u0b71\\u0b83\\u0b85-\\u0b8a\\u0b8e-\\u0b90\\u0b92-\\u0b95\\u0b99\\u0b9a\\u0b9c\\u0b9e\\u0b9f\\u0ba3\\u0ba4\\u0ba8-\\u0baa\\u0bae-\\u0bb9\\u0bd0\\u0c05-\\u0c0c\\u0c0e-\\u0c10\\u0c12-\\u0c28\\u0c2a-\\u0c33\\u0c35-\\u0c39\\u0c3d\\u0c58\\u0c59\\u0c60\\u0c61\\u0c85-\\u0c8c\\u0c8e-\\u0c90\\u0c92-\\u0ca8\\u0caa-\\u0cb3\\u0cb5-\\u0cb9\\u0cbd\\u0cde\\u0ce0\\u0ce1\\u0cf1\\u0cf2\\u0d05-\\u0d0c\\u0d0e-\\u0d10\\u0d12-\\u0d3a\\u0d3d\\u0d4e\\u0d60\\u0d61\\u0d7a-\\u0d7f\\u0d85-\\u0d96\\u0d9a-\\u0db1\\u0db3-\\u0dbb\\u0dbd\\u0dc0-\\u0dc6\\u0e01-\\u0e30\\u0e32\\u0e33\\u0e40-\\u0e46\\u0e81\\u0e82\\u0e84\\u0e87\\u0e88\\u0e8a\\u0e8d\\u0e94-\\u0e97\\u0e99-\\u0e9f\\u0ea1-\\u0ea3\\u0ea5\\u0ea7\\u0eaa\\u0eab\\u0ead-\\u0eb0\\u0eb2\\u0eb3\\u0ebd\\u0ec0-\\u0ec4\\u0ec6\\u0edc-\\u0edf\\u0f00\\u0f40-\\u0f47\\u0f49-\\u0f6c\\u0f88-\\u0f8c\\u1000-\\u102a\\u103f\\u1050-\\u1055\\u105a-\\u105d\\u1061\\u1065\\u1066\\u106e-\\u1070\\u1075-\\u1081\\u108e\\u10a0-\\u10c5\\u10c7\\u10cd\\u10d0-\\u10fa\\u10fc-\\u1248\\u124a-\\u124d\\u1250-\\u1256\\u1258\\u125a-\\u125d\\u1260-\\u1288\\u128a-\\u128d\\u1290-\\u12b0\\u12b2-\\u12b5\\u12b8-\\u12be\\u12c0\\u12c2-\\u12c5\\u12c8-\\u12d6\\u12d8-\\u1310\\u1312-\\u1315\\u1318-\\u135a\\u1380-\\u138f\\u13a0-\\u13f4\\u1401-\\u166c\\u166f-\\u167f\\u1681-\\u169a\\u16a0-\\u16ea\\u16ee-\\u16f0\\u1700-\\u170c\\u170e-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176c\\u176e-\\u1770\\u1780-\\u17b3\\u17d7\\u17dc\\u1820-\\u1877\\u1880-\\u18a8\\u18aa\\u18b0-\\u18f5\\u1900-\\u191c\\u1950-\\u196d\\u1970-\\u1974\\u1980-\\u19ab\\u19c1-\\u19c7\\u1a00-\\u1a16\\u1a20-\\u1a54\\u1aa7\\u1b05-\\u1b33\\u1b45-\\u1b4b\\u1b83-\\u1ba0\\u1bae\\u1baf\\u1bba-\\u1be5\\u1c00-\\u1c23\\u1c4d-\\u1c4f\\u1c5a-\\u1c7d\\u1ce9-\\u1cec\\u1cee-\\u1cf1\\u1cf5\\u1cf6\\u1d00-\\u1dbf\\u1e00-\\u1f15\\u1f18-\\u1f1d\\u1f20-\\u1f45\\u1f48-\\u1f4d\\u1f50-\\u1f57\\u1f59\\u1f5b\\u1f5d\\u1f5f-\\u1f7d\\u1f80-\\u1fb4\\u1fb6-\\u1fbc\\u1fbe\\u1fc2-\\u1fc4\\u1fc6-\\u1fcc\\u1fd0-\\u1fd3\\u1fd6-\\u1fdb\\u1fe0-\\u1fec\\u1ff2-\\u1ff4\\u1ff6-\\u1ffc\\u2071\\u207f\\u2090-\\u209c\\u2102\\u2107\\u210a-\\u2113\\u2115\\u2119-\\u211d\\u2124\\u2126\\u2128\\u212a-\\u212d\\u212f-\\u2139\\u213c-\\u213f\\u2145-\\u2149\\u214e\\u2160-\\u2188\\u2c00-\\u2c2e\\u2c30-\\u2c5e\\u2c60-\\u2ce4\\u2ceb-\\u2cee\\u2cf2\\u2cf3\\u2d00-\\u2d25\\u2d27\\u2d2d\\u2d30-\\u2d67\\u2d6f\\u2d80-\\u2d96\\u2da0-\\u2da6\\u2da8-\\u2dae\\u2db0-\\u2db6\\u2db8-\\u2dbe\\u2dc0-\\u2dc6\\u2dc8-\\u2dce\\u2dd0-\\u2dd6\\u2dd8-\\u2dde\\u2e2f\\u3005-\\u3007\\u3021-\\u3029\\u3031-\\u3035\\u3038-\\u303c\\u3041-\\u3096\\u309d-\\u309f\\u30a1-\\u30fa\\u30fc-\\u30ff\\u3105-\\u312d\\u3131-\\u318e\\u31a0-\\u31ba\\u31f0-\\u31ff\\u3400-\\u4db5\\u4e00-\\u9fcc\\ua000-\\ua48c\\ua4d0-\\ua4fd\\ua500-\\ua60c\\ua610-\\ua61f\\ua62a\\ua62b\\ua640-\\ua66e\\ua67f-\\ua697\\ua6a0-\\ua6ef\\ua717-\\ua71f\\ua722-\\ua788\\ua78b-\\ua78e\\ua790-\\ua793\\ua7a0-\\ua7aa\\ua7f8-\\ua801\\ua803-\\ua805\\ua807-\\ua80a\\ua80c-\\ua822\\ua840-\\ua873\\ua882-\\ua8b3\\ua8f2-\\ua8f7\\ua8fb\\ua90a-\\ua925\\ua930-\\ua946\\ua960-\\ua97c\\ua984-\\ua9b2\\ua9cf\\uaa00-\\uaa28\\uaa40-\\uaa42\\uaa44-\\uaa4b\\uaa60-\\uaa76\\uaa7a\\uaa80-\\uaaaf\\uaab1\\uaab5\\uaab6\\uaab9-\\uaabd\\uaac0\\uaac2\\uaadb-\\uaadd\\uaae0-\\uaaea\\uaaf2-\\uaaf4\\uab01-\\uab06\\uab09-\\uab0e\\uab11-\\uab16\\uab20-\\uab26\\uab28-\\uab2e\\uabc0-\\uabe2\\uac00-\\ud7a3\\ud7b0-\\ud7c6\\ud7cb-\\ud7fb\\uf900-\\ufa6d\\ufa70-\\ufad9\\ufb00-\\ufb06\\ufb13-\\ufb17\\ufb1d\\ufb1f-\\ufb28\\ufb2a-\\ufb36\\ufb38-\\ufb3c\\ufb3e\\ufb40\\ufb41\\ufb43\\ufb44\\ufb46-\\ufbb1\\ufbd3-\\ufd3d\\ufd50-\\ufd8f\\ufd92-\\ufdc7\\ufdf0-\\ufdfb\\ufe70-\\ufe74\\ufe76-\\ufefc\\uff21-\\uff3a\\uff41-\\uff5a\\uff66-\\uffbe\\uffc2-\\uffc7\\uffca-\\uffcf\\uffd2-\\uffd7\\uffda-\\uffdc";
3496 var nonASCIIidentifierChars = "\\u0300-\\u036f\\u0483-\\u0487\\u0591-\\u05bd\\u05bf\\u05c1\\u05c2\\u05c4\\u05c5\\u05c7\\u0610-\\u061a\\u0620-\\u0649\\u0672-\\u06d3\\u06e7-\\u06e8\\u06fb-\\u06fc\\u0730-\\u074a\\u0800-\\u0814\\u081b-\\u0823\\u0825-\\u0827\\u0829-\\u082d\\u0840-\\u0857\\u08e4-\\u08fe\\u0900-\\u0903\\u093a-\\u093c\\u093e-\\u094f\\u0951-\\u0957\\u0962-\\u0963\\u0966-\\u096f\\u0981-\\u0983\\u09bc\\u09be-\\u09c4\\u09c7\\u09c8\\u09d7\\u09df-\\u09e0\\u0a01-\\u0a03\\u0a3c\\u0a3e-\\u0a42\\u0a47\\u0a48\\u0a4b-\\u0a4d\\u0a51\\u0a66-\\u0a71\\u0a75\\u0a81-\\u0a83\\u0abc\\u0abe-\\u0ac5\\u0ac7-\\u0ac9\\u0acb-\\u0acd\\u0ae2-\\u0ae3\\u0ae6-\\u0aef\\u0b01-\\u0b03\\u0b3c\\u0b3e-\\u0b44\\u0b47\\u0b48\\u0b4b-\\u0b4d\\u0b56\\u0b57\\u0b5f-\\u0b60\\u0b66-\\u0b6f\\u0b82\\u0bbe-\\u0bc2\\u0bc6-\\u0bc8\\u0bca-\\u0bcd\\u0bd7\\u0be6-\\u0bef\\u0c01-\\u0c03\\u0c46-\\u0c48\\u0c4a-\\u0c4d\\u0c55\\u0c56\\u0c62-\\u0c63\\u0c66-\\u0c6f\\u0c82\\u0c83\\u0cbc\\u0cbe-\\u0cc4\\u0cc6-\\u0cc8\\u0cca-\\u0ccd\\u0cd5\\u0cd6\\u0ce2-\\u0ce3\\u0ce6-\\u0cef\\u0d02\\u0d03\\u0d46-\\u0d48\\u0d57\\u0d62-\\u0d63\\u0d66-\\u0d6f\\u0d82\\u0d83\\u0dca\\u0dcf-\\u0dd4\\u0dd6\\u0dd8-\\u0ddf\\u0df2\\u0df3\\u0e34-\\u0e3a\\u0e40-\\u0e45\\u0e50-\\u0e59\\u0eb4-\\u0eb9\\u0ec8-\\u0ecd\\u0ed0-\\u0ed9\\u0f18\\u0f19\\u0f20-\\u0f29\\u0f35\\u0f37\\u0f39\\u0f41-\\u0f47\\u0f71-\\u0f84\\u0f86-\\u0f87\\u0f8d-\\u0f97\\u0f99-\\u0fbc\\u0fc6\\u1000-\\u1029\\u1040-\\u1049\\u1067-\\u106d\\u1071-\\u1074\\u1082-\\u108d\\u108f-\\u109d\\u135d-\\u135f\\u170e-\\u1710\\u1720-\\u1730\\u1740-\\u1750\\u1772\\u1773\\u1780-\\u17b2\\u17dd\\u17e0-\\u17e9\\u180b-\\u180d\\u1810-\\u1819\\u1920-\\u192b\\u1930-\\u193b\\u1951-\\u196d\\u19b0-\\u19c0\\u19c8-\\u19c9\\u19d0-\\u19d9\\u1a00-\\u1a15\\u1a20-\\u1a53\\u1a60-\\u1a7c\\u1a7f-\\u1a89\\u1a90-\\u1a99\\u1b46-\\u1b4b\\u1b50-\\u1b59\\u1b6b-\\u1b73\\u1bb0-\\u1bb9\\u1be6-\\u1bf3\\u1c00-\\u1c22\\u1c40-\\u1c49\\u1c5b-\\u1c7d\\u1cd0-\\u1cd2\\u1d00-\\u1dbe\\u1e01-\\u1f15\\u200c\\u200d\\u203f\\u2040\\u2054\\u20d0-\\u20dc\\u20e1\\u20e5-\\u20f0\\u2d81-\\u2d96\\u2de0-\\u2dff\\u3021-\\u3028\\u3099\\u309a\\ua640-\\ua66d\\ua674-\\ua67d\\ua69f\\ua6f0-\\ua6f1\\ua7f8-\\ua800\\ua806\\ua80b\\ua823-\\ua827\\ua880-\\ua881\\ua8b4-\\ua8c4\\ua8d0-\\ua8d9\\ua8f3-\\ua8f7\\ua900-\\ua909\\ua926-\\ua92d\\ua930-\\ua945\\ua980-\\ua983\\ua9b3-\\ua9c0\\uaa00-\\uaa27\\uaa40-\\uaa41\\uaa4c-\\uaa4d\\uaa50-\\uaa59\\uaa7b\\uaae0-\\uaae9\\uaaf2-\\uaaf3\\uabc0-\\uabe1\\uabec\\uabed\\uabf0-\\uabf9\\ufb20-\\ufb28\\ufe00-\\ufe0f\\ufe20-\\ufe26\\ufe33\\ufe34\\ufe4d-\\ufe4f\\uff10-\\uff19\\uff3f";
3497 //var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
3498 //var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
3499
3500 var identifierStart = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
3501 var identifierChars = "(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
3502
3503 exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
3504 exports.identifierStart = new RegExp(identifierStart);
3505 exports.identifierMatch = new RegExp("(?:\\\\u[0-9a-fA-F]{4}|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
3506
3507 // Whether a single character denotes a newline.
3508
3509 exports.newline = /[\n\r\u2028\u2029]/;
3510
3511 // Matches a whole line break (where CRLF is considered a single
3512 // line break). Used to count lines.
3513
3514 // in javascript, these two differ
3515 // in python they are the same, different methods are called on them
3516 exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
3517 exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
3518 });
3519 var acorn_1 = acorn.identifier;
3520 var acorn_2 = acorn.identifierStart;
3521 var acorn_3 = acorn.identifierMatch;
3522 var acorn_4 = acorn.newline;
3523 var acorn_5 = acorn.lineBreak;
3524 var acorn_6 = acorn.allLineBreaks;
3525
3526 /*jshint node:true */
3527
3528 function Options(options, merge_child_field) {
3529 this.raw_options = _mergeOpts(options, merge_child_field);
3530
3531 // Support passing the source text back with no change
3532 this.disabled = this._get_boolean('disabled');
3533
3534 this.eol = this._get_characters('eol', 'auto');
3535 this.end_with_newline = this._get_boolean('end_with_newline');
3536 this.indent_size = this._get_number('indent_size', 4);
3537 this.indent_char = this._get_characters('indent_char', ' ');
3538 this.indent_level = this._get_number('indent_level');
3539
3540 this.preserve_newlines = this._get_boolean('preserve_newlines', true);
3541 this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
3542 if (!this.preserve_newlines) {
3543 this.max_preserve_newlines = 0;
3544 }
3545
3546 this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
3547 if (this.indent_with_tabs) {
3548 this.indent_char = '\t';
3549
3550 // indent_size behavior changed after 1.8.6
3551 // It used to be that indent_size would be
3552 // set to 1 for indent_with_tabs. That is no longer needed and
3553 // actually doesn't make sense - why not use spaces? Further,
3554 // that might produce unexpected behavior - tabs being used
3555 // for single-column alignment. So, when indent_with_tabs is true
3556 // and indent_size is 1, reset indent_size to 4.
3557 if (this.indent_size === 1) {
3558 this.indent_size = 4;
3559 }
3560 }
3561
3562 // Backwards compat with 1.3.x
3563 this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
3564
3565 this.indent_empty_lines = this._get_boolean('indent_empty_lines');
3566
3567 // valid templating languages ['django', 'erb', 'handlebars', 'php']
3568 // For now, 'auto' = all off for javascript, all on for html (and inline javascript).
3569 // other values ignored
3570 this.templating = this._get_selection_list('templating', ['auto', 'none', 'django', 'erb', 'handlebars', 'php'], ['auto']);
3571 }
3572
3573 Options.prototype._get_array = function(name, default_value) {
3574 var option_value = this.raw_options[name];
3575 var result = default_value || [];
3576 if (typeof option_value === 'object') {
3577 if (option_value !== null && typeof option_value.concat === 'function') {
3578 result = option_value.concat();
3579 }
3580 } else if (typeof option_value === 'string') {
3581 result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
3582 }
3583 return result;
3584 };
3585
3586 Options.prototype._get_boolean = function(name, default_value) {
3587 var option_value = this.raw_options[name];
3588 var result = option_value === undefined ? !!default_value : !!option_value;
3589 return result;
3590 };
3591
3592 Options.prototype._get_characters = function(name, default_value) {
3593 var option_value = this.raw_options[name];
3594 var result = default_value || '';
3595 if (typeof option_value === 'string') {
3596 result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
3597 }
3598 return result;
3599 };
3600
3601 Options.prototype._get_number = function(name, default_value) {
3602 var option_value = this.raw_options[name];
3603 default_value = parseInt(default_value, 10);
3604 if (isNaN(default_value)) {
3605 default_value = 0;
3606 }
3607 var result = parseInt(option_value, 10);
3608 if (isNaN(result)) {
3609 result = default_value;
3610 }
3611 return result;
3612 };
3613
3614 Options.prototype._get_selection = function(name, selection_list, default_value) {
3615 var result = this._get_selection_list(name, selection_list, default_value);
3616 if (result.length !== 1) {
3617 throw new Error(
3618 "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
3619 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3620 }
3621
3622 return result[0];
3623 };
3624
3625
3626 Options.prototype._get_selection_list = function(name, selection_list, default_value) {
3627 if (!selection_list || selection_list.length === 0) {
3628 throw new Error("Selection list cannot be empty.");
3629 }
3630
3631 default_value = default_value || [selection_list[0]];
3632 if (!this._is_valid_selection(default_value, selection_list)) {
3633 throw new Error("Invalid Default Value!");
3634 }
3635
3636 var result = this._get_array(name, default_value);
3637 if (!this._is_valid_selection(result, selection_list)) {
3638 throw new Error(
3639 "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
3640 selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
3641 }
3642
3643 return result;
3644 };
3645
3646 Options.prototype._is_valid_selection = function(result, selection_list) {
3647 return result.length && selection_list.length &&
3648 !result.some(function(item) { return selection_list.indexOf(item) === -1; });
3649 };
3650
3651
3652 // merges child options up with the parent options object
3653 // Example: obj = {a: 1, b: {a: 2}}
3654 // mergeOpts(obj, 'b')
3655 //
3656 // Returns: {a: 2}
3657 function _mergeOpts(allOptions, childFieldName) {
3658 var finalOpts = {};
3659 allOptions = _normalizeOpts(allOptions);
3660 var name;
3661
3662 for (name in allOptions) {
3663 if (name !== childFieldName) {
3664 finalOpts[name] = allOptions[name];
3665 }
3666 }
3667
3668 //merge in the per type settings for the childFieldName
3669 if (childFieldName && allOptions[childFieldName]) {
3670 for (name in allOptions[childFieldName]) {
3671 finalOpts[name] = allOptions[childFieldName][name];
3672 }
3673 }
3674 return finalOpts;
3675 }
3676
3677 function _normalizeOpts(options) {
3678 var convertedOpts = {};
3679 var key;
3680
3681 for (key in options) {
3682 var newKey = key.replace(/-/g, "_");
3683 convertedOpts[newKey] = options[key];
3684 }
3685 return convertedOpts;
3686 }
3687
3688 var Options_1 = Options;
3689 var normalizeOpts = _normalizeOpts;
3690 var mergeOpts = _mergeOpts;
3691
3692 var options = {
3693 Options: Options_1,
3694 normalizeOpts: normalizeOpts,
3695 mergeOpts: mergeOpts
3696 };
3697
3698 var BaseOptions = options.Options;
3699
3700 var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
3701
3702 function Options$1(options) {
3703 BaseOptions.call(this, options, 'js');
3704
3705 // compatibility, re
3706 var raw_brace_style = this.raw_options.brace_style || null;
3707 if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
3708 this.raw_options.brace_style = "expand";
3709 } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
3710 this.raw_options.brace_style = "collapse,preserve-inline";
3711 } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
3712 this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
3713 // } else if (!raw_brace_style) { //Nothing exists to set it
3714 // raw_brace_style = "collapse";
3715 }
3716
3717 //preserve-inline in delimited string will trigger brace_preserve_inline, everything
3718 //else is considered a brace_style and the last one only will have an effect
3719
3720 var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
3721
3722 this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
3723 this.brace_style = "collapse";
3724
3725 for (var bs = 0; bs < brace_style_split.length; bs++) {
3726 if (brace_style_split[bs] === "preserve-inline") {
3727 this.brace_preserve_inline = true;
3728 } else {
3729 this.brace_style = brace_style_split[bs];
3730 }
3731 }
3732
3733 this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
3734 this.break_chained_methods = this._get_boolean('break_chained_methods');
3735 this.space_in_paren = this._get_boolean('space_in_paren');
3736 this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
3737 this.jslint_happy = this._get_boolean('jslint_happy');
3738 this.space_after_anon_function = this._get_boolean('space_after_anon_function');
3739 this.space_after_named_function = this._get_boolean('space_after_named_function');
3740 this.keep_array_indentation = this._get_boolean('keep_array_indentation');
3741 this.space_before_conditional = this._get_boolean('space_before_conditional', true);
3742 this.unescape_strings = this._get_boolean('unescape_strings');
3743 this.e4x = this._get_boolean('e4x');
3744 this.comma_first = this._get_boolean('comma_first');
3745 this.operator_position = this._get_selection('operator_position', validPositionValues);
3746
3747 // For testing of beautify preserve:start directive
3748 this.test_output_raw = this._get_boolean('test_output_raw');
3749
3750 // force this._options.space_after_anon_function to true if this._options.jslint_happy
3751 if (this.jslint_happy) {
3752 this.space_after_anon_function = true;
3753 }
3754
3755 }
3756 Options$1.prototype = new BaseOptions();
3757
3758
3759
3760 var Options_1$1 = Options$1;
3761
3762 var options$1 = {
3763 Options: Options_1$1
3764 };
3765
3766 /*jshint node:true */
3767
3768 var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
3769
3770 function InputScanner(input_string) {
3771 this.__input = input_string || '';
3772 this.__input_length = this.__input.length;
3773 this.__position = 0;
3774 }
3775
3776 InputScanner.prototype.restart = function() {
3777 this.__position = 0;
3778 };
3779
3780 InputScanner.prototype.back = function() {
3781 if (this.__position > 0) {
3782 this.__position -= 1;
3783 }
3784 };
3785
3786 InputScanner.prototype.hasNext = function() {
3787 return this.__position < this.__input_length;
3788 };
3789
3790 InputScanner.prototype.next = function() {
3791 var val = null;
3792 if (this.hasNext()) {
3793 val = this.__input.charAt(this.__position);
3794 this.__position += 1;
3795 }
3796 return val;
3797 };
3798
3799 InputScanner.prototype.peek = function(index) {
3800 var val = null;
3801 index = index || 0;
3802 index += this.__position;
3803 if (index >= 0 && index < this.__input_length) {
3804 val = this.__input.charAt(index);
3805 }
3806 return val;
3807 };
3808
3809 // This is a JavaScript only helper function (not in python)
3810 // Javascript doesn't have a match method
3811 // and not all implementation support "sticky" flag.
3812 // If they do not support sticky then both this.match() and this.test() method
3813 // must get the match and check the index of the match.
3814 // If sticky is supported and set, this method will use it.
3815 // Otherwise it will check that global is set, and fall back to the slower method.
3816 InputScanner.prototype.__match = function(pattern, index) {
3817 pattern.lastIndex = index;
3818 var pattern_match = pattern.exec(this.__input);
3819
3820 if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
3821 if (pattern_match.index !== index) {
3822 pattern_match = null;
3823 }
3824 }
3825
3826 return pattern_match;
3827 };
3828
3829 InputScanner.prototype.test = function(pattern, index) {
3830 index = index || 0;
3831 index += this.__position;
3832
3833 if (index >= 0 && index < this.__input_length) {
3834 return !!this.__match(pattern, index);
3835 } else {
3836 return false;
3837 }
3838 };
3839
3840 InputScanner.prototype.testChar = function(pattern, index) {
3841 // test one character regex match
3842 var val = this.peek(index);
3843 pattern.lastIndex = 0;
3844 return val !== null && pattern.test(val);
3845 };
3846
3847 InputScanner.prototype.match = function(pattern) {
3848 var pattern_match = this.__match(pattern, this.__position);
3849 if (pattern_match) {
3850 this.__position += pattern_match[0].length;
3851 } else {
3852 pattern_match = null;
3853 }
3854 return pattern_match;
3855 };
3856
3857 InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
3858 var val = '';
3859 var match;
3860 if (starting_pattern) {
3861 match = this.match(starting_pattern);
3862 if (match) {
3863 val += match[0];
3864 }
3865 }
3866 if (until_pattern && (match || !starting_pattern)) {
3867 val += this.readUntil(until_pattern, until_after);
3868 }
3869 return val;
3870 };
3871
3872 InputScanner.prototype.readUntil = function(pattern, until_after) {
3873 var val = '';
3874 var match_index = this.__position;
3875 pattern.lastIndex = this.__position;
3876 var pattern_match = pattern.exec(this.__input);
3877 if (pattern_match) {
3878 match_index = pattern_match.index;
3879 if (until_after) {
3880 match_index += pattern_match[0].length;
3881 }
3882 } else {
3883 match_index = this.__input_length;
3884 }
3885
3886 val = this.__input.substring(this.__position, match_index);
3887 this.__position = match_index;
3888 return val;
3889 };
3890
3891 InputScanner.prototype.readUntilAfter = function(pattern) {
3892 return this.readUntil(pattern, true);
3893 };
3894
3895 InputScanner.prototype.get_regexp = function(pattern, match_from) {
3896 var result = null;
3897 var flags = 'g';
3898 if (match_from && regexp_has_sticky) {
3899 flags = 'y';
3900 }
3901 // strings are converted to regexp
3902 if (typeof pattern === "string" && pattern !== '') {
3903 // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
3904 result = new RegExp(pattern, flags);
3905 } else if (pattern) {
3906 result = new RegExp(pattern.source, flags);
3907 }
3908 return result;
3909 };
3910
3911 InputScanner.prototype.get_literal_regexp = function(literal_string) {
3912 return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
3913 };
3914
3915 /* css beautifier legacy helpers */
3916 InputScanner.prototype.peekUntilAfter = function(pattern) {
3917 var start = this.__position;
3918 var val = this.readUntilAfter(pattern);
3919 this.__position = start;
3920 return val;
3921 };
3922
3923 InputScanner.prototype.lookBack = function(testVal) {
3924 var start = this.__position - 1;
3925 return start >= testVal.length && this.__input.substring(start - testVal.length, start)
3926 .toLowerCase() === testVal;
3927 };
3928
3929 var InputScanner_1 = InputScanner;
3930
3931 var inputscanner = {
3932 InputScanner: InputScanner_1
3933 };
3934
3935 /*jshint node:true */
3936
3937 function TokenStream(parent_token) {
3938 // private
3939 this.__tokens = [];
3940 this.__tokens_length = this.__tokens.length;
3941 this.__position = 0;
3942 this.__parent_token = parent_token;
3943 }
3944
3945 TokenStream.prototype.restart = function() {
3946 this.__position = 0;
3947 };
3948
3949 TokenStream.prototype.isEmpty = function() {
3950 return this.__tokens_length === 0;
3951 };
3952
3953 TokenStream.prototype.hasNext = function() {
3954 return this.__position < this.__tokens_length;
3955 };
3956
3957 TokenStream.prototype.next = function() {
3958 var val = null;
3959 if (this.hasNext()) {
3960 val = this.__tokens[this.__position];
3961 this.__position += 1;
3962 }
3963 return val;
3964 };
3965
3966 TokenStream.prototype.peek = function(index) {
3967 var val = null;
3968 index = index || 0;
3969 index += this.__position;
3970 if (index >= 0 && index < this.__tokens_length) {
3971 val = this.__tokens[index];
3972 }
3973 return val;
3974 };
3975
3976 TokenStream.prototype.add = function(token) {
3977 if (this.__parent_token) {
3978 token.parent = this.__parent_token;
3979 }
3980 this.__tokens.push(token);
3981 this.__tokens_length += 1;
3982 };
3983
3984 var TokenStream_1 = TokenStream;
3985
3986 var tokenstream = {
3987 TokenStream: TokenStream_1
3988 };
3989
3990 /*jshint node:true */
3991
3992 function Pattern(input_scanner, parent) {
3993 this._input = input_scanner;
3994 this._starting_pattern = null;
3995 this._match_pattern = null;
3996 this._until_pattern = null;
3997 this._until_after = false;
3998
3999 if (parent) {
4000 this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
4001 this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
4002 this._until_pattern = this._input.get_regexp(parent._until_pattern);
4003 this._until_after = parent._until_after;
4004 }
4005 }
4006
4007 Pattern.prototype.read = function() {
4008 var result = this._input.read(this._starting_pattern);
4009 if (!this._starting_pattern || result) {
4010 result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
4011 }
4012 return result;
4013 };
4014
4015 Pattern.prototype.read_match = function() {
4016 return this._input.match(this._match_pattern);
4017 };
4018
4019 Pattern.prototype.until_after = function(pattern) {
4020 var result = this._create();
4021 result._until_after = true;
4022 result._until_pattern = this._input.get_regexp(pattern);
4023 result._update();
4024 return result;
4025 };
4026
4027 Pattern.prototype.until = function(pattern) {
4028 var result = this._create();
4029 result._until_after = false;
4030 result._until_pattern = this._input.get_regexp(pattern);
4031 result._update();
4032 return result;
4033 };
4034
4035 Pattern.prototype.starting_with = function(pattern) {
4036 var result = this._create();
4037 result._starting_pattern = this._input.get_regexp(pattern, true);
4038 result._update();
4039 return result;
4040 };
4041
4042 Pattern.prototype.matching = function(pattern) {
4043 var result = this._create();
4044 result._match_pattern = this._input.get_regexp(pattern, true);
4045 result._update();
4046 return result;
4047 };
4048
4049 Pattern.prototype._create = function() {
4050 return new Pattern(this._input, this);
4051 };
4052
4053 Pattern.prototype._update = function() {};
4054
4055 var Pattern_1 = Pattern;
4056
4057 var pattern = {
4058 Pattern: Pattern_1
4059 };
4060
4061 var Pattern$1 = pattern.Pattern;
4062
4063 function WhitespacePattern(input_scanner, parent) {
4064 Pattern$1.call(this, input_scanner, parent);
4065 if (parent) {
4066 this._line_regexp = this._input.get_regexp(parent._line_regexp);
4067 } else {
4068 this.__set_whitespace_patterns('', '');
4069 }
4070
4071 this.newline_count = 0;
4072 this.whitespace_before_token = '';
4073 }
4074 WhitespacePattern.prototype = new Pattern$1();
4075
4076 WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
4077 whitespace_chars += '\\t ';
4078 newline_chars += '\\n\\r';
4079
4080 this._match_pattern = this._input.get_regexp(
4081 '[' + whitespace_chars + newline_chars + ']+', true);
4082 this._newline_regexp = this._input.get_regexp(
4083 '\\r\\n|[' + newline_chars + ']');
4084 };
4085
4086 WhitespacePattern.prototype.read = function() {
4087 this.newline_count = 0;
4088 this.whitespace_before_token = '';
4089
4090 var resulting_string = this._input.read(this._match_pattern);
4091 if (resulting_string === ' ') {
4092 this.whitespace_before_token = ' ';
4093 } else if (resulting_string) {
4094 var matches = this.__split(this._newline_regexp, resulting_string);
4095 this.newline_count = matches.length - 1;
4096 this.whitespace_before_token = matches[this.newline_count];
4097 }
4098
4099 return resulting_string;
4100 };
4101
4102 WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
4103 var result = this._create();
4104 result.__set_whitespace_patterns(whitespace_chars, newline_chars);
4105 result._update();
4106 return result;
4107 };
4108
4109 WhitespacePattern.prototype._create = function() {
4110 return new WhitespacePattern(this._input, this);
4111 };
4112
4113 WhitespacePattern.prototype.__split = function(regexp, input_string) {
4114 regexp.lastIndex = 0;
4115 var start_index = 0;
4116 var result = [];
4117 var next_match = regexp.exec(input_string);
4118 while (next_match) {
4119 result.push(input_string.substring(start_index, next_match.index));
4120 start_index = next_match.index + next_match[0].length;
4121 next_match = regexp.exec(input_string);
4122 }
4123
4124 if (start_index < input_string.length) {
4125 result.push(input_string.substring(start_index, input_string.length));
4126 } else {
4127 result.push('');
4128 }
4129
4130 return result;
4131 };
4132
4133
4134
4135 var WhitespacePattern_1 = WhitespacePattern;
4136
4137 var whitespacepattern = {
4138 WhitespacePattern: WhitespacePattern_1
4139 };
4140
4141 var InputScanner$1 = inputscanner.InputScanner;
4142 var Token$1 = token.Token;
4143 var TokenStream$1 = tokenstream.TokenStream;
4144 var WhitespacePattern$1 = whitespacepattern.WhitespacePattern;
4145
4146 var TOKEN = {
4147 START: 'TK_START',
4148 RAW: 'TK_RAW',
4149 EOF: 'TK_EOF'
4150 };
4151
4152 var Tokenizer = function(input_string, options) {
4153 this._input = new InputScanner$1(input_string);
4154 this._options = options || {};
4155 this.__tokens = null;
4156
4157 this._patterns = {};
4158 this._patterns.whitespace = new WhitespacePattern$1(this._input);
4159 };
4160
4161 Tokenizer.prototype.tokenize = function() {
4162 this._input.restart();
4163 this.__tokens = new TokenStream$1();
4164
4165 this._reset();
4166
4167 var current;
4168 var previous = new Token$1(TOKEN.START, '');
4169 var open_token = null;
4170 var open_stack = [];
4171 var comments = new TokenStream$1();
4172
4173 while (previous.type !== TOKEN.EOF) {
4174 current = this._get_next_token(previous, open_token);
4175 while (this._is_comment(current)) {
4176 comments.add(current);
4177 current = this._get_next_token(previous, open_token);
4178 }
4179
4180 if (!comments.isEmpty()) {
4181 current.comments_before = comments;
4182 comments = new TokenStream$1();
4183 }
4184
4185 current.parent = open_token;
4186
4187 if (this._is_opening(current)) {
4188 open_stack.push(open_token);
4189 open_token = current;
4190 } else if (open_token && this._is_closing(current, open_token)) {
4191 current.opened = open_token;
4192 open_token.closed = current;
4193 open_token = open_stack.pop();
4194 current.parent = open_token;
4195 }
4196
4197 current.previous = previous;
4198 previous.next = current;
4199
4200 this.__tokens.add(current);
4201 previous = current;
4202 }
4203
4204 return this.__tokens;
4205 };
4206
4207
4208 Tokenizer.prototype._is_first_token = function() {
4209 return this.__tokens.isEmpty();
4210 };
4211
4212 Tokenizer.prototype._reset = function() {};
4213
4214 Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4215 this._readWhitespace();
4216 var resulting_string = this._input.read(/.+/g);
4217 if (resulting_string) {
4218 return this._create_token(TOKEN.RAW, resulting_string);
4219 } else {
4220 return this._create_token(TOKEN.EOF, '');
4221 }
4222 };
4223
4224 Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
4225 return false;
4226 };
4227
4228 Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
4229 return false;
4230 };
4231
4232 Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
4233 return false;
4234 };
4235
4236 Tokenizer.prototype._create_token = function(type, text) {
4237 var token = new Token$1(type, text,
4238 this._patterns.whitespace.newline_count,
4239 this._patterns.whitespace.whitespace_before_token);
4240 return token;
4241 };
4242
4243 Tokenizer.prototype._readWhitespace = function() {
4244 return this._patterns.whitespace.read();
4245 };
4246
4247
4248
4249 var Tokenizer_1 = Tokenizer;
4250 var TOKEN_1 = TOKEN;
4251
4252 var tokenizer = {
4253 Tokenizer: Tokenizer_1,
4254 TOKEN: TOKEN_1
4255 };
4256
4257 /*jshint node:true */
4258
4259 function Directives(start_block_pattern, end_block_pattern) {
4260 start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
4261 end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
4262 this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
4263 this.__directive_pattern = / (\w+)[:](\w+)/g;
4264
4265 this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
4266 }
4267
4268 Directives.prototype.get_directives = function(text) {
4269 if (!text.match(this.__directives_block_pattern)) {
4270 return null;
4271 }
4272
4273 var directives = {};
4274 this.__directive_pattern.lastIndex = 0;
4275 var directive_match = this.__directive_pattern.exec(text);
4276
4277 while (directive_match) {
4278 directives[directive_match[1]] = directive_match[2];
4279 directive_match = this.__directive_pattern.exec(text);
4280 }
4281
4282 return directives;
4283 };
4284
4285 Directives.prototype.readIgnored = function(input) {
4286 return input.readUntilAfter(this.__directives_end_ignore_pattern);
4287 };
4288
4289
4290 var Directives_1 = Directives;
4291
4292 var directives = {
4293 Directives: Directives_1
4294 };
4295
4296 var Pattern$2 = pattern.Pattern;
4297
4298
4299 var template_names = {
4300 django: false,
4301 erb: false,
4302 handlebars: false,
4303 php: false
4304 };
4305
4306 // This lets templates appear anywhere we would do a readUntil
4307 // The cost is higher but it is pay to play.
4308 function TemplatablePattern(input_scanner, parent) {
4309 Pattern$2.call(this, input_scanner, parent);
4310 this.__template_pattern = null;
4311 this._disabled = Object.assign({}, template_names);
4312 this._excluded = Object.assign({}, template_names);
4313
4314 if (parent) {
4315 this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
4316 this._excluded = Object.assign(this._excluded, parent._excluded);
4317 this._disabled = Object.assign(this._disabled, parent._disabled);
4318 }
4319 var pattern = new Pattern$2(input_scanner);
4320 this.__patterns = {
4321 handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
4322 handlebars: pattern.starting_with(/{{/).until_after(/}}/),
4323 php: pattern.starting_with(/<\?(?:[=]|php)/).until_after(/\?>/),
4324 erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
4325 // django coflicts with handlebars a bit.
4326 django: pattern.starting_with(/{%/).until_after(/%}/),
4327 django_value: pattern.starting_with(/{{/).until_after(/}}/),
4328 django_comment: pattern.starting_with(/{#/).until_after(/#}/)
4329 };
4330 }
4331 TemplatablePattern.prototype = new Pattern$2();
4332
4333 TemplatablePattern.prototype._create = function() {
4334 return new TemplatablePattern(this._input, this);
4335 };
4336
4337 TemplatablePattern.prototype._update = function() {
4338 this.__set_templated_pattern();
4339 };
4340
4341 TemplatablePattern.prototype.disable = function(language) {
4342 var result = this._create();
4343 result._disabled[language] = true;
4344 result._update();
4345 return result;
4346 };
4347
4348 TemplatablePattern.prototype.read_options = function(options) {
4349 var result = this._create();
4350 for (var language in template_names) {
4351 result._disabled[language] = options.templating.indexOf(language) === -1;
4352 }
4353 result._update();
4354 return result;
4355 };
4356
4357 TemplatablePattern.prototype.exclude = function(language) {
4358 var result = this._create();
4359 result._excluded[language] = true;
4360 result._update();
4361 return result;
4362 };
4363
4364 TemplatablePattern.prototype.read = function() {
4365 var result = '';
4366 if (this._match_pattern) {
4367 result = this._input.read(this._starting_pattern);
4368 } else {
4369 result = this._input.read(this._starting_pattern, this.__template_pattern);
4370 }
4371 var next = this._read_template();
4372 while (next) {
4373 if (this._match_pattern) {
4374 next += this._input.read(this._match_pattern);
4375 } else {
4376 next += this._input.readUntil(this.__template_pattern);
4377 }
4378 result += next;
4379 next = this._read_template();
4380 }
4381
4382 if (this._until_after) {
4383 result += this._input.readUntilAfter(this._until_pattern);
4384 }
4385 return result;
4386 };
4387
4388 TemplatablePattern.prototype.__set_templated_pattern = function() {
4389 var items = [];
4390
4391 if (!this._disabled.php) {
4392 items.push(this.__patterns.php._starting_pattern.source);
4393 }
4394 if (!this._disabled.handlebars) {
4395 items.push(this.__patterns.handlebars._starting_pattern.source);
4396 }
4397 if (!this._disabled.erb) {
4398 items.push(this.__patterns.erb._starting_pattern.source);
4399 }
4400 if (!this._disabled.django) {
4401 items.push(this.__patterns.django._starting_pattern.source);
4402 items.push(this.__patterns.django_value._starting_pattern.source);
4403 items.push(this.__patterns.django_comment._starting_pattern.source);
4404 }
4405
4406 if (this._until_pattern) {
4407 items.push(this._until_pattern.source);
4408 }
4409 this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
4410 };
4411
4412 TemplatablePattern.prototype._read_template = function() {
4413 var resulting_string = '';
4414 var c = this._input.peek();
4415 if (c === '<') {
4416 var peek1 = this._input.peek(1);
4417 //if we're in a comment, do something special
4418 // We treat all comments as literals, even more than preformatted tags
4419 // we just look for the appropriate close tag
4420 if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
4421 resulting_string = resulting_string ||
4422 this.__patterns.php.read();
4423 }
4424 if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
4425 resulting_string = resulting_string ||
4426 this.__patterns.erb.read();
4427 }
4428 } else if (c === '{') {
4429 if (!this._disabled.handlebars && !this._excluded.handlebars) {
4430 resulting_string = resulting_string ||
4431 this.__patterns.handlebars_comment.read();
4432 resulting_string = resulting_string ||
4433 this.__patterns.handlebars.read();
4434 }
4435 if (!this._disabled.django) {
4436 // django coflicts with handlebars a bit.
4437 if (!this._excluded.django && !this._excluded.handlebars) {
4438 resulting_string = resulting_string ||
4439 this.__patterns.django_value.read();
4440 }
4441 if (!this._excluded.django) {
4442 resulting_string = resulting_string ||
4443 this.__patterns.django_comment.read();
4444 resulting_string = resulting_string ||
4445 this.__patterns.django.read();
4446 }
4447 }
4448 }
4449 return resulting_string;
4450 };
4451
4452
4453 var TemplatablePattern_1 = TemplatablePattern;
4454
4455 var templatablepattern = {
4456 TemplatablePattern: TemplatablePattern_1
4457 };
4458
4459 var InputScanner$2 = inputscanner.InputScanner;
4460 var BaseTokenizer = tokenizer.Tokenizer;
4461 var BASETOKEN = tokenizer.TOKEN;
4462 var Directives$1 = directives.Directives;
4463
4464 var Pattern$3 = pattern.Pattern;
4465 var TemplatablePattern$1 = templatablepattern.TemplatablePattern;
4466
4467
4468 function in_array(what, arr) {
4469 return arr.indexOf(what) !== -1;
4470 }
4471
4472
4473 var TOKEN$1 = {
4474 START_EXPR: 'TK_START_EXPR',
4475 END_EXPR: 'TK_END_EXPR',
4476 START_BLOCK: 'TK_START_BLOCK',
4477 END_BLOCK: 'TK_END_BLOCK',
4478 WORD: 'TK_WORD',
4479 RESERVED: 'TK_RESERVED',
4480 SEMICOLON: 'TK_SEMICOLON',
4481 STRING: 'TK_STRING',
4482 EQUALS: 'TK_EQUALS',
4483 OPERATOR: 'TK_OPERATOR',
4484 COMMA: 'TK_COMMA',
4485 BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
4486 COMMENT: 'TK_COMMENT',
4487 DOT: 'TK_DOT',
4488 UNKNOWN: 'TK_UNKNOWN',
4489 START: BASETOKEN.START,
4490 RAW: BASETOKEN.RAW,
4491 EOF: BASETOKEN.EOF
4492 };
4493
4494
4495 var directives_core = new Directives$1(/\/\*/, /\*\//);
4496
4497 var number_pattern = /0[xX][0123456789abcdefABCDEF]*|0[oO][01234567]*|0[bB][01]*|\d+n|(?:\.\d+|\d+\.?\d*)(?:[eE][+-]?\d+)?/;
4498
4499 var digit = /[0-9]/;
4500
4501 // Dot "." must be distinguished from "..." and decimal
4502 var dot_pattern = /[^\d\.]/;
4503
4504 var positionable_operators = (
4505 ">>> === !== " +
4506 "<< && >= ** != == <= >> || " +
4507 "< / - + > : & % ? ^ | *").split(' ');
4508
4509 // IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
4510 // Also, you must update possitionable operators separately from punct
4511 var punct =
4512 ">>>= " +
4513 "... >>= <<= === >>> !== **= " +
4514 "=> ^= :: /= << <= == && -= >= >> != -- += ** || ++ %= &= *= |= " +
4515 "= ! ? > < : / ^ - + * & % ~ |";
4516
4517 punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
4518 punct = punct.replace(/ /g, '|');
4519
4520 var punct_pattern = new RegExp(punct);
4521
4522 // words which should always start on new line.
4523 var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
4524 var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as']);
4525 var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
4526
4527 // var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
4528
4529 var in_html_comment;
4530
4531 var Tokenizer$1 = function(input_string, options) {
4532 BaseTokenizer.call(this, input_string, options);
4533
4534 this._patterns.whitespace = this._patterns.whitespace.matching(
4535 /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
4536 /\u2028\u2029/.source);
4537
4538 var pattern_reader = new Pattern$3(this._input);
4539 var templatable = new TemplatablePattern$1(this._input)
4540 .read_options(this._options);
4541
4542 this.__patterns = {
4543 template: templatable,
4544 identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
4545 number: pattern_reader.matching(number_pattern),
4546 punct: pattern_reader.matching(punct_pattern),
4547 // comment ends just before nearest linefeed or end of file
4548 comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
4549 // /* ... */ comment ends with nearest */ or end of file
4550 block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
4551 html_comment_start: pattern_reader.matching(/<!--/),
4552 html_comment_end: pattern_reader.matching(/-->/),
4553 include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
4554 shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
4555 xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[\s\S]+?}|!\[CDATA\[[\s\S]*?\]\])(\s+{[\s\S]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{[\s\S]+?}))*\s*(\/?)\s*>/),
4556 single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
4557 double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
4558 template_text: templatable.until(/[`\\$]/),
4559 template_expression: templatable.until(/[`}\\]/)
4560 };
4561
4562 };
4563 Tokenizer$1.prototype = new BaseTokenizer();
4564
4565 Tokenizer$1.prototype._is_comment = function(current_token) {
4566 return current_token.type === TOKEN$1.COMMENT || current_token.type === TOKEN$1.BLOCK_COMMENT || current_token.type === TOKEN$1.UNKNOWN;
4567 };
4568
4569 Tokenizer$1.prototype._is_opening = function(current_token) {
4570 return current_token.type === TOKEN$1.START_BLOCK || current_token.type === TOKEN$1.START_EXPR;
4571 };
4572
4573 Tokenizer$1.prototype._is_closing = function(current_token, open_token) {
4574 return (current_token.type === TOKEN$1.END_BLOCK || current_token.type === TOKEN$1.END_EXPR) &&
4575 (open_token && (
4576 (current_token.text === ']' && open_token.text === '[') ||
4577 (current_token.text === ')' && open_token.text === '(') ||
4578 (current_token.text === '}' && open_token.text === '{')));
4579 };
4580
4581 Tokenizer$1.prototype._reset = function() {
4582 in_html_comment = false;
4583 };
4584
4585 Tokenizer$1.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
4586 var token = null;
4587 this._readWhitespace();
4588 var c = this._input.peek();
4589
4590 if (c === null) {
4591 return this._create_token(TOKEN$1.EOF, '');
4592 }
4593
4594 token = token || this._read_string(c);
4595 token = token || this._read_word(previous_token);
4596 token = token || this._read_singles(c);
4597 token = token || this._read_comment(c);
4598 token = token || this._read_regexp(c, previous_token);
4599 token = token || this._read_xml(c, previous_token);
4600 token = token || this._read_non_javascript(c);
4601 token = token || this._read_punctuation();
4602 token = token || this._create_token(TOKEN$1.UNKNOWN, this._input.next());
4603
4604 return token;
4605 };
4606
4607 Tokenizer$1.prototype._read_word = function(previous_token) {
4608 var resulting_string;
4609 resulting_string = this.__patterns.identifier.read();
4610 if (resulting_string !== '') {
4611 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4612 if (!(previous_token.type === TOKEN$1.DOT ||
4613 (previous_token.type === TOKEN$1.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
4614 reserved_word_pattern.test(resulting_string)) {
4615 if (resulting_string === 'in' || resulting_string === 'of') { // hack for 'in' and 'of' operators
4616 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4617 }
4618 return this._create_token(TOKEN$1.RESERVED, resulting_string);
4619 }
4620 return this._create_token(TOKEN$1.WORD, resulting_string);
4621 }
4622
4623 resulting_string = this.__patterns.number.read();
4624 if (resulting_string !== '') {
4625 return this._create_token(TOKEN$1.WORD, resulting_string);
4626 }
4627 };
4628
4629 Tokenizer$1.prototype._read_singles = function(c) {
4630 var token = null;
4631 if (c === '(' || c === '[') {
4632 token = this._create_token(TOKEN$1.START_EXPR, c);
4633 } else if (c === ')' || c === ']') {
4634 token = this._create_token(TOKEN$1.END_EXPR, c);
4635 } else if (c === '{') {
4636 token = this._create_token(TOKEN$1.START_BLOCK, c);
4637 } else if (c === '}') {
4638 token = this._create_token(TOKEN$1.END_BLOCK, c);
4639 } else if (c === ';') {
4640 token = this._create_token(TOKEN$1.SEMICOLON, c);
4641 } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
4642 token = this._create_token(TOKEN$1.DOT, c);
4643 } else if (c === ',') {
4644 token = this._create_token(TOKEN$1.COMMA, c);
4645 }
4646
4647 if (token) {
4648 this._input.next();
4649 }
4650 return token;
4651 };
4652
4653 Tokenizer$1.prototype._read_punctuation = function() {
4654 var resulting_string = this.__patterns.punct.read();
4655
4656 if (resulting_string !== '') {
4657 if (resulting_string === '=') {
4658 return this._create_token(TOKEN$1.EQUALS, resulting_string);
4659 } else {
4660 return this._create_token(TOKEN$1.OPERATOR, resulting_string);
4661 }
4662 }
4663 };
4664
4665 Tokenizer$1.prototype._read_non_javascript = function(c) {
4666 var resulting_string = '';
4667
4668 if (c === '#') {
4669 if (this._is_first_token()) {
4670 resulting_string = this.__patterns.shebang.read();
4671
4672 if (resulting_string) {
4673 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4674 }
4675 }
4676
4677 // handles extendscript #includes
4678 resulting_string = this.__patterns.include.read();
4679
4680 if (resulting_string) {
4681 return this._create_token(TOKEN$1.UNKNOWN, resulting_string.trim() + '\n');
4682 }
4683
4684 c = this._input.next();
4685
4686 // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
4687 var sharp = '#';
4688 if (this._input.hasNext() && this._input.testChar(digit)) {
4689 do {
4690 c = this._input.next();
4691 sharp += c;
4692 } while (this._input.hasNext() && c !== '#' && c !== '=');
4693 if (c === '#') ; else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
4694 sharp += '[]';
4695 this._input.next();
4696 this._input.next();
4697 } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
4698 sharp += '{}';
4699 this._input.next();
4700 this._input.next();
4701 }
4702 return this._create_token(TOKEN$1.WORD, sharp);
4703 }
4704
4705 this._input.back();
4706
4707 } else if (c === '<' && this._is_first_token()) {
4708 resulting_string = this.__patterns.html_comment_start.read();
4709 if (resulting_string) {
4710 while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
4711 resulting_string += this._input.next();
4712 }
4713 in_html_comment = true;
4714 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4715 }
4716 } else if (in_html_comment && c === '-') {
4717 resulting_string = this.__patterns.html_comment_end.read();
4718 if (resulting_string) {
4719 in_html_comment = false;
4720 return this._create_token(TOKEN$1.COMMENT, resulting_string);
4721 }
4722 }
4723
4724 return null;
4725 };
4726
4727 Tokenizer$1.prototype._read_comment = function(c) {
4728 var token = null;
4729 if (c === '/') {
4730 var comment = '';
4731 if (this._input.peek(1) === '*') {
4732 // peek for comment /* ... */
4733 comment = this.__patterns.block_comment.read();
4734 var directives = directives_core.get_directives(comment);
4735 if (directives && directives.ignore === 'start') {
4736 comment += directives_core.readIgnored(this._input);
4737 }
4738 comment = comment.replace(acorn.allLineBreaks, '\n');
4739 token = this._create_token(TOKEN$1.BLOCK_COMMENT, comment);
4740 token.directives = directives;
4741 } else if (this._input.peek(1) === '/') {
4742 // peek for comment // ...
4743 comment = this.__patterns.comment.read();
4744 token = this._create_token(TOKEN$1.COMMENT, comment);
4745 }
4746 }
4747 return token;
4748 };
4749
4750 Tokenizer$1.prototype._read_string = function(c) {
4751 if (c === '`' || c === "'" || c === '"') {
4752 var resulting_string = this._input.next();
4753 this.has_char_escapes = false;
4754
4755 if (c === '`') {
4756 resulting_string += this._read_string_recursive('`', true, '${');
4757 } else {
4758 resulting_string += this._read_string_recursive(c);
4759 }
4760
4761 if (this.has_char_escapes && this._options.unescape_strings) {
4762 resulting_string = unescape_string(resulting_string);
4763 }
4764
4765 if (this._input.peek() === c) {
4766 resulting_string += this._input.next();
4767 }
4768
4769 resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
4770
4771 return this._create_token(TOKEN$1.STRING, resulting_string);
4772 }
4773
4774 return null;
4775 };
4776
4777 Tokenizer$1.prototype._allow_regexp_or_xml = function(previous_token) {
4778 // regex and xml can only appear in specific locations during parsing
4779 return (previous_token.type === TOKEN$1.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
4780 (previous_token.type === TOKEN$1.END_EXPR && previous_token.text === ')' &&
4781 previous_token.opened.previous.type === TOKEN$1.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
4782 (in_array(previous_token.type, [TOKEN$1.COMMENT, TOKEN$1.START_EXPR, TOKEN$1.START_BLOCK, TOKEN$1.START,
4783 TOKEN$1.END_BLOCK, TOKEN$1.OPERATOR, TOKEN$1.EQUALS, TOKEN$1.EOF, TOKEN$1.SEMICOLON, TOKEN$1.COMMA
4784 ]));
4785 };
4786
4787 Tokenizer$1.prototype._read_regexp = function(c, previous_token) {
4788
4789 if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
4790 // handle regexp
4791 //
4792 var resulting_string = this._input.next();
4793 var esc = false;
4794
4795 var in_char_class = false;
4796 while (this._input.hasNext() &&
4797 ((esc || in_char_class || this._input.peek() !== c) &&
4798 !this._input.testChar(acorn.newline))) {
4799 resulting_string += this._input.peek();
4800 if (!esc) {
4801 esc = this._input.peek() === '\\';
4802 if (this._input.peek() === '[') {
4803 in_char_class = true;
4804 } else if (this._input.peek() === ']') {
4805 in_char_class = false;
4806 }
4807 } else {
4808 esc = false;
4809 }
4810 this._input.next();
4811 }
4812
4813 if (this._input.peek() === c) {
4814 resulting_string += this._input.next();
4815
4816 // regexps may have modifiers /regexp/MOD , so fetch those, too
4817 // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
4818 resulting_string += this._input.read(acorn.identifier);
4819 }
4820 return this._create_token(TOKEN$1.STRING, resulting_string);
4821 }
4822 return null;
4823 };
4824
4825 Tokenizer$1.prototype._read_xml = function(c, previous_token) {
4826
4827 if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
4828 var xmlStr = '';
4829 var match = this.__patterns.xml.read_match();
4830 // handle e4x xml literals
4831 //
4832 if (match) {
4833 // Trim root tag to attempt to
4834 var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
4835 var isCurlyRoot = rootTag.indexOf('{') === 0;
4836 var depth = 0;
4837 while (match) {
4838 var isEndTag = !!match[1];
4839 var tagName = match[2];
4840 var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
4841 if (!isSingletonTag &&
4842 (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
4843 if (isEndTag) {
4844 --depth;
4845 } else {
4846 ++depth;
4847 }
4848 }
4849 xmlStr += match[0];
4850 if (depth <= 0) {
4851 break;
4852 }
4853 match = this.__patterns.xml.read_match();
4854 }
4855 // if we didn't close correctly, keep unformatted.
4856 if (!match) {
4857 xmlStr += this._input.match(/[\s\S]*/g)[0];
4858 }
4859 xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
4860 return this._create_token(TOKEN$1.STRING, xmlStr);
4861 }
4862 }
4863
4864 return null;
4865 };
4866
4867 function unescape_string(s) {
4868 // You think that a regex would work for this
4869 // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
4870 // return String.fromCharCode(parseInt(val, 16));
4871 // })
4872 // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
4873 var out = '',
4874 escaped = 0;
4875
4876 var input_scan = new InputScanner$2(s);
4877 var matched = null;
4878
4879 while (input_scan.hasNext()) {
4880 // Keep any whitespace, non-slash characters
4881 // also keep slash pairs.
4882 matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
4883
4884 if (matched) {
4885 out += matched[0];
4886 }
4887
4888 if (input_scan.peek() === '\\') {
4889 input_scan.next();
4890 if (input_scan.peek() === 'x') {
4891 matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
4892 } else if (input_scan.peek() === 'u') {
4893 matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
4894 } else {
4895 out += '\\';
4896 if (input_scan.hasNext()) {
4897 out += input_scan.next();
4898 }
4899 continue;
4900 }
4901
4902 // If there's some error decoding, return the original string
4903 if (!matched) {
4904 return s;
4905 }
4906
4907 escaped = parseInt(matched[1], 16);
4908
4909 if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
4910 // we bail out on \x7f..\xff,
4911 // leaving whole string escaped,
4912 // as it's probably completely binary
4913 return s;
4914 } else if (escaped >= 0x00 && escaped < 0x20) {
4915 // leave 0x00...0x1f escaped
4916 out += '\\' + matched[0];
4917 continue;
4918 } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
4919 // single-quote, apostrophe, backslash - escape these
4920 out += '\\' + String.fromCharCode(escaped);
4921 } else {
4922 out += String.fromCharCode(escaped);
4923 }
4924 }
4925 }
4926
4927 return out;
4928 }
4929
4930 // handle string
4931 //
4932 Tokenizer$1.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
4933 var current_char;
4934 var pattern;
4935 if (delimiter === '\'') {
4936 pattern = this.__patterns.single_quote;
4937 } else if (delimiter === '"') {
4938 pattern = this.__patterns.double_quote;
4939 } else if (delimiter === '`') {
4940 pattern = this.__patterns.template_text;
4941 } else if (delimiter === '}') {
4942 pattern = this.__patterns.template_expression;
4943 }
4944
4945 var resulting_string = pattern.read();
4946 var next = '';
4947 while (this._input.hasNext()) {
4948 next = this._input.next();
4949 if (next === delimiter ||
4950 (!allow_unescaped_newlines && acorn.newline.test(next))) {
4951 this._input.back();
4952 break;
4953 } else if (next === '\\' && this._input.hasNext()) {
4954 current_char = this._input.peek();
4955
4956 if (current_char === 'x' || current_char === 'u') {
4957 this.has_char_escapes = true;
4958 } else if (current_char === '\r' && this._input.peek(1) === '\n') {
4959 this._input.next();
4960 }
4961 next += this._input.next();
4962 } else if (start_sub) {
4963 if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
4964 next += this._input.next();
4965 }
4966
4967 if (start_sub === next) {
4968 if (delimiter === '`') {
4969 next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
4970 } else {
4971 next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
4972 }
4973 if (this._input.hasNext()) {
4974 next += this._input.next();
4975 }
4976 }
4977 }
4978 next += pattern.read();
4979 resulting_string += next;
4980 }
4981
4982 return resulting_string;
4983 };
4984
4985 var Tokenizer_1$1 = Tokenizer$1;
4986 var TOKEN_1$1 = TOKEN$1;
4987 var positionable_operators_1 = positionable_operators.slice();
4988 var line_starters_1 = line_starters.slice();
4989
4990 var tokenizer$1 = {
4991 Tokenizer: Tokenizer_1$1,
4992 TOKEN: TOKEN_1$1,
4993 positionable_operators: positionable_operators_1,
4994 line_starters: line_starters_1
4995 };
4996
4997 var Output$1 = output.Output;
4998 var Token$2 = token.Token;
4999
5000 var Options$2 = options$1.Options;
5001 var Tokenizer$2 = tokenizer$1.Tokenizer;
5002 var line_starters$1 = tokenizer$1.line_starters;
5003 var positionable_operators$1 = tokenizer$1.positionable_operators;
5004 var TOKEN$2 = tokenizer$1.TOKEN;
5005
5006
5007 function in_array$1(what, arr) {
5008 return arr.indexOf(what) !== -1;
5009 }
5010
5011 function ltrim(s) {
5012 return s.replace(/^\s+/g, '');
5013 }
5014
5015 function generateMapFromStrings(list) {
5016 var result = {};
5017 for (var x = 0; x < list.length; x++) {
5018 // make the mapped names underscored instead of dash
5019 result[list[x].replace(/-/g, '_')] = list[x];
5020 }
5021 return result;
5022 }
5023
5024 function reserved_word(token, word) {
5025 return token && token.type === TOKEN$2.RESERVED && token.text === word;
5026 }
5027
5028 function reserved_array(token, words) {
5029 return token && token.type === TOKEN$2.RESERVED && in_array$1(token.text, words);
5030 }
5031 // Unsure of what they mean, but they work. Worth cleaning up in future.
5032 var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
5033
5034 var validPositionValues$1 = ['before-newline', 'after-newline', 'preserve-newline'];
5035
5036 // Generate map from array
5037 var OPERATOR_POSITION = generateMapFromStrings(validPositionValues$1);
5038
5039 var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
5040
5041 var MODE = {
5042 BlockStatement: 'BlockStatement', // 'BLOCK'
5043 Statement: 'Statement', // 'STATEMENT'
5044 ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
5045 ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
5046 ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
5047 Conditional: 'Conditional', //'(COND-EXPRESSION)',
5048 Expression: 'Expression' //'(EXPRESSION)'
5049 };
5050
5051 function remove_redundant_indentation(output, frame) {
5052 // This implementation is effective but has some issues:
5053 // - can cause line wrap to happen too soon due to indent removal
5054 // after wrap points are calculated
5055 // These issues are minor compared to ugly indentation.
5056
5057 if (frame.multiline_frame ||
5058 frame.mode === MODE.ForInitializer ||
5059 frame.mode === MODE.Conditional) {
5060 return;
5061 }
5062
5063 // remove one indent from each line inside this section
5064 output.remove_indent(frame.start_line_index);
5065 }
5066
5067 // we could use just string.split, but
5068 // IE doesn't like returning empty strings
5069 function split_linebreaks(s) {
5070 //return s.split(/\x0d\x0a|\x0a/);
5071
5072 s = s.replace(acorn.allLineBreaks, '\n');
5073 var out = [],
5074 idx = s.indexOf("\n");
5075 while (idx !== -1) {
5076 out.push(s.substring(0, idx));
5077 s = s.substring(idx + 1);
5078 idx = s.indexOf("\n");
5079 }
5080 if (s.length) {
5081 out.push(s);
5082 }
5083 return out;
5084 }
5085
5086 function is_array(mode) {
5087 return mode === MODE.ArrayLiteral;
5088 }
5089
5090 function is_expression(mode) {
5091 return in_array$1(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
5092 }
5093
5094 function all_lines_start_with(lines, c) {
5095 for (var i = 0; i < lines.length; i++) {
5096 var line = lines[i].trim();
5097 if (line.charAt(0) !== c) {
5098 return false;
5099 }
5100 }
5101 return true;
5102 }
5103
5104 function each_line_matches_indent(lines, indent) {
5105 var i = 0,
5106 len = lines.length,
5107 line;
5108 for (; i < len; i++) {
5109 line = lines[i];
5110 // allow empty lines to pass through
5111 if (line && line.indexOf(indent) !== 0) {
5112 return false;
5113 }
5114 }
5115 return true;
5116 }
5117
5118
5119 function Beautifier(source_text, options) {
5120 options = options || {};
5121 this._source_text = source_text || '';
5122
5123 this._output = null;
5124 this._tokens = null;
5125 this._last_last_text = null;
5126 this._flags = null;
5127 this._previous_flags = null;
5128
5129 this._flag_store = null;
5130 this._options = new Options$2(options);
5131 }
5132
5133 Beautifier.prototype.create_flags = function(flags_base, mode) {
5134 var next_indent_level = 0;
5135 if (flags_base) {
5136 next_indent_level = flags_base.indentation_level;
5137 if (!this._output.just_added_newline() &&
5138 flags_base.line_indent_level > next_indent_level) {
5139 next_indent_level = flags_base.line_indent_level;
5140 }
5141 }
5142
5143 var next_flags = {
5144 mode: mode,
5145 parent: flags_base,
5146 last_token: flags_base ? flags_base.last_token : new Token$2(TOKEN$2.START_BLOCK, ''), // last token text
5147 last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
5148 declaration_statement: false,
5149 declaration_assignment: false,
5150 multiline_frame: false,
5151 inline_frame: false,
5152 if_block: false,
5153 else_block: false,
5154 do_block: false,
5155 do_while: false,
5156 import_block: false,
5157 in_case_statement: false, // switch(..){ INSIDE HERE }
5158 in_case: false, // we're on the exact line with "case 0:"
5159 case_body: false, // the indented case-action block
5160 indentation_level: next_indent_level,
5161 alignment: 0,
5162 line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
5163 start_line_index: this._output.get_line_number(),
5164 ternary_depth: 0
5165 };
5166 return next_flags;
5167 };
5168
5169 Beautifier.prototype._reset = function(source_text) {
5170 var baseIndentString = source_text.match(/^[\t ]*/)[0];
5171
5172 this._last_last_text = ''; // pre-last token text
5173 this._output = new Output$1(this._options, baseIndentString);
5174
5175 // If testing the ignore directive, start with output disable set to true
5176 this._output.raw = this._options.test_output_raw;
5177
5178
5179 // Stack of parsing/formatting states, including MODE.
5180 // We tokenize, parse, and output in an almost purely a forward-only stream of token input
5181 // and formatted output. This makes the beautifier less accurate than full parsers
5182 // but also far more tolerant of syntax errors.
5183 //
5184 // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
5185 // MODE.BlockStatement on the the stack, even though it could be object literal. If we later
5186 // encounter a ":", we'll switch to to MODE.ObjectLiteral. If we then see a ";",
5187 // most full parsers would die, but the beautifier gracefully falls back to
5188 // MODE.BlockStatement and continues on.
5189 this._flag_store = [];
5190 this.set_mode(MODE.BlockStatement);
5191 var tokenizer = new Tokenizer$2(source_text, this._options);
5192 this._tokens = tokenizer.tokenize();
5193 return source_text;
5194 };
5195
5196 Beautifier.prototype.beautify = function() {
5197 // if disabled, return the input unchanged.
5198 if (this._options.disabled) {
5199 return this._source_text;
5200 }
5201
5202 var sweet_code;
5203 var source_text = this._reset(this._source_text);
5204
5205 var eol = this._options.eol;
5206 if (this._options.eol === 'auto') {
5207 eol = '\n';
5208 if (source_text && acorn.lineBreak.test(source_text || '')) {
5209 eol = source_text.match(acorn.lineBreak)[0];
5210 }
5211 }
5212
5213 var current_token = this._tokens.next();
5214 while (current_token) {
5215 this.handle_token(current_token);
5216
5217 this._last_last_text = this._flags.last_token.text;
5218 this._flags.last_token = current_token;
5219
5220 current_token = this._tokens.next();
5221 }
5222
5223 sweet_code = this._output.get_code(eol);
5224
5225 return sweet_code;
5226 };
5227
5228 Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
5229 if (current_token.type === TOKEN$2.START_EXPR) {
5230 this.handle_start_expr(current_token);
5231 } else if (current_token.type === TOKEN$2.END_EXPR) {
5232 this.handle_end_expr(current_token);
5233 } else if (current_token.type === TOKEN$2.START_BLOCK) {
5234 this.handle_start_block(current_token);
5235 } else if (current_token.type === TOKEN$2.END_BLOCK) {
5236 this.handle_end_block(current_token);
5237 } else if (current_token.type === TOKEN$2.WORD) {
5238 this.handle_word(current_token);
5239 } else if (current_token.type === TOKEN$2.RESERVED) {
5240 this.handle_word(current_token);
5241 } else if (current_token.type === TOKEN$2.SEMICOLON) {
5242 this.handle_semicolon(current_token);
5243 } else if (current_token.type === TOKEN$2.STRING) {
5244 this.handle_string(current_token);
5245 } else if (current_token.type === TOKEN$2.EQUALS) {
5246 this.handle_equals(current_token);
5247 } else if (current_token.type === TOKEN$2.OPERATOR) {
5248 this.handle_operator(current_token);
5249 } else if (current_token.type === TOKEN$2.COMMA) {
5250 this.handle_comma(current_token);
5251 } else if (current_token.type === TOKEN$2.BLOCK_COMMENT) {
5252 this.handle_block_comment(current_token, preserve_statement_flags);
5253 } else if (current_token.type === TOKEN$2.COMMENT) {
5254 this.handle_comment(current_token, preserve_statement_flags);
5255 } else if (current_token.type === TOKEN$2.DOT) {
5256 this.handle_dot(current_token);
5257 } else if (current_token.type === TOKEN$2.EOF) {
5258 this.handle_eof(current_token);
5259 } else if (current_token.type === TOKEN$2.UNKNOWN) {
5260 this.handle_unknown(current_token, preserve_statement_flags);
5261 } else {
5262 this.handle_unknown(current_token, preserve_statement_flags);
5263 }
5264 };
5265
5266 Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
5267 var newlines = current_token.newlines;
5268 var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
5269
5270 if (current_token.comments_before) {
5271 var comment_token = current_token.comments_before.next();
5272 while (comment_token) {
5273 // The cleanest handling of inline comments is to treat them as though they aren't there.
5274 // Just continue formatting and the behavior should be logical.
5275 // Also ignore unknown tokens. Again, this should result in better behavior.
5276 this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
5277 this.handle_token(comment_token, preserve_statement_flags);
5278 comment_token = current_token.comments_before.next();
5279 }
5280 }
5281
5282 if (keep_whitespace) {
5283 for (var i = 0; i < newlines; i += 1) {
5284 this.print_newline(i > 0, preserve_statement_flags);
5285 }
5286 } else {
5287 if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
5288 newlines = this._options.max_preserve_newlines;
5289 }
5290
5291 if (this._options.preserve_newlines) {
5292 if (newlines > 1) {
5293 this.print_newline(false, preserve_statement_flags);
5294 for (var j = 1; j < newlines; j += 1) {
5295 this.print_newline(true, preserve_statement_flags);
5296 }
5297 }
5298 }
5299 }
5300
5301 };
5302
5303 var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
5304
5305 Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
5306 force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
5307
5308 // Never wrap the first token on a line
5309 if (this._output.just_added_newline()) {
5310 return;
5311 }
5312
5313 var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
5314 var operatorLogicApplies = in_array$1(this._flags.last_token.text, positionable_operators$1) ||
5315 in_array$1(current_token.text, positionable_operators$1);
5316
5317 if (operatorLogicApplies) {
5318 var shouldPrintOperatorNewline = (
5319 in_array$1(this._flags.last_token.text, positionable_operators$1) &&
5320 in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
5321 ) ||
5322 in_array$1(current_token.text, positionable_operators$1);
5323 shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
5324 }
5325
5326 if (shouldPreserveOrForce) {
5327 this.print_newline(false, true);
5328 } else if (this._options.wrap_line_length) {
5329 if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5330 // These tokens should never have a newline inserted
5331 // between them and the following expression.
5332 return;
5333 }
5334 this._output.set_wrap_point();
5335 }
5336 };
5337
5338 Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
5339 if (!preserve_statement_flags) {
5340 if (this._flags.last_token.text !== ';' && this._flags.last_token.text !== ',' && this._flags.last_token.text !== '=' && (this._flags.last_token.type !== TOKEN$2.OPERATOR || this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) {
5341 var next_token = this._tokens.peek();
5342 while (this._flags.mode === MODE.Statement &&
5343 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
5344 !this._flags.do_block) {
5345 this.restore_mode();
5346 }
5347 }
5348 }
5349
5350 if (this._output.add_new_line(force_newline)) {
5351 this._flags.multiline_frame = true;
5352 }
5353 };
5354
5355 Beautifier.prototype.print_token_line_indentation = function(current_token) {
5356 if (this._output.just_added_newline()) {
5357 if (this._options.keep_array_indentation &&
5358 current_token.newlines &&
5359 (current_token.text === '[' || is_array(this._flags.mode))) {
5360 this._output.current_line.set_indent(-1);
5361 this._output.current_line.push(current_token.whitespace_before);
5362 this._output.space_before_token = false;
5363 } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
5364 this._flags.line_indent_level = this._flags.indentation_level;
5365 }
5366 }
5367 };
5368
5369 Beautifier.prototype.print_token = function(current_token) {
5370 if (this._output.raw) {
5371 this._output.add_raw_token(current_token);
5372 return;
5373 }
5374
5375 if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN$2.COMMA &&
5376 this._output.just_added_newline()) {
5377 if (this._output.previous_line.last() === ',') {
5378 var popped = this._output.previous_line.pop();
5379 // if the comma was already at the start of the line,
5380 // pull back onto that line and reprint the indentation
5381 if (this._output.previous_line.is_empty()) {
5382 this._output.previous_line.push(popped);
5383 this._output.trim(true);
5384 this._output.current_line.pop();
5385 this._output.trim();
5386 }
5387
5388 // add the comma in front of the next token
5389 this.print_token_line_indentation(current_token);
5390 this._output.add_token(',');
5391 this._output.space_before_token = true;
5392 }
5393 }
5394
5395 this.print_token_line_indentation(current_token);
5396 this._output.non_breaking_space = true;
5397 this._output.add_token(current_token.text);
5398 if (this._output.previous_token_wrapped) {
5399 this._flags.multiline_frame = true;
5400 }
5401 };
5402
5403 Beautifier.prototype.indent = function() {
5404 this._flags.indentation_level += 1;
5405 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5406 };
5407
5408 Beautifier.prototype.deindent = function() {
5409 if (this._flags.indentation_level > 0 &&
5410 ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
5411 this._flags.indentation_level -= 1;
5412 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5413 }
5414 };
5415
5416 Beautifier.prototype.set_mode = function(mode) {
5417 if (this._flags) {
5418 this._flag_store.push(this._flags);
5419 this._previous_flags = this._flags;
5420 } else {
5421 this._previous_flags = this.create_flags(null, mode);
5422 }
5423
5424 this._flags = this.create_flags(this._previous_flags, mode);
5425 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5426 };
5427
5428
5429 Beautifier.prototype.restore_mode = function() {
5430 if (this._flag_store.length > 0) {
5431 this._previous_flags = this._flags;
5432 this._flags = this._flag_store.pop();
5433 if (this._previous_flags.mode === MODE.Statement) {
5434 remove_redundant_indentation(this._output, this._previous_flags);
5435 }
5436 this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
5437 }
5438 };
5439
5440 Beautifier.prototype.start_of_object_property = function() {
5441 return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
5442 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
5443 };
5444
5445 Beautifier.prototype.start_of_statement = function(current_token) {
5446 var start = false;
5447 start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD;
5448 start = start || reserved_word(this._flags.last_token, 'do');
5449 start = start || (!(this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement)) && reserved_array(this._flags.last_token, newline_restricted_tokens) && !current_token.newlines;
5450 start = start || reserved_word(this._flags.last_token, 'else') &&
5451 !(reserved_word(current_token, 'if') && !current_token.comments_before);
5452 start = start || (this._flags.last_token.type === TOKEN$2.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
5453 start = start || (this._flags.last_token.type === TOKEN$2.WORD && this._flags.mode === MODE.BlockStatement &&
5454 !this._flags.in_case &&
5455 !(current_token.text === '--' || current_token.text === '++') &&
5456 this._last_last_text !== 'function' &&
5457 current_token.type !== TOKEN$2.WORD && current_token.type !== TOKEN$2.RESERVED);
5458 start = start || (this._flags.mode === MODE.ObjectLiteral && (
5459 (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
5460
5461 if (start) {
5462 this.set_mode(MODE.Statement);
5463 this.indent();
5464
5465 this.handle_whitespace_and_comments(current_token, true);
5466
5467 // Issue #276:
5468 // If starting a new statement with [if, for, while, do], push to a new line.
5469 // if (a) if (b) if(c) d(); else e(); else f();
5470 if (!this.start_of_object_property()) {
5471 this.allow_wrap_or_preserved_newline(current_token,
5472 reserved_array(current_token, ['do', 'for', 'if', 'while']));
5473 }
5474 return true;
5475 }
5476 return false;
5477 };
5478
5479 Beautifier.prototype.handle_start_expr = function(current_token) {
5480 // The conditional starts the statement if appropriate.
5481 if (!this.start_of_statement(current_token)) {
5482 this.handle_whitespace_and_comments(current_token);
5483 }
5484
5485 var next_mode = MODE.Expression;
5486 if (current_token.text === '[') {
5487
5488 if (this._flags.last_token.type === TOKEN$2.WORD || this._flags.last_token.text === ')') {
5489 // this is array index specifier, break immediately
5490 // a[x], fn()[x]
5491 if (reserved_array(this._flags.last_token, line_starters$1)) {
5492 this._output.space_before_token = true;
5493 }
5494 this.print_token(current_token);
5495 this.set_mode(next_mode);
5496 this.indent();
5497 if (this._options.space_in_paren) {
5498 this._output.space_before_token = true;
5499 }
5500 return;
5501 }
5502
5503 next_mode = MODE.ArrayLiteral;
5504 if (is_array(this._flags.mode)) {
5505 if (this._flags.last_token.text === '[' ||
5506 (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
5507 // ], [ goes to new line
5508 // }, [ goes to new line
5509 if (!this._options.keep_array_indentation) {
5510 this.print_newline();
5511 }
5512 }
5513 }
5514
5515 if (!in_array$1(this._flags.last_token.type, [TOKEN$2.START_EXPR, TOKEN$2.END_EXPR, TOKEN$2.WORD, TOKEN$2.OPERATOR])) {
5516 this._output.space_before_token = true;
5517 }
5518 } else {
5519 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
5520 if (this._flags.last_token.text === 'for') {
5521 this._output.space_before_token = this._options.space_before_conditional;
5522 next_mode = MODE.ForInitializer;
5523 } else if (in_array$1(this._flags.last_token.text, ['if', 'while'])) {
5524 this._output.space_before_token = this._options.space_before_conditional;
5525 next_mode = MODE.Conditional;
5526 } else if (in_array$1(this._flags.last_word, ['await', 'async'])) {
5527 // Should be a space between await and an IIFE, or async and an arrow function
5528 this._output.space_before_token = true;
5529 } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
5530 this._output.space_before_token = false;
5531 } else if (in_array$1(this._flags.last_token.text, line_starters$1) || this._flags.last_token.text === 'catch') {
5532 this._output.space_before_token = true;
5533 }
5534 } else if (this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
5535 // Support of this kind of newline preservation.
5536 // a = (b &&
5537 // (c || d));
5538 if (!this.start_of_object_property()) {
5539 this.allow_wrap_or_preserved_newline(current_token);
5540 }
5541 } else if (this._flags.last_token.type === TOKEN$2.WORD) {
5542 this._output.space_before_token = false;
5543
5544 // function name() vs function name ()
5545 // function* name() vs function* name ()
5546 // async name() vs async name ()
5547 // In ES6, you can also define the method properties of an object
5548 // var obj = {a: function() {}}
5549 // It can be abbreviated
5550 // var obj = {a() {}}
5551 // var obj = { a() {}} vs var obj = { a () {}}
5552 // var obj = { * a() {}} vs var obj = { * a () {}}
5553 var peek_back_two = this._tokens.peek(-3);
5554 if (this._options.space_after_named_function && peek_back_two) {
5555 // peek starts at next character so -1 is current token
5556 var peek_back_three = this._tokens.peek(-4);
5557 if (reserved_array(peek_back_two, ['async', 'function']) ||
5558 (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
5559 this._output.space_before_token = true;
5560 } else if (this._flags.mode === MODE.ObjectLiteral) {
5561 if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
5562 (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
5563 this._output.space_before_token = true;
5564 }
5565 }
5566 }
5567 } else {
5568 // Support preserving wrapped arrow function expressions
5569 // a.b('c',
5570 // () => d.e
5571 // )
5572 this.allow_wrap_or_preserved_newline(current_token);
5573 }
5574
5575 // function() vs function ()
5576 // yield*() vs yield* ()
5577 // function*() vs function* ()
5578 if ((this._flags.last_token.type === TOKEN$2.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
5579 (this._flags.last_token.text === '*' &&
5580 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5581 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5582 this._output.space_before_token = this._options.space_after_anon_function;
5583 }
5584 }
5585
5586 if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5587 this.print_newline();
5588 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.END_BLOCK || this._flags.last_token.text === '.' || this._flags.last_token.type === TOKEN$2.COMMA) {
5589 // do nothing on (( and )( and ][ and ]( and .(
5590 // TODO: Consider whether forcing this is required. Review failing tests when removed.
5591 this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
5592 }
5593
5594 this.print_token(current_token);
5595 this.set_mode(next_mode);
5596 if (this._options.space_in_paren) {
5597 this._output.space_before_token = true;
5598 }
5599
5600 // In all cases, if we newline while inside an expression it should be indented.
5601 this.indent();
5602 };
5603
5604 Beautifier.prototype.handle_end_expr = function(current_token) {
5605 // statements inside expressions are not valid syntax, but...
5606 // statements must all be closed when their container closes
5607 while (this._flags.mode === MODE.Statement) {
5608 this.restore_mode();
5609 }
5610
5611 this.handle_whitespace_and_comments(current_token);
5612
5613 if (this._flags.multiline_frame) {
5614 this.allow_wrap_or_preserved_newline(current_token,
5615 current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
5616 }
5617
5618 if (this._options.space_in_paren) {
5619 if (this._flags.last_token.type === TOKEN$2.START_EXPR && !this._options.space_in_empty_paren) {
5620 // () [] no inner space in empty parens like these, ever, ref #320
5621 this._output.trim();
5622 this._output.space_before_token = false;
5623 } else {
5624 this._output.space_before_token = true;
5625 }
5626 }
5627 this.deindent();
5628 this.print_token(current_token);
5629 this.restore_mode();
5630
5631 remove_redundant_indentation(this._output, this._previous_flags);
5632
5633 // do {} while () // no statement required after
5634 if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
5635 this._previous_flags.mode = MODE.Expression;
5636 this._flags.do_block = false;
5637 this._flags.do_while = false;
5638
5639 }
5640 };
5641
5642 Beautifier.prototype.handle_start_block = function(current_token) {
5643 this.handle_whitespace_and_comments(current_token);
5644
5645 // Check if this is should be treated as a ObjectLiteral
5646 var next_token = this._tokens.peek();
5647 var second_token = this._tokens.peek(1);
5648 if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN$2.END_EXPR) {
5649 this.set_mode(MODE.BlockStatement);
5650 this._flags.in_case_statement = true;
5651 } else if (this._flags.case_body) {
5652 this.set_mode(MODE.BlockStatement);
5653 } else if (second_token && (
5654 (in_array$1(second_token.text, [':', ',']) && in_array$1(next_token.type, [TOKEN$2.STRING, TOKEN$2.WORD, TOKEN$2.RESERVED])) ||
5655 (in_array$1(next_token.text, ['get', 'set', '...']) && in_array$1(second_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]))
5656 )) {
5657 // We don't support TypeScript,but we didn't break it for a very long time.
5658 // We'll try to keep not breaking it.
5659 if (!in_array$1(this._last_last_text, ['class', 'interface'])) {
5660 this.set_mode(MODE.ObjectLiteral);
5661 } else {
5662 this.set_mode(MODE.BlockStatement);
5663 }
5664 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR && this._flags.last_token.text === '=>') {
5665 // arrow function: (param1, paramN) => { statements }
5666 this.set_mode(MODE.BlockStatement);
5667 } else if (in_array$1(this._flags.last_token.type, [TOKEN$2.EQUALS, TOKEN$2.START_EXPR, TOKEN$2.COMMA, TOKEN$2.OPERATOR]) ||
5668 reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
5669 ) {
5670 // Detecting shorthand function syntax is difficult by scanning forward,
5671 // so check the surrounding context.
5672 // If the block is being returned, imported, export default, passed as arg,
5673 // assigned with = or assigned in a nested object, treat as an ObjectLiteral.
5674 this.set_mode(MODE.ObjectLiteral);
5675 } else {
5676 this.set_mode(MODE.BlockStatement);
5677 }
5678
5679 var empty_braces = !next_token.comments_before && next_token.text === '}';
5680 var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
5681 this._flags.last_token.type === TOKEN$2.END_EXPR;
5682
5683 if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
5684 {
5685 // search forward for a newline wanted inside this block
5686 var index = 0;
5687 var check_token = null;
5688 this._flags.inline_frame = true;
5689 do {
5690 index += 1;
5691 check_token = this._tokens.peek(index - 1);
5692 if (check_token.newlines) {
5693 this._flags.inline_frame = false;
5694 break;
5695 }
5696 } while (check_token.type !== TOKEN$2.EOF &&
5697 !(check_token.type === TOKEN$2.END_BLOCK && check_token.opened === current_token));
5698 }
5699
5700 if ((this._options.brace_style === "expand" ||
5701 (this._options.brace_style === "none" && current_token.newlines)) &&
5702 !this._flags.inline_frame) {
5703 if (this._flags.last_token.type !== TOKEN$2.OPERATOR &&
5704 (empty_anonymous_function ||
5705 this._flags.last_token.type === TOKEN$2.EQUALS ||
5706 (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
5707 this._output.space_before_token = true;
5708 } else {
5709 this.print_newline(false, true);
5710 }
5711 } else { // collapse || inline_frame
5712 if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.COMMA)) {
5713 if (this._flags.last_token.type === TOKEN$2.COMMA || this._options.space_in_paren) {
5714 this._output.space_before_token = true;
5715 }
5716
5717 if (this._flags.last_token.type === TOKEN$2.COMMA || (this._flags.last_token.type === TOKEN$2.START_EXPR && this._flags.inline_frame)) {
5718 this.allow_wrap_or_preserved_newline(current_token);
5719 this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
5720 this._flags.multiline_frame = false;
5721 }
5722 }
5723 if (this._flags.last_token.type !== TOKEN$2.OPERATOR && this._flags.last_token.type !== TOKEN$2.START_EXPR) {
5724 if (this._flags.last_token.type === TOKEN$2.START_BLOCK && !this._flags.inline_frame) {
5725 this.print_newline();
5726 } else {
5727 this._output.space_before_token = true;
5728 }
5729 }
5730 }
5731 this.print_token(current_token);
5732 this.indent();
5733
5734 // Except for specific cases, open braces are followed by a new line.
5735 if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
5736 this.print_newline();
5737 }
5738 };
5739
5740 Beautifier.prototype.handle_end_block = function(current_token) {
5741 // statements must all be closed when their container closes
5742 this.handle_whitespace_and_comments(current_token);
5743
5744 while (this._flags.mode === MODE.Statement) {
5745 this.restore_mode();
5746 }
5747
5748 var empty_braces = this._flags.last_token.type === TOKEN$2.START_BLOCK;
5749
5750 if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
5751 this._output.space_before_token = true;
5752 } else if (this._options.brace_style === "expand") {
5753 if (!empty_braces) {
5754 this.print_newline();
5755 }
5756 } else {
5757 // skip {}
5758 if (!empty_braces) {
5759 if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
5760 // we REALLY need a newline here, but newliner would skip that
5761 this._options.keep_array_indentation = false;
5762 this.print_newline();
5763 this._options.keep_array_indentation = true;
5764
5765 } else {
5766 this.print_newline();
5767 }
5768 }
5769 }
5770 this.restore_mode();
5771 this.print_token(current_token);
5772 };
5773
5774 Beautifier.prototype.handle_word = function(current_token) {
5775 if (current_token.type === TOKEN$2.RESERVED) {
5776 if (in_array$1(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
5777 current_token.type = TOKEN$2.WORD;
5778 } else if (current_token.text === 'import' && this._tokens.peek().text === '(') {
5779 current_token.type = TOKEN$2.WORD;
5780 } else if (in_array$1(current_token.text, ['as', 'from']) && !this._flags.import_block) {
5781 current_token.type = TOKEN$2.WORD;
5782 } else if (this._flags.mode === MODE.ObjectLiteral) {
5783 var next_token = this._tokens.peek();
5784 if (next_token.text === ':') {
5785 current_token.type = TOKEN$2.WORD;
5786 }
5787 }
5788 }
5789
5790 if (this.start_of_statement(current_token)) {
5791 // The conditional starts the statement if appropriate.
5792 if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN$2.WORD) {
5793 this._flags.declaration_statement = true;
5794 }
5795 } else if (current_token.newlines && !is_expression(this._flags.mode) &&
5796 (this._flags.last_token.type !== TOKEN$2.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
5797 this._flags.last_token.type !== TOKEN$2.EQUALS &&
5798 (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
5799 this.handle_whitespace_and_comments(current_token);
5800 this.print_newline();
5801 } else {
5802 this.handle_whitespace_and_comments(current_token);
5803 }
5804
5805 if (this._flags.do_block && !this._flags.do_while) {
5806 if (reserved_word(current_token, 'while')) {
5807 // do {} ## while ()
5808 this._output.space_before_token = true;
5809 this.print_token(current_token);
5810 this._output.space_before_token = true;
5811 this._flags.do_while = true;
5812 return;
5813 } else {
5814 // do {} should always have while as the next word.
5815 // if we don't see the expected while, recover
5816 this.print_newline();
5817 this._flags.do_block = false;
5818 }
5819 }
5820
5821 // if may be followed by else, or not
5822 // Bare/inline ifs are tricky
5823 // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
5824 if (this._flags.if_block) {
5825 if (!this._flags.else_block && reserved_word(current_token, 'else')) {
5826 this._flags.else_block = true;
5827 } else {
5828 while (this._flags.mode === MODE.Statement) {
5829 this.restore_mode();
5830 }
5831 this._flags.if_block = false;
5832 this._flags.else_block = false;
5833 }
5834 }
5835
5836 if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
5837 this.print_newline();
5838 if (this._flags.last_token.type !== TOKEN$2.END_BLOCK && (this._flags.case_body || this._options.jslint_happy)) {
5839 // switch cases following one another
5840 this.deindent();
5841 }
5842 this._flags.case_body = false;
5843
5844 this.print_token(current_token);
5845 this._flags.in_case = true;
5846 return;
5847 }
5848
5849 if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
5850 if (!this.start_of_object_property()) {
5851 this.allow_wrap_or_preserved_newline(current_token);
5852 }
5853 }
5854
5855 if (reserved_word(current_token, 'function')) {
5856 if (in_array$1(this._flags.last_token.text, ['}', ';']) ||
5857 (this._output.just_added_newline() && !(in_array$1(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN$2.OPERATOR))) {
5858 // make sure there is a nice clean space of at least one blank line
5859 // before a new function definition
5860 if (!this._output.just_added_blankline() && !current_token.comments_before) {
5861 this.print_newline();
5862 this.print_newline(true);
5863 }
5864 }
5865 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD) {
5866 if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
5867 reserved_array(this._flags.last_token, newline_restricted_tokens)) {
5868 this._output.space_before_token = true;
5869 } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
5870 this._output.space_before_token = true;
5871 } else if (this._flags.last_token.text === 'declare') {
5872 // accomodates Typescript declare function formatting
5873 this._output.space_before_token = true;
5874 } else {
5875 this.print_newline();
5876 }
5877 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR || this._flags.last_token.text === '=') {
5878 // foo = function
5879 this._output.space_before_token = true;
5880 } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) ; else {
5881 this.print_newline();
5882 }
5883
5884 this.print_token(current_token);
5885 this._flags.last_word = current_token.text;
5886 return;
5887 }
5888
5889 var prefix = 'NONE';
5890
5891 if (this._flags.last_token.type === TOKEN$2.END_BLOCK) {
5892
5893 if (this._previous_flags.inline_frame) {
5894 prefix = 'SPACE';
5895 } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
5896 prefix = 'NEWLINE';
5897 } else {
5898 if (this._options.brace_style === "expand" ||
5899 this._options.brace_style === "end-expand" ||
5900 (this._options.brace_style === "none" && current_token.newlines)) {
5901 prefix = 'NEWLINE';
5902 } else {
5903 prefix = 'SPACE';
5904 this._output.space_before_token = true;
5905 }
5906 }
5907 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
5908 // TODO: Should this be for STATEMENT as well?
5909 prefix = 'NEWLINE';
5910 } else if (this._flags.last_token.type === TOKEN$2.SEMICOLON && is_expression(this._flags.mode)) {
5911 prefix = 'SPACE';
5912 } else if (this._flags.last_token.type === TOKEN$2.STRING) {
5913 prefix = 'NEWLINE';
5914 } else if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD ||
5915 (this._flags.last_token.text === '*' &&
5916 (in_array$1(this._last_last_text, ['function', 'yield']) ||
5917 (this._flags.mode === MODE.ObjectLiteral && in_array$1(this._last_last_text, ['{', ',']))))) {
5918 prefix = 'SPACE';
5919 } else if (this._flags.last_token.type === TOKEN$2.START_BLOCK) {
5920 if (this._flags.inline_frame) {
5921 prefix = 'SPACE';
5922 } else {
5923 prefix = 'NEWLINE';
5924 }
5925 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
5926 this._output.space_before_token = true;
5927 prefix = 'NEWLINE';
5928 }
5929
5930 if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5931 if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
5932 prefix = 'SPACE';
5933 } else {
5934 prefix = 'NEWLINE';
5935 }
5936
5937 }
5938
5939 if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
5940 if ((!(this._flags.last_token.type === TOKEN$2.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
5941 this._options.brace_style === "expand" ||
5942 this._options.brace_style === "end-expand" ||
5943 (this._options.brace_style === "none" && current_token.newlines)) &&
5944 !this._flags.inline_frame) {
5945 this.print_newline();
5946 } else {
5947 this._output.trim(true);
5948 var line = this._output.current_line;
5949 // If we trimmed and there's something other than a close block before us
5950 // put a newline back in. Handles '} // comment' scenario.
5951 if (line.last() !== '}') {
5952 this.print_newline();
5953 }
5954 this._output.space_before_token = true;
5955 }
5956 } else if (prefix === 'NEWLINE') {
5957 if (reserved_array(this._flags.last_token, special_words)) {
5958 // no newline between 'return nnn'
5959 this._output.space_before_token = true;
5960 } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
5961 // accomodates Typescript declare formatting
5962 this._output.space_before_token = true;
5963 } else if (this._flags.last_token.type !== TOKEN$2.END_EXPR) {
5964 if ((this._flags.last_token.type !== TOKEN$2.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
5965 // no need to force newline on 'var': for (var x = 0...)
5966 if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
5967 // no newline for } else if {
5968 this._output.space_before_token = true;
5969 } else {
5970 this.print_newline();
5971 }
5972 }
5973 } else if (reserved_array(current_token, line_starters$1) && this._flags.last_token.text !== ')') {
5974 this.print_newline();
5975 }
5976 } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
5977 this.print_newline(); // }, in lists get a newline treatment
5978 } else if (prefix === 'SPACE') {
5979 this._output.space_before_token = true;
5980 }
5981 if (current_token.previous && (current_token.previous.type === TOKEN$2.WORD || current_token.previous.type === TOKEN$2.RESERVED)) {
5982 this._output.space_before_token = true;
5983 }
5984 this.print_token(current_token);
5985 this._flags.last_word = current_token.text;
5986
5987 if (current_token.type === TOKEN$2.RESERVED) {
5988 if (current_token.text === 'do') {
5989 this._flags.do_block = true;
5990 } else if (current_token.text === 'if') {
5991 this._flags.if_block = true;
5992 } else if (current_token.text === 'import') {
5993 this._flags.import_block = true;
5994 } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
5995 this._flags.import_block = false;
5996 }
5997 }
5998 };
5999
6000 Beautifier.prototype.handle_semicolon = function(current_token) {
6001 if (this.start_of_statement(current_token)) {
6002 // The conditional starts the statement if appropriate.
6003 // Semicolon can be the start (and end) of a statement
6004 this._output.space_before_token = false;
6005 } else {
6006 this.handle_whitespace_and_comments(current_token);
6007 }
6008
6009 var next_token = this._tokens.peek();
6010 while (this._flags.mode === MODE.Statement &&
6011 !(this._flags.if_block && reserved_word(next_token, 'else')) &&
6012 !this._flags.do_block) {
6013 this.restore_mode();
6014 }
6015
6016 // hacky but effective for the moment
6017 if (this._flags.import_block) {
6018 this._flags.import_block = false;
6019 }
6020 this.print_token(current_token);
6021 };
6022
6023 Beautifier.prototype.handle_string = function(current_token) {
6024 if (this.start_of_statement(current_token)) {
6025 // The conditional starts the statement if appropriate.
6026 // One difference - strings want at least a space before
6027 this._output.space_before_token = true;
6028 } else {
6029 this.handle_whitespace_and_comments(current_token);
6030 if (this._flags.last_token.type === TOKEN$2.RESERVED || this._flags.last_token.type === TOKEN$2.WORD || this._flags.inline_frame) {
6031 this._output.space_before_token = true;
6032 } else if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR || this._flags.last_token.type === TOKEN$2.EQUALS || this._flags.last_token.type === TOKEN$2.OPERATOR) {
6033 if (!this.start_of_object_property()) {
6034 this.allow_wrap_or_preserved_newline(current_token);
6035 }
6036 } else {
6037 this.print_newline();
6038 }
6039 }
6040 this.print_token(current_token);
6041 };
6042
6043 Beautifier.prototype.handle_equals = function(current_token) {
6044 if (this.start_of_statement(current_token)) ; else {
6045 this.handle_whitespace_and_comments(current_token);
6046 }
6047
6048 if (this._flags.declaration_statement) {
6049 // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
6050 this._flags.declaration_assignment = true;
6051 }
6052 this._output.space_before_token = true;
6053 this.print_token(current_token);
6054 this._output.space_before_token = true;
6055 };
6056
6057 Beautifier.prototype.handle_comma = function(current_token) {
6058 this.handle_whitespace_and_comments(current_token, true);
6059
6060 this.print_token(current_token);
6061 this._output.space_before_token = true;
6062 if (this._flags.declaration_statement) {
6063 if (is_expression(this._flags.parent.mode)) {
6064 // do not break on comma, for(var a = 1, b = 2)
6065 this._flags.declaration_assignment = false;
6066 }
6067
6068 if (this._flags.declaration_assignment) {
6069 this._flags.declaration_assignment = false;
6070 this.print_newline(false, true);
6071 } else if (this._options.comma_first) {
6072 // for comma-first, we want to allow a newline before the comma
6073 // to turn into a newline after the comma, which we will fixup later
6074 this.allow_wrap_or_preserved_newline(current_token);
6075 }
6076 } else if (this._flags.mode === MODE.ObjectLiteral ||
6077 (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
6078 if (this._flags.mode === MODE.Statement) {
6079 this.restore_mode();
6080 }
6081
6082 if (!this._flags.inline_frame) {
6083 this.print_newline();
6084 }
6085 } else if (this._options.comma_first) {
6086 // EXPR or DO_BLOCK
6087 // for comma-first, we want to allow a newline before the comma
6088 // to turn into a newline after the comma, which we will fixup later
6089 this.allow_wrap_or_preserved_newline(current_token);
6090 }
6091 };
6092
6093 Beautifier.prototype.handle_operator = function(current_token) {
6094 var isGeneratorAsterisk = current_token.text === '*' &&
6095 (reserved_array(this._flags.last_token, ['function', 'yield']) ||
6096 (in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.COMMA, TOKEN$2.END_BLOCK, TOKEN$2.SEMICOLON]))
6097 );
6098 var isUnary = in_array$1(current_token.text, ['-', '+']) && (
6099 in_array$1(this._flags.last_token.type, [TOKEN$2.START_BLOCK, TOKEN$2.START_EXPR, TOKEN$2.EQUALS, TOKEN$2.OPERATOR]) ||
6100 in_array$1(this._flags.last_token.text, line_starters$1) ||
6101 this._flags.last_token.text === ','
6102 );
6103
6104 if (this.start_of_statement(current_token)) ; else {
6105 var preserve_statement_flags = !isGeneratorAsterisk;
6106 this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
6107 }
6108
6109 if (reserved_array(this._flags.last_token, special_words)) {
6110 // "return" had a special handling in TK_WORD. Now we need to return the favor
6111 this._output.space_before_token = true;
6112 this.print_token(current_token);
6113 return;
6114 }
6115
6116 // hack for actionscript's import .*;
6117 if (current_token.text === '*' && this._flags.last_token.type === TOKEN$2.DOT) {
6118 this.print_token(current_token);
6119 return;
6120 }
6121
6122 if (current_token.text === '::') {
6123 // no spaces around exotic namespacing syntax operator
6124 this.print_token(current_token);
6125 return;
6126 }
6127
6128 // Allow line wrapping between operators when operator_position is
6129 // set to before or preserve
6130 if (this._flags.last_token.type === TOKEN$2.OPERATOR && in_array$1(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
6131 this.allow_wrap_or_preserved_newline(current_token);
6132 }
6133
6134 if (current_token.text === ':' && this._flags.in_case) {
6135 this.print_token(current_token);
6136
6137 this._flags.in_case = false;
6138 this._flags.case_body = true;
6139 if (this._tokens.peek().type !== TOKEN$2.START_BLOCK) {
6140 this.indent();
6141 this.print_newline();
6142 } else {
6143 this._output.space_before_token = true;
6144 }
6145 return;
6146 }
6147
6148 var space_before = true;
6149 var space_after = true;
6150 var in_ternary = false;
6151 if (current_token.text === ':') {
6152 if (this._flags.ternary_depth === 0) {
6153 // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
6154 space_before = false;
6155 } else {
6156 this._flags.ternary_depth -= 1;
6157 in_ternary = true;
6158 }
6159 } else if (current_token.text === '?') {
6160 this._flags.ternary_depth += 1;
6161 }
6162
6163 // let's handle the operator_position option prior to any conflicting logic
6164 if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array$1(current_token.text, positionable_operators$1)) {
6165 var isColon = current_token.text === ':';
6166 var isTernaryColon = (isColon && in_ternary);
6167 var isOtherColon = (isColon && !in_ternary);
6168
6169 switch (this._options.operator_position) {
6170 case OPERATOR_POSITION.before_newline:
6171 // if the current token is : and it's not a ternary statement then we set space_before to false
6172 this._output.space_before_token = !isOtherColon;
6173
6174 this.print_token(current_token);
6175
6176 if (!isColon || isTernaryColon) {
6177 this.allow_wrap_or_preserved_newline(current_token);
6178 }
6179
6180 this._output.space_before_token = true;
6181 return;
6182
6183 case OPERATOR_POSITION.after_newline:
6184 // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
6185 // then print a newline.
6186
6187 this._output.space_before_token = true;
6188
6189 if (!isColon || isTernaryColon) {
6190 if (this._tokens.peek().newlines) {
6191 this.print_newline(false, true);
6192 } else {
6193 this.allow_wrap_or_preserved_newline(current_token);
6194 }
6195 } else {
6196 this._output.space_before_token = false;
6197 }
6198
6199 this.print_token(current_token);
6200
6201 this._output.space_before_token = true;
6202 return;
6203
6204 case OPERATOR_POSITION.preserve_newline:
6205 if (!isOtherColon) {
6206 this.allow_wrap_or_preserved_newline(current_token);
6207 }
6208
6209 // if we just added a newline, or the current token is : and it's not a ternary statement,
6210 // then we set space_before to false
6211 space_before = !(this._output.just_added_newline() || isOtherColon);
6212
6213 this._output.space_before_token = space_before;
6214 this.print_token(current_token);
6215 this._output.space_before_token = true;
6216 return;
6217 }
6218 }
6219
6220 if (isGeneratorAsterisk) {
6221 this.allow_wrap_or_preserved_newline(current_token);
6222 space_before = false;
6223 var next_token = this._tokens.peek();
6224 space_after = next_token && in_array$1(next_token.type, [TOKEN$2.WORD, TOKEN$2.RESERVED]);
6225 } else if (current_token.text === '...') {
6226 this.allow_wrap_or_preserved_newline(current_token);
6227 space_before = this._flags.last_token.type === TOKEN$2.START_BLOCK;
6228 space_after = false;
6229 } else if (in_array$1(current_token.text, ['--', '++', '!', '~']) || isUnary) {
6230 // unary operators (and binary +/- pretending to be unary) special cases
6231 if (this._flags.last_token.type === TOKEN$2.COMMA || this._flags.last_token.type === TOKEN$2.START_EXPR) {
6232 this.allow_wrap_or_preserved_newline(current_token);
6233 }
6234
6235 space_before = false;
6236 space_after = false;
6237
6238 // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
6239 // if there is a newline between -- or ++ and anything else we should preserve it.
6240 if (current_token.newlines && (current_token.text === '--' || current_token.text === '++')) {
6241 this.print_newline(false, true);
6242 }
6243
6244 if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
6245 // for (;; ++i)
6246 // ^^^
6247 space_before = true;
6248 }
6249
6250 if (this._flags.last_token.type === TOKEN$2.RESERVED) {
6251 space_before = true;
6252 } else if (this._flags.last_token.type === TOKEN$2.END_EXPR) {
6253 space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
6254 } else if (this._flags.last_token.type === TOKEN$2.OPERATOR) {
6255 // a++ + ++b;
6256 // a - -b
6257 space_before = in_array$1(current_token.text, ['--', '-', '++', '+']) && in_array$1(this._flags.last_token.text, ['--', '-', '++', '+']);
6258 // + and - are not unary when preceeded by -- or ++ operator
6259 // a-- + b
6260 // a * +b
6261 // a - -b
6262 if (in_array$1(current_token.text, ['+', '-']) && in_array$1(this._flags.last_token.text, ['--', '++'])) {
6263 space_after = true;
6264 }
6265 }
6266
6267
6268 if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
6269 (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
6270 // { foo; --i }
6271 // foo(); --bar;
6272 this.print_newline();
6273 }
6274 }
6275
6276 this._output.space_before_token = this._output.space_before_token || space_before;
6277 this.print_token(current_token);
6278 this._output.space_before_token = space_after;
6279 };
6280
6281 Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
6282 if (this._output.raw) {
6283 this._output.add_raw_token(current_token);
6284 if (current_token.directives && current_token.directives.preserve === 'end') {
6285 // If we're testing the raw output behavior, do not allow a directive to turn it off.
6286 this._output.raw = this._options.test_output_raw;
6287 }
6288 return;
6289 }
6290
6291 if (current_token.directives) {
6292 this.print_newline(false, preserve_statement_flags);
6293 this.print_token(current_token);
6294 if (current_token.directives.preserve === 'start') {
6295 this._output.raw = true;
6296 }
6297 this.print_newline(false, true);
6298 return;
6299 }
6300
6301 // inline block
6302 if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
6303 this._output.space_before_token = true;
6304 this.print_token(current_token);
6305 this._output.space_before_token = true;
6306 return;
6307 } else {
6308 this.print_block_commment(current_token, preserve_statement_flags);
6309 }
6310 };
6311
6312 Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
6313 var lines = split_linebreaks(current_token.text);
6314 var j; // iterator for this case
6315 var javadoc = false;
6316 var starless = false;
6317 var lastIndent = current_token.whitespace_before;
6318 var lastIndentLength = lastIndent.length;
6319
6320 // block comment starts with a new line
6321 this.print_newline(false, preserve_statement_flags);
6322
6323 // first line always indented
6324 this.print_token_line_indentation(current_token);
6325 this._output.add_token(lines[0]);
6326 this.print_newline(false, preserve_statement_flags);
6327
6328
6329 if (lines.length > 1) {
6330 lines = lines.slice(1);
6331 javadoc = all_lines_start_with(lines, '*');
6332 starless = each_line_matches_indent(lines, lastIndent);
6333
6334 if (javadoc) {
6335 this._flags.alignment = 1;
6336 }
6337
6338 for (j = 0; j < lines.length; j++) {
6339 if (javadoc) {
6340 // javadoc: reformat and re-indent
6341 this.print_token_line_indentation(current_token);
6342 this._output.add_token(ltrim(lines[j]));
6343 } else if (starless && lines[j]) {
6344 // starless: re-indent non-empty content, avoiding trim
6345 this.print_token_line_indentation(current_token);
6346 this._output.add_token(lines[j].substring(lastIndentLength));
6347 } else {
6348 // normal comments output raw
6349 this._output.current_line.set_indent(-1);
6350 this._output.add_token(lines[j]);
6351 }
6352
6353 // for comments on their own line or more than one line, make sure there's a new line after
6354 this.print_newline(false, preserve_statement_flags);
6355 }
6356
6357 this._flags.alignment = 0;
6358 }
6359 };
6360
6361
6362 Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
6363 if (current_token.newlines) {
6364 this.print_newline(false, preserve_statement_flags);
6365 } else {
6366 this._output.trim(true);
6367 }
6368
6369 this._output.space_before_token = true;
6370 this.print_token(current_token);
6371 this.print_newline(false, preserve_statement_flags);
6372 };
6373
6374 Beautifier.prototype.handle_dot = function(current_token) {
6375 if (this.start_of_statement(current_token)) ; else {
6376 this.handle_whitespace_and_comments(current_token, true);
6377 }
6378
6379 if (reserved_array(this._flags.last_token, special_words)) {
6380 this._output.space_before_token = false;
6381 } else {
6382 // allow preserved newlines before dots in general
6383 // force newlines on dots after close paren when break_chained - for bar().baz()
6384 this.allow_wrap_or_preserved_newline(current_token,
6385 this._flags.last_token.text === ')' && this._options.break_chained_methods);
6386 }
6387
6388 // Only unindent chained method dot if this dot starts a new line.
6389 // Otherwise the automatic extra indentation removal will handle the over indent
6390 if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
6391 this.deindent();
6392 }
6393
6394 this.print_token(current_token);
6395 };
6396
6397 Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
6398 this.print_token(current_token);
6399
6400 if (current_token.text[current_token.text.length - 1] === '\n') {
6401 this.print_newline(false, preserve_statement_flags);
6402 }
6403 };
6404
6405 Beautifier.prototype.handle_eof = function(current_token) {
6406 // Unwind any open statements
6407 while (this._flags.mode === MODE.Statement) {
6408 this.restore_mode();
6409 }
6410 this.handle_whitespace_and_comments(current_token);
6411 };
6412
6413 var Beautifier_1 = Beautifier;
6414
6415 var beautifier = {
6416 Beautifier: Beautifier_1
6417 };
6418
6419 var Beautifier$1 = beautifier.Beautifier,
6420 Options$3 = options$1.Options;
6421
6422 function js_beautify(js_source_text, options) {
6423 var beautifier = new Beautifier$1(js_source_text, options);
6424 return beautifier.beautify();
6425 }
6426
6427 var javascript = js_beautify;
6428 var defaultOptions = function() {
6429 return new Options$3();
6430 };
6431 javascript.defaultOptions = defaultOptions;
6432
6433 var BaseOptions$1 = options.Options;
6434
6435 function Options$4(options) {
6436 BaseOptions$1.call(this, options, 'css');
6437
6438 this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
6439 this.newline_between_rules = this._get_boolean('newline_between_rules', true);
6440 var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
6441 this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
6442
6443 }
6444 Options$4.prototype = new BaseOptions$1();
6445
6446
6447
6448 var Options_1$2 = Options$4;
6449
6450 var options$2 = {
6451 Options: Options_1$2
6452 };
6453
6454 var Options$5 = options$2.Options;
6455 var Output$2 = output.Output;
6456 var InputScanner$3 = inputscanner.InputScanner;
6457 var Directives$2 = directives.Directives;
6458
6459 var directives_core$1 = new Directives$2(/\/\*/, /\*\//);
6460
6461 var lineBreak = /\r\n|[\r\n]/;
6462 var allLineBreaks = /\r\n|[\r\n]/g;
6463
6464 // tokenizer
6465 var whitespaceChar = /\s/;
6466 var whitespacePattern = /(?:\s|\n)+/g;
6467 var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
6468 var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
6469
6470 function Beautifier$2(source_text, options) {
6471 this._source_text = source_text || '';
6472 // Allow the setting of language/file-type specific options
6473 // with inheritance of overall settings
6474 this._options = new Options$5(options);
6475 this._ch = null;
6476 this._input = null;
6477
6478 // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
6479 this.NESTED_AT_RULE = {
6480 "@page": true,
6481 "@font-face": true,
6482 "@keyframes": true,
6483 // also in CONDITIONAL_GROUP_RULE below
6484 "@media": true,
6485 "@supports": true,
6486 "@document": true
6487 };
6488 this.CONDITIONAL_GROUP_RULE = {
6489 "@media": true,
6490 "@supports": true,
6491 "@document": true
6492 };
6493
6494 }
6495
6496 Beautifier$2.prototype.eatString = function(endChars) {
6497 var result = '';
6498 this._ch = this._input.next();
6499 while (this._ch) {
6500 result += this._ch;
6501 if (this._ch === "\\") {
6502 result += this._input.next();
6503 } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
6504 break;
6505 }
6506 this._ch = this._input.next();
6507 }
6508 return result;
6509 };
6510
6511 // Skips any white space in the source text from the current position.
6512 // When allowAtLeastOneNewLine is true, will output new lines for each
6513 // newline character found; if the user has preserve_newlines off, only
6514 // the first newline will be output
6515 Beautifier$2.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
6516 var result = whitespaceChar.test(this._input.peek());
6517 var isFirstNewLine = true;
6518
6519 while (whitespaceChar.test(this._input.peek())) {
6520 this._ch = this._input.next();
6521 if (allowAtLeastOneNewLine && this._ch === '\n') {
6522 if (this._options.preserve_newlines || isFirstNewLine) {
6523 isFirstNewLine = false;
6524 this._output.add_new_line(true);
6525 }
6526 }
6527 }
6528 return result;
6529 };
6530
6531 // Nested pseudo-class if we are insideRule
6532 // and the next special character found opens
6533 // a new block
6534 Beautifier$2.prototype.foundNestedPseudoClass = function() {
6535 var openParen = 0;
6536 var i = 1;
6537 var ch = this._input.peek(i);
6538 while (ch) {
6539 if (ch === "{") {
6540 return true;
6541 } else if (ch === '(') {
6542 // pseudoclasses can contain ()
6543 openParen += 1;
6544 } else if (ch === ')') {
6545 if (openParen === 0) {
6546 return false;
6547 }
6548 openParen -= 1;
6549 } else if (ch === ";" || ch === "}") {
6550 return false;
6551 }
6552 i++;
6553 ch = this._input.peek(i);
6554 }
6555 return false;
6556 };
6557
6558 Beautifier$2.prototype.print_string = function(output_string) {
6559 this._output.set_indent(this._indentLevel);
6560 this._output.non_breaking_space = true;
6561 this._output.add_token(output_string);
6562 };
6563
6564 Beautifier$2.prototype.preserveSingleSpace = function(isAfterSpace) {
6565 if (isAfterSpace) {
6566 this._output.space_before_token = true;
6567 }
6568 };
6569
6570 Beautifier$2.prototype.indent = function() {
6571 this._indentLevel++;
6572 };
6573
6574 Beautifier$2.prototype.outdent = function() {
6575 if (this._indentLevel > 0) {
6576 this._indentLevel--;
6577 }
6578 };
6579
6580 /*_____________________--------------------_____________________*/
6581
6582 Beautifier$2.prototype.beautify = function() {
6583 if (this._options.disabled) {
6584 return this._source_text;
6585 }
6586
6587 var source_text = this._source_text;
6588 var eol = this._options.eol;
6589 if (eol === 'auto') {
6590 eol = '\n';
6591 if (source_text && lineBreak.test(source_text || '')) {
6592 eol = source_text.match(lineBreak)[0];
6593 }
6594 }
6595
6596
6597 // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
6598 source_text = source_text.replace(allLineBreaks, '\n');
6599
6600 // reset
6601 var baseIndentString = source_text.match(/^[\t ]*/)[0];
6602
6603 this._output = new Output$2(this._options, baseIndentString);
6604 this._input = new InputScanner$3(source_text);
6605 this._indentLevel = 0;
6606 this._nestedLevel = 0;
6607
6608 this._ch = null;
6609 var parenLevel = 0;
6610
6611 var insideRule = false;
6612 // This is the value side of a property value pair (blue in the following ex)
6613 // label { content: blue }
6614 var insidePropertyValue = false;
6615 var enteringConditionalGroup = false;
6616 var insideAtExtend = false;
6617 var insideAtImport = false;
6618 var topCharacter = this._ch;
6619 var whitespace;
6620 var isAfterSpace;
6621 var previous_ch;
6622
6623 while (true) {
6624 whitespace = this._input.read(whitespacePattern);
6625 isAfterSpace = whitespace !== '';
6626 previous_ch = topCharacter;
6627 this._ch = this._input.next();
6628 if (this._ch === '\\' && this._input.hasNext()) {
6629 this._ch += this._input.next();
6630 }
6631 topCharacter = this._ch;
6632
6633 if (!this._ch) {
6634 break;
6635 } else if (this._ch === '/' && this._input.peek() === '*') {
6636 // /* css comment */
6637 // Always start block comments on a new line.
6638 // This handles scenarios where a block comment immediately
6639 // follows a property definition on the same line or where
6640 // minified code is being beautified.
6641 this._output.add_new_line();
6642 this._input.back();
6643
6644 var comment = this._input.read(block_comment_pattern);
6645
6646 // Handle ignore directive
6647 var directives = directives_core$1.get_directives(comment);
6648 if (directives && directives.ignore === 'start') {
6649 comment += directives_core$1.readIgnored(this._input);
6650 }
6651
6652 this.print_string(comment);
6653
6654 // Ensures any new lines following the comment are preserved
6655 this.eatWhitespace(true);
6656
6657 // Block comments are followed by a new line so they don't
6658 // share a line with other properties
6659 this._output.add_new_line();
6660 } else if (this._ch === '/' && this._input.peek() === '/') {
6661 // // single line comment
6662 // Preserves the space before a comment
6663 // on the same line as a rule
6664 this._output.space_before_token = true;
6665 this._input.back();
6666 this.print_string(this._input.read(comment_pattern));
6667
6668 // Ensures any new lines following the comment are preserved
6669 this.eatWhitespace(true);
6670 } else if (this._ch === '@') {
6671 this.preserveSingleSpace(isAfterSpace);
6672
6673 // deal with less propery mixins @{...}
6674 if (this._input.peek() === '{') {
6675 this.print_string(this._ch + this.eatString('}'));
6676 } else {
6677 this.print_string(this._ch);
6678
6679 // strip trailing space, if present, for hash property checks
6680 var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
6681
6682 if (variableOrRule.match(/[ :]$/)) {
6683 // we have a variable or pseudo-class, add it and insert one space before continuing
6684 variableOrRule = this.eatString(": ").replace(/\s$/, '');
6685 this.print_string(variableOrRule);
6686 this._output.space_before_token = true;
6687 }
6688
6689 variableOrRule = variableOrRule.replace(/\s$/, '');
6690
6691 if (variableOrRule === 'extend') {
6692 insideAtExtend = true;
6693 } else if (variableOrRule === 'import') {
6694 insideAtImport = true;
6695 }
6696
6697 // might be a nesting at-rule
6698 if (variableOrRule in this.NESTED_AT_RULE) {
6699 this._nestedLevel += 1;
6700 if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
6701 enteringConditionalGroup = true;
6702 }
6703 // might be less variable
6704 } else if (!insideRule && parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
6705 insidePropertyValue = true;
6706 this.indent();
6707 }
6708 }
6709 } else if (this._ch === '#' && this._input.peek() === '{') {
6710 this.preserveSingleSpace(isAfterSpace);
6711 this.print_string(this._ch + this.eatString('}'));
6712 } else if (this._ch === '{') {
6713 if (insidePropertyValue) {
6714 insidePropertyValue = false;
6715 this.outdent();
6716 }
6717 this.indent();
6718 this._output.space_before_token = true;
6719 this.print_string(this._ch);
6720
6721 // when entering conditional groups, only rulesets are allowed
6722 if (enteringConditionalGroup) {
6723 enteringConditionalGroup = false;
6724 insideRule = (this._indentLevel > this._nestedLevel);
6725 } else {
6726 // otherwise, declarations are also allowed
6727 insideRule = (this._indentLevel >= this._nestedLevel);
6728 }
6729 if (this._options.newline_between_rules && insideRule) {
6730 if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
6731 this._output.ensure_empty_line_above('/', ',');
6732 }
6733 }
6734 this.eatWhitespace(true);
6735 this._output.add_new_line();
6736 } else if (this._ch === '}') {
6737 this.outdent();
6738 this._output.add_new_line();
6739 if (previous_ch === '{') {
6740 this._output.trim(true);
6741 }
6742 insideAtImport = false;
6743 insideAtExtend = false;
6744 if (insidePropertyValue) {
6745 this.outdent();
6746 insidePropertyValue = false;
6747 }
6748 this.print_string(this._ch);
6749 insideRule = false;
6750 if (this._nestedLevel) {
6751 this._nestedLevel--;
6752 }
6753
6754 this.eatWhitespace(true);
6755 this._output.add_new_line();
6756
6757 if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
6758 if (this._input.peek() !== '}') {
6759 this._output.add_new_line(true);
6760 }
6761 }
6762 } else if (this._ch === ":") {
6763 if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
6764 // 'property: value' delimiter
6765 // which could be in a conditional group query
6766 this.print_string(':');
6767 if (!insidePropertyValue) {
6768 insidePropertyValue = true;
6769 this._output.space_before_token = true;
6770 this.eatWhitespace(true);
6771 this.indent();
6772 }
6773 } else {
6774 // sass/less parent reference don't use a space
6775 // sass nested pseudo-class don't use a space
6776
6777 // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
6778 if (this._input.lookBack(" ")) {
6779 this._output.space_before_token = true;
6780 }
6781 if (this._input.peek() === ":") {
6782 // pseudo-element
6783 this._ch = this._input.next();
6784 this.print_string("::");
6785 } else {
6786 // pseudo-class
6787 this.print_string(':');
6788 }
6789 }
6790 } else if (this._ch === '"' || this._ch === '\'') {
6791 this.preserveSingleSpace(isAfterSpace);
6792 this.print_string(this._ch + this.eatString(this._ch));
6793 this.eatWhitespace(true);
6794 } else if (this._ch === ';') {
6795 if (parenLevel === 0) {
6796 if (insidePropertyValue) {
6797 this.outdent();
6798 insidePropertyValue = false;
6799 }
6800 insideAtExtend = false;
6801 insideAtImport = false;
6802 this.print_string(this._ch);
6803 this.eatWhitespace(true);
6804
6805 // This maintains single line comments on the same
6806 // line. Block comments are also affected, but
6807 // a new line is always output before one inside
6808 // that section
6809 if (this._input.peek() !== '/') {
6810 this._output.add_new_line();
6811 }
6812 } else {
6813 this.print_string(this._ch);
6814 this.eatWhitespace(true);
6815 this._output.space_before_token = true;
6816 }
6817 } else if (this._ch === '(') { // may be a url
6818 if (this._input.lookBack("url")) {
6819 this.print_string(this._ch);
6820 this.eatWhitespace();
6821 parenLevel++;
6822 this.indent();
6823 this._ch = this._input.next();
6824 if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
6825 this._input.back();
6826 } else if (this._ch) {
6827 this.print_string(this._ch + this.eatString(')'));
6828 if (parenLevel) {
6829 parenLevel--;
6830 this.outdent();
6831 }
6832 }
6833 } else {
6834 this.preserveSingleSpace(isAfterSpace);
6835 this.print_string(this._ch);
6836 this.eatWhitespace();
6837 parenLevel++;
6838 this.indent();
6839 }
6840 } else if (this._ch === ')') {
6841 if (parenLevel) {
6842 parenLevel--;
6843 this.outdent();
6844 }
6845 this.print_string(this._ch);
6846 } else if (this._ch === ',') {
6847 this.print_string(this._ch);
6848 this.eatWhitespace(true);
6849 if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport) {
6850 this._output.add_new_line();
6851 } else {
6852 this._output.space_before_token = true;
6853 }
6854 } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
6855 //handle combinator spacing
6856 if (this._options.space_around_combinator) {
6857 this._output.space_before_token = true;
6858 this.print_string(this._ch);
6859 this._output.space_before_token = true;
6860 } else {
6861 this.print_string(this._ch);
6862 this.eatWhitespace();
6863 // squash extra whitespace
6864 if (this._ch && whitespaceChar.test(this._ch)) {
6865 this._ch = '';
6866 }
6867 }
6868 } else if (this._ch === ']') {
6869 this.print_string(this._ch);
6870 } else if (this._ch === '[') {
6871 this.preserveSingleSpace(isAfterSpace);
6872 this.print_string(this._ch);
6873 } else if (this._ch === '=') { // no whitespace before or after
6874 this.eatWhitespace();
6875 this.print_string('=');
6876 if (whitespaceChar.test(this._ch)) {
6877 this._ch = '';
6878 }
6879 } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
6880 this.print_string(' ');
6881 this.print_string(this._ch);
6882 } else {
6883 this.preserveSingleSpace(isAfterSpace);
6884 this.print_string(this._ch);
6885 }
6886 }
6887
6888 var sweetCode = this._output.get_code(eol);
6889
6890 return sweetCode;
6891 };
6892
6893 var Beautifier_1$1 = Beautifier$2;
6894
6895 var beautifier$1 = {
6896 Beautifier: Beautifier_1$1
6897 };
6898
6899 var Beautifier$3 = beautifier$1.Beautifier,
6900 Options$6 = options$2.Options;
6901
6902 function css_beautify(source_text, options) {
6903 var beautifier = new Beautifier$3(source_text, options);
6904 return beautifier.beautify();
6905 }
6906
6907 var css = css_beautify;
6908 var defaultOptions$1 = function() {
6909 return new Options$6();
6910 };
6911 css.defaultOptions = defaultOptions$1;
6912
6913 var BaseOptions$2 = options.Options;
6914
6915 function Options$7(options) {
6916 BaseOptions$2.call(this, options, 'html');
6917 if (this.templating.length === 1 && this.templating[0] === 'auto') {
6918 this.templating = ['django', 'erb', 'handlebars', 'php'];
6919 }
6920
6921 this.indent_inner_html = this._get_boolean('indent_inner_html');
6922 this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
6923 this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
6924
6925 this.indent_handlebars = this._get_boolean('indent_handlebars', true);
6926 this.wrap_attributes = this._get_selection('wrap_attributes',
6927 ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
6928 this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
6929 this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
6930
6931 // Block vs inline elements
6932 // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
6933 // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
6934 // https://www.w3.org/TR/html5/dom.html#phrasing-content
6935 this.inline = this._get_array('inline', [
6936 'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
6937 'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
6938 'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
6939 'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
6940 'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
6941 'video', 'wbr', 'text',
6942 // obsolete inline tags
6943 'acronym', 'big', 'strike', 'tt'
6944 ]);
6945 this.void_elements = this._get_array('void_elements', [
6946 // HTLM void elements - aka self-closing tags - aka singletons
6947 // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
6948 'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
6949 'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
6950 // NOTE: Optional tags are too complex for a simple list
6951 // they are hard coded in _do_optional_end_element
6952
6953 // Doctype and xml elements
6954 '!doctype', '?xml',
6955
6956 // obsolete tags
6957 // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
6958 // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
6959 'basefont', 'isindex'
6960 ]);
6961 this.unformatted = this._get_array('unformatted', []);
6962 this.content_unformatted = this._get_array('content_unformatted', [
6963 'pre', 'textarea'
6964 ]);
6965 this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
6966 this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
6967
6968 }
6969 Options$7.prototype = new BaseOptions$2();
6970
6971
6972
6973 var Options_1$3 = Options$7;
6974
6975 var options$3 = {
6976 Options: Options_1$3
6977 };
6978
6979 var BaseTokenizer$1 = tokenizer.Tokenizer;
6980 var BASETOKEN$1 = tokenizer.TOKEN;
6981 var Directives$3 = directives.Directives;
6982 var TemplatablePattern$2 = templatablepattern.TemplatablePattern;
6983 var Pattern$4 = pattern.Pattern;
6984
6985 var TOKEN$3 = {
6986 TAG_OPEN: 'TK_TAG_OPEN',
6987 TAG_CLOSE: 'TK_TAG_CLOSE',
6988 ATTRIBUTE: 'TK_ATTRIBUTE',
6989 EQUALS: 'TK_EQUALS',
6990 VALUE: 'TK_VALUE',
6991 COMMENT: 'TK_COMMENT',
6992 TEXT: 'TK_TEXT',
6993 UNKNOWN: 'TK_UNKNOWN',
6994 START: BASETOKEN$1.START,
6995 RAW: BASETOKEN$1.RAW,
6996 EOF: BASETOKEN$1.EOF
6997 };
6998
6999 var directives_core$2 = new Directives$3(/<\!--/, /-->/);
7000
7001 var Tokenizer$3 = function(input_string, options) {
7002 BaseTokenizer$1.call(this, input_string, options);
7003 this._current_tag_name = '';
7004
7005 // Words end at whitespace or when a tag starts
7006 // if we are indenting handlebars, they are considered tags
7007 var templatable_reader = new TemplatablePattern$2(this._input).read_options(this._options);
7008 var pattern_reader = new Pattern$4(this._input);
7009
7010 this.__patterns = {
7011 word: templatable_reader.until(/[\n\r\t <]/),
7012 single_quote: templatable_reader.until_after(/'/),
7013 double_quote: templatable_reader.until_after(/"/),
7014 attribute: templatable_reader.until(/[\n\r\t =\/>]/),
7015 element_name: templatable_reader.until(/[\n\r\t >\/]/),
7016
7017 handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
7018 handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
7019 handlebars_open: pattern_reader.until(/[\n\r\t }]/),
7020 handlebars_raw_close: pattern_reader.until(/}}/),
7021 comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
7022 cdata: pattern_reader.starting_with(/<!\[cdata\[/).until_after(/]]>/),
7023 // https://en.wikipedia.org/wiki/Conditional_comment
7024 conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
7025 processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
7026 };
7027
7028 if (this._options.indent_handlebars) {
7029 this.__patterns.word = this.__patterns.word.exclude('handlebars');
7030 }
7031
7032 this._unformatted_content_delimiter = null;
7033
7034 if (this._options.unformatted_content_delimiter) {
7035 var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
7036 this.__patterns.unformatted_content_delimiter =
7037 pattern_reader.matching(literal_regexp)
7038 .until_after(literal_regexp);
7039 }
7040 };
7041 Tokenizer$3.prototype = new BaseTokenizer$1();
7042
7043 Tokenizer$3.prototype._is_comment = function(current_token) { // jshint unused:false
7044 return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
7045 };
7046
7047 Tokenizer$3.prototype._is_opening = function(current_token) {
7048 return current_token.type === TOKEN$3.TAG_OPEN;
7049 };
7050
7051 Tokenizer$3.prototype._is_closing = function(current_token, open_token) {
7052 return current_token.type === TOKEN$3.TAG_CLOSE &&
7053 (open_token && (
7054 ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
7055 (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')));
7056 };
7057
7058 Tokenizer$3.prototype._reset = function() {
7059 this._current_tag_name = '';
7060 };
7061
7062 Tokenizer$3.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
7063 var token = null;
7064 this._readWhitespace();
7065 var c = this._input.peek();
7066
7067 if (c === null) {
7068 return this._create_token(TOKEN$3.EOF, '');
7069 }
7070
7071 token = token || this._read_open_handlebars(c, open_token);
7072 token = token || this._read_attribute(c, previous_token, open_token);
7073 token = token || this._read_raw_content(c, previous_token, open_token);
7074 token = token || this._read_close(c, open_token);
7075 token = token || this._read_content_word(c);
7076 token = token || this._read_comment(c);
7077 token = token || this._read_open(c, open_token);
7078 token = token || this._create_token(TOKEN$3.UNKNOWN, this._input.next());
7079
7080 return token;
7081 };
7082
7083 Tokenizer$3.prototype._read_comment = function(c) { // jshint unused:false
7084 var token = null;
7085 var resulting_string = null;
7086 var directives = null;
7087
7088 if (c === '<') {
7089 var peek1 = this._input.peek(1);
7090 //if we're in a comment, do something special
7091 // We treat all comments as literals, even more than preformatted tags
7092 // we just look for the appropriate close tag
7093 if (c === '<' && (peek1 === '!' || peek1 === '?')) {
7094 resulting_string = this.__patterns.comment.read();
7095
7096 // only process directive on html comments
7097 if (resulting_string) {
7098 directives = directives_core$2.get_directives(resulting_string);
7099 if (directives && directives.ignore === 'start') {
7100 resulting_string += directives_core$2.readIgnored(this._input);
7101 }
7102 } else {
7103 resulting_string = this.__patterns.cdata.read();
7104 resulting_string = resulting_string || this.__patterns.conditional_comment.read();
7105 resulting_string = resulting_string || this.__patterns.processing.read();
7106 }
7107 }
7108
7109 if (resulting_string) {
7110 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7111 token.directives = directives;
7112 }
7113 }
7114
7115 return token;
7116 };
7117
7118 Tokenizer$3.prototype._read_open = function(c, open_token) {
7119 var resulting_string = null;
7120 var token = null;
7121 if (!open_token) {
7122 if (c === '<') {
7123
7124 resulting_string = this._input.next();
7125 if (this._input.peek() === '/') {
7126 resulting_string += this._input.next();
7127 }
7128 resulting_string += this.__patterns.element_name.read();
7129 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7130 }
7131 }
7132 return token;
7133 };
7134
7135 Tokenizer$3.prototype._read_open_handlebars = function(c, open_token) {
7136 var resulting_string = null;
7137 var token = null;
7138 if (!open_token) {
7139 if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
7140 if (this._input.peek(2) === '!') {
7141 resulting_string = this.__patterns.handlebars_comment.read();
7142 resulting_string = resulting_string || this.__patterns.handlebars.read();
7143 token = this._create_token(TOKEN$3.COMMENT, resulting_string);
7144 } else {
7145 resulting_string = this.__patterns.handlebars_open.read();
7146 token = this._create_token(TOKEN$3.TAG_OPEN, resulting_string);
7147 }
7148 }
7149 }
7150 return token;
7151 };
7152
7153
7154 Tokenizer$3.prototype._read_close = function(c, open_token) {
7155 var resulting_string = null;
7156 var token = null;
7157 if (open_token) {
7158 if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
7159 resulting_string = this._input.next();
7160 if (c === '/') { // for close tag "/>"
7161 resulting_string += this._input.next();
7162 }
7163 token = this._create_token(TOKEN$3.TAG_CLOSE, resulting_string);
7164 } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
7165 this._input.next();
7166 this._input.next();
7167 token = this._create_token(TOKEN$3.TAG_CLOSE, '}}');
7168 }
7169 }
7170
7171 return token;
7172 };
7173
7174 Tokenizer$3.prototype._read_attribute = function(c, previous_token, open_token) {
7175 var token = null;
7176 var resulting_string = '';
7177 if (open_token && open_token.text[0] === '<') {
7178
7179 if (c === '=') {
7180 token = this._create_token(TOKEN$3.EQUALS, this._input.next());
7181 } else if (c === '"' || c === "'") {
7182 var content = this._input.next();
7183 if (c === '"') {
7184 content += this.__patterns.double_quote.read();
7185 } else {
7186 content += this.__patterns.single_quote.read();
7187 }
7188 token = this._create_token(TOKEN$3.VALUE, content);
7189 } else {
7190 resulting_string = this.__patterns.attribute.read();
7191
7192 if (resulting_string) {
7193 if (previous_token.type === TOKEN$3.EQUALS) {
7194 token = this._create_token(TOKEN$3.VALUE, resulting_string);
7195 } else {
7196 token = this._create_token(TOKEN$3.ATTRIBUTE, resulting_string);
7197 }
7198 }
7199 }
7200 }
7201 return token;
7202 };
7203
7204 Tokenizer$3.prototype._is_content_unformatted = function(tag_name) {
7205 // void_elements have no content and so cannot have unformatted content
7206 // script and style tags should always be read as unformatted content
7207 // finally content_unformatted and unformatted element contents are unformatted
7208 return this._options.void_elements.indexOf(tag_name) === -1 &&
7209 (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
7210 this._options.unformatted.indexOf(tag_name) !== -1);
7211 };
7212
7213
7214 Tokenizer$3.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
7215 var resulting_string = '';
7216 if (open_token && open_token.text[0] === '{') {
7217 resulting_string = this.__patterns.handlebars_raw_close.read();
7218 } else if (previous_token.type === TOKEN$3.TAG_CLOSE && (previous_token.opened.text[0] === '<')) {
7219 var tag_name = previous_token.opened.text.substr(1).toLowerCase();
7220 if (tag_name === 'script' || tag_name === 'style') {
7221 // Script and style tags are allowed to have comments wrapping their content
7222 // or just have regular content.
7223 var token = this._read_comment(c);
7224 if (token) {
7225 token.type = TOKEN$3.TEXT;
7226 return token;
7227 }
7228 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7229 } else if (this._is_content_unformatted(tag_name)) {
7230 resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
7231 }
7232 }
7233
7234 if (resulting_string) {
7235 return this._create_token(TOKEN$3.TEXT, resulting_string);
7236 }
7237
7238 return null;
7239 };
7240
7241 Tokenizer$3.prototype._read_content_word = function(c) {
7242 var resulting_string = '';
7243 if (this._options.unformatted_content_delimiter) {
7244 if (c === this._options.unformatted_content_delimiter[0]) {
7245 resulting_string = this.__patterns.unformatted_content_delimiter.read();
7246 }
7247 }
7248
7249 if (!resulting_string) {
7250 resulting_string = this.__patterns.word.read();
7251 }
7252 if (resulting_string) {
7253 return this._create_token(TOKEN$3.TEXT, resulting_string);
7254 }
7255 };
7256
7257 var Tokenizer_1$2 = Tokenizer$3;
7258 var TOKEN_1$2 = TOKEN$3;
7259
7260 var tokenizer$2 = {
7261 Tokenizer: Tokenizer_1$2,
7262 TOKEN: TOKEN_1$2
7263 };
7264
7265 var Options$8 = options$3.Options;
7266 var Output$3 = output.Output;
7267 var Tokenizer$4 = tokenizer$2.Tokenizer;
7268 var TOKEN$4 = tokenizer$2.TOKEN;
7269
7270 var lineBreak$1 = /\r\n|[\r\n]/;
7271 var allLineBreaks$1 = /\r\n|[\r\n]/g;
7272
7273 var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
7274
7275 this.indent_level = 0;
7276 this.alignment_size = 0;
7277 this.max_preserve_newlines = options.max_preserve_newlines;
7278 this.preserve_newlines = options.preserve_newlines;
7279
7280 this._output = new Output$3(options, base_indent_string);
7281
7282 };
7283
7284 Printer.prototype.current_line_has_match = function(pattern) {
7285 return this._output.current_line.has_match(pattern);
7286 };
7287
7288 Printer.prototype.set_space_before_token = function(value, non_breaking) {
7289 this._output.space_before_token = value;
7290 this._output.non_breaking_space = non_breaking;
7291 };
7292
7293 Printer.prototype.set_wrap_point = function() {
7294 this._output.set_indent(this.indent_level, this.alignment_size);
7295 this._output.set_wrap_point();
7296 };
7297
7298
7299 Printer.prototype.add_raw_token = function(token) {
7300 this._output.add_raw_token(token);
7301 };
7302
7303 Printer.prototype.print_preserved_newlines = function(raw_token) {
7304 var newlines = 0;
7305 if (raw_token.type !== TOKEN$4.TEXT && raw_token.previous.type !== TOKEN$4.TEXT) {
7306 newlines = raw_token.newlines ? 1 : 0;
7307 }
7308
7309 if (this.preserve_newlines) {
7310 newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
7311 }
7312 for (var n = 0; n < newlines; n++) {
7313 this.print_newline(n > 0);
7314 }
7315
7316 return newlines !== 0;
7317 };
7318
7319 Printer.prototype.traverse_whitespace = function(raw_token) {
7320 if (raw_token.whitespace_before || raw_token.newlines) {
7321 if (!this.print_preserved_newlines(raw_token)) {
7322 this._output.space_before_token = true;
7323 }
7324 return true;
7325 }
7326 return false;
7327 };
7328
7329 Printer.prototype.previous_token_wrapped = function() {
7330 return this._output.previous_token_wrapped;
7331 };
7332
7333 Printer.prototype.print_newline = function(force) {
7334 this._output.add_new_line(force);
7335 };
7336
7337 Printer.prototype.print_token = function(token) {
7338 if (token.text) {
7339 this._output.set_indent(this.indent_level, this.alignment_size);
7340 this._output.add_token(token.text);
7341 }
7342 };
7343
7344 Printer.prototype.indent = function() {
7345 this.indent_level++;
7346 };
7347
7348 Printer.prototype.get_full_indent = function(level) {
7349 level = this.indent_level + (level || 0);
7350 if (level < 1) {
7351 return '';
7352 }
7353
7354 return this._output.get_indent_string(level);
7355 };
7356
7357 var get_type_attribute = function(start_token) {
7358 var result = null;
7359 var raw_token = start_token.next;
7360
7361 // Search attributes for a type attribute
7362 while (raw_token.type !== TOKEN$4.EOF && start_token.closed !== raw_token) {
7363 if (raw_token.type === TOKEN$4.ATTRIBUTE && raw_token.text === 'type') {
7364 if (raw_token.next && raw_token.next.type === TOKEN$4.EQUALS &&
7365 raw_token.next.next && raw_token.next.next.type === TOKEN$4.VALUE) {
7366 result = raw_token.next.next.text;
7367 }
7368 break;
7369 }
7370 raw_token = raw_token.next;
7371 }
7372
7373 return result;
7374 };
7375
7376 var get_custom_beautifier_name = function(tag_check, raw_token) {
7377 var typeAttribute = null;
7378 var result = null;
7379
7380 if (!raw_token.closed) {
7381 return null;
7382 }
7383
7384 if (tag_check === 'script') {
7385 typeAttribute = 'text/javascript';
7386 } else if (tag_check === 'style') {
7387 typeAttribute = 'text/css';
7388 }
7389
7390 typeAttribute = get_type_attribute(raw_token) || typeAttribute;
7391
7392 // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
7393 // For those without a type attribute use default;
7394 if (typeAttribute.search('text/css') > -1) {
7395 result = 'css';
7396 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect)/) > -1) {
7397 result = 'javascript';
7398 } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
7399 result = 'html';
7400 } else if (typeAttribute.search(/test\/null/) > -1) {
7401 // Test only mime-type for testing the beautifier when null is passed as beautifing function
7402 result = 'null';
7403 }
7404
7405 return result;
7406 };
7407
7408 function in_array$2(what, arr) {
7409 return arr.indexOf(what) !== -1;
7410 }
7411
7412 function TagFrame(parent, parser_token, indent_level) {
7413 this.parent = parent || null;
7414 this.tag = parser_token ? parser_token.tag_name : '';
7415 this.indent_level = indent_level || 0;
7416 this.parser_token = parser_token || null;
7417 }
7418
7419 function TagStack(printer) {
7420 this._printer = printer;
7421 this._current_frame = null;
7422 }
7423
7424 TagStack.prototype.get_parser_token = function() {
7425 return this._current_frame ? this._current_frame.parser_token : null;
7426 };
7427
7428 TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
7429 var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
7430 this._current_frame = new_frame;
7431 };
7432
7433 TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
7434 var parser_token = null;
7435
7436 if (frame) {
7437 parser_token = frame.parser_token;
7438 this._printer.indent_level = frame.indent_level;
7439 this._current_frame = frame.parent;
7440 }
7441
7442 return parser_token;
7443 };
7444
7445 TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
7446 var frame = this._current_frame;
7447
7448 while (frame) { //till we reach '' (the initial value);
7449 if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
7450 break;
7451 } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
7452 frame = null;
7453 break;
7454 }
7455 frame = frame.parent;
7456 }
7457
7458 return frame;
7459 };
7460
7461 TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
7462 var frame = this._get_frame([tag], stop_list);
7463 return this._try_pop_frame(frame);
7464 };
7465
7466 TagStack.prototype.indent_to_tag = function(tag_list) {
7467 var frame = this._get_frame(tag_list);
7468 if (frame) {
7469 this._printer.indent_level = frame.indent_level;
7470 }
7471 };
7472
7473 function Beautifier$4(source_text, options, js_beautify, css_beautify) {
7474 //Wrapper function to invoke all the necessary constructors and deal with the output.
7475 this._source_text = source_text || '';
7476 options = options || {};
7477 this._js_beautify = js_beautify;
7478 this._css_beautify = css_beautify;
7479 this._tag_stack = null;
7480
7481 // Allow the setting of language/file-type specific options
7482 // with inheritance of overall settings
7483 var optionHtml = new Options$8(options, 'html');
7484
7485 this._options = optionHtml;
7486
7487 this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
7488 this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
7489 this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
7490 this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
7491 this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
7492 this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
7493 }
7494
7495 Beautifier$4.prototype.beautify = function() {
7496
7497 // if disabled, return the input unchanged.
7498 if (this._options.disabled) {
7499 return this._source_text;
7500 }
7501
7502 var source_text = this._source_text;
7503 var eol = this._options.eol;
7504 if (this._options.eol === 'auto') {
7505 eol = '\n';
7506 if (source_text && lineBreak$1.test(source_text)) {
7507 eol = source_text.match(lineBreak$1)[0];
7508 }
7509 }
7510
7511 // HACK: newline parsing inconsistent. This brute force normalizes the input.
7512 source_text = source_text.replace(allLineBreaks$1, '\n');
7513
7514 var baseIndentString = source_text.match(/^[\t ]*/)[0];
7515
7516 var last_token = {
7517 text: '',
7518 type: ''
7519 };
7520
7521 var last_tag_token = new TagOpenParserToken();
7522
7523 var printer = new Printer(this._options, baseIndentString);
7524 var tokens = new Tokenizer$4(source_text, this._options).tokenize();
7525
7526 this._tag_stack = new TagStack(printer);
7527
7528 var parser_token = null;
7529 var raw_token = tokens.next();
7530 while (raw_token.type !== TOKEN$4.EOF) {
7531
7532 if (raw_token.type === TOKEN$4.TAG_OPEN || raw_token.type === TOKEN$4.COMMENT) {
7533 parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token);
7534 last_tag_token = parser_token;
7535 } else if ((raw_token.type === TOKEN$4.ATTRIBUTE || raw_token.type === TOKEN$4.EQUALS || raw_token.type === TOKEN$4.VALUE) ||
7536 (raw_token.type === TOKEN$4.TEXT && !last_tag_token.tag_complete)) {
7537 parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, tokens);
7538 } else if (raw_token.type === TOKEN$4.TAG_CLOSE) {
7539 parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
7540 } else if (raw_token.type === TOKEN$4.TEXT) {
7541 parser_token = this._handle_text(printer, raw_token, last_tag_token);
7542 } else {
7543 // This should never happen, but if it does. Print the raw token
7544 printer.add_raw_token(raw_token);
7545 }
7546
7547 last_token = parser_token;
7548
7549 raw_token = tokens.next();
7550 }
7551 var sweet_code = printer._output.get_code(eol);
7552
7553 return sweet_code;
7554 };
7555
7556 Beautifier$4.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
7557 var parser_token = {
7558 text: raw_token.text,
7559 type: raw_token.type
7560 };
7561 printer.alignment_size = 0;
7562 last_tag_token.tag_complete = true;
7563
7564 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7565 if (last_tag_token.is_unformatted) {
7566 printer.add_raw_token(raw_token);
7567 } else {
7568 if (last_tag_token.tag_start_char === '<') {
7569 printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
7570 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
7571 printer.print_newline(false);
7572 }
7573 }
7574 printer.print_token(raw_token);
7575
7576 }
7577
7578 if (last_tag_token.indent_content &&
7579 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7580 printer.indent();
7581
7582 // only indent once per opened tag
7583 last_tag_token.indent_content = false;
7584 }
7585
7586 if (!last_tag_token.is_inline_element &&
7587 !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7588 printer.set_wrap_point();
7589 }
7590
7591 return parser_token;
7592 };
7593
7594 Beautifier$4.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, tokens) {
7595 var wrapped = last_tag_token.has_wrapped_attrs;
7596 var parser_token = {
7597 text: raw_token.text,
7598 type: raw_token.type
7599 };
7600
7601 printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7602 if (last_tag_token.is_unformatted) {
7603 printer.add_raw_token(raw_token);
7604 } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN$4.TEXT) {
7605 // For the insides of handlebars allow newlines or a single space between open and contents
7606 if (printer.print_preserved_newlines(raw_token)) {
7607 raw_token.newlines = 0;
7608 printer.add_raw_token(raw_token);
7609 } else {
7610 printer.print_token(raw_token);
7611 }
7612 } else {
7613 if (raw_token.type === TOKEN$4.ATTRIBUTE) {
7614 printer.set_space_before_token(true);
7615 last_tag_token.attr_count += 1;
7616 } else if (raw_token.type === TOKEN$4.EQUALS) { //no space before =
7617 printer.set_space_before_token(false);
7618 } else if (raw_token.type === TOKEN$4.VALUE && raw_token.previous.type === TOKEN$4.EQUALS) { //no space before value
7619 printer.set_space_before_token(false);
7620 }
7621
7622 if (raw_token.type === TOKEN$4.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
7623 if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
7624 printer.traverse_whitespace(raw_token);
7625 wrapped = wrapped || raw_token.newlines !== 0;
7626 }
7627
7628
7629 if (this._is_wrap_attributes_force) {
7630 var force_attr_wrap = last_tag_token.attr_count > 1;
7631 if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.attr_count === 1) {
7632 var is_only_attribute = true;
7633 var peek_index = 0;
7634 var peek_token;
7635 do {
7636 peek_token = tokens.peek(peek_index);
7637 if (peek_token.type === TOKEN$4.ATTRIBUTE) {
7638 is_only_attribute = false;
7639 break;
7640 }
7641 peek_index += 1;
7642 } while (peek_index < 4 && peek_token.type !== TOKEN$4.EOF && peek_token.type !== TOKEN$4.TAG_CLOSE);
7643
7644 force_attr_wrap = !is_only_attribute;
7645 }
7646
7647 if (force_attr_wrap) {
7648 printer.print_newline(false);
7649 wrapped = true;
7650 }
7651 }
7652 }
7653 printer.print_token(raw_token);
7654 wrapped = wrapped || printer.previous_token_wrapped();
7655 last_tag_token.has_wrapped_attrs = wrapped;
7656 }
7657 return parser_token;
7658 };
7659
7660 Beautifier$4.prototype._handle_text = function(printer, raw_token, last_tag_token) {
7661 var parser_token = {
7662 text: raw_token.text,
7663 type: 'TK_CONTENT'
7664 };
7665 if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
7666 this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
7667 } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
7668 printer.add_raw_token(raw_token);
7669 } else {
7670 printer.traverse_whitespace(raw_token);
7671 printer.print_token(raw_token);
7672 }
7673 return parser_token;
7674 };
7675
7676 Beautifier$4.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
7677 var local = this;
7678 if (raw_token.text !== '') {
7679
7680 var text = raw_token.text,
7681 _beautifier,
7682 script_indent_level = 1,
7683 pre = '',
7684 post = '';
7685 if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
7686 _beautifier = this._js_beautify;
7687 } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
7688 _beautifier = this._css_beautify;
7689 } else if (last_tag_token.custom_beautifier_name === 'html') {
7690 _beautifier = function(html_source, options) {
7691 var beautifier = new Beautifier$4(html_source, options, local._js_beautify, local._css_beautify);
7692 return beautifier.beautify();
7693 };
7694 }
7695
7696 if (this._options.indent_scripts === "keep") {
7697 script_indent_level = 0;
7698 } else if (this._options.indent_scripts === "separate") {
7699 script_indent_level = -printer.indent_level;
7700 }
7701
7702 var indentation = printer.get_full_indent(script_indent_level);
7703
7704 // if there is at least one empty line at the end of this text, strip it
7705 // we'll be adding one back after the text but before the containing tag.
7706 text = text.replace(/\n[ \t]*$/, '');
7707
7708 // Handle the case where content is wrapped in a comment or cdata.
7709 if (last_tag_token.custom_beautifier_name !== 'html' &&
7710 text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
7711 var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
7712
7713 // if we start to wrap but don't finish, print raw
7714 if (!matched) {
7715 printer.add_raw_token(raw_token);
7716 return;
7717 }
7718
7719 pre = indentation + matched[1] + '\n';
7720 text = matched[4];
7721 if (matched[5]) {
7722 post = indentation + matched[5];
7723 }
7724
7725 // if there is at least one empty line at the end of this text, strip it
7726 // we'll be adding one back after the text but before the containing tag.
7727 text = text.replace(/\n[ \t]*$/, '');
7728
7729 if (matched[2] || matched[3].indexOf('\n') !== -1) {
7730 // if the first line of the non-comment text has spaces
7731 // use that as the basis for indenting in null case.
7732 matched = matched[3].match(/[ \t]+$/);
7733 if (matched) {
7734 raw_token.whitespace_before = matched[0];
7735 }
7736 }
7737 }
7738
7739 if (text) {
7740 if (_beautifier) {
7741
7742 // call the Beautifier if avaliable
7743 var Child_options = function() {
7744 this.eol = '\n';
7745 };
7746 Child_options.prototype = this._options.raw_options;
7747 var child_options = new Child_options();
7748 text = _beautifier(indentation + text, child_options);
7749 } else {
7750 // simply indent the string otherwise
7751 var white = raw_token.whitespace_before;
7752 if (white) {
7753 text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
7754 }
7755
7756 text = indentation + text.replace(/\n/g, '\n' + indentation);
7757 }
7758 }
7759
7760 if (pre) {
7761 if (!text) {
7762 text = pre + post;
7763 } else {
7764 text = pre + text + '\n' + post;
7765 }
7766 }
7767
7768 printer.print_newline(false);
7769 if (text) {
7770 raw_token.text = text;
7771 raw_token.whitespace_before = '';
7772 raw_token.newlines = 0;
7773 printer.add_raw_token(raw_token);
7774 printer.print_newline(true);
7775 }
7776 }
7777 };
7778
7779 Beautifier$4.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token) {
7780 var parser_token = this._get_tag_open_token(raw_token);
7781
7782 if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
7783 raw_token.type === TOKEN$4.TAG_OPEN && raw_token.text.indexOf('</') === 0) {
7784 // End element tags for unformatted or content_unformatted elements
7785 // are printed raw to keep any newlines inside them exactly the same.
7786 printer.add_raw_token(raw_token);
7787 } else {
7788 printer.traverse_whitespace(raw_token);
7789 this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
7790 if (!parser_token.is_inline_element) {
7791 printer.set_wrap_point();
7792 }
7793 printer.print_token(raw_token);
7794 }
7795
7796 //indent attributes an auto, forced, aligned or forced-align line-wrap
7797 if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
7798 parser_token.alignment_size = raw_token.text.length + 1;
7799 }
7800
7801 if (!parser_token.tag_complete && !parser_token.is_unformatted) {
7802 printer.alignment_size = parser_token.alignment_size;
7803 }
7804
7805 return parser_token;
7806 };
7807
7808 var TagOpenParserToken = function(parent, raw_token) {
7809 this.parent = parent || null;
7810 this.text = '';
7811 this.type = 'TK_TAG_OPEN';
7812 this.tag_name = '';
7813 this.is_inline_element = false;
7814 this.is_unformatted = false;
7815 this.is_content_unformatted = false;
7816 this.is_empty_element = false;
7817 this.is_start_tag = false;
7818 this.is_end_tag = false;
7819 this.indent_content = false;
7820 this.multiline_content = false;
7821 this.custom_beautifier_name = null;
7822 this.start_tag_token = null;
7823 this.attr_count = 0;
7824 this.has_wrapped_attrs = false;
7825 this.alignment_size = 0;
7826 this.tag_complete = false;
7827 this.tag_start_char = '';
7828 this.tag_check = '';
7829
7830 if (!raw_token) {
7831 this.tag_complete = true;
7832 } else {
7833 var tag_check_match;
7834
7835 this.tag_start_char = raw_token.text[0];
7836 this.text = raw_token.text;
7837
7838 if (this.tag_start_char === '<') {
7839 tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
7840 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7841 } else {
7842 tag_check_match = raw_token.text.match(/^{{[#\^]?([^\s}]+)/);
7843 this.tag_check = tag_check_match ? tag_check_match[1] : '';
7844 }
7845 this.tag_check = this.tag_check.toLowerCase();
7846
7847 if (raw_token.type === TOKEN$4.COMMENT) {
7848 this.tag_complete = true;
7849 }
7850
7851 this.is_start_tag = this.tag_check.charAt(0) !== '/';
7852 this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
7853 this.is_end_tag = !this.is_start_tag ||
7854 (raw_token.closed && raw_token.closed.text === '/>');
7855
7856 // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
7857 this.is_end_tag = this.is_end_tag ||
7858 (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(2)))));
7859 }
7860 };
7861
7862 Beautifier$4.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
7863 var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
7864
7865 parser_token.alignment_size = this._options.wrap_attributes_indent_size;
7866
7867 parser_token.is_end_tag = parser_token.is_end_tag ||
7868 in_array$2(parser_token.tag_check, this._options.void_elements);
7869
7870 parser_token.is_empty_element = parser_token.tag_complete ||
7871 (parser_token.is_start_tag && parser_token.is_end_tag);
7872
7873 parser_token.is_unformatted = !parser_token.tag_complete && in_array$2(parser_token.tag_check, this._options.unformatted);
7874 parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array$2(parser_token.tag_check, this._options.content_unformatted);
7875 parser_token.is_inline_element = in_array$2(parser_token.tag_name, this._options.inline) || parser_token.tag_start_char === '{';
7876
7877 return parser_token;
7878 };
7879
7880 Beautifier$4.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
7881
7882 if (!parser_token.is_empty_element) {
7883 if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7884 parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
7885 } else { // it's a start-tag
7886 // check if this tag is starting an element that has optional end element
7887 // and do an ending needed
7888 if (this._do_optional_end_element(parser_token)) {
7889 if (!parser_token.is_inline_element) {
7890 if (parser_token.parent) {
7891 parser_token.parent.multiline_content = true;
7892 }
7893 printer.print_newline(false);
7894 }
7895
7896 }
7897
7898 this._tag_stack.record_tag(parser_token); //push it on the tag stack
7899
7900 if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
7901 !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
7902 parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
7903 }
7904 }
7905 }
7906
7907 if (in_array$2(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
7908 printer.print_newline(false);
7909 if (!printer._output.just_added_blankline()) {
7910 printer.print_newline(true);
7911 }
7912 }
7913
7914 if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
7915
7916 // if you hit an else case, reset the indent level if you are inside an:
7917 // 'if', 'unless', or 'each' block.
7918 if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
7919 this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
7920 parser_token.indent_content = true;
7921 // Don't add a newline if opening {{#if}} tag is on the current line
7922 var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
7923 if (!foundIfOnCurrentLine) {
7924 printer.print_newline(false);
7925 }
7926 }
7927
7928 // Don't add a newline before elements that should remain where they are.
7929 if (parser_token.tag_name === '!--' && last_token.type === TOKEN$4.TAG_CLOSE &&
7930 last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) ; else if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7931 printer.print_newline(false);
7932 }
7933 } else if (parser_token.is_unformatted || parser_token.is_content_unformatted) {
7934 if (!parser_token.is_inline_element && !parser_token.is_unformatted) {
7935 printer.print_newline(false);
7936 }
7937 } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
7938 if ((parser_token.start_tag_token && parser_token.start_tag_token.multiline_content) ||
7939 !(parser_token.is_inline_element ||
7940 (last_tag_token.is_inline_element) ||
7941 (last_token.type === TOKEN$4.TAG_CLOSE &&
7942 parser_token.start_tag_token === last_tag_token) ||
7943 (last_token.type === 'TK_CONTENT')
7944 )) {
7945 printer.print_newline(false);
7946 }
7947 } else { // it's a start-tag
7948 parser_token.indent_content = !parser_token.custom_beautifier_name;
7949
7950 if (parser_token.tag_start_char === '<') {
7951 if (parser_token.tag_name === 'html') {
7952 parser_token.indent_content = this._options.indent_inner_html;
7953 } else if (parser_token.tag_name === 'head') {
7954 parser_token.indent_content = this._options.indent_head_inner_html;
7955 } else if (parser_token.tag_name === 'body') {
7956 parser_token.indent_content = this._options.indent_body_inner_html;
7957 }
7958 }
7959
7960 if (!parser_token.is_inline_element && last_token.type !== 'TK_CONTENT') {
7961 if (parser_token.parent) {
7962 parser_token.parent.multiline_content = true;
7963 }
7964 printer.print_newline(false);
7965 }
7966 }
7967 };
7968
7969 //To be used for <p> tag special case:
7970 //var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
7971
7972 Beautifier$4.prototype._do_optional_end_element = function(parser_token) {
7973 var result = null;
7974 // NOTE: cases of "if there is no more content in the parent element"
7975 // are handled automatically by the beautifier.
7976 // It assumes parent or ancestor close tag closes all children.
7977 // https://www.w3.org/TR/html5/syntax.html#optional-tags
7978 if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
7979 return;
7980
7981 } else if (parser_token.tag_name === 'body') {
7982 // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
7983 result = result || this._tag_stack.try_pop('head');
7984
7985 //} else if (parser_token.tag_name === 'body') {
7986 // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
7987
7988 } else if (parser_token.tag_name === 'li') {
7989 // An li element’s end tag may be omitted if the li element is immediately followed by another li element or if there is no more content in the parent element.
7990 result = result || this._tag_stack.try_pop('li', ['ol', 'ul']);
7991
7992 } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
7993 // A dd element’s end tag may be omitted if the dd element is immediately followed by another dd element or a dt element, or if there is no more content in the parent element.
7994 // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
7995 result = result || this._tag_stack.try_pop('dt', ['dl']);
7996 result = result || this._tag_stack.try_pop('dd', ['dl']);
7997
7998 //} else if (p_closers.indexOf(parser_token.tag_name) !== -1) {
7999 //TODO: THIS IS A BUG FARM. We are not putting this into 1.8.0 as it is likely to blow up.
8000 //A p element’s end tag may be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hr, main, nav, ol, p, pre, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.
8001 //result = result || this._tag_stack.try_pop('p', ['body']);
8002
8003 } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
8004 // An rt element’s end tag may be omitted if the rt element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
8005 // An rp element’s end tag may be omitted if the rp element is immediately followed by an rt or rp element, or if there is no more content in the parent element.
8006 result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
8007 result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
8008
8009 } else if (parser_token.tag_name === 'optgroup') {
8010 // An optgroup element’s end tag may be omitted if the optgroup element is immediately followed by another optgroup element, or if there is no more content in the parent element.
8011 // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
8012 result = result || this._tag_stack.try_pop('optgroup', ['select']);
8013 //result = result || this._tag_stack.try_pop('option', ['select']);
8014
8015 } else if (parser_token.tag_name === 'option') {
8016 // An option element’s end tag may be omitted if the option element is immediately followed by another option element, or if it is immediately followed by an optgroup element, or if there is no more content in the parent element.
8017 result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
8018
8019 } else if (parser_token.tag_name === 'colgroup') {
8020 // DONE: A colgroup element’s end tag may be omitted if the colgroup element is not immediately followed by a space character or a comment.
8021 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8022 result = result || this._tag_stack.try_pop('caption', ['table']);
8023
8024 } else if (parser_token.tag_name === 'thead') {
8025 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8026 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8027 result = result || this._tag_stack.try_pop('caption', ['table']);
8028 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8029
8030 //} else if (parser_token.tag_name === 'caption') {
8031 // DONE: A caption element’s end tag may be omitted if the caption element is not immediately followed by a space character or a comment.
8032
8033 } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
8034 // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
8035 // A tbody element’s end tag may be omitted if the tbody element is immediately followed by a tbody or tfoot element, or if there is no more content in the parent element.
8036 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8037 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8038 result = result || this._tag_stack.try_pop('caption', ['table']);
8039 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8040 result = result || this._tag_stack.try_pop('thead', ['table']);
8041 result = result || this._tag_stack.try_pop('tbody', ['table']);
8042
8043 //} else if (parser_token.tag_name === 'tfoot') {
8044 // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
8045
8046 } else if (parser_token.tag_name === 'tr') {
8047 // A tr element’s end tag may be omitted if the tr element is immediately followed by another tr element, or if there is no more content in the parent element.
8048 // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8049 // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8050 result = result || this._tag_stack.try_pop('caption', ['table']);
8051 result = result || this._tag_stack.try_pop('colgroup', ['table']);
8052 result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
8053
8054 } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
8055 // A td element’s end tag may be omitted if the td element is immediately followed by a td or th element, or if there is no more content in the parent element.
8056 // A th element’s end tag may be omitted if the th element is immediately followed by a td or th element, or if there is no more content in the parent element.
8057 result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8058 result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8059 }
8060
8061 // Start element omission not handled currently
8062 // A head element’s start tag may be omitted if the element is empty, or if the first thing inside the head element is an element.
8063 // A tbody element’s start tag may be omitted if the first thing inside the tbody element is a tr element, and if the element is not immediately preceded by a tbody, thead, or tfoot element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
8064 // A colgroup element’s start tag may be omitted if the first thing inside the colgroup element is a col element, and if the element is not immediately preceded by another colgroup element whose end tag has been omitted. (It can’t be omitted if the element is empty.)
8065
8066 // Fix up the parent of the parser token
8067 parser_token.parent = this._tag_stack.get_parser_token();
8068
8069 return result;
8070 };
8071
8072 var Beautifier_1$2 = Beautifier$4;
8073
8074 var beautifier$2 = {
8075 Beautifier: Beautifier_1$2
8076 };
8077
8078 var Beautifier$5 = beautifier$2.Beautifier,
8079 Options$9 = options$3.Options;
8080
8081 function style_html(html_source, options, js_beautify, css_beautify) {
8082 var beautifier = new Beautifier$5(html_source, options, js_beautify, css_beautify);
8083 return beautifier.beautify();
8084 }
8085
8086 var html = style_html;
8087 var defaultOptions$2 = function() {
8088 return new Options$9();
8089 };
8090 html.defaultOptions = defaultOptions$2;
8091
8092 function style_html$1(html_source, options, js, css$1) {
8093 js = js || javascript;
8094 css$1 = css$1 || css;
8095 return html(html_source, options, js, css$1);
8096 }
8097 style_html$1.defaultOptions = html.defaultOptions;
8098
8099 var js = javascript;
8100 var css$1 = css;
8101 var html$1 = style_html$1;
8102
8103 var src = {
8104 js: js,
8105 css: css$1,
8106 html: html$1
8107 };
8108
8109 var js$1 = createCommonjsModule(function (module) {
8110
8111 /**
8112 The following batches are equivalent:
8113
8114 var beautify_js = require('js-beautify');
8115 var beautify_js = require('js-beautify').js;
8116 var beautify_js = require('js-beautify').js_beautify;
8117
8118 var beautify_css = require('js-beautify').css;
8119 var beautify_css = require('js-beautify').css_beautify;
8120
8121 var beautify_html = require('js-beautify').html;
8122 var beautify_html = require('js-beautify').html_beautify;
8123
8124 All methods returned accept two arguments, the source string and an options object.
8125 **/
8126
8127 function get_beautify(js_beautify, css_beautify, html_beautify) {
8128 // the default is js
8129 var beautify = function(src, config) {
8130 return js_beautify.js_beautify(src, config);
8131 };
8132
8133 // short aliases
8134 beautify.js = js_beautify.js_beautify;
8135 beautify.css = css_beautify.css_beautify;
8136 beautify.html = html_beautify.html_beautify;
8137
8138 // legacy aliases
8139 beautify.js_beautify = js_beautify.js_beautify;
8140 beautify.css_beautify = css_beautify.css_beautify;
8141 beautify.html_beautify = html_beautify.html_beautify;
8142
8143 return beautify;
8144 }
8145
8146 {
8147 (function(mod) {
8148 var beautifier = src;
8149 beautifier.js_beautify = beautifier.js;
8150 beautifier.css_beautify = beautifier.css;
8151 beautifier.html_beautify = beautifier.html;
8152
8153 mod.exports = get_beautify(beautifier, beautifier, beautifier);
8154
8155 })(module);
8156 }
8157 });
8158
8159 /*!
8160 * is-whitespace <https://github.com/jonschlinkert/is-whitespace>
8161 *
8162 * Copyright (c) 2014-2015, Jon Schlinkert.
8163 * Licensed under the MIT License.
8164 */
8165
8166 var cache;
8167
8168 var isWhitespace = function isWhitespace(str) {
8169 return (typeof str === 'string') && regex().test(str);
8170 };
8171
8172 function regex() {
8173 // ensure that runtime compilation only happens once
8174 return cache || (cache = new RegExp('^[\\s\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF"]+$'));
8175 }
8176
8177 /*!
8178 * is-extendable <https://github.com/jonschlinkert/is-extendable>
8179 *
8180 * Copyright (c) 2015, Jon Schlinkert.
8181 * Licensed under the MIT License.
8182 */
8183
8184 var isExtendable = function isExtendable(val) {
8185 return typeof val !== 'undefined' && val !== null
8186 && (typeof val === 'object' || typeof val === 'function');
8187 };
8188
8189 var extendShallow = function extend(o/*, objects*/) {
8190 var arguments$1 = arguments;
8191
8192 if (!isExtendable(o)) { o = {}; }
8193
8194 var len = arguments.length;
8195 for (var i = 1; i < len; i++) {
8196 var obj = arguments$1[i];
8197
8198 if (isExtendable(obj)) {
8199 assign(o, obj);
8200 }
8201 }
8202 return o;
8203 };
8204
8205 function assign(a, b) {
8206 for (var key in b) {
8207 if (hasOwn(b, key)) {
8208 a[key] = b[key];
8209 }
8210 }
8211 }
8212
8213 /**
8214 * Returns true if the given `key` is an own property of `obj`.
8215 */
8216
8217 function hasOwn(obj, key) {
8218 return Object.prototype.hasOwnProperty.call(obj, key);
8219 }
8220
8221 /*!
8222 * Determine if an object is a Buffer
8223 *
8224 * @author Feross Aboukhadijeh <https://feross.org>
8225 * @license MIT
8226 */
8227
8228 // The _isBuffer check is for Safari 5-7 support, because it's missing
8229 // Object.prototype.constructor. Remove this eventually
8230 var isBuffer_1 = function (obj) {
8231 return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
8232 };
8233
8234 function isBuffer (obj) {
8235 return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
8236 }
8237
8238 // For Node v0.10 support. Remove this eventually.
8239 function isSlowBuffer (obj) {
8240 return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
8241 }
8242
8243 var toString = Object.prototype.toString;
8244
8245 /**
8246 * Get the native `typeof` a value.
8247 *
8248 * @param {*} `val`
8249 * @return {*} Native javascript type
8250 */
8251
8252 var kindOf = function kindOf(val) {
8253 // primitivies
8254 if (typeof val === 'undefined') {
8255 return 'undefined';
8256 }
8257 if (val === null) {
8258 return 'null';
8259 }
8260 if (val === true || val === false || val instanceof Boolean) {
8261 return 'boolean';
8262 }
8263 if (typeof val === 'string' || val instanceof String) {
8264 return 'string';
8265 }
8266 if (typeof val === 'number' || val instanceof Number) {
8267 return 'number';
8268 }
8269
8270 // functions
8271 if (typeof val === 'function' || val instanceof Function) {
8272 return 'function';
8273 }
8274
8275 // array
8276 if (typeof Array.isArray !== 'undefined' && Array.isArray(val)) {
8277 return 'array';
8278 }
8279
8280 // check for instances of RegExp and Date before calling `toString`
8281 if (val instanceof RegExp) {
8282 return 'regexp';
8283 }
8284 if (val instanceof Date) {
8285 return 'date';
8286 }
8287
8288 // other objects
8289 var type = toString.call(val);
8290
8291 if (type === '[object RegExp]') {
8292 return 'regexp';
8293 }
8294 if (type === '[object Date]') {
8295 return 'date';
8296 }
8297 if (type === '[object Arguments]') {
8298 return 'arguments';
8299 }
8300 if (type === '[object Error]') {
8301 return 'error';
8302 }
8303
8304 // buffer
8305 if (isBuffer_1(val)) {
8306 return 'buffer';
8307 }
8308
8309 // es6: Map, WeakMap, Set, WeakSet
8310 if (type === '[object Set]') {
8311 return 'set';
8312 }
8313 if (type === '[object WeakSet]') {
8314 return 'weakset';
8315 }
8316 if (type === '[object Map]') {
8317 return 'map';
8318 }
8319 if (type === '[object WeakMap]') {
8320 return 'weakmap';
8321 }
8322 if (type === '[object Symbol]') {
8323 return 'symbol';
8324 }
8325
8326 // typed arrays
8327 if (type === '[object Int8Array]') {
8328 return 'int8array';
8329 }
8330 if (type === '[object Uint8Array]') {
8331 return 'uint8array';
8332 }
8333 if (type === '[object Uint8ClampedArray]') {
8334 return 'uint8clampedarray';
8335 }
8336 if (type === '[object Int16Array]') {
8337 return 'int16array';
8338 }
8339 if (type === '[object Uint16Array]') {
8340 return 'uint16array';
8341 }
8342 if (type === '[object Int32Array]') {
8343 return 'int32array';
8344 }
8345 if (type === '[object Uint32Array]') {
8346 return 'uint32array';
8347 }
8348 if (type === '[object Float32Array]') {
8349 return 'float32array';
8350 }
8351 if (type === '[object Float64Array]') {
8352 return 'float64array';
8353 }
8354
8355 // must be a plain object
8356 return 'object';
8357 };
8358
8359 var condenseNewlines = function(str, options) {
8360 var opts = extendShallow({}, options);
8361 var sep = opts.sep || '\n\n';
8362 var min = opts.min;
8363 var re;
8364
8365 if (typeof min === 'number' && min !== 2) {
8366 re = new RegExp('(\\r\\n|\\n|\\u2424) {' + min + ',}');
8367 }
8368 if (typeof re === 'undefined') {
8369 re = opts.regex || /(\r\n|\n|\u2424){2,}/g;
8370 }
8371
8372 // if a line is 100% whitespace it will be trimmed, so that
8373 // later we can condense newlines correctly
8374 if (opts.keepWhitespace !== true) {
8375 str = str.split('\n').map(function(line) {
8376 return isWhitespace(line) ? line.trim() : line;
8377 }).join('\n');
8378 }
8379
8380 str = trailingNewline(str, opts);
8381 return str.replace(re, sep);
8382 };
8383
8384 function trailingNewline(str, options) {
8385 var val = options.trailingNewline;
8386 if (val === false) {
8387 return str;
8388 }
8389
8390 switch (kindOf(val)) {
8391 case 'string':
8392 str = str.replace(/\s+$/, options.trailingNewline);
8393 break;
8394 case 'function':
8395 str = options.trailingNewline(str);
8396 break;
8397 case 'undefined':
8398 case 'boolean':
8399 default: {
8400 str = str.replace(/\s+$/, '\n');
8401 break;
8402 }
8403 }
8404 return str;
8405 }
8406
8407 var defaults = {
8408 unformatted: ['code', 'pre', 'em', 'strong', 'span'],
8409 indent_inner_html: true,
8410 indent_char: ' ',
8411 indent_size: 2,
8412 sep: '\n'
8413 };
8414
8415 var pretty = function pretty(str, options) {
8416 var opts = extendShallow({}, defaults, options);
8417 str = js$1.html(str, opts);
8418
8419 if (opts.ocd === true) {
8420 if (opts.newlines) { opts.sep = opts.newlines; }
8421 return ocd(str, opts);
8422 }
8423
8424 return str;
8425 };
8426
8427 function ocd(str, options) {
8428 // Normalize and condense all newlines
8429 return condenseNewlines(str, options)
8430 // Remove empty whitespace the top of a file.
8431 .replace(/^\s+/g, '')
8432 // Remove extra whitespace from eof
8433 .replace(/\s+$/g, '\n')
8434
8435 // Add a space above each comment
8436 .replace(/(\s*<!--)/g, '\n$1')
8437 // Bring closing comments up to the same line as closing tag.
8438 .replace(/>(\s*)(?=<!--\s*\/)/g, '> ');
8439 }
8440
8441 //
8442
8443 function getSelectorType(selector) {
8444 if (isDomSelector(selector)) { return DOM_SELECTOR }
8445 if (isVueComponent(selector)) { return COMPONENT_SELECTOR }
8446 if (isNameSelector(selector)) { return NAME_SELECTOR }
8447 if (isRefSelector(selector)) { return REF_SELECTOR }
8448
8449 return INVALID_SELECTOR
8450 }
8451
8452 function getSelector(
8453 selector,
8454 methodName
8455 ) {
8456 var type = getSelectorType(selector);
8457 if (type === INVALID_SELECTOR) {
8458 throwError(
8459 "wrapper." + methodName + "() must be passed a valid CSS selector, Vue " +
8460 "constructor, or valid find option object"
8461 );
8462 }
8463 return {
8464 type: type,
8465 value: selector
8466 }
8467 }
8468
8469 //
8470
8471 var WrapperArray = function WrapperArray(wrappers) {
8472 var length = wrappers.length;
8473 // $FlowIgnore
8474 Object.defineProperty(this, 'wrappers', {
8475 get: function () { return wrappers; },
8476 set: function () { return throwError('wrapperArray.wrappers is read-only'); }
8477 });
8478 // $FlowIgnore
8479 Object.defineProperty(this, 'length', {
8480 get: function () { return length; },
8481 set: function () { return throwError('wrapperArray.length is read-only'); }
8482 });
8483 };
8484
8485 WrapperArray.prototype.at = function at (index) {
8486 var normalizedIndex = index < 0 ? this.length + index : index;
8487 if (normalizedIndex > this.length - 1 || normalizedIndex < 0) {
8488 var error = "no item exists at " + index;
8489 error += index < 0 ? (" (normalized to " + normalizedIndex + ")") : '';
8490 throwError(error);
8491 }
8492 return this.wrappers[normalizedIndex]
8493 };
8494
8495 WrapperArray.prototype.attributes = function attributes () {
8496 this.throwErrorIfWrappersIsEmpty('attributes');
8497
8498 throwError(
8499 "attributes must be called on a single wrapper, use " +
8500 "at(i) to access a wrapper"
8501 );
8502 };
8503
8504 WrapperArray.prototype.classes = function classes () {
8505 this.throwErrorIfWrappersIsEmpty('classes');
8506
8507 throwError(
8508 "classes must be called on a single wrapper, use " +
8509 "at(i) to access a wrapper"
8510 );
8511 };
8512
8513 WrapperArray.prototype.contains = function contains (selector) {
8514 this.throwErrorIfWrappersIsEmpty('contains');
8515
8516 return this.wrappers.every(function (wrapper) { return wrapper.contains(selector); })
8517 };
8518
8519 WrapperArray.prototype.exists = function exists () {
8520 return this.length > 0 && this.wrappers.every(function (wrapper) { return wrapper.exists(); })
8521 };
8522
8523 WrapperArray.prototype.filter = function filter (predicate) {
8524 return new WrapperArray(this.wrappers.filter(predicate))
8525 };
8526
8527 WrapperArray.prototype.emitted = function emitted () {
8528 this.throwErrorIfWrappersIsEmpty('emitted');
8529
8530 throwError(
8531 "emitted must be called on a single wrapper, use " +
8532 "at(i) to access a wrapper"
8533 );
8534 };
8535
8536 WrapperArray.prototype.emittedByOrder = function emittedByOrder () {
8537 this.throwErrorIfWrappersIsEmpty('emittedByOrder');
8538
8539 throwError(
8540 "emittedByOrder must be called on a single wrapper, " +
8541 "use at(i) to access a wrapper"
8542 );
8543 };
8544
8545 WrapperArray.prototype.findAll = function findAll () {
8546 this.throwErrorIfWrappersIsEmpty('findAll');
8547
8548 throwError(
8549 "findAll must be called on a single wrapper, use " +
8550 "at(i) to access a wrapper"
8551 );
8552 };
8553
8554 WrapperArray.prototype.find = function find () {
8555 this.throwErrorIfWrappersIsEmpty('find');
8556
8557 throwError(
8558 "find must be called on a single wrapper, use at(i) " +
8559 "to access a wrapper"
8560 );
8561 };
8562
8563 WrapperArray.prototype.html = function html () {
8564 this.throwErrorIfWrappersIsEmpty('html');
8565
8566 throwError(
8567 "html must be called on a single wrapper, use at(i) " +
8568 "to access a wrapper"
8569 );
8570 };
8571
8572 WrapperArray.prototype.is = function is (selector) {
8573 this.throwErrorIfWrappersIsEmpty('is');
8574
8575 return this.wrappers.every(function (wrapper) { return wrapper.is(selector); })
8576 };
8577
8578 WrapperArray.prototype.isEmpty = function isEmpty () {
8579 this.throwErrorIfWrappersIsEmpty('isEmpty');
8580
8581 return this.wrappers.every(function (wrapper) { return wrapper.isEmpty(); })
8582 };
8583
8584 WrapperArray.prototype.isVisible = function isVisible () {
8585 this.throwErrorIfWrappersIsEmpty('isVisible');
8586
8587 return this.wrappers.every(function (wrapper) { return wrapper.isVisible(); })
8588 };
8589
8590 WrapperArray.prototype.isVueInstance = function isVueInstance () {
8591 this.throwErrorIfWrappersIsEmpty('isVueInstance');
8592
8593 return this.wrappers.every(function (wrapper) { return wrapper.isVueInstance(); })
8594 };
8595
8596 WrapperArray.prototype.name = function name () {
8597 this.throwErrorIfWrappersIsEmpty('name');
8598
8599 throwError(
8600 "name must be called on a single wrapper, use at(i) " +
8601 "to access a wrapper"
8602 );
8603 };
8604
8605 WrapperArray.prototype.overview = function overview () {
8606 this.throwErrorIfWrappersIsEmpty('overview()');
8607
8608 throwError(
8609 "overview() must be called on a single wrapper, use at(i) " +
8610 "to access a wrapper"
8611 );
8612 };
8613
8614 WrapperArray.prototype.props = function props () {
8615 this.throwErrorIfWrappersIsEmpty('props');
8616
8617 throwError(
8618 "props must be called on a single wrapper, use " +
8619 "at(i) to access a wrapper"
8620 );
8621 };
8622
8623 WrapperArray.prototype.text = function text () {
8624 this.throwErrorIfWrappersIsEmpty('text');
8625
8626 throwError(
8627 "text must be called on a single wrapper, use at(i) " +
8628 "to access a wrapper"
8629 );
8630 };
8631
8632 WrapperArray.prototype.throwErrorIfWrappersIsEmpty = function throwErrorIfWrappersIsEmpty (method) {
8633 if (this.wrappers.length === 0) {
8634 throwError((method + " cannot be called on 0 items"));
8635 }
8636 };
8637
8638 WrapperArray.prototype.setData = function setData (data) {
8639 this.throwErrorIfWrappersIsEmpty('setData');
8640
8641 this.wrappers.forEach(function (wrapper) { return wrapper.setData(data); });
8642 };
8643
8644 WrapperArray.prototype.setMethods = function setMethods (props) {
8645 this.throwErrorIfWrappersIsEmpty('setMethods');
8646
8647 this.wrappers.forEach(function (wrapper) { return wrapper.setMethods(props); });
8648 };
8649
8650 WrapperArray.prototype.setProps = function setProps (props) {
8651 this.throwErrorIfWrappersIsEmpty('setProps');
8652
8653 this.wrappers.forEach(function (wrapper) { return wrapper.setProps(props); });
8654 };
8655
8656 WrapperArray.prototype.setValue = function setValue (value) {
8657 this.throwErrorIfWrappersIsEmpty('setValue');
8658
8659 this.wrappers.forEach(function (wrapper) { return wrapper.setValue(value); });
8660 };
8661
8662 WrapperArray.prototype.setChecked = function setChecked (checked) {
8663 if ( checked === void 0 ) checked = true;
8664
8665 this.throwErrorIfWrappersIsEmpty('setChecked');
8666
8667 this.wrappers.forEach(function (wrapper) { return wrapper.setChecked(checked); });
8668 };
8669
8670 WrapperArray.prototype.setSelected = function setSelected () {
8671 this.throwErrorIfWrappersIsEmpty('setSelected');
8672
8673 throwError(
8674 "setSelected must be called on a single wrapper, " +
8675 "use at(i) to access a wrapper"
8676 );
8677 };
8678
8679 WrapperArray.prototype.trigger = function trigger (event, options) {
8680 this.throwErrorIfWrappersIsEmpty('trigger');
8681
8682 this.wrappers.forEach(function (wrapper) { return wrapper.trigger(event, options); });
8683 };
8684
8685 WrapperArray.prototype.destroy = function destroy () {
8686 this.throwErrorIfWrappersIsEmpty('destroy');
8687
8688 this.wrappers.forEach(function (wrapper) { return wrapper.destroy(); });
8689 };
8690
8691 //
8692
8693 var buildSelectorString = function (selector) {
8694 if (getSelectorType(selector) === REF_SELECTOR) {
8695 return ("ref=\"" + (selector.value.ref) + "\"")
8696 }
8697
8698 if (typeof selector === 'string') {
8699 return selector
8700 }
8701
8702 return 'Component'
8703 };
8704
8705 var ErrorWrapper = function ErrorWrapper(selector) {
8706 this.selector = selector;
8707 };
8708
8709 ErrorWrapper.prototype.at = function at () {
8710 throwError(
8711 ("find did not return " + (buildSelectorString(
8712 this.selector
8713 )) + ", cannot call at() on empty Wrapper")
8714 );
8715 };
8716
8717 ErrorWrapper.prototype.attributes = function attributes () {
8718 throwError(
8719 ("find did not return " + (buildSelectorString(
8720 this.selector
8721 )) + ", cannot call attributes() on empty Wrapper")
8722 );
8723 };
8724
8725 ErrorWrapper.prototype.classes = function classes () {
8726 throwError(
8727 ("find did not return " + (buildSelectorString(
8728 this.selector
8729 )) + ", cannot call classes() on empty Wrapper")
8730 );
8731 };
8732
8733 ErrorWrapper.prototype.contains = function contains () {
8734 throwError(
8735 ("find did not return " + (buildSelectorString(
8736 this.selector
8737 )) + ", cannot call contains() on empty Wrapper")
8738 );
8739 };
8740
8741 ErrorWrapper.prototype.emitted = function emitted () {
8742 throwError(
8743 ("find did not return " + (buildSelectorString(
8744 this.selector
8745 )) + ", cannot call emitted() on empty Wrapper")
8746 );
8747 };
8748
8749 ErrorWrapper.prototype.emittedByOrder = function emittedByOrder () {
8750 throwError(
8751 ("find did not return " + (buildSelectorString(
8752 this.selector
8753 )) + ", cannot call emittedByOrder() on empty Wrapper")
8754 );
8755 };
8756
8757 ErrorWrapper.prototype.exists = function exists () {
8758 return false
8759 };
8760
8761 ErrorWrapper.prototype.filter = function filter () {
8762 throwError(
8763 ("find did not return " + (buildSelectorString(
8764 this.selector
8765 )) + ", cannot call filter() on empty Wrapper")
8766 );
8767 };
8768
8769 ErrorWrapper.prototype.visible = function visible () {
8770 throwError(
8771 ("find did not return " + (buildSelectorString(
8772 this.selector
8773 )) + ", cannot call visible() on empty Wrapper")
8774 );
8775 };
8776
8777 ErrorWrapper.prototype.hasAttribute = function hasAttribute () {
8778 throwError(
8779 ("find did not return " + (buildSelectorString(
8780 this.selector
8781 )) + ", cannot call hasAttribute() on empty Wrapper")
8782 );
8783 };
8784
8785 ErrorWrapper.prototype.hasClass = function hasClass () {
8786 throwError(
8787 ("find did not return " + (buildSelectorString(
8788 this.selector
8789 )) + ", cannot call hasClass() on empty Wrapper")
8790 );
8791 };
8792
8793 ErrorWrapper.prototype.hasProp = function hasProp () {
8794 throwError(
8795 ("find did not return " + (buildSelectorString(
8796 this.selector
8797 )) + ", cannot call hasProp() on empty Wrapper")
8798 );
8799 };
8800
8801 ErrorWrapper.prototype.hasStyle = function hasStyle () {
8802 throwError(
8803 ("find did not return " + (buildSelectorString(
8804 this.selector
8805 )) + ", cannot call hasStyle() on empty Wrapper")
8806 );
8807 };
8808
8809 ErrorWrapper.prototype.findAll = function findAll () {
8810 throwError(
8811 ("find did not return " + (buildSelectorString(
8812 this.selector
8813 )) + ", cannot call findAll() on empty Wrapper")
8814 );
8815 };
8816
8817 ErrorWrapper.prototype.find = function find () {
8818 throwError(
8819 ("find did not return " + (buildSelectorString(
8820 this.selector
8821 )) + ", cannot call find() on empty Wrapper")
8822 );
8823 };
8824
8825 ErrorWrapper.prototype.html = function html () {
8826 throwError(
8827 ("find did not return " + (buildSelectorString(
8828 this.selector
8829 )) + ", cannot call html() on empty Wrapper")
8830 );
8831 };
8832
8833 ErrorWrapper.prototype.is = function is () {
8834 throwError(
8835 ("find did not return " + (buildSelectorString(
8836 this.selector
8837 )) + ", cannot call is() on empty Wrapper")
8838 );
8839 };
8840
8841 ErrorWrapper.prototype.isEmpty = function isEmpty () {
8842 throwError(
8843 ("find did not return " + (buildSelectorString(
8844 this.selector
8845 )) + ", cannot call isEmpty() on empty Wrapper")
8846 );
8847 };
8848
8849 ErrorWrapper.prototype.isVisible = function isVisible () {
8850 throwError(
8851 ("find did not return " + (buildSelectorString(
8852 this.selector
8853 )) + ", cannot call isVisible() on empty Wrapper")
8854 );
8855 };
8856
8857 ErrorWrapper.prototype.isVueInstance = function isVueInstance () {
8858 throwError(
8859 ("find did not return " + (buildSelectorString(
8860 this.selector
8861 )) + ", cannot call isVueInstance() on empty Wrapper")
8862 );
8863 };
8864
8865 ErrorWrapper.prototype.name = function name () {
8866 throwError(
8867 ("find did not return " + (buildSelectorString(
8868 this.selector
8869 )) + ", cannot call name() on empty Wrapper")
8870 );
8871 };
8872
8873 ErrorWrapper.prototype.overview = function overview () {
8874 throwError(
8875 ("find did not return " + (buildSelectorString(
8876 this.selector
8877 )) + ", cannot call overview() on empty Wrapper")
8878 );
8879 };
8880
8881 ErrorWrapper.prototype.props = function props () {
8882 throwError(
8883 ("find did not return " + (buildSelectorString(
8884 this.selector
8885 )) + ", cannot call props() on empty Wrapper")
8886 );
8887 };
8888
8889 ErrorWrapper.prototype.text = function text () {
8890 throwError(
8891 ("find did not return " + (buildSelectorString(
8892 this.selector
8893 )) + ", cannot call text() on empty Wrapper")
8894 );
8895 };
8896
8897 ErrorWrapper.prototype.setComputed = function setComputed () {
8898 throwError(
8899 ("find did not return " + (buildSelectorString(
8900 this.selector
8901 )) + ", cannot call setComputed() on empty Wrapper")
8902 );
8903 };
8904
8905 ErrorWrapper.prototype.setData = function setData () {
8906 throwError(
8907 ("find did not return " + (buildSelectorString(
8908 this.selector
8909 )) + ", cannot call setData() on empty Wrapper")
8910 );
8911 };
8912
8913 ErrorWrapper.prototype.setMethods = function setMethods () {
8914 throwError(
8915 ("find did not return " + (buildSelectorString(
8916 this.selector
8917 )) + ", cannot call setMethods() on empty Wrapper")
8918 );
8919 };
8920
8921 ErrorWrapper.prototype.setProps = function setProps () {
8922 throwError(
8923 ("find did not return " + (buildSelectorString(
8924 this.selector
8925 )) + ", cannot call setProps() on empty Wrapper")
8926 );
8927 };
8928
8929 ErrorWrapper.prototype.setValue = function setValue () {
8930 throwError(
8931 ("find did not return " + (buildSelectorString(
8932 this.selector
8933 )) + ", cannot call setValue() on empty Wrapper")
8934 );
8935 };
8936
8937 ErrorWrapper.prototype.setChecked = function setChecked () {
8938 throwError(
8939 ("find did not return " + (buildSelectorString(
8940 this.selector
8941 )) + ", cannot call setChecked() on empty Wrapper")
8942 );
8943 };
8944
8945 ErrorWrapper.prototype.setSelected = function setSelected () {
8946 throwError(
8947 ("find did not return " + (buildSelectorString(
8948 this.selector
8949 )) + ", cannot call setSelected() on empty Wrapper")
8950 );
8951 };
8952
8953 ErrorWrapper.prototype.trigger = function trigger () {
8954 throwError(
8955 ("find did not return " + (buildSelectorString(
8956 this.selector
8957 )) + ", cannot call trigger() on empty Wrapper")
8958 );
8959 };
8960
8961 ErrorWrapper.prototype.destroy = function destroy () {
8962 throwError(
8963 ("find did not return " + (buildSelectorString(
8964 this.selector
8965 )) + ", cannot call destroy() on empty Wrapper")
8966 );
8967 };
8968
8969 function recursivelySetData(vm, target, data) {
8970 Object.keys(data).forEach(function (key) {
8971 var val = data[key];
8972 var targetVal = target[key];
8973
8974 if (isPlainObject(val) && isPlainObject(targetVal)) {
8975 recursivelySetData(vm, targetVal, val);
8976 } else {
8977 vm.$set(target, key, val);
8978 }
8979 });
8980 }
8981
8982 var abort = {
8983 eventInterface: "Event",
8984 bubbles: false,
8985 cancelable: false
8986 };
8987 var afterprint = {
8988 eventInterface: "Event",
8989 bubbles: false,
8990 cancelable: false
8991 };
8992 var animationend = {
8993 eventInterface: "AnimationEvent",
8994 bubbles: true,
8995 cancelable: false
8996 };
8997 var animationiteration = {
8998 eventInterface: "AnimationEvent",
8999 bubbles: true,
9000 cancelable: false
9001 };
9002 var animationstart = {
9003 eventInterface: "AnimationEvent",
9004 bubbles: true,
9005 cancelable: false
9006 };
9007 var appinstalled = {
9008 eventInterface: "Event",
9009 bubbles: false,
9010 cancelable: false
9011 };
9012 var audioprocess = {
9013 eventInterface: "AudioProcessingEvent"
9014 };
9015 var audioend = {
9016 eventInterface: "Event",
9017 bubbles: false,
9018 cancelable: false
9019 };
9020 var audiostart = {
9021 eventInterface: "Event",
9022 bubbles: false,
9023 cancelable: false
9024 };
9025 var beforeprint = {
9026 eventInterface: "Event",
9027 bubbles: false,
9028 cancelable: false
9029 };
9030 var beforeunload = {
9031 eventInterface: "BeforeUnloadEvent",
9032 bubbles: false,
9033 cancelable: true
9034 };
9035 var beginEvent = {
9036 eventInterface: "TimeEvent",
9037 bubbles: false,
9038 cancelable: false
9039 };
9040 var blur = {
9041 eventInterface: "FocusEvent",
9042 bubbles: false,
9043 cancelable: false
9044 };
9045 var boundary = {
9046 eventInterface: "SpeechSynthesisEvent",
9047 bubbles: false,
9048 cancelable: false
9049 };
9050 var cached = {
9051 eventInterface: "Event",
9052 bubbles: false,
9053 cancelable: false
9054 };
9055 var canplay = {
9056 eventInterface: "Event",
9057 bubbles: false,
9058 cancelable: false
9059 };
9060 var canplaythrough = {
9061 eventInterface: "Event",
9062 bubbles: false,
9063 cancelable: false
9064 };
9065 var change = {
9066 eventInterface: "Event",
9067 bubbles: true,
9068 cancelable: false
9069 };
9070 var chargingchange = {
9071 eventInterface: "Event",
9072 bubbles: false,
9073 cancelable: false
9074 };
9075 var chargingtimechange = {
9076 eventInterface: "Event",
9077 bubbles: false,
9078 cancelable: false
9079 };
9080 var checking = {
9081 eventInterface: "Event",
9082 bubbles: false,
9083 cancelable: false
9084 };
9085 var click = {
9086 eventInterface: "MouseEvent",
9087 bubbles: true,
9088 cancelable: true
9089 };
9090 var close = {
9091 eventInterface: "Event",
9092 bubbles: false,
9093 cancelable: false
9094 };
9095 var complete = {
9096 eventInterface: "OfflineAudioCompletionEvent"
9097 };
9098 var compositionend = {
9099 eventInterface: "CompositionEvent",
9100 bubbles: true,
9101 cancelable: true
9102 };
9103 var compositionstart = {
9104 eventInterface: "CompositionEvent",
9105 bubbles: true,
9106 cancelable: true
9107 };
9108 var compositionupdate = {
9109 eventInterface: "CompositionEvent",
9110 bubbles: true,
9111 cancelable: false
9112 };
9113 var contextmenu = {
9114 eventInterface: "MouseEvent",
9115 bubbles: true,
9116 cancelable: true
9117 };
9118 var copy = {
9119 eventInterface: "ClipboardEvent"
9120 };
9121 var cut = {
9122 eventInterface: "ClipboardEvent",
9123 bubbles: true,
9124 cancelable: true
9125 };
9126 var dblclick = {
9127 eventInterface: "MouseEvent",
9128 bubbles: true,
9129 cancelable: true
9130 };
9131 var devicechange = {
9132 eventInterface: "Event",
9133 bubbles: false,
9134 cancelable: false
9135 };
9136 var devicelight = {
9137 eventInterface: "DeviceLightEvent",
9138 bubbles: false,
9139 cancelable: false
9140 };
9141 var devicemotion = {
9142 eventInterface: "DeviceMotionEvent",
9143 bubbles: false,
9144 cancelable: false
9145 };
9146 var deviceorientation = {
9147 eventInterface: "DeviceOrientationEvent",
9148 bubbles: false,
9149 cancelable: false
9150 };
9151 var deviceproximity = {
9152 eventInterface: "DeviceProximityEvent",
9153 bubbles: false,
9154 cancelable: false
9155 };
9156 var dischargingtimechange = {
9157 eventInterface: "Event",
9158 bubbles: false,
9159 cancelable: false
9160 };
9161 var DOMActivate = {
9162 eventInterface: "UIEvent",
9163 bubbles: true,
9164 cancelable: true
9165 };
9166 var DOMAttributeNameChanged = {
9167 eventInterface: "MutationNameEvent",
9168 bubbles: true,
9169 cancelable: true
9170 };
9171 var DOMAttrModified = {
9172 eventInterface: "MutationEvent",
9173 bubbles: true,
9174 cancelable: true
9175 };
9176 var DOMCharacterDataModified = {
9177 eventInterface: "MutationEvent",
9178 bubbles: true,
9179 cancelable: true
9180 };
9181 var DOMContentLoaded = {
9182 eventInterface: "Event",
9183 bubbles: true,
9184 cancelable: true
9185 };
9186 var DOMElementNameChanged = {
9187 eventInterface: "MutationNameEvent",
9188 bubbles: true,
9189 cancelable: true
9190 };
9191 var DOMFocusIn = {
9192 eventInterface: "FocusEvent",
9193 bubbles: true,
9194 cancelable: true
9195 };
9196 var DOMFocusOut = {
9197 eventInterface: "FocusEvent",
9198 bubbles: true,
9199 cancelable: true
9200 };
9201 var DOMNodeInserted = {
9202 eventInterface: "MutationEvent",
9203 bubbles: true,
9204 cancelable: true
9205 };
9206 var DOMNodeInsertedIntoDocument = {
9207 eventInterface: "MutationEvent",
9208 bubbles: true,
9209 cancelable: true
9210 };
9211 var DOMNodeRemoved = {
9212 eventInterface: "MutationEvent",
9213 bubbles: true,
9214 cancelable: true
9215 };
9216 var DOMNodeRemovedFromDocument = {
9217 eventInterface: "MutationEvent",
9218 bubbles: true,
9219 cancelable: true
9220 };
9221 var DOMSubtreeModified = {
9222 eventInterface: "MutationEvent"
9223 };
9224 var downloading = {
9225 eventInterface: "Event",
9226 bubbles: false,
9227 cancelable: false
9228 };
9229 var drag = {
9230 eventInterface: "DragEvent",
9231 bubbles: true,
9232 cancelable: true
9233 };
9234 var dragend = {
9235 eventInterface: "DragEvent",
9236 bubbles: true,
9237 cancelable: false
9238 };
9239 var dragenter = {
9240 eventInterface: "DragEvent",
9241 bubbles: true,
9242 cancelable: true
9243 };
9244 var dragleave = {
9245 eventInterface: "DragEvent",
9246 bubbles: true,
9247 cancelable: false
9248 };
9249 var dragover = {
9250 eventInterface: "DragEvent",
9251 bubbles: true,
9252 cancelable: true
9253 };
9254 var dragstart = {
9255 eventInterface: "DragEvent",
9256 bubbles: true,
9257 cancelable: true
9258 };
9259 var drop = {
9260 eventInterface: "DragEvent",
9261 bubbles: true,
9262 cancelable: true
9263 };
9264 var durationchange = {
9265 eventInterface: "Event",
9266 bubbles: false,
9267 cancelable: false
9268 };
9269 var emptied = {
9270 eventInterface: "Event",
9271 bubbles: false,
9272 cancelable: false
9273 };
9274 var end = {
9275 eventInterface: "Event",
9276 bubbles: false,
9277 cancelable: false
9278 };
9279 var ended = {
9280 eventInterface: "Event",
9281 bubbles: false,
9282 cancelable: false
9283 };
9284 var endEvent = {
9285 eventInterface: "TimeEvent",
9286 bubbles: false,
9287 cancelable: false
9288 };
9289 var error = {
9290 eventInterface: "Event",
9291 bubbles: false,
9292 cancelable: false
9293 };
9294 var focus = {
9295 eventInterface: "FocusEvent",
9296 bubbles: false,
9297 cancelable: false
9298 };
9299 var focusin = {
9300 eventInterface: "FocusEvent",
9301 bubbles: true,
9302 cancelable: false
9303 };
9304 var focusout = {
9305 eventInterface: "FocusEvent",
9306 bubbles: true,
9307 cancelable: false
9308 };
9309 var fullscreenchange = {
9310 eventInterface: "Event",
9311 bubbles: true,
9312 cancelable: false
9313 };
9314 var fullscreenerror = {
9315 eventInterface: "Event",
9316 bubbles: true,
9317 cancelable: false
9318 };
9319 var gamepadconnected = {
9320 eventInterface: "GamepadEvent",
9321 bubbles: false,
9322 cancelable: false
9323 };
9324 var gamepaddisconnected = {
9325 eventInterface: "GamepadEvent",
9326 bubbles: false,
9327 cancelable: false
9328 };
9329 var gotpointercapture = {
9330 eventInterface: "PointerEvent",
9331 bubbles: false,
9332 cancelable: false
9333 };
9334 var hashchange = {
9335 eventInterface: "HashChangeEvent",
9336 bubbles: true,
9337 cancelable: false
9338 };
9339 var lostpointercapture = {
9340 eventInterface: "PointerEvent",
9341 bubbles: false,
9342 cancelable: false
9343 };
9344 var input = {
9345 eventInterface: "Event",
9346 bubbles: true,
9347 cancelable: false
9348 };
9349 var invalid = {
9350 eventInterface: "Event",
9351 cancelable: true,
9352 bubbles: false
9353 };
9354 var keydown = {
9355 eventInterface: "KeyboardEvent",
9356 bubbles: true,
9357 cancelable: true
9358 };
9359 var keypress = {
9360 eventInterface: "KeyboardEvent",
9361 bubbles: true,
9362 cancelable: true
9363 };
9364 var keyup = {
9365 eventInterface: "KeyboardEvent",
9366 bubbles: true,
9367 cancelable: true
9368 };
9369 var languagechange = {
9370 eventInterface: "Event",
9371 bubbles: false,
9372 cancelable: false
9373 };
9374 var levelchange = {
9375 eventInterface: "Event",
9376 bubbles: false,
9377 cancelable: false
9378 };
9379 var load = {
9380 eventInterface: "UIEvent",
9381 bubbles: false,
9382 cancelable: false
9383 };
9384 var loadeddata = {
9385 eventInterface: "Event",
9386 bubbles: false,
9387 cancelable: false
9388 };
9389 var loadedmetadata = {
9390 eventInterface: "Event",
9391 bubbles: false,
9392 cancelable: false
9393 };
9394 var loadend = {
9395 eventInterface: "ProgressEvent",
9396 bubbles: false,
9397 cancelable: false
9398 };
9399 var loadstart = {
9400 eventInterface: "ProgressEvent",
9401 bubbles: false,
9402 cancelable: false
9403 };
9404 var mark = {
9405 eventInterface: "SpeechSynthesisEvent",
9406 bubbles: false,
9407 cancelable: false
9408 };
9409 var message = {
9410 eventInterface: "MessageEvent",
9411 bubbles: false,
9412 cancelable: false
9413 };
9414 var messageerror = {
9415 eventInterface: "MessageEvent",
9416 bubbles: false,
9417 cancelable: false
9418 };
9419 var mousedown = {
9420 eventInterface: "MouseEvent",
9421 bubbles: true,
9422 cancelable: true
9423 };
9424 var mouseenter = {
9425 eventInterface: "MouseEvent",
9426 bubbles: false,
9427 cancelable: false
9428 };
9429 var mouseleave = {
9430 eventInterface: "MouseEvent",
9431 bubbles: false,
9432 cancelable: false
9433 };
9434 var mousemove = {
9435 eventInterface: "MouseEvent",
9436 bubbles: true,
9437 cancelable: true
9438 };
9439 var mouseout = {
9440 eventInterface: "MouseEvent",
9441 bubbles: true,
9442 cancelable: true
9443 };
9444 var mouseover = {
9445 eventInterface: "MouseEvent",
9446 bubbles: true,
9447 cancelable: true
9448 };
9449 var mouseup = {
9450 eventInterface: "MouseEvent",
9451 bubbles: true,
9452 cancelable: true
9453 };
9454 var nomatch = {
9455 eventInterface: "SpeechRecognitionEvent",
9456 bubbles: false,
9457 cancelable: false
9458 };
9459 var notificationclick = {
9460 eventInterface: "NotificationEvent",
9461 bubbles: false,
9462 cancelable: false
9463 };
9464 var noupdate = {
9465 eventInterface: "Event",
9466 bubbles: false,
9467 cancelable: false
9468 };
9469 var obsolete = {
9470 eventInterface: "Event",
9471 bubbles: false,
9472 cancelable: false
9473 };
9474 var offline = {
9475 eventInterface: "Event",
9476 bubbles: false,
9477 cancelable: false
9478 };
9479 var online = {
9480 eventInterface: "Event",
9481 bubbles: false,
9482 cancelable: false
9483 };
9484 var open = {
9485 eventInterface: "Event",
9486 bubbles: false,
9487 cancelable: false
9488 };
9489 var orientationchange = {
9490 eventInterface: "Event",
9491 bubbles: false,
9492 cancelable: false
9493 };
9494 var pagehide = {
9495 eventInterface: "PageTransitionEvent",
9496 bubbles: false,
9497 cancelable: false
9498 };
9499 var pageshow = {
9500 eventInterface: "PageTransitionEvent",
9501 bubbles: false,
9502 cancelable: false
9503 };
9504 var paste = {
9505 eventInterface: "ClipboardEvent",
9506 bubbles: true,
9507 cancelable: true
9508 };
9509 var pause = {
9510 eventInterface: "SpeechSynthesisEvent",
9511 bubbles: false,
9512 cancelable: false
9513 };
9514 var pointercancel = {
9515 eventInterface: "PointerEvent",
9516 bubbles: true,
9517 cancelable: false
9518 };
9519 var pointerdown = {
9520 eventInterface: "PointerEvent",
9521 bubbles: true,
9522 cancelable: true
9523 };
9524 var pointerenter = {
9525 eventInterface: "PointerEvent",
9526 bubbles: false,
9527 cancelable: false
9528 };
9529 var pointerleave = {
9530 eventInterface: "PointerEvent",
9531 bubbles: false,
9532 cancelable: false
9533 };
9534 var pointerlockchange = {
9535 eventInterface: "Event",
9536 bubbles: true,
9537 cancelable: false
9538 };
9539 var pointerlockerror = {
9540 eventInterface: "Event",
9541 bubbles: true,
9542 cancelable: false
9543 };
9544 var pointermove = {
9545 eventInterface: "PointerEvent",
9546 bubbles: true,
9547 cancelable: true
9548 };
9549 var pointerout = {
9550 eventInterface: "PointerEvent",
9551 bubbles: true,
9552 cancelable: true
9553 };
9554 var pointerover = {
9555 eventInterface: "PointerEvent",
9556 bubbles: true,
9557 cancelable: true
9558 };
9559 var pointerup = {
9560 eventInterface: "PointerEvent",
9561 bubbles: true,
9562 cancelable: true
9563 };
9564 var play = {
9565 eventInterface: "Event",
9566 bubbles: false,
9567 cancelable: false
9568 };
9569 var playing = {
9570 eventInterface: "Event",
9571 bubbles: false,
9572 cancelable: false
9573 };
9574 var popstate = {
9575 eventInterface: "PopStateEvent",
9576 bubbles: true,
9577 cancelable: false
9578 };
9579 var progress = {
9580 eventInterface: "ProgressEvent",
9581 bubbles: false,
9582 cancelable: false
9583 };
9584 var push = {
9585 eventInterface: "PushEvent",
9586 bubbles: false,
9587 cancelable: false
9588 };
9589 var pushsubscriptionchange = {
9590 eventInterface: "PushEvent",
9591 bubbles: false,
9592 cancelable: false
9593 };
9594 var ratechange = {
9595 eventInterface: "Event",
9596 bubbles: false,
9597 cancelable: false
9598 };
9599 var readystatechange = {
9600 eventInterface: "Event",
9601 bubbles: false,
9602 cancelable: false
9603 };
9604 var repeatEvent = {
9605 eventInterface: "TimeEvent",
9606 bubbles: false,
9607 cancelable: false
9608 };
9609 var reset = {
9610 eventInterface: "Event",
9611 bubbles: true,
9612 cancelable: true
9613 };
9614 var resize = {
9615 eventInterface: "UIEvent",
9616 bubbles: false,
9617 cancelable: false
9618 };
9619 var resourcetimingbufferfull = {
9620 eventInterface: "Performance",
9621 bubbles: true,
9622 cancelable: true
9623 };
9624 var result = {
9625 eventInterface: "SpeechRecognitionEvent",
9626 bubbles: false,
9627 cancelable: false
9628 };
9629 var resume = {
9630 eventInterface: "SpeechSynthesisEvent",
9631 bubbles: false,
9632 cancelable: false
9633 };
9634 var scroll = {
9635 eventInterface: "UIEvent",
9636 bubbles: false,
9637 cancelable: false
9638 };
9639 var seeked = {
9640 eventInterface: "Event",
9641 bubbles: false,
9642 cancelable: false
9643 };
9644 var seeking = {
9645 eventInterface: "Event",
9646 bubbles: false,
9647 cancelable: false
9648 };
9649 var select = {
9650 eventInterface: "UIEvent",
9651 bubbles: true,
9652 cancelable: false
9653 };
9654 var selectstart = {
9655 eventInterface: "Event",
9656 bubbles: true,
9657 cancelable: true
9658 };
9659 var selectionchange = {
9660 eventInterface: "Event",
9661 bubbles: false,
9662 cancelable: false
9663 };
9664 var show = {
9665 eventInterface: "MouseEvent",
9666 bubbles: false,
9667 cancelable: false
9668 };
9669 var slotchange = {
9670 eventInterface: "Event",
9671 bubbles: true,
9672 cancelable: false
9673 };
9674 var soundend = {
9675 eventInterface: "Event",
9676 bubbles: false,
9677 cancelable: false
9678 };
9679 var soundstart = {
9680 eventInterface: "Event",
9681 bubbles: false,
9682 cancelable: false
9683 };
9684 var speechend = {
9685 eventInterface: "Event",
9686 bubbles: false,
9687 cancelable: false
9688 };
9689 var speechstart = {
9690 eventInterface: "Event",
9691 bubbles: false,
9692 cancelable: false
9693 };
9694 var stalled = {
9695 eventInterface: "Event",
9696 bubbles: false,
9697 cancelable: false
9698 };
9699 var start = {
9700 eventInterface: "SpeechSynthesisEvent",
9701 bubbles: false,
9702 cancelable: false
9703 };
9704 var storage = {
9705 eventInterface: "StorageEvent",
9706 bubbles: false,
9707 cancelable: false
9708 };
9709 var submit = {
9710 eventInterface: "Event",
9711 bubbles: true,
9712 cancelable: true
9713 };
9714 var success = {
9715 eventInterface: "Event",
9716 bubbles: false,
9717 cancelable: false
9718 };
9719 var suspend = {
9720 eventInterface: "Event",
9721 bubbles: false,
9722 cancelable: false
9723 };
9724 var SVGAbort = {
9725 eventInterface: "SVGEvent",
9726 bubbles: true,
9727 cancelable: false
9728 };
9729 var SVGError = {
9730 eventInterface: "SVGEvent",
9731 bubbles: true,
9732 cancelable: false
9733 };
9734 var SVGLoad = {
9735 eventInterface: "SVGEvent",
9736 bubbles: false,
9737 cancelable: false
9738 };
9739 var SVGResize = {
9740 eventInterface: "SVGEvent",
9741 bubbles: true,
9742 cancelable: false
9743 };
9744 var SVGScroll = {
9745 eventInterface: "SVGEvent",
9746 bubbles: true,
9747 cancelable: false
9748 };
9749 var SVGUnload = {
9750 eventInterface: "SVGEvent",
9751 bubbles: false,
9752 cancelable: false
9753 };
9754 var SVGZoom = {
9755 eventInterface: "SVGZoomEvent",
9756 bubbles: true,
9757 cancelable: false
9758 };
9759 var timeout = {
9760 eventInterface: "ProgressEvent",
9761 bubbles: false,
9762 cancelable: false
9763 };
9764 var timeupdate = {
9765 eventInterface: "Event",
9766 bubbles: false,
9767 cancelable: false
9768 };
9769 var touchcancel = {
9770 eventInterface: "TouchEvent",
9771 bubbles: true,
9772 cancelable: false
9773 };
9774 var touchend = {
9775 eventInterface: "TouchEvent",
9776 bubbles: true,
9777 cancelable: true
9778 };
9779 var touchmove = {
9780 eventInterface: "TouchEvent",
9781 bubbles: true,
9782 cancelable: true
9783 };
9784 var touchstart = {
9785 eventInterface: "TouchEvent",
9786 bubbles: true,
9787 cancelable: true
9788 };
9789 var transitionend = {
9790 eventInterface: "TransitionEvent",
9791 bubbles: true,
9792 cancelable: true
9793 };
9794 var unload = {
9795 eventInterface: "UIEvent",
9796 bubbles: false
9797 };
9798 var updateready = {
9799 eventInterface: "Event",
9800 bubbles: false,
9801 cancelable: false
9802 };
9803 var userproximity = {
9804 eventInterface: "UserProximityEvent",
9805 bubbles: false,
9806 cancelable: false
9807 };
9808 var voiceschanged = {
9809 eventInterface: "Event",
9810 bubbles: false,
9811 cancelable: false
9812 };
9813 var visibilitychange = {
9814 eventInterface: "Event",
9815 bubbles: true,
9816 cancelable: false
9817 };
9818 var volumechange = {
9819 eventInterface: "Event",
9820 bubbles: false,
9821 cancelable: false
9822 };
9823 var waiting = {
9824 eventInterface: "Event",
9825 bubbles: false,
9826 cancelable: false
9827 };
9828 var wheel = {
9829 eventInterface: "WheelEvent",
9830 bubbles: true,
9831 cancelable: true
9832 };
9833 var domEventTypes = {
9834 abort: abort,
9835 afterprint: afterprint,
9836 animationend: animationend,
9837 animationiteration: animationiteration,
9838 animationstart: animationstart,
9839 appinstalled: appinstalled,
9840 audioprocess: audioprocess,
9841 audioend: audioend,
9842 audiostart: audiostart,
9843 beforeprint: beforeprint,
9844 beforeunload: beforeunload,
9845 beginEvent: beginEvent,
9846 blur: blur,
9847 boundary: boundary,
9848 cached: cached,
9849 canplay: canplay,
9850 canplaythrough: canplaythrough,
9851 change: change,
9852 chargingchange: chargingchange,
9853 chargingtimechange: chargingtimechange,
9854 checking: checking,
9855 click: click,
9856 close: close,
9857 complete: complete,
9858 compositionend: compositionend,
9859 compositionstart: compositionstart,
9860 compositionupdate: compositionupdate,
9861 contextmenu: contextmenu,
9862 copy: copy,
9863 cut: cut,
9864 dblclick: dblclick,
9865 devicechange: devicechange,
9866 devicelight: devicelight,
9867 devicemotion: devicemotion,
9868 deviceorientation: deviceorientation,
9869 deviceproximity: deviceproximity,
9870 dischargingtimechange: dischargingtimechange,
9871 DOMActivate: DOMActivate,
9872 DOMAttributeNameChanged: DOMAttributeNameChanged,
9873 DOMAttrModified: DOMAttrModified,
9874 DOMCharacterDataModified: DOMCharacterDataModified,
9875 DOMContentLoaded: DOMContentLoaded,
9876 DOMElementNameChanged: DOMElementNameChanged,
9877 DOMFocusIn: DOMFocusIn,
9878 DOMFocusOut: DOMFocusOut,
9879 DOMNodeInserted: DOMNodeInserted,
9880 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
9881 DOMNodeRemoved: DOMNodeRemoved,
9882 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
9883 DOMSubtreeModified: DOMSubtreeModified,
9884 downloading: downloading,
9885 drag: drag,
9886 dragend: dragend,
9887 dragenter: dragenter,
9888 dragleave: dragleave,
9889 dragover: dragover,
9890 dragstart: dragstart,
9891 drop: drop,
9892 durationchange: durationchange,
9893 emptied: emptied,
9894 end: end,
9895 ended: ended,
9896 endEvent: endEvent,
9897 error: error,
9898 focus: focus,
9899 focusin: focusin,
9900 focusout: focusout,
9901 fullscreenchange: fullscreenchange,
9902 fullscreenerror: fullscreenerror,
9903 gamepadconnected: gamepadconnected,
9904 gamepaddisconnected: gamepaddisconnected,
9905 gotpointercapture: gotpointercapture,
9906 hashchange: hashchange,
9907 lostpointercapture: lostpointercapture,
9908 input: input,
9909 invalid: invalid,
9910 keydown: keydown,
9911 keypress: keypress,
9912 keyup: keyup,
9913 languagechange: languagechange,
9914 levelchange: levelchange,
9915 load: load,
9916 loadeddata: loadeddata,
9917 loadedmetadata: loadedmetadata,
9918 loadend: loadend,
9919 loadstart: loadstart,
9920 mark: mark,
9921 message: message,
9922 messageerror: messageerror,
9923 mousedown: mousedown,
9924 mouseenter: mouseenter,
9925 mouseleave: mouseleave,
9926 mousemove: mousemove,
9927 mouseout: mouseout,
9928 mouseover: mouseover,
9929 mouseup: mouseup,
9930 nomatch: nomatch,
9931 notificationclick: notificationclick,
9932 noupdate: noupdate,
9933 obsolete: obsolete,
9934 offline: offline,
9935 online: online,
9936 open: open,
9937 orientationchange: orientationchange,
9938 pagehide: pagehide,
9939 pageshow: pageshow,
9940 paste: paste,
9941 pause: pause,
9942 pointercancel: pointercancel,
9943 pointerdown: pointerdown,
9944 pointerenter: pointerenter,
9945 pointerleave: pointerleave,
9946 pointerlockchange: pointerlockchange,
9947 pointerlockerror: pointerlockerror,
9948 pointermove: pointermove,
9949 pointerout: pointerout,
9950 pointerover: pointerover,
9951 pointerup: pointerup,
9952 play: play,
9953 playing: playing,
9954 popstate: popstate,
9955 progress: progress,
9956 push: push,
9957 pushsubscriptionchange: pushsubscriptionchange,
9958 ratechange: ratechange,
9959 readystatechange: readystatechange,
9960 repeatEvent: repeatEvent,
9961 reset: reset,
9962 resize: resize,
9963 resourcetimingbufferfull: resourcetimingbufferfull,
9964 result: result,
9965 resume: resume,
9966 scroll: scroll,
9967 seeked: seeked,
9968 seeking: seeking,
9969 select: select,
9970 selectstart: selectstart,
9971 selectionchange: selectionchange,
9972 show: show,
9973 slotchange: slotchange,
9974 soundend: soundend,
9975 soundstart: soundstart,
9976 speechend: speechend,
9977 speechstart: speechstart,
9978 stalled: stalled,
9979 start: start,
9980 storage: storage,
9981 submit: submit,
9982 success: success,
9983 suspend: suspend,
9984 SVGAbort: SVGAbort,
9985 SVGError: SVGError,
9986 SVGLoad: SVGLoad,
9987 SVGResize: SVGResize,
9988 SVGScroll: SVGScroll,
9989 SVGUnload: SVGUnload,
9990 SVGZoom: SVGZoom,
9991 timeout: timeout,
9992 timeupdate: timeupdate,
9993 touchcancel: touchcancel,
9994 touchend: touchend,
9995 touchmove: touchmove,
9996 touchstart: touchstart,
9997 transitionend: transitionend,
9998 unload: unload,
9999 updateready: updateready,
10000 userproximity: userproximity,
10001 voiceschanged: voiceschanged,
10002 visibilitychange: visibilitychange,
10003 volumechange: volumechange,
10004 waiting: waiting,
10005 wheel: wheel
10006 };
10007
10008 var domEventTypes$1 = /*#__PURE__*/Object.freeze({
10009 __proto__: null,
10010 abort: abort,
10011 afterprint: afterprint,
10012 animationend: animationend,
10013 animationiteration: animationiteration,
10014 animationstart: animationstart,
10015 appinstalled: appinstalled,
10016 audioprocess: audioprocess,
10017 audioend: audioend,
10018 audiostart: audiostart,
10019 beforeprint: beforeprint,
10020 beforeunload: beforeunload,
10021 beginEvent: beginEvent,
10022 blur: blur,
10023 boundary: boundary,
10024 cached: cached,
10025 canplay: canplay,
10026 canplaythrough: canplaythrough,
10027 change: change,
10028 chargingchange: chargingchange,
10029 chargingtimechange: chargingtimechange,
10030 checking: checking,
10031 click: click,
10032 close: close,
10033 complete: complete,
10034 compositionend: compositionend,
10035 compositionstart: compositionstart,
10036 compositionupdate: compositionupdate,
10037 contextmenu: contextmenu,
10038 copy: copy,
10039 cut: cut,
10040 dblclick: dblclick,
10041 devicechange: devicechange,
10042 devicelight: devicelight,
10043 devicemotion: devicemotion,
10044 deviceorientation: deviceorientation,
10045 deviceproximity: deviceproximity,
10046 dischargingtimechange: dischargingtimechange,
10047 DOMActivate: DOMActivate,
10048 DOMAttributeNameChanged: DOMAttributeNameChanged,
10049 DOMAttrModified: DOMAttrModified,
10050 DOMCharacterDataModified: DOMCharacterDataModified,
10051 DOMContentLoaded: DOMContentLoaded,
10052 DOMElementNameChanged: DOMElementNameChanged,
10053 DOMFocusIn: DOMFocusIn,
10054 DOMFocusOut: DOMFocusOut,
10055 DOMNodeInserted: DOMNodeInserted,
10056 DOMNodeInsertedIntoDocument: DOMNodeInsertedIntoDocument,
10057 DOMNodeRemoved: DOMNodeRemoved,
10058 DOMNodeRemovedFromDocument: DOMNodeRemovedFromDocument,
10059 DOMSubtreeModified: DOMSubtreeModified,
10060 downloading: downloading,
10061 drag: drag,
10062 dragend: dragend,
10063 dragenter: dragenter,
10064 dragleave: dragleave,
10065 dragover: dragover,
10066 dragstart: dragstart,
10067 drop: drop,
10068 durationchange: durationchange,
10069 emptied: emptied,
10070 end: end,
10071 ended: ended,
10072 endEvent: endEvent,
10073 error: error,
10074 focus: focus,
10075 focusin: focusin,
10076 focusout: focusout,
10077 fullscreenchange: fullscreenchange,
10078 fullscreenerror: fullscreenerror,
10079 gamepadconnected: gamepadconnected,
10080 gamepaddisconnected: gamepaddisconnected,
10081 gotpointercapture: gotpointercapture,
10082 hashchange: hashchange,
10083 lostpointercapture: lostpointercapture,
10084 input: input,
10085 invalid: invalid,
10086 keydown: keydown,
10087 keypress: keypress,
10088 keyup: keyup,
10089 languagechange: languagechange,
10090 levelchange: levelchange,
10091 load: load,
10092 loadeddata: loadeddata,
10093 loadedmetadata: loadedmetadata,
10094 loadend: loadend,
10095 loadstart: loadstart,
10096 mark: mark,
10097 message: message,
10098 messageerror: messageerror,
10099 mousedown: mousedown,
10100 mouseenter: mouseenter,
10101 mouseleave: mouseleave,
10102 mousemove: mousemove,
10103 mouseout: mouseout,
10104 mouseover: mouseover,
10105 mouseup: mouseup,
10106 nomatch: nomatch,
10107 notificationclick: notificationclick,
10108 noupdate: noupdate,
10109 obsolete: obsolete,
10110 offline: offline,
10111 online: online,
10112 open: open,
10113 orientationchange: orientationchange,
10114 pagehide: pagehide,
10115 pageshow: pageshow,
10116 paste: paste,
10117 pause: pause,
10118 pointercancel: pointercancel,
10119 pointerdown: pointerdown,
10120 pointerenter: pointerenter,
10121 pointerleave: pointerleave,
10122 pointerlockchange: pointerlockchange,
10123 pointerlockerror: pointerlockerror,
10124 pointermove: pointermove,
10125 pointerout: pointerout,
10126 pointerover: pointerover,
10127 pointerup: pointerup,
10128 play: play,
10129 playing: playing,
10130 popstate: popstate,
10131 progress: progress,
10132 push: push,
10133 pushsubscriptionchange: pushsubscriptionchange,
10134 ratechange: ratechange,
10135 readystatechange: readystatechange,
10136 repeatEvent: repeatEvent,
10137 reset: reset,
10138 resize: resize,
10139 resourcetimingbufferfull: resourcetimingbufferfull,
10140 result: result,
10141 resume: resume,
10142 scroll: scroll,
10143 seeked: seeked,
10144 seeking: seeking,
10145 select: select,
10146 selectstart: selectstart,
10147 selectionchange: selectionchange,
10148 show: show,
10149 slotchange: slotchange,
10150 soundend: soundend,
10151 soundstart: soundstart,
10152 speechend: speechend,
10153 speechstart: speechstart,
10154 stalled: stalled,
10155 start: start,
10156 storage: storage,
10157 submit: submit,
10158 success: success,
10159 suspend: suspend,
10160 SVGAbort: SVGAbort,
10161 SVGError: SVGError,
10162 SVGLoad: SVGLoad,
10163 SVGResize: SVGResize,
10164 SVGScroll: SVGScroll,
10165 SVGUnload: SVGUnload,
10166 SVGZoom: SVGZoom,
10167 timeout: timeout,
10168 timeupdate: timeupdate,
10169 touchcancel: touchcancel,
10170 touchend: touchend,
10171 touchmove: touchmove,
10172 touchstart: touchstart,
10173 transitionend: transitionend,
10174 unload: unload,
10175 updateready: updateready,
10176 userproximity: userproximity,
10177 voiceschanged: voiceschanged,
10178 visibilitychange: visibilitychange,
10179 volumechange: volumechange,
10180 waiting: waiting,
10181 wheel: wheel,
10182 'default': domEventTypes
10183 });
10184
10185 var require$$0 = getCjsExportFromNamespace(domEventTypes$1);
10186
10187 var domEventTypes$2 = require$$0;
10188
10189 var defaultEventType = {
10190 eventInterface: 'Event',
10191 cancelable: true,
10192 bubbles: true
10193 };
10194
10195 var modifiers = {
10196 enter: 13,
10197 tab: 9,
10198 delete: 46,
10199 esc: 27,
10200 space: 32,
10201 up: 38,
10202 down: 40,
10203 left: 37,
10204 right: 39,
10205 end: 35,
10206 home: 36,
10207 backspace: 8,
10208 insert: 45,
10209 pageup: 33,
10210 pagedown: 34
10211 };
10212
10213 function getOptions(eventParams) {
10214 var modifier = eventParams.modifier;
10215 var meta = eventParams.meta;
10216 var options = eventParams.options;
10217 var keyCode = modifiers[modifier] || options.keyCode || options.code;
10218
10219 return Object.assign({}, options, // What the user passed in as the second argument to #trigger
10220
10221 {bubbles: meta.bubbles,
10222 cancelable: meta.cancelable,
10223
10224 // Any derived options should go here
10225 keyCode: keyCode,
10226 code: keyCode})
10227 }
10228
10229 function createEvent(eventParams) {
10230 var eventType = eventParams.eventType;
10231 var meta = eventParams.meta; if ( meta === void 0 ) meta = {};
10232
10233 var SupportedEventInterface =
10234 typeof window[meta.eventInterface] === 'function'
10235 ? window[meta.eventInterface]
10236 : window.Event;
10237
10238 var event = new SupportedEventInterface(
10239 eventType,
10240 // event properties can only be added when the event is instantiated
10241 // custom properties must be added after the event has been instantiated
10242 getOptions(eventParams)
10243 );
10244
10245 return event
10246 }
10247
10248 function createOldEvent(eventParams) {
10249 var eventType = eventParams.eventType;
10250 var modifier = eventParams.modifier;
10251 var meta = eventParams.meta;
10252 var bubbles = meta.bubbles;
10253 var cancelable = meta.cancelable;
10254
10255 var event = document.createEvent('Event');
10256 event.initEvent(eventType, bubbles, cancelable);
10257 event.keyCode = modifiers[modifier];
10258 return event
10259 }
10260
10261 function createDOMEvent(type, options) {
10262 var ref = type.split('.');
10263 var eventType = ref[0];
10264 var modifier = ref[1];
10265 var meta = domEventTypes$2[eventType] || defaultEventType;
10266
10267 var eventParams = { eventType: eventType, modifier: modifier, meta: meta, options: options };
10268
10269 // Fallback for IE10,11 - https://stackoverflow.com/questions/26596123
10270 var event =
10271 typeof window.Event === 'function'
10272 ? createEvent(eventParams)
10273 : createOldEvent(eventParams);
10274
10275 var eventPrototype = Object.getPrototypeOf(event);
10276 Object.keys(options || {}).forEach(function (key) {
10277 var propertyDescriptor = Object.getOwnPropertyDescriptor(
10278 eventPrototype,
10279 key
10280 );
10281
10282 var canSetProperty = !(
10283 propertyDescriptor && propertyDescriptor.setter === undefined
10284 );
10285 if (canSetProperty) {
10286 event[key] = options[key];
10287 }
10288 });
10289
10290 return event
10291 }
10292
10293 //
10294
10295 var Wrapper = function Wrapper(
10296 node,
10297 options,
10298 isVueWrapper
10299 ) {
10300 var vnode = node instanceof Element ? null : node;
10301 var element = node instanceof Element ? node : node.elm;
10302 // Prevent redefine by VueWrapper
10303 if (!isVueWrapper) {
10304 // $FlowIgnore : issue with defineProperty
10305 Object.defineProperty(this, 'rootNode', {
10306 get: function () { return vnode || element; },
10307 set: function () { return throwError('wrapper.rootNode is read-only'); }
10308 });
10309 // $FlowIgnore
10310 Object.defineProperty(this, 'vnode', {
10311 get: function () { return vnode; },
10312 set: function () { return throwError('wrapper.vnode is read-only'); }
10313 });
10314 // $FlowIgnore
10315 Object.defineProperty(this, 'element', {
10316 get: function () { return element; },
10317 set: function () { return throwError('wrapper.element is read-only'); }
10318 });
10319 // $FlowIgnore
10320 Object.defineProperty(this, 'vm', {
10321 get: function () { return undefined; },
10322 set: function () { return throwError('wrapper.vm is read-only'); }
10323 });
10324 }
10325 var frozenOptions = Object.freeze(options);
10326 // $FlowIgnore
10327 Object.defineProperty(this, 'options', {
10328 get: function () { return frozenOptions; },
10329 set: function () { return throwError('wrapper.options is read-only'); }
10330 });
10331 if (
10332 this.vnode &&
10333 (this.vnode[FUNCTIONAL_OPTIONS] || this.vnode.functionalContext)
10334 ) {
10335 this.isFunctionalComponent = true;
10336 }
10337 };
10338
10339 Wrapper.prototype.at = function at () {
10340 throwError('at() must be called on a WrapperArray');
10341 };
10342
10343 /**
10344 * Returns an Object containing all the attribute/value pairs on the element.
10345 */
10346 Wrapper.prototype.attributes = function attributes (key) {
10347 var attributes = this.element.attributes;
10348 var attributeMap = {};
10349 for (var i = 0; i < attributes.length; i++) {
10350 var att = attributes.item(i);
10351 attributeMap[att.localName] = att.value;
10352 }
10353
10354 return key ? attributeMap[key] : attributeMap
10355 };
10356
10357 /**
10358 * Returns an Array containing all the classes on the element
10359 */
10360 Wrapper.prototype.classes = function classes (className) {
10361 var this$1 = this;
10362
10363 var classAttribute = this.element.getAttribute('class');
10364 var classes = classAttribute ? classAttribute.split(' ') : [];
10365 // Handle converting cssmodules identifiers back to the original class name
10366 if (this.vm && this.vm.$style) {
10367 var cssModuleIdentifiers = Object.keys(this.vm.$style).reduce(
10368 function (acc, key) {
10369 // $FlowIgnore
10370 var moduleIdent = this$1.vm.$style[key];
10371 if (moduleIdent) {
10372 acc[moduleIdent.split(' ')[0]] = key;
10373 }
10374 return acc
10375 },
10376 {}
10377 );
10378 classes = classes.map(function (name) { return cssModuleIdentifiers[name] || name; });
10379 }
10380
10381 return className ? !!(classes.indexOf(className) > -1) : classes
10382 };
10383
10384 /**
10385 * Checks if wrapper contains provided selector.
10386 * @deprecated
10387 */
10388 Wrapper.prototype.contains = function contains (rawSelector) {
10389 warnDeprecated(
10390 'contains',
10391 'Use `wrapper.find`, `wrapper.findComponent` or `wrapper.get` instead'
10392 );
10393 var selector = getSelector(rawSelector, 'contains');
10394 var nodes = find(this.rootNode, this.vm, selector);
10395 return nodes.length > 0
10396 };
10397
10398 /**
10399 * Calls destroy on vm
10400 */
10401 Wrapper.prototype.destroy = function destroy () {
10402 if (!this.vm && !this.isFunctionalComponent) {
10403 throwError(
10404 "wrapper.destroy() can only be called on a Vue instance or " +
10405 "functional component."
10406 );
10407 }
10408
10409 if (this.element.parentNode) {
10410 this.element.parentNode.removeChild(this.element);
10411 }
10412
10413 if (this.vm) {
10414 // $FlowIgnore
10415 this.vm.$destroy();
10416 throwIfInstancesThrew(this.vm);
10417 }
10418 };
10419
10420 /**
10421 * Returns an object containing custom events emitted by the Wrapper vm
10422 */
10423 Wrapper.prototype.emitted = function emitted (
10424 event
10425 ) {
10426 if (!this._emitted && !this.vm) {
10427 throwError("wrapper.emitted() can only be called on a Vue instance");
10428 }
10429 if (event) {
10430 return this._emitted[event]
10431 }
10432 return this._emitted
10433 };
10434
10435 /**
10436 * Returns an Array containing custom events emitted by the Wrapper vm
10437 * @deprecated
10438 */
10439 Wrapper.prototype.emittedByOrder = function emittedByOrder () {
10440 warnDeprecated('emittedByOrder', 'Use `wrapper.emitted` instead');
10441 if (!this._emittedByOrder && !this.vm) {
10442 throwError(
10443 "wrapper.emittedByOrder() can only be called on a Vue instance"
10444 );
10445 }
10446 return this._emittedByOrder
10447 };
10448
10449 /**
10450 * Utility to check wrapper exists. Returns true as Wrapper always exists
10451 */
10452 Wrapper.prototype.exists = function exists () {
10453 if (this.vm) {
10454 return !!this.vm && !this.vm._isDestroyed
10455 }
10456 return true
10457 };
10458
10459 Wrapper.prototype.filter = function filter () {
10460 throwError('filter() must be called on a WrapperArray');
10461 };
10462
10463 /**
10464 * Gets first node in tree of the current wrapper that
10465 * matches the provided selector.
10466 */
10467 Wrapper.prototype.get = function get (rawSelector) {
10468 var found = this.find(rawSelector);
10469 if (found instanceof ErrorWrapper) {
10470 throw new Error(("Unable to find " + rawSelector + " within: " + (this.html())))
10471 }
10472 return found
10473 };
10474
10475 /**
10476 * Finds first DOM node in tree of the current wrapper that
10477 * matches the provided selector.
10478 */
10479 Wrapper.prototype.find = function find (rawSelector) {
10480 var selector = getSelector(rawSelector, 'find');
10481 if (selector.type !== DOM_SELECTOR) {
10482 warnDeprecated(
10483 'finding components with `find`',
10484 'Use `findComponent` instead'
10485 );
10486 }
10487
10488 return this.__find(rawSelector, selector)
10489 };
10490
10491 /**
10492 * Finds first component in tree of the current wrapper that
10493 * matches the provided selector.
10494 */
10495 Wrapper.prototype.findComponent = function findComponent (rawSelector) {
10496 var selector = getSelector(rawSelector, 'findComponent');
10497 if (!this.vm && !this.isFunctionalComponent) {
10498 throwError(
10499 'You cannot chain findComponent off a DOM element. It can only be used on Vue Components.'
10500 );
10501 }
10502
10503 if (selector.type === DOM_SELECTOR) {
10504 throwError(
10505 'findComponent requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10506 );
10507 }
10508
10509 return this.__find(rawSelector, selector)
10510 };
10511
10512 Wrapper.prototype.__find = function __find (rawSelector, selector) {
10513 var node = find(this.rootNode, this.vm, selector)[0];
10514
10515 if (!node) {
10516 return new ErrorWrapper(rawSelector)
10517 }
10518
10519 var wrapper = createWrapper(node, this.options);
10520 wrapper.selector = rawSelector;
10521 return wrapper
10522 };
10523
10524 /**
10525 * Finds DOM elements in tree of the current wrapper that matches
10526 * the provided selector.
10527 */
10528 Wrapper.prototype.findAll = function findAll (rawSelector) {
10529 var selector = getSelector(rawSelector, 'findAll');
10530 if (selector.type !== DOM_SELECTOR) {
10531 warnDeprecated(
10532 'finding components with `findAll`',
10533 'Use `findAllComponents` instead'
10534 );
10535 }
10536 return this.__findAll(rawSelector, selector)
10537 };
10538
10539 /**
10540 * Finds components in tree of the current wrapper that matches
10541 * the provided selector.
10542 */
10543 Wrapper.prototype.findAllComponents = function findAllComponents (rawSelector) {
10544 var selector = getSelector(rawSelector, 'findAll');
10545 if (!this.vm) {
10546 throwError(
10547 'You cannot chain findAllComponents off a DOM element. It can only be used on Vue Components.'
10548 );
10549 }
10550 if (selector.type === DOM_SELECTOR) {
10551 throwError(
10552 'findAllComponents requires a Vue constructor or valid find object. If you are searching for DOM nodes, use `find` instead'
10553 );
10554 }
10555 return this.__findAll(rawSelector, selector)
10556 };
10557
10558 Wrapper.prototype.__findAll = function __findAll (rawSelector, selector) {
10559 var this$1 = this;
10560
10561 var nodes = find(this.rootNode, this.vm, selector);
10562 var wrappers = nodes.map(function (node) {
10563 // Using CSS Selector, returns a VueWrapper instance if the root element
10564 // binds a Vue instance.
10565 var wrapper = createWrapper(node, this$1.options);
10566 wrapper.selector = rawSelector;
10567 return wrapper
10568 });
10569
10570 var wrapperArray = new WrapperArray(wrappers);
10571 wrapperArray.selector = rawSelector;
10572 return wrapperArray
10573 };
10574
10575 /**
10576 * Returns HTML of element as a string
10577 */
10578 Wrapper.prototype.html = function html () {
10579 return pretty(this.element.outerHTML)
10580 };
10581
10582 /**
10583 * Checks if node matches selector
10584 * @deprecated
10585 */
10586 Wrapper.prototype.is = function is (rawSelector) {
10587 warnDeprecated('is', 'Use element.tagName instead');
10588 var selector = getSelector(rawSelector, 'is');
10589
10590 if (selector.type === REF_SELECTOR) {
10591 throwError('$ref selectors can not be used with wrapper.is()');
10592 }
10593
10594 return matches(this.rootNode, selector)
10595 };
10596
10597 /**
10598 * Checks if node is empty
10599 * @deprecated
10600 */
10601 Wrapper.prototype.isEmpty = function isEmpty () {
10602 warnDeprecated(
10603 'isEmpty',
10604 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobeempty. ' +
10605 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10606 );
10607 if (!this.vnode) {
10608 return this.element.innerHTML === ''
10609 }
10610 var nodes = [];
10611 var node = this.vnode;
10612 var i = 0;
10613
10614 while (node) {
10615 if (node.child) {
10616 nodes.push(node.child._vnode);
10617 }
10618 node.children &&
10619 node.children.forEach(function (n) {
10620 nodes.push(n);
10621 });
10622 node = nodes[i++];
10623 }
10624 return nodes.every(function (n) { return n.isComment || n.child; })
10625 };
10626
10627 /**
10628 * Checks if node is visible
10629 * @deprecated
10630 */
10631 Wrapper.prototype.isVisible = function isVisible () {
10632 warnDeprecated(
10633 'isVisible',
10634 'Consider a custom matcher such as those provided in jest-dom: https://github.com/testing-library/jest-dom#tobevisible. ' +
10635 'When using with findComponent, access the DOM element with findComponent(Comp).element'
10636 );
10637 var element = this.element;
10638 while (element) {
10639 if (
10640 element.hidden ||
10641 (element.style &&
10642 (element.style.visibility === 'hidden' ||
10643 element.style.display === 'none'))
10644 ) {
10645 return false
10646 }
10647 element = element.parentElement;
10648 }
10649
10650 return true
10651 };
10652
10653 /**
10654 * Checks if wrapper is a vue instance
10655 * @deprecated
10656 */
10657 Wrapper.prototype.isVueInstance = function isVueInstance () {
10658 warnDeprecated("isVueInstance");
10659 return !!this.vm
10660 };
10661
10662 /**
10663 * Returns name of component, or tag name if node is not a Vue component
10664 * @deprecated
10665 */
10666 Wrapper.prototype.name = function name () {
10667 warnDeprecated("name");
10668
10669 if (this.vm) {
10670 return (
10671 this.vm.$options.name ||
10672 // compat for Vue < 2.3
10673 (this.vm.$options.extendOptions && this.vm.$options.extendOptions.name)
10674 )
10675 }
10676
10677 if (!this.vnode) {
10678 return this.element.tagName
10679 }
10680
10681 return this.vnode.tag
10682 };
10683
10684 /**
10685 * Prints a simple overview of the wrapper current state
10686 * with useful information for debugging
10687 * @deprecated
10688 */
10689 Wrapper.prototype.overview = function overview () {
10690 var this$1 = this;
10691
10692 warnDeprecated("overview");
10693
10694 if (!this.vm) {
10695 throwError("wrapper.overview() can only be called on a Vue instance");
10696 }
10697
10698 var identation = 4;
10699 var formatJSON = function (json, replacer) {
10700 if ( replacer === void 0 ) replacer = null;
10701
10702 return JSON.stringify(json, replacer, identation).replace(/"/g, '');
10703 };
10704
10705 var visibility = this.isVisible() ? 'Visible' : 'Not visible';
10706
10707 var html = this.html()
10708 ? this.html().replace(/^(?!\s*$)/gm, ' '.repeat(identation)) + '\n'
10709 : '';
10710
10711 // $FlowIgnore
10712 var data = formatJSON(this.vm.$data);
10713
10714 /* eslint-disable operator-linebreak */
10715 // $FlowIgnore
10716 var computed = this.vm._computedWatchers
10717 ? formatJSON.apply(
10718 // $FlowIgnore
10719 void 0, Object.keys(this.vm._computedWatchers).map(function (computedKey) {
10720 var obj;
10721
10722 return (( obj = {}, obj[computedKey] = this$1.vm[computedKey], obj ));
10723 })
10724 )
10725 : // $FlowIgnore
10726 this.vm.$options.computed
10727 ? formatJSON.apply(
10728 // $FlowIgnore
10729 void 0, Object.entries(this.vm.$options.computed).map(function (ref) {
10730 var obj;
10731
10732 var key = ref[0];
10733 var value = ref[1];
10734 return (( obj = {}, obj[key] = value(), obj ));
10735 })
10736 )
10737 : '{}';
10738 /* eslint-enable operator-linebreak */
10739
10740 var emittedJSONReplacer = function (key, value) { return value instanceof Array
10741 ? value.map(function (calledWith, index) {
10742 var callParams = calledWith.map(function (param) { return typeof param === 'object'
10743 ? JSON.stringify(param)
10744 .replace(/"/g, '')
10745 .replace(/,/g, ', ')
10746 : param; }
10747 );
10748
10749 return (index + ": [ " + (callParams.join(', ')) + " ]")
10750 })
10751 : value; };
10752
10753 var emitted = formatJSON(this.emitted(), emittedJSONReplacer);
10754
10755 console.log(
10756 '\n' +
10757 "Wrapper (" + visibility + "):\n\n" +
10758 "Html:\n" + html + "\n" +
10759 "Data: " + data + "\n\n" +
10760 "Computed: " + computed + "\n\n" +
10761 "Emitted: " + emitted + "\n"
10762 );
10763 };
10764
10765 /**
10766 * Returns an Object containing the prop name/value pairs on the element
10767 */
10768 Wrapper.prototype.props = function props (key) {
10769 var this$1 = this;
10770
10771 if (this.isFunctionalComponent) {
10772 throwError(
10773 "wrapper.props() cannot be called on a mounted functional component."
10774 );
10775 }
10776 if (!this.vm) {
10777 throwError('wrapper.props() must be called on a Vue instance');
10778 }
10779
10780 var props = {};
10781 var keys = this.vm && this.vm.$options._propKeys;
10782
10783 if (keys) {
10784 (keys || {}).forEach(function (key) {
10785 if (this$1.vm) {
10786 props[key] = this$1.vm[key];
10787 }
10788 });
10789 }
10790
10791 if (key) {
10792 return props[key]
10793 }
10794
10795 return props
10796 };
10797
10798 /**
10799 * Checks radio button or checkbox element
10800 * @deprecated
10801 */
10802 Wrapper.prototype.setChecked = function setChecked (checked) {
10803 if ( checked === void 0 ) checked = true;
10804
10805 if (typeof checked !== 'boolean') {
10806 throwError('wrapper.setChecked() must be passed a boolean');
10807 }
10808 var tagName = this.element.tagName;
10809 // $FlowIgnore
10810 var type = this.attributes().type;
10811 var event = getCheckedEvent();
10812
10813 if (tagName === 'INPUT' && type === 'checkbox') {
10814 if (this.element.checked === checked) {
10815 return nextTick()
10816 }
10817 if (event !== 'click' || isPhantomJS) {
10818 // $FlowIgnore
10819 this.element.checked = checked;
10820 }
10821 return this.trigger(event)
10822 }
10823
10824 if (tagName === 'INPUT' && type === 'radio') {
10825 if (!checked) {
10826 throwError(
10827 "wrapper.setChecked() cannot be called with parameter false on a " +
10828 "<input type=\"radio\" /> element."
10829 );
10830 }
10831
10832 if (this.element.checked === checked) {
10833 return nextTick()
10834 }
10835
10836 if (event !== 'click' || isPhantomJS) {
10837 // $FlowIgnore
10838 this.element.selected = true;
10839 }
10840 return this.trigger(event)
10841 }
10842
10843 throwError("wrapper.setChecked() cannot be called on this element");
10844 return nextTick()
10845 };
10846
10847 /**
10848 * Selects <option></option> element
10849 * @deprecated
10850 */
10851 Wrapper.prototype.setSelected = function setSelected () {
10852 var tagName = this.element.tagName;
10853
10854 if (tagName === 'SELECT') {
10855 throwError(
10856 "wrapper.setSelected() cannot be called on select. Call it on one of " +
10857 "its options"
10858 );
10859 }
10860
10861 if (tagName !== 'OPTION') {
10862 throwError("wrapper.setSelected() cannot be called on this element");
10863 }
10864
10865 if (this.element.selected) {
10866 return nextTick()
10867 }
10868
10869 // $FlowIgnore
10870 this.element.selected = true;
10871 // $FlowIgnore
10872 var parentElement = this.element.parentElement;
10873
10874 // $FlowIgnore
10875 if (parentElement.tagName === 'OPTGROUP') {
10876 // $FlowIgnore
10877 parentElement = parentElement.parentElement;
10878 }
10879
10880 // $FlowIgnore
10881 return createWrapper(parentElement, this.options).trigger('change')
10882 };
10883
10884 /**
10885 * Sets vm data
10886 */
10887 Wrapper.prototype.setData = function setData (data) {
10888 if (this.isFunctionalComponent) {
10889 throwError("wrapper.setData() cannot be called on a functional component");
10890 }
10891
10892 if (!this.vm) {
10893 throwError("wrapper.setData() can only be called on a Vue instance");
10894 }
10895
10896 recursivelySetData(this.vm, this.vm, data);
10897 return nextTick()
10898 };
10899
10900 /**
10901 * Sets vm methods
10902 * @deprecated
10903 */
10904 Wrapper.prototype.setMethods = function setMethods (methods) {
10905 var this$1 = this;
10906
10907 warnDeprecated(
10908 "setMethods",
10909 "There is no clear migration path for setMethods - Vue does not support arbitrarily replacement of methods, nor should VTU. To stub a complex method extract it from the component and test it in isolation. Otherwise, the suggestion is to rethink those tests"
10910 );
10911
10912 if (!this.vm) {
10913 throwError("wrapper.setMethods() can only be called on a Vue instance");
10914 }
10915 Object.keys(methods).forEach(function (key) {
10916 // $FlowIgnore : Problem with possibly null this.vm
10917 this$1.vm[key] = methods[key];
10918 // $FlowIgnore : Problem with possibly null this.vm
10919 this$1.vm.$options.methods[key] = methods[key];
10920 });
10921
10922 if (this.vnode) {
10923 var context = this.vnode.context;
10924 if (context.$options.render) { context._update(context._render()); }
10925 }
10926 };
10927
10928 /**
10929 * Sets vm props
10930 */
10931 Wrapper.prototype.setProps = function setProps (data) {
10932 var this$1 = this;
10933
10934 // Validate the setProps method call
10935 if (this.isFunctionalComponent) {
10936 throwError(
10937 "wrapper.setProps() cannot be called on a functional component"
10938 );
10939 }
10940
10941 if (!this.vm) {
10942 throwError("wrapper.setProps() can only be called on a Vue instance");
10943 }
10944
10945 // Save the original "silent" config so that we can directly mutate props
10946 var originalConfig = Vue.config.silent;
10947 Vue.config.silent = config.silent;
10948
10949 try {
10950 Object.keys(data).forEach(function (key) {
10951 // Don't let people set entire objects, because reactivity won't work
10952 if (
10953 typeof data[key] === 'object' &&
10954 data[key] !== null &&
10955 // $FlowIgnore : Problem with possibly null this.vm
10956 data[key] === this$1.vm[key]
10957 ) {
10958 throwError(
10959 "wrapper.setProps() called with the same object of the existing " +
10960 key + " property. You must call wrapper.setProps() with a new " +
10961 "object to trigger reactivity"
10962 );
10963 }
10964
10965 if (
10966 !this$1.vm ||
10967 !this$1.vm.$options._propKeys ||
10968 !this$1.vm.$options._propKeys.some(function (prop) { return prop === key; })
10969 ) {
10970 if (VUE_VERSION > 2.3) {
10971 // $FlowIgnore : Problem with possibly null this.vm
10972 this$1.vm.$attrs[key] = data[key];
10973 return nextTick()
10974 }
10975 throwError(
10976 "wrapper.setProps() called with " + key + " property which " +
10977 "is not defined on the component"
10978 );
10979 }
10980
10981 // Actually set the prop
10982 // $FlowIgnore : Problem with possibly null this.vm
10983 this$1.vm[key] = data[key];
10984 });
10985
10986 // $FlowIgnore : Problem with possibly null this.vm
10987 this.vm.$forceUpdate();
10988 return new Promise(function (resolve) {
10989 nextTick().then(function () {
10990 var isUpdated = Object.keys(data).some(function (key) {
10991 return (
10992 // $FlowIgnore : Problem with possibly null this.vm
10993 this$1.vm[key] === data[key] ||
10994 // $FlowIgnore : Problem with possibly null this.vm
10995 (this$1.vm.$attrs && this$1.vm.$attrs[key] === data[key])
10996 )
10997 });
10998 return !isUpdated ? this$1.setProps(data).then(resolve()) : resolve()
10999 });
11000 })
11001 } catch (err) {
11002 throw err
11003 } finally {
11004 // Ensure you teardown the modifications you made to the user's config
11005 // After all the props are set, then reset the state
11006 Vue.config.silent = originalConfig;
11007 }
11008 };
11009
11010 /**
11011 * Sets element value and triggers input event
11012 */
11013 Wrapper.prototype.setValue = function setValue (value) {
11014 var tagName = this.element.tagName;
11015 // $FlowIgnore
11016 var type = this.attributes().type;
11017
11018 if (tagName === 'OPTION') {
11019 throwError(
11020 "wrapper.setValue() cannot be called on an <option> element. Use " +
11021 "wrapper.setSelected() instead"
11022 );
11023 } else if (tagName === 'INPUT' && type === 'checkbox') {
11024 throwError(
11025 "wrapper.setValue() cannot be called on a <input type=\"checkbox\" /> " +
11026 "element. Use wrapper.setChecked() instead"
11027 );
11028 } else if (tagName === 'INPUT' && type === 'radio') {
11029 throwError(
11030 "wrapper.setValue() cannot be called on a <input type=\"radio\" /> " +
11031 "element. Use wrapper.setChecked() instead"
11032 );
11033 } else if (tagName === 'SELECT') {
11034 if (Array.isArray(value)) {
11035 // $FlowIgnore
11036 var options = this.element.options;
11037 for (var i = 0; i < options.length; i++) {
11038 var option = options[i];
11039 option.selected = value.indexOf(option.value) >= 0;
11040 }
11041 } else {
11042 // $FlowIgnore
11043 this.element.value = value;
11044 }
11045
11046 this.trigger('change');
11047 return nextTick()
11048 } else if (tagName === 'INPUT' || tagName === 'TEXTAREA') {
11049 // $FlowIgnore
11050 this.element.value = value;
11051
11052 this.trigger('input');
11053
11054 // for v-model.lazy, we need to trigger a change event, too.
11055 // $FlowIgnore
11056 if (this.element._vModifiers && this.element._vModifiers.lazy) {
11057 this.trigger('change');
11058 }
11059 return nextTick()
11060 }
11061 throwError("wrapper.setValue() cannot be called on this element");
11062 return nextTick()
11063 };
11064
11065 /**
11066 * Return text of wrapper element
11067 */
11068 Wrapper.prototype.text = function text () {
11069 return this.element.textContent.trim()
11070 };
11071
11072 /**
11073 * Dispatches a DOM event on wrapper
11074 */
11075 Wrapper.prototype.trigger = function trigger (type, options) {
11076 if ( options === void 0 ) options = {};
11077
11078 if (typeof type !== 'string') {
11079 throwError('wrapper.trigger() must be passed a string');
11080 }
11081
11082 if (options.target) {
11083 throwError(
11084 "you cannot set the target value of an event. See the notes section " +
11085 "of the docs for more details—" +
11086 "https://vue-test-utils.vuejs.org/api/wrapper/trigger.html"
11087 );
11088 }
11089
11090 /**
11091 * Avoids firing events on specific disabled elements
11092 * See more: https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/disabled
11093 */
11094
11095 var supportedTags = [
11096 'BUTTON',
11097 'COMMAND',
11098 'FIELDSET',
11099 'KEYGEN',
11100 'OPTGROUP',
11101 'OPTION',
11102 'SELECT',
11103 'TEXTAREA',
11104 'INPUT'
11105 ];
11106 var tagName = this.element.tagName;
11107
11108 if (this.attributes().disabled && supportedTags.indexOf(tagName) > -1) {
11109 return nextTick()
11110 }
11111
11112 var event = createDOMEvent(type, options);
11113 this.element.dispatchEvent(event);
11114 return nextTick()
11115 };
11116
11117 //
11118
11119 var VueWrapper = /*@__PURE__*/(function (Wrapper) {
11120 function VueWrapper(vm, options) {
11121 var this$1 = this;
11122
11123 Wrapper.call(this, vm._vnode, options, true);
11124 // $FlowIgnore : issue with defineProperty
11125 Object.defineProperty(this, 'rootNode', {
11126 get: function () { return vm.$vnode || { child: this$1.vm }; },
11127 set: function () { return throwError('wrapper.vnode is read-only'); }
11128 });
11129 // $FlowIgnore : issue with defineProperty
11130 Object.defineProperty(this, 'vnode', {
11131 get: function () { return vm._vnode; },
11132 set: function () { return throwError('wrapper.vnode is read-only'); }
11133 });
11134 // $FlowIgnore
11135 Object.defineProperty(this, 'element', {
11136 get: function () { return vm.$el; },
11137 set: function () { return throwError('wrapper.element is read-only'); }
11138 });
11139 // $FlowIgnore
11140 Object.defineProperty(this, 'vm', {
11141 get: function () { return vm; },
11142 set: function () { return throwError('wrapper.vm is read-only'); }
11143 });
11144 this.isFunctionalComponent = vm.$options._isFunctionalContainer;
11145 this._emitted = vm.__emitted;
11146 this._emittedByOrder = vm.__emittedByOrder;
11147 }
11148
11149 if ( Wrapper ) VueWrapper.__proto__ = Wrapper;
11150 VueWrapper.prototype = Object.create( Wrapper && Wrapper.prototype );
11151 VueWrapper.prototype.constructor = VueWrapper;
11152
11153 return VueWrapper;
11154 }(Wrapper));
11155
11156 //
11157
11158 var isEnabled = false;
11159 var wrapperInstances = [];
11160
11161 function resetAutoDestroyState() {
11162 isEnabled = false;
11163 wrapperInstances.length = 0;
11164 }
11165
11166 function enableAutoDestroy(hook) {
11167 if (isEnabled) {
11168 throwError('enableAutoDestroy cannot be called more than once');
11169 }
11170
11171 isEnabled = true;
11172
11173 hook(function () {
11174 wrapperInstances.forEach(function (wrapper) {
11175 // skip child wrappers created by wrapper.find()
11176 if (wrapper.selector) { return }
11177
11178 wrapper.destroy();
11179 });
11180
11181 wrapperInstances.length = 0;
11182 });
11183 }
11184
11185 function trackInstance(wrapper) {
11186 if (!isEnabled) { return }
11187
11188 wrapperInstances.push(wrapper);
11189 }
11190
11191 //
11192
11193 function createWrapper(
11194 node,
11195 options
11196 ) {
11197 if ( options === void 0 ) options = {};
11198
11199 var componentInstance = node.child;
11200 if (componentInstance) {
11201 var wrapper$1 = new VueWrapper(componentInstance, options);
11202 trackInstance(wrapper$1);
11203 return wrapper$1
11204 }
11205 var wrapper =
11206 node instanceof Vue
11207 ? new VueWrapper(node, options)
11208 : new Wrapper(node, options);
11209 trackInstance(wrapper);
11210 return wrapper
11211 }
11212
11213 /**
11214 * Removes all key-value entries from the list cache.
11215 *
11216 * @private
11217 * @name clear
11218 * @memberOf ListCache
11219 */
11220 function listCacheClear() {
11221 this.__data__ = [];
11222 this.size = 0;
11223 }
11224
11225 var _listCacheClear = listCacheClear;
11226
11227 /**
11228 * Performs a
11229 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
11230 * comparison between two values to determine if they are equivalent.
11231 *
11232 * @static
11233 * @memberOf _
11234 * @since 4.0.0
11235 * @category Lang
11236 * @param {*} value The value to compare.
11237 * @param {*} other The other value to compare.
11238 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
11239 * @example
11240 *
11241 * var object = { 'a': 1 };
11242 * var other = { 'a': 1 };
11243 *
11244 * _.eq(object, object);
11245 * // => true
11246 *
11247 * _.eq(object, other);
11248 * // => false
11249 *
11250 * _.eq('a', 'a');
11251 * // => true
11252 *
11253 * _.eq('a', Object('a'));
11254 * // => false
11255 *
11256 * _.eq(NaN, NaN);
11257 * // => true
11258 */
11259 function eq(value, other) {
11260 return value === other || (value !== value && other !== other);
11261 }
11262
11263 var eq_1 = eq;
11264
11265 /**
11266 * Gets the index at which the `key` is found in `array` of key-value pairs.
11267 *
11268 * @private
11269 * @param {Array} array The array to inspect.
11270 * @param {*} key The key to search for.
11271 * @returns {number} Returns the index of the matched value, else `-1`.
11272 */
11273 function assocIndexOf(array, key) {
11274 var length = array.length;
11275 while (length--) {
11276 if (eq_1(array[length][0], key)) {
11277 return length;
11278 }
11279 }
11280 return -1;
11281 }
11282
11283 var _assocIndexOf = assocIndexOf;
11284
11285 /** Used for built-in method references. */
11286 var arrayProto = Array.prototype;
11287
11288 /** Built-in value references. */
11289 var splice = arrayProto.splice;
11290
11291 /**
11292 * Removes `key` and its value from the list cache.
11293 *
11294 * @private
11295 * @name delete
11296 * @memberOf ListCache
11297 * @param {string} key The key of the value to remove.
11298 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11299 */
11300 function listCacheDelete(key) {
11301 var data = this.__data__,
11302 index = _assocIndexOf(data, key);
11303
11304 if (index < 0) {
11305 return false;
11306 }
11307 var lastIndex = data.length - 1;
11308 if (index == lastIndex) {
11309 data.pop();
11310 } else {
11311 splice.call(data, index, 1);
11312 }
11313 --this.size;
11314 return true;
11315 }
11316
11317 var _listCacheDelete = listCacheDelete;
11318
11319 /**
11320 * Gets the list cache value for `key`.
11321 *
11322 * @private
11323 * @name get
11324 * @memberOf ListCache
11325 * @param {string} key The key of the value to get.
11326 * @returns {*} Returns the entry value.
11327 */
11328 function listCacheGet(key) {
11329 var data = this.__data__,
11330 index = _assocIndexOf(data, key);
11331
11332 return index < 0 ? undefined : data[index][1];
11333 }
11334
11335 var _listCacheGet = listCacheGet;
11336
11337 /**
11338 * Checks if a list cache value for `key` exists.
11339 *
11340 * @private
11341 * @name has
11342 * @memberOf ListCache
11343 * @param {string} key The key of the entry to check.
11344 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11345 */
11346 function listCacheHas(key) {
11347 return _assocIndexOf(this.__data__, key) > -1;
11348 }
11349
11350 var _listCacheHas = listCacheHas;
11351
11352 /**
11353 * Sets the list cache `key` to `value`.
11354 *
11355 * @private
11356 * @name set
11357 * @memberOf ListCache
11358 * @param {string} key The key of the value to set.
11359 * @param {*} value The value to set.
11360 * @returns {Object} Returns the list cache instance.
11361 */
11362 function listCacheSet(key, value) {
11363 var data = this.__data__,
11364 index = _assocIndexOf(data, key);
11365
11366 if (index < 0) {
11367 ++this.size;
11368 data.push([key, value]);
11369 } else {
11370 data[index][1] = value;
11371 }
11372 return this;
11373 }
11374
11375 var _listCacheSet = listCacheSet;
11376
11377 /**
11378 * Creates an list cache object.
11379 *
11380 * @private
11381 * @constructor
11382 * @param {Array} [entries] The key-value pairs to cache.
11383 */
11384 function ListCache(entries) {
11385 var index = -1,
11386 length = entries == null ? 0 : entries.length;
11387
11388 this.clear();
11389 while (++index < length) {
11390 var entry = entries[index];
11391 this.set(entry[0], entry[1]);
11392 }
11393 }
11394
11395 // Add methods to `ListCache`.
11396 ListCache.prototype.clear = _listCacheClear;
11397 ListCache.prototype['delete'] = _listCacheDelete;
11398 ListCache.prototype.get = _listCacheGet;
11399 ListCache.prototype.has = _listCacheHas;
11400 ListCache.prototype.set = _listCacheSet;
11401
11402 var _ListCache = ListCache;
11403
11404 /**
11405 * Removes all key-value entries from the stack.
11406 *
11407 * @private
11408 * @name clear
11409 * @memberOf Stack
11410 */
11411 function stackClear() {
11412 this.__data__ = new _ListCache;
11413 this.size = 0;
11414 }
11415
11416 var _stackClear = stackClear;
11417
11418 /**
11419 * Removes `key` and its value from the stack.
11420 *
11421 * @private
11422 * @name delete
11423 * @memberOf Stack
11424 * @param {string} key The key of the value to remove.
11425 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11426 */
11427 function stackDelete(key) {
11428 var data = this.__data__,
11429 result = data['delete'](key);
11430
11431 this.size = data.size;
11432 return result;
11433 }
11434
11435 var _stackDelete = stackDelete;
11436
11437 /**
11438 * Gets the stack value for `key`.
11439 *
11440 * @private
11441 * @name get
11442 * @memberOf Stack
11443 * @param {string} key The key of the value to get.
11444 * @returns {*} Returns the entry value.
11445 */
11446 function stackGet(key) {
11447 return this.__data__.get(key);
11448 }
11449
11450 var _stackGet = stackGet;
11451
11452 /**
11453 * Checks if a stack value for `key` exists.
11454 *
11455 * @private
11456 * @name has
11457 * @memberOf Stack
11458 * @param {string} key The key of the entry to check.
11459 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11460 */
11461 function stackHas(key) {
11462 return this.__data__.has(key);
11463 }
11464
11465 var _stackHas = stackHas;
11466
11467 /** Detect free variable `global` from Node.js. */
11468 var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
11469
11470 var _freeGlobal = freeGlobal;
11471
11472 /** Detect free variable `self`. */
11473 var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
11474
11475 /** Used as a reference to the global object. */
11476 var root = _freeGlobal || freeSelf || Function('return this')();
11477
11478 var _root = root;
11479
11480 /** Built-in value references. */
11481 var Symbol = _root.Symbol;
11482
11483 var _Symbol = Symbol;
11484
11485 /** Used for built-in method references. */
11486 var objectProto = Object.prototype;
11487
11488 /** Used to check objects for own properties. */
11489 var hasOwnProperty$1 = objectProto.hasOwnProperty;
11490
11491 /**
11492 * Used to resolve the
11493 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11494 * of values.
11495 */
11496 var nativeObjectToString = objectProto.toString;
11497
11498 /** Built-in value references. */
11499 var symToStringTag = _Symbol ? _Symbol.toStringTag : undefined;
11500
11501 /**
11502 * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
11503 *
11504 * @private
11505 * @param {*} value The value to query.
11506 * @returns {string} Returns the raw `toStringTag`.
11507 */
11508 function getRawTag(value) {
11509 var isOwn = hasOwnProperty$1.call(value, symToStringTag),
11510 tag = value[symToStringTag];
11511
11512 try {
11513 value[symToStringTag] = undefined;
11514 var unmasked = true;
11515 } catch (e) {}
11516
11517 var result = nativeObjectToString.call(value);
11518 if (unmasked) {
11519 if (isOwn) {
11520 value[symToStringTag] = tag;
11521 } else {
11522 delete value[symToStringTag];
11523 }
11524 }
11525 return result;
11526 }
11527
11528 var _getRawTag = getRawTag;
11529
11530 /** Used for built-in method references. */
11531 var objectProto$1 = Object.prototype;
11532
11533 /**
11534 * Used to resolve the
11535 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
11536 * of values.
11537 */
11538 var nativeObjectToString$1 = objectProto$1.toString;
11539
11540 /**
11541 * Converts `value` to a string using `Object.prototype.toString`.
11542 *
11543 * @private
11544 * @param {*} value The value to convert.
11545 * @returns {string} Returns the converted string.
11546 */
11547 function objectToString(value) {
11548 return nativeObjectToString$1.call(value);
11549 }
11550
11551 var _objectToString = objectToString;
11552
11553 /** `Object#toString` result references. */
11554 var nullTag = '[object Null]',
11555 undefinedTag = '[object Undefined]';
11556
11557 /** Built-in value references. */
11558 var symToStringTag$1 = _Symbol ? _Symbol.toStringTag : undefined;
11559
11560 /**
11561 * The base implementation of `getTag` without fallbacks for buggy environments.
11562 *
11563 * @private
11564 * @param {*} value The value to query.
11565 * @returns {string} Returns the `toStringTag`.
11566 */
11567 function baseGetTag(value) {
11568 if (value == null) {
11569 return value === undefined ? undefinedTag : nullTag;
11570 }
11571 return (symToStringTag$1 && symToStringTag$1 in Object(value))
11572 ? _getRawTag(value)
11573 : _objectToString(value);
11574 }
11575
11576 var _baseGetTag = baseGetTag;
11577
11578 /**
11579 * Checks if `value` is the
11580 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
11581 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
11582 *
11583 * @static
11584 * @memberOf _
11585 * @since 0.1.0
11586 * @category Lang
11587 * @param {*} value The value to check.
11588 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
11589 * @example
11590 *
11591 * _.isObject({});
11592 * // => true
11593 *
11594 * _.isObject([1, 2, 3]);
11595 * // => true
11596 *
11597 * _.isObject(_.noop);
11598 * // => true
11599 *
11600 * _.isObject(null);
11601 * // => false
11602 */
11603 function isObject(value) {
11604 var type = typeof value;
11605 return value != null && (type == 'object' || type == 'function');
11606 }
11607
11608 var isObject_1 = isObject;
11609
11610 /** `Object#toString` result references. */
11611 var asyncTag = '[object AsyncFunction]',
11612 funcTag = '[object Function]',
11613 genTag = '[object GeneratorFunction]',
11614 proxyTag = '[object Proxy]';
11615
11616 /**
11617 * Checks if `value` is classified as a `Function` object.
11618 *
11619 * @static
11620 * @memberOf _
11621 * @since 0.1.0
11622 * @category Lang
11623 * @param {*} value The value to check.
11624 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
11625 * @example
11626 *
11627 * _.isFunction(_);
11628 * // => true
11629 *
11630 * _.isFunction(/abc/);
11631 * // => false
11632 */
11633 function isFunction(value) {
11634 if (!isObject_1(value)) {
11635 return false;
11636 }
11637 // The use of `Object#toString` avoids issues with the `typeof` operator
11638 // in Safari 9 which returns 'object' for typed arrays and other constructors.
11639 var tag = _baseGetTag(value);
11640 return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
11641 }
11642
11643 var isFunction_1 = isFunction;
11644
11645 /** Used to detect overreaching core-js shims. */
11646 var coreJsData = _root['__core-js_shared__'];
11647
11648 var _coreJsData = coreJsData;
11649
11650 /** Used to detect methods masquerading as native. */
11651 var maskSrcKey = (function() {
11652 var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
11653 return uid ? ('Symbol(src)_1.' + uid) : '';
11654 }());
11655
11656 /**
11657 * Checks if `func` has its source masked.
11658 *
11659 * @private
11660 * @param {Function} func The function to check.
11661 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
11662 */
11663 function isMasked(func) {
11664 return !!maskSrcKey && (maskSrcKey in func);
11665 }
11666
11667 var _isMasked = isMasked;
11668
11669 /** Used for built-in method references. */
11670 var funcProto = Function.prototype;
11671
11672 /** Used to resolve the decompiled source of functions. */
11673 var funcToString = funcProto.toString;
11674
11675 /**
11676 * Converts `func` to its source code.
11677 *
11678 * @private
11679 * @param {Function} func The function to convert.
11680 * @returns {string} Returns the source code.
11681 */
11682 function toSource(func) {
11683 if (func != null) {
11684 try {
11685 return funcToString.call(func);
11686 } catch (e) {}
11687 try {
11688 return (func + '');
11689 } catch (e) {}
11690 }
11691 return '';
11692 }
11693
11694 var _toSource = toSource;
11695
11696 /**
11697 * Used to match `RegExp`
11698 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
11699 */
11700 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
11701
11702 /** Used to detect host constructors (Safari). */
11703 var reIsHostCtor = /^\[object .+?Constructor\]$/;
11704
11705 /** Used for built-in method references. */
11706 var funcProto$1 = Function.prototype,
11707 objectProto$2 = Object.prototype;
11708
11709 /** Used to resolve the decompiled source of functions. */
11710 var funcToString$1 = funcProto$1.toString;
11711
11712 /** Used to check objects for own properties. */
11713 var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
11714
11715 /** Used to detect if a method is native. */
11716 var reIsNative = RegExp('^' +
11717 funcToString$1.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
11718 .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
11719 );
11720
11721 /**
11722 * The base implementation of `_.isNative` without bad shim checks.
11723 *
11724 * @private
11725 * @param {*} value The value to check.
11726 * @returns {boolean} Returns `true` if `value` is a native function,
11727 * else `false`.
11728 */
11729 function baseIsNative(value) {
11730 if (!isObject_1(value) || _isMasked(value)) {
11731 return false;
11732 }
11733 var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
11734 return pattern.test(_toSource(value));
11735 }
11736
11737 var _baseIsNative = baseIsNative;
11738
11739 /**
11740 * Gets the value at `key` of `object`.
11741 *
11742 * @private
11743 * @param {Object} [object] The object to query.
11744 * @param {string} key The key of the property to get.
11745 * @returns {*} Returns the property value.
11746 */
11747 function getValue(object, key) {
11748 return object == null ? undefined : object[key];
11749 }
11750
11751 var _getValue = getValue;
11752
11753 /**
11754 * Gets the native function at `key` of `object`.
11755 *
11756 * @private
11757 * @param {Object} object The object to query.
11758 * @param {string} key The key of the method to get.
11759 * @returns {*} Returns the function if it's native, else `undefined`.
11760 */
11761 function getNative(object, key) {
11762 var value = _getValue(object, key);
11763 return _baseIsNative(value) ? value : undefined;
11764 }
11765
11766 var _getNative = getNative;
11767
11768 /* Built-in method references that are verified to be native. */
11769 var Map = _getNative(_root, 'Map');
11770
11771 var _Map = Map;
11772
11773 /* Built-in method references that are verified to be native. */
11774 var nativeCreate = _getNative(Object, 'create');
11775
11776 var _nativeCreate = nativeCreate;
11777
11778 /**
11779 * Removes all key-value entries from the hash.
11780 *
11781 * @private
11782 * @name clear
11783 * @memberOf Hash
11784 */
11785 function hashClear() {
11786 this.__data__ = _nativeCreate ? _nativeCreate(null) : {};
11787 this.size = 0;
11788 }
11789
11790 var _hashClear = hashClear;
11791
11792 /**
11793 * Removes `key` and its value from the hash.
11794 *
11795 * @private
11796 * @name delete
11797 * @memberOf Hash
11798 * @param {Object} hash The hash to modify.
11799 * @param {string} key The key of the value to remove.
11800 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11801 */
11802 function hashDelete(key) {
11803 var result = this.has(key) && delete this.__data__[key];
11804 this.size -= result ? 1 : 0;
11805 return result;
11806 }
11807
11808 var _hashDelete = hashDelete;
11809
11810 /** Used to stand-in for `undefined` hash values. */
11811 var HASH_UNDEFINED = '__lodash_hash_undefined__';
11812
11813 /** Used for built-in method references. */
11814 var objectProto$3 = Object.prototype;
11815
11816 /** Used to check objects for own properties. */
11817 var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
11818
11819 /**
11820 * Gets the hash value for `key`.
11821 *
11822 * @private
11823 * @name get
11824 * @memberOf Hash
11825 * @param {string} key The key of the value to get.
11826 * @returns {*} Returns the entry value.
11827 */
11828 function hashGet(key) {
11829 var data = this.__data__;
11830 if (_nativeCreate) {
11831 var result = data[key];
11832 return result === HASH_UNDEFINED ? undefined : result;
11833 }
11834 return hasOwnProperty$3.call(data, key) ? data[key] : undefined;
11835 }
11836
11837 var _hashGet = hashGet;
11838
11839 /** Used for built-in method references. */
11840 var objectProto$4 = Object.prototype;
11841
11842 /** Used to check objects for own properties. */
11843 var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
11844
11845 /**
11846 * Checks if a hash value for `key` exists.
11847 *
11848 * @private
11849 * @name has
11850 * @memberOf Hash
11851 * @param {string} key The key of the entry to check.
11852 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
11853 */
11854 function hashHas(key) {
11855 var data = this.__data__;
11856 return _nativeCreate ? (data[key] !== undefined) : hasOwnProperty$4.call(data, key);
11857 }
11858
11859 var _hashHas = hashHas;
11860
11861 /** Used to stand-in for `undefined` hash values. */
11862 var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
11863
11864 /**
11865 * Sets the hash `key` to `value`.
11866 *
11867 * @private
11868 * @name set
11869 * @memberOf Hash
11870 * @param {string} key The key of the value to set.
11871 * @param {*} value The value to set.
11872 * @returns {Object} Returns the hash instance.
11873 */
11874 function hashSet(key, value) {
11875 var data = this.__data__;
11876 this.size += this.has(key) ? 0 : 1;
11877 data[key] = (_nativeCreate && value === undefined) ? HASH_UNDEFINED$1 : value;
11878 return this;
11879 }
11880
11881 var _hashSet = hashSet;
11882
11883 /**
11884 * Creates a hash object.
11885 *
11886 * @private
11887 * @constructor
11888 * @param {Array} [entries] The key-value pairs to cache.
11889 */
11890 function Hash(entries) {
11891 var index = -1,
11892 length = entries == null ? 0 : entries.length;
11893
11894 this.clear();
11895 while (++index < length) {
11896 var entry = entries[index];
11897 this.set(entry[0], entry[1]);
11898 }
11899 }
11900
11901 // Add methods to `Hash`.
11902 Hash.prototype.clear = _hashClear;
11903 Hash.prototype['delete'] = _hashDelete;
11904 Hash.prototype.get = _hashGet;
11905 Hash.prototype.has = _hashHas;
11906 Hash.prototype.set = _hashSet;
11907
11908 var _Hash = Hash;
11909
11910 /**
11911 * Removes all key-value entries from the map.
11912 *
11913 * @private
11914 * @name clear
11915 * @memberOf MapCache
11916 */
11917 function mapCacheClear() {
11918 this.size = 0;
11919 this.__data__ = {
11920 'hash': new _Hash,
11921 'map': new (_Map || _ListCache),
11922 'string': new _Hash
11923 };
11924 }
11925
11926 var _mapCacheClear = mapCacheClear;
11927
11928 /**
11929 * Checks if `value` is suitable for use as unique object key.
11930 *
11931 * @private
11932 * @param {*} value The value to check.
11933 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
11934 */
11935 function isKeyable(value) {
11936 var type = typeof value;
11937 return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
11938 ? (value !== '__proto__')
11939 : (value === null);
11940 }
11941
11942 var _isKeyable = isKeyable;
11943
11944 /**
11945 * Gets the data for `map`.
11946 *
11947 * @private
11948 * @param {Object} map The map to query.
11949 * @param {string} key The reference key.
11950 * @returns {*} Returns the map data.
11951 */
11952 function getMapData(map, key) {
11953 var data = map.__data__;
11954 return _isKeyable(key)
11955 ? data[typeof key == 'string' ? 'string' : 'hash']
11956 : data.map;
11957 }
11958
11959 var _getMapData = getMapData;
11960
11961 /**
11962 * Removes `key` and its value from the map.
11963 *
11964 * @private
11965 * @name delete
11966 * @memberOf MapCache
11967 * @param {string} key The key of the value to remove.
11968 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
11969 */
11970 function mapCacheDelete(key) {
11971 var result = _getMapData(this, key)['delete'](key);
11972 this.size -= result ? 1 : 0;
11973 return result;
11974 }
11975
11976 var _mapCacheDelete = mapCacheDelete;
11977
11978 /**
11979 * Gets the map value for `key`.
11980 *
11981 * @private
11982 * @name get
11983 * @memberOf MapCache
11984 * @param {string} key The key of the value to get.
11985 * @returns {*} Returns the entry value.
11986 */
11987 function mapCacheGet(key) {
11988 return _getMapData(this, key).get(key);
11989 }
11990
11991 var _mapCacheGet = mapCacheGet;
11992
11993 /**
11994 * Checks if a map value for `key` exists.
11995 *
11996 * @private
11997 * @name has
11998 * @memberOf MapCache
11999 * @param {string} key The key of the entry to check.
12000 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
12001 */
12002 function mapCacheHas(key) {
12003 return _getMapData(this, key).has(key);
12004 }
12005
12006 var _mapCacheHas = mapCacheHas;
12007
12008 /**
12009 * Sets the map `key` to `value`.
12010 *
12011 * @private
12012 * @name set
12013 * @memberOf MapCache
12014 * @param {string} key The key of the value to set.
12015 * @param {*} value The value to set.
12016 * @returns {Object} Returns the map cache instance.
12017 */
12018 function mapCacheSet(key, value) {
12019 var data = _getMapData(this, key),
12020 size = data.size;
12021
12022 data.set(key, value);
12023 this.size += data.size == size ? 0 : 1;
12024 return this;
12025 }
12026
12027 var _mapCacheSet = mapCacheSet;
12028
12029 /**
12030 * Creates a map cache object to store key-value pairs.
12031 *
12032 * @private
12033 * @constructor
12034 * @param {Array} [entries] The key-value pairs to cache.
12035 */
12036 function MapCache(entries) {
12037 var index = -1,
12038 length = entries == null ? 0 : entries.length;
12039
12040 this.clear();
12041 while (++index < length) {
12042 var entry = entries[index];
12043 this.set(entry[0], entry[1]);
12044 }
12045 }
12046
12047 // Add methods to `MapCache`.
12048 MapCache.prototype.clear = _mapCacheClear;
12049 MapCache.prototype['delete'] = _mapCacheDelete;
12050 MapCache.prototype.get = _mapCacheGet;
12051 MapCache.prototype.has = _mapCacheHas;
12052 MapCache.prototype.set = _mapCacheSet;
12053
12054 var _MapCache = MapCache;
12055
12056 /** Used as the size to enable large array optimizations. */
12057 var LARGE_ARRAY_SIZE = 200;
12058
12059 /**
12060 * Sets the stack `key` to `value`.
12061 *
12062 * @private
12063 * @name set
12064 * @memberOf Stack
12065 * @param {string} key The key of the value to set.
12066 * @param {*} value The value to set.
12067 * @returns {Object} Returns the stack cache instance.
12068 */
12069 function stackSet(key, value) {
12070 var data = this.__data__;
12071 if (data instanceof _ListCache) {
12072 var pairs = data.__data__;
12073 if (!_Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
12074 pairs.push([key, value]);
12075 this.size = ++data.size;
12076 return this;
12077 }
12078 data = this.__data__ = new _MapCache(pairs);
12079 }
12080 data.set(key, value);
12081 this.size = data.size;
12082 return this;
12083 }
12084
12085 var _stackSet = stackSet;
12086
12087 /**
12088 * Creates a stack cache object to store key-value pairs.
12089 *
12090 * @private
12091 * @constructor
12092 * @param {Array} [entries] The key-value pairs to cache.
12093 */
12094 function Stack(entries) {
12095 var data = this.__data__ = new _ListCache(entries);
12096 this.size = data.size;
12097 }
12098
12099 // Add methods to `Stack`.
12100 Stack.prototype.clear = _stackClear;
12101 Stack.prototype['delete'] = _stackDelete;
12102 Stack.prototype.get = _stackGet;
12103 Stack.prototype.has = _stackHas;
12104 Stack.prototype.set = _stackSet;
12105
12106 var _Stack = Stack;
12107
12108 /**
12109 * A specialized version of `_.forEach` for arrays without support for
12110 * iteratee shorthands.
12111 *
12112 * @private
12113 * @param {Array} [array] The array to iterate over.
12114 * @param {Function} iteratee The function invoked per iteration.
12115 * @returns {Array} Returns `array`.
12116 */
12117 function arrayEach(array, iteratee) {
12118 var index = -1,
12119 length = array == null ? 0 : array.length;
12120
12121 while (++index < length) {
12122 if (iteratee(array[index], index, array) === false) {
12123 break;
12124 }
12125 }
12126 return array;
12127 }
12128
12129 var _arrayEach = arrayEach;
12130
12131 var defineProperty = (function() {
12132 try {
12133 var func = _getNative(Object, 'defineProperty');
12134 func({}, '', {});
12135 return func;
12136 } catch (e) {}
12137 }());
12138
12139 var _defineProperty = defineProperty;
12140
12141 /**
12142 * The base implementation of `assignValue` and `assignMergeValue` without
12143 * value checks.
12144 *
12145 * @private
12146 * @param {Object} object The object to modify.
12147 * @param {string} key The key of the property to assign.
12148 * @param {*} value The value to assign.
12149 */
12150 function baseAssignValue(object, key, value) {
12151 if (key == '__proto__' && _defineProperty) {
12152 _defineProperty(object, key, {
12153 'configurable': true,
12154 'enumerable': true,
12155 'value': value,
12156 'writable': true
12157 });
12158 } else {
12159 object[key] = value;
12160 }
12161 }
12162
12163 var _baseAssignValue = baseAssignValue;
12164
12165 /** Used for built-in method references. */
12166 var objectProto$5 = Object.prototype;
12167
12168 /** Used to check objects for own properties. */
12169 var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
12170
12171 /**
12172 * Assigns `value` to `key` of `object` if the existing value is not equivalent
12173 * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
12174 * for equality comparisons.
12175 *
12176 * @private
12177 * @param {Object} object The object to modify.
12178 * @param {string} key The key of the property to assign.
12179 * @param {*} value The value to assign.
12180 */
12181 function assignValue(object, key, value) {
12182 var objValue = object[key];
12183 if (!(hasOwnProperty$5.call(object, key) && eq_1(objValue, value)) ||
12184 (value === undefined && !(key in object))) {
12185 _baseAssignValue(object, key, value);
12186 }
12187 }
12188
12189 var _assignValue = assignValue;
12190
12191 /**
12192 * Copies properties of `source` to `object`.
12193 *
12194 * @private
12195 * @param {Object} source The object to copy properties from.
12196 * @param {Array} props The property identifiers to copy.
12197 * @param {Object} [object={}] The object to copy properties to.
12198 * @param {Function} [customizer] The function to customize copied values.
12199 * @returns {Object} Returns `object`.
12200 */
12201 function copyObject(source, props, object, customizer) {
12202 var isNew = !object;
12203 object || (object = {});
12204
12205 var index = -1,
12206 length = props.length;
12207
12208 while (++index < length) {
12209 var key = props[index];
12210
12211 var newValue = customizer
12212 ? customizer(object[key], source[key], key, object, source)
12213 : undefined;
12214
12215 if (newValue === undefined) {
12216 newValue = source[key];
12217 }
12218 if (isNew) {
12219 _baseAssignValue(object, key, newValue);
12220 } else {
12221 _assignValue(object, key, newValue);
12222 }
12223 }
12224 return object;
12225 }
12226
12227 var _copyObject = copyObject;
12228
12229 /**
12230 * The base implementation of `_.times` without support for iteratee shorthands
12231 * or max array length checks.
12232 *
12233 * @private
12234 * @param {number} n The number of times to invoke `iteratee`.
12235 * @param {Function} iteratee The function invoked per iteration.
12236 * @returns {Array} Returns the array of results.
12237 */
12238 function baseTimes(n, iteratee) {
12239 var index = -1,
12240 result = Array(n);
12241
12242 while (++index < n) {
12243 result[index] = iteratee(index);
12244 }
12245 return result;
12246 }
12247
12248 var _baseTimes = baseTimes;
12249
12250 /**
12251 * Checks if `value` is object-like. A value is object-like if it's not `null`
12252 * and has a `typeof` result of "object".
12253 *
12254 * @static
12255 * @memberOf _
12256 * @since 4.0.0
12257 * @category Lang
12258 * @param {*} value The value to check.
12259 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
12260 * @example
12261 *
12262 * _.isObjectLike({});
12263 * // => true
12264 *
12265 * _.isObjectLike([1, 2, 3]);
12266 * // => true
12267 *
12268 * _.isObjectLike(_.noop);
12269 * // => false
12270 *
12271 * _.isObjectLike(null);
12272 * // => false
12273 */
12274 function isObjectLike(value) {
12275 return value != null && typeof value == 'object';
12276 }
12277
12278 var isObjectLike_1 = isObjectLike;
12279
12280 /** `Object#toString` result references. */
12281 var argsTag = '[object Arguments]';
12282
12283 /**
12284 * The base implementation of `_.isArguments`.
12285 *
12286 * @private
12287 * @param {*} value The value to check.
12288 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12289 */
12290 function baseIsArguments(value) {
12291 return isObjectLike_1(value) && _baseGetTag(value) == argsTag;
12292 }
12293
12294 var _baseIsArguments = baseIsArguments;
12295
12296 /** Used for built-in method references. */
12297 var objectProto$6 = Object.prototype;
12298
12299 /** Used to check objects for own properties. */
12300 var hasOwnProperty$6 = objectProto$6.hasOwnProperty;
12301
12302 /** Built-in value references. */
12303 var propertyIsEnumerable = objectProto$6.propertyIsEnumerable;
12304
12305 /**
12306 * Checks if `value` is likely an `arguments` object.
12307 *
12308 * @static
12309 * @memberOf _
12310 * @since 0.1.0
12311 * @category Lang
12312 * @param {*} value The value to check.
12313 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
12314 * else `false`.
12315 * @example
12316 *
12317 * _.isArguments(function() { return arguments; }());
12318 * // => true
12319 *
12320 * _.isArguments([1, 2, 3]);
12321 * // => false
12322 */
12323 var isArguments = _baseIsArguments(function() { return arguments; }()) ? _baseIsArguments : function(value) {
12324 return isObjectLike_1(value) && hasOwnProperty$6.call(value, 'callee') &&
12325 !propertyIsEnumerable.call(value, 'callee');
12326 };
12327
12328 var isArguments_1 = isArguments;
12329
12330 /**
12331 * Checks if `value` is classified as an `Array` object.
12332 *
12333 * @static
12334 * @memberOf _
12335 * @since 0.1.0
12336 * @category Lang
12337 * @param {*} value The value to check.
12338 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
12339 * @example
12340 *
12341 * _.isArray([1, 2, 3]);
12342 * // => true
12343 *
12344 * _.isArray(document.body.children);
12345 * // => false
12346 *
12347 * _.isArray('abc');
12348 * // => false
12349 *
12350 * _.isArray(_.noop);
12351 * // => false
12352 */
12353 var isArray = Array.isArray;
12354
12355 var isArray_1 = isArray;
12356
12357 /**
12358 * This method returns `false`.
12359 *
12360 * @static
12361 * @memberOf _
12362 * @since 4.13.0
12363 * @category Util
12364 * @returns {boolean} Returns `false`.
12365 * @example
12366 *
12367 * _.times(2, _.stubFalse);
12368 * // => [false, false]
12369 */
12370 function stubFalse() {
12371 return false;
12372 }
12373
12374 var stubFalse_1 = stubFalse;
12375
12376 var isBuffer_1$1 = createCommonjsModule(function (module, exports) {
12377 /** Detect free variable `exports`. */
12378 var freeExports = exports && !exports.nodeType && exports;
12379
12380 /** Detect free variable `module`. */
12381 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12382
12383 /** Detect the popular CommonJS extension `module.exports`. */
12384 var moduleExports = freeModule && freeModule.exports === freeExports;
12385
12386 /** Built-in value references. */
12387 var Buffer = moduleExports ? _root.Buffer : undefined;
12388
12389 /* Built-in method references for those with the same name as other `lodash` methods. */
12390 var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
12391
12392 /**
12393 * Checks if `value` is a buffer.
12394 *
12395 * @static
12396 * @memberOf _
12397 * @since 4.3.0
12398 * @category Lang
12399 * @param {*} value The value to check.
12400 * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
12401 * @example
12402 *
12403 * _.isBuffer(new Buffer(2));
12404 * // => true
12405 *
12406 * _.isBuffer(new Uint8Array(2));
12407 * // => false
12408 */
12409 var isBuffer = nativeIsBuffer || stubFalse_1;
12410
12411 module.exports = isBuffer;
12412 });
12413
12414 /** Used as references for various `Number` constants. */
12415 var MAX_SAFE_INTEGER = 9007199254740991;
12416
12417 /** Used to detect unsigned integer values. */
12418 var reIsUint = /^(?:0|[1-9]\d*)$/;
12419
12420 /**
12421 * Checks if `value` is a valid array-like index.
12422 *
12423 * @private
12424 * @param {*} value The value to check.
12425 * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
12426 * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
12427 */
12428 function isIndex(value, length) {
12429 var type = typeof value;
12430 length = length == null ? MAX_SAFE_INTEGER : length;
12431
12432 return !!length &&
12433 (type == 'number' ||
12434 (type != 'symbol' && reIsUint.test(value))) &&
12435 (value > -1 && value % 1 == 0 && value < length);
12436 }
12437
12438 var _isIndex = isIndex;
12439
12440 /** Used as references for various `Number` constants. */
12441 var MAX_SAFE_INTEGER$1 = 9007199254740991;
12442
12443 /**
12444 * Checks if `value` is a valid array-like length.
12445 *
12446 * **Note:** This method is loosely based on
12447 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
12448 *
12449 * @static
12450 * @memberOf _
12451 * @since 4.0.0
12452 * @category Lang
12453 * @param {*} value The value to check.
12454 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
12455 * @example
12456 *
12457 * _.isLength(3);
12458 * // => true
12459 *
12460 * _.isLength(Number.MIN_VALUE);
12461 * // => false
12462 *
12463 * _.isLength(Infinity);
12464 * // => false
12465 *
12466 * _.isLength('3');
12467 * // => false
12468 */
12469 function isLength(value) {
12470 return typeof value == 'number' &&
12471 value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER$1;
12472 }
12473
12474 var isLength_1 = isLength;
12475
12476 /** `Object#toString` result references. */
12477 var argsTag$1 = '[object Arguments]',
12478 arrayTag = '[object Array]',
12479 boolTag = '[object Boolean]',
12480 dateTag = '[object Date]',
12481 errorTag = '[object Error]',
12482 funcTag$1 = '[object Function]',
12483 mapTag = '[object Map]',
12484 numberTag = '[object Number]',
12485 objectTag = '[object Object]',
12486 regexpTag = '[object RegExp]',
12487 setTag = '[object Set]',
12488 stringTag = '[object String]',
12489 weakMapTag = '[object WeakMap]';
12490
12491 var arrayBufferTag = '[object ArrayBuffer]',
12492 dataViewTag = '[object DataView]',
12493 float32Tag = '[object Float32Array]',
12494 float64Tag = '[object Float64Array]',
12495 int8Tag = '[object Int8Array]',
12496 int16Tag = '[object Int16Array]',
12497 int32Tag = '[object Int32Array]',
12498 uint8Tag = '[object Uint8Array]',
12499 uint8ClampedTag = '[object Uint8ClampedArray]',
12500 uint16Tag = '[object Uint16Array]',
12501 uint32Tag = '[object Uint32Array]';
12502
12503 /** Used to identify `toStringTag` values of typed arrays. */
12504 var typedArrayTags = {};
12505 typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
12506 typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
12507 typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
12508 typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
12509 typedArrayTags[uint32Tag] = true;
12510 typedArrayTags[argsTag$1] = typedArrayTags[arrayTag] =
12511 typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
12512 typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
12513 typedArrayTags[errorTag] = typedArrayTags[funcTag$1] =
12514 typedArrayTags[mapTag] = typedArrayTags[numberTag] =
12515 typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
12516 typedArrayTags[setTag] = typedArrayTags[stringTag] =
12517 typedArrayTags[weakMapTag] = false;
12518
12519 /**
12520 * The base implementation of `_.isTypedArray` without Node.js optimizations.
12521 *
12522 * @private
12523 * @param {*} value The value to check.
12524 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12525 */
12526 function baseIsTypedArray(value) {
12527 return isObjectLike_1(value) &&
12528 isLength_1(value.length) && !!typedArrayTags[_baseGetTag(value)];
12529 }
12530
12531 var _baseIsTypedArray = baseIsTypedArray;
12532
12533 /**
12534 * The base implementation of `_.unary` without support for storing metadata.
12535 *
12536 * @private
12537 * @param {Function} func The function to cap arguments for.
12538 * @returns {Function} Returns the new capped function.
12539 */
12540 function baseUnary(func) {
12541 return function(value) {
12542 return func(value);
12543 };
12544 }
12545
12546 var _baseUnary = baseUnary;
12547
12548 var _nodeUtil = createCommonjsModule(function (module, exports) {
12549 /** Detect free variable `exports`. */
12550 var freeExports = exports && !exports.nodeType && exports;
12551
12552 /** Detect free variable `module`. */
12553 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12554
12555 /** Detect the popular CommonJS extension `module.exports`. */
12556 var moduleExports = freeModule && freeModule.exports === freeExports;
12557
12558 /** Detect free variable `process` from Node.js. */
12559 var freeProcess = moduleExports && _freeGlobal.process;
12560
12561 /** Used to access faster Node.js helpers. */
12562 var nodeUtil = (function() {
12563 try {
12564 // Use `util.types` for Node.js 10+.
12565 var types = freeModule && freeModule.require && freeModule.require('util').types;
12566
12567 if (types) {
12568 return types;
12569 }
12570
12571 // Legacy `process.binding('util')` for Node.js < 10.
12572 return freeProcess && freeProcess.binding && freeProcess.binding('util');
12573 } catch (e) {}
12574 }());
12575
12576 module.exports = nodeUtil;
12577 });
12578
12579 /* Node.js helper references. */
12580 var nodeIsTypedArray = _nodeUtil && _nodeUtil.isTypedArray;
12581
12582 /**
12583 * Checks if `value` is classified as a typed array.
12584 *
12585 * @static
12586 * @memberOf _
12587 * @since 3.0.0
12588 * @category Lang
12589 * @param {*} value The value to check.
12590 * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
12591 * @example
12592 *
12593 * _.isTypedArray(new Uint8Array);
12594 * // => true
12595 *
12596 * _.isTypedArray([]);
12597 * // => false
12598 */
12599 var isTypedArray = nodeIsTypedArray ? _baseUnary(nodeIsTypedArray) : _baseIsTypedArray;
12600
12601 var isTypedArray_1 = isTypedArray;
12602
12603 /** Used for built-in method references. */
12604 var objectProto$7 = Object.prototype;
12605
12606 /** Used to check objects for own properties. */
12607 var hasOwnProperty$7 = objectProto$7.hasOwnProperty;
12608
12609 /**
12610 * Creates an array of the enumerable property names of the array-like `value`.
12611 *
12612 * @private
12613 * @param {*} value The value to query.
12614 * @param {boolean} inherited Specify returning inherited property names.
12615 * @returns {Array} Returns the array of property names.
12616 */
12617 function arrayLikeKeys(value, inherited) {
12618 var isArr = isArray_1(value),
12619 isArg = !isArr && isArguments_1(value),
12620 isBuff = !isArr && !isArg && isBuffer_1$1(value),
12621 isType = !isArr && !isArg && !isBuff && isTypedArray_1(value),
12622 skipIndexes = isArr || isArg || isBuff || isType,
12623 result = skipIndexes ? _baseTimes(value.length, String) : [],
12624 length = result.length;
12625
12626 for (var key in value) {
12627 if ((inherited || hasOwnProperty$7.call(value, key)) &&
12628 !(skipIndexes && (
12629 // Safari 9 has enumerable `arguments.length` in strict mode.
12630 key == 'length' ||
12631 // Node.js 0.10 has enumerable non-index properties on buffers.
12632 (isBuff && (key == 'offset' || key == 'parent')) ||
12633 // PhantomJS 2 has enumerable non-index properties on typed arrays.
12634 (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
12635 // Skip index properties.
12636 _isIndex(key, length)
12637 ))) {
12638 result.push(key);
12639 }
12640 }
12641 return result;
12642 }
12643
12644 var _arrayLikeKeys = arrayLikeKeys;
12645
12646 /** Used for built-in method references. */
12647 var objectProto$8 = Object.prototype;
12648
12649 /**
12650 * Checks if `value` is likely a prototype object.
12651 *
12652 * @private
12653 * @param {*} value The value to check.
12654 * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
12655 */
12656 function isPrototype(value) {
12657 var Ctor = value && value.constructor,
12658 proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$8;
12659
12660 return value === proto;
12661 }
12662
12663 var _isPrototype = isPrototype;
12664
12665 /**
12666 * Creates a unary function that invokes `func` with its argument transformed.
12667 *
12668 * @private
12669 * @param {Function} func The function to wrap.
12670 * @param {Function} transform The argument transform.
12671 * @returns {Function} Returns the new function.
12672 */
12673 function overArg(func, transform) {
12674 return function(arg) {
12675 return func(transform(arg));
12676 };
12677 }
12678
12679 var _overArg = overArg;
12680
12681 /* Built-in method references for those with the same name as other `lodash` methods. */
12682 var nativeKeys = _overArg(Object.keys, Object);
12683
12684 var _nativeKeys = nativeKeys;
12685
12686 /** Used for built-in method references. */
12687 var objectProto$9 = Object.prototype;
12688
12689 /** Used to check objects for own properties. */
12690 var hasOwnProperty$8 = objectProto$9.hasOwnProperty;
12691
12692 /**
12693 * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
12694 *
12695 * @private
12696 * @param {Object} object The object to query.
12697 * @returns {Array} Returns the array of property names.
12698 */
12699 function baseKeys(object) {
12700 if (!_isPrototype(object)) {
12701 return _nativeKeys(object);
12702 }
12703 var result = [];
12704 for (var key in Object(object)) {
12705 if (hasOwnProperty$8.call(object, key) && key != 'constructor') {
12706 result.push(key);
12707 }
12708 }
12709 return result;
12710 }
12711
12712 var _baseKeys = baseKeys;
12713
12714 /**
12715 * Checks if `value` is array-like. A value is considered array-like if it's
12716 * not a function and has a `value.length` that's an integer greater than or
12717 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
12718 *
12719 * @static
12720 * @memberOf _
12721 * @since 4.0.0
12722 * @category Lang
12723 * @param {*} value The value to check.
12724 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
12725 * @example
12726 *
12727 * _.isArrayLike([1, 2, 3]);
12728 * // => true
12729 *
12730 * _.isArrayLike(document.body.children);
12731 * // => true
12732 *
12733 * _.isArrayLike('abc');
12734 * // => true
12735 *
12736 * _.isArrayLike(_.noop);
12737 * // => false
12738 */
12739 function isArrayLike(value) {
12740 return value != null && isLength_1(value.length) && !isFunction_1(value);
12741 }
12742
12743 var isArrayLike_1 = isArrayLike;
12744
12745 /**
12746 * Creates an array of the own enumerable property names of `object`.
12747 *
12748 * **Note:** Non-object values are coerced to objects. See the
12749 * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12750 * for more details.
12751 *
12752 * @static
12753 * @since 0.1.0
12754 * @memberOf _
12755 * @category Object
12756 * @param {Object} object The object to query.
12757 * @returns {Array} Returns the array of property names.
12758 * @example
12759 *
12760 * function Foo() {
12761 * this.a = 1;
12762 * this.b = 2;
12763 * }
12764 *
12765 * Foo.prototype.c = 3;
12766 *
12767 * _.keys(new Foo);
12768 * // => ['a', 'b'] (iteration order is not guaranteed)
12769 *
12770 * _.keys('hi');
12771 * // => ['0', '1']
12772 */
12773 function keys$1(object) {
12774 return isArrayLike_1(object) ? _arrayLikeKeys(object) : _baseKeys(object);
12775 }
12776
12777 var keys_1 = keys$1;
12778
12779 /**
12780 * The base implementation of `_.assign` without support for multiple sources
12781 * or `customizer` functions.
12782 *
12783 * @private
12784 * @param {Object} object The destination object.
12785 * @param {Object} source The source object.
12786 * @returns {Object} Returns `object`.
12787 */
12788 function baseAssign(object, source) {
12789 return object && _copyObject(source, keys_1(source), object);
12790 }
12791
12792 var _baseAssign = baseAssign;
12793
12794 /**
12795 * This function is like
12796 * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
12797 * except that it includes inherited enumerable properties.
12798 *
12799 * @private
12800 * @param {Object} object The object to query.
12801 * @returns {Array} Returns the array of property names.
12802 */
12803 function nativeKeysIn(object) {
12804 var result = [];
12805 if (object != null) {
12806 for (var key in Object(object)) {
12807 result.push(key);
12808 }
12809 }
12810 return result;
12811 }
12812
12813 var _nativeKeysIn = nativeKeysIn;
12814
12815 /** Used for built-in method references. */
12816 var objectProto$a = Object.prototype;
12817
12818 /** Used to check objects for own properties. */
12819 var hasOwnProperty$9 = objectProto$a.hasOwnProperty;
12820
12821 /**
12822 * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
12823 *
12824 * @private
12825 * @param {Object} object The object to query.
12826 * @returns {Array} Returns the array of property names.
12827 */
12828 function baseKeysIn(object) {
12829 if (!isObject_1(object)) {
12830 return _nativeKeysIn(object);
12831 }
12832 var isProto = _isPrototype(object),
12833 result = [];
12834
12835 for (var key in object) {
12836 if (!(key == 'constructor' && (isProto || !hasOwnProperty$9.call(object, key)))) {
12837 result.push(key);
12838 }
12839 }
12840 return result;
12841 }
12842
12843 var _baseKeysIn = baseKeysIn;
12844
12845 /**
12846 * Creates an array of the own and inherited enumerable property names of `object`.
12847 *
12848 * **Note:** Non-object values are coerced to objects.
12849 *
12850 * @static
12851 * @memberOf _
12852 * @since 3.0.0
12853 * @category Object
12854 * @param {Object} object The object to query.
12855 * @returns {Array} Returns the array of property names.
12856 * @example
12857 *
12858 * function Foo() {
12859 * this.a = 1;
12860 * this.b = 2;
12861 * }
12862 *
12863 * Foo.prototype.c = 3;
12864 *
12865 * _.keysIn(new Foo);
12866 * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
12867 */
12868 function keysIn$1(object) {
12869 return isArrayLike_1(object) ? _arrayLikeKeys(object, true) : _baseKeysIn(object);
12870 }
12871
12872 var keysIn_1 = keysIn$1;
12873
12874 /**
12875 * The base implementation of `_.assignIn` without support for multiple sources
12876 * or `customizer` functions.
12877 *
12878 * @private
12879 * @param {Object} object The destination object.
12880 * @param {Object} source The source object.
12881 * @returns {Object} Returns `object`.
12882 */
12883 function baseAssignIn(object, source) {
12884 return object && _copyObject(source, keysIn_1(source), object);
12885 }
12886
12887 var _baseAssignIn = baseAssignIn;
12888
12889 var _cloneBuffer = createCommonjsModule(function (module, exports) {
12890 /** Detect free variable `exports`. */
12891 var freeExports = exports && !exports.nodeType && exports;
12892
12893 /** Detect free variable `module`. */
12894 var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
12895
12896 /** Detect the popular CommonJS extension `module.exports`. */
12897 var moduleExports = freeModule && freeModule.exports === freeExports;
12898
12899 /** Built-in value references. */
12900 var Buffer = moduleExports ? _root.Buffer : undefined,
12901 allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
12902
12903 /**
12904 * Creates a clone of `buffer`.
12905 *
12906 * @private
12907 * @param {Buffer} buffer The buffer to clone.
12908 * @param {boolean} [isDeep] Specify a deep clone.
12909 * @returns {Buffer} Returns the cloned buffer.
12910 */
12911 function cloneBuffer(buffer, isDeep) {
12912 if (isDeep) {
12913 return buffer.slice();
12914 }
12915 var length = buffer.length,
12916 result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
12917
12918 buffer.copy(result);
12919 return result;
12920 }
12921
12922 module.exports = cloneBuffer;
12923 });
12924
12925 /**
12926 * Copies the values of `source` to `array`.
12927 *
12928 * @private
12929 * @param {Array} source The array to copy values from.
12930 * @param {Array} [array=[]] The array to copy values to.
12931 * @returns {Array} Returns `array`.
12932 */
12933 function copyArray(source, array) {
12934 var index = -1,
12935 length = source.length;
12936
12937 array || (array = Array(length));
12938 while (++index < length) {
12939 array[index] = source[index];
12940 }
12941 return array;
12942 }
12943
12944 var _copyArray = copyArray;
12945
12946 /**
12947 * A specialized version of `_.filter` for arrays without support for
12948 * iteratee shorthands.
12949 *
12950 * @private
12951 * @param {Array} [array] The array to iterate over.
12952 * @param {Function} predicate The function invoked per iteration.
12953 * @returns {Array} Returns the new filtered array.
12954 */
12955 function arrayFilter(array, predicate) {
12956 var index = -1,
12957 length = array == null ? 0 : array.length,
12958 resIndex = 0,
12959 result = [];
12960
12961 while (++index < length) {
12962 var value = array[index];
12963 if (predicate(value, index, array)) {
12964 result[resIndex++] = value;
12965 }
12966 }
12967 return result;
12968 }
12969
12970 var _arrayFilter = arrayFilter;
12971
12972 /**
12973 * This method returns a new empty array.
12974 *
12975 * @static
12976 * @memberOf _
12977 * @since 4.13.0
12978 * @category Util
12979 * @returns {Array} Returns the new empty array.
12980 * @example
12981 *
12982 * var arrays = _.times(2, _.stubArray);
12983 *
12984 * console.log(arrays);
12985 * // => [[], []]
12986 *
12987 * console.log(arrays[0] === arrays[1]);
12988 * // => false
12989 */
12990 function stubArray() {
12991 return [];
12992 }
12993
12994 var stubArray_1 = stubArray;
12995
12996 /** Used for built-in method references. */
12997 var objectProto$b = Object.prototype;
12998
12999 /** Built-in value references. */
13000 var propertyIsEnumerable$1 = objectProto$b.propertyIsEnumerable;
13001
13002 /* Built-in method references for those with the same name as other `lodash` methods. */
13003 var nativeGetSymbols = Object.getOwnPropertySymbols;
13004
13005 /**
13006 * Creates an array of the own enumerable symbols of `object`.
13007 *
13008 * @private
13009 * @param {Object} object The object to query.
13010 * @returns {Array} Returns the array of symbols.
13011 */
13012 var getSymbols = !nativeGetSymbols ? stubArray_1 : function(object) {
13013 if (object == null) {
13014 return [];
13015 }
13016 object = Object(object);
13017 return _arrayFilter(nativeGetSymbols(object), function(symbol) {
13018 return propertyIsEnumerable$1.call(object, symbol);
13019 });
13020 };
13021
13022 var _getSymbols = getSymbols;
13023
13024 /**
13025 * Copies own symbols of `source` to `object`.
13026 *
13027 * @private
13028 * @param {Object} source The object to copy symbols from.
13029 * @param {Object} [object={}] The object to copy symbols to.
13030 * @returns {Object} Returns `object`.
13031 */
13032 function copySymbols(source, object) {
13033 return _copyObject(source, _getSymbols(source), object);
13034 }
13035
13036 var _copySymbols = copySymbols;
13037
13038 /**
13039 * Appends the elements of `values` to `array`.
13040 *
13041 * @private
13042 * @param {Array} array The array to modify.
13043 * @param {Array} values The values to append.
13044 * @returns {Array} Returns `array`.
13045 */
13046 function arrayPush(array, values) {
13047 var index = -1,
13048 length = values.length,
13049 offset = array.length;
13050
13051 while (++index < length) {
13052 array[offset + index] = values[index];
13053 }
13054 return array;
13055 }
13056
13057 var _arrayPush = arrayPush;
13058
13059 /** Built-in value references. */
13060 var getPrototype = _overArg(Object.getPrototypeOf, Object);
13061
13062 var _getPrototype = getPrototype;
13063
13064 /* Built-in method references for those with the same name as other `lodash` methods. */
13065 var nativeGetSymbols$1 = Object.getOwnPropertySymbols;
13066
13067 /**
13068 * Creates an array of the own and inherited enumerable symbols of `object`.
13069 *
13070 * @private
13071 * @param {Object} object The object to query.
13072 * @returns {Array} Returns the array of symbols.
13073 */
13074 var getSymbolsIn = !nativeGetSymbols$1 ? stubArray_1 : function(object) {
13075 var result = [];
13076 while (object) {
13077 _arrayPush(result, _getSymbols(object));
13078 object = _getPrototype(object);
13079 }
13080 return result;
13081 };
13082
13083 var _getSymbolsIn = getSymbolsIn;
13084
13085 /**
13086 * Copies own and inherited symbols of `source` to `object`.
13087 *
13088 * @private
13089 * @param {Object} source The object to copy symbols from.
13090 * @param {Object} [object={}] The object to copy symbols to.
13091 * @returns {Object} Returns `object`.
13092 */
13093 function copySymbolsIn(source, object) {
13094 return _copyObject(source, _getSymbolsIn(source), object);
13095 }
13096
13097 var _copySymbolsIn = copySymbolsIn;
13098
13099 /**
13100 * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
13101 * `keysFunc` and `symbolsFunc` to get the enumerable property names and
13102 * symbols of `object`.
13103 *
13104 * @private
13105 * @param {Object} object The object to query.
13106 * @param {Function} keysFunc The function to get the keys of `object`.
13107 * @param {Function} symbolsFunc The function to get the symbols of `object`.
13108 * @returns {Array} Returns the array of property names and symbols.
13109 */
13110 function baseGetAllKeys(object, keysFunc, symbolsFunc) {
13111 var result = keysFunc(object);
13112 return isArray_1(object) ? result : _arrayPush(result, symbolsFunc(object));
13113 }
13114
13115 var _baseGetAllKeys = baseGetAllKeys;
13116
13117 /**
13118 * Creates an array of own enumerable property names and symbols of `object`.
13119 *
13120 * @private
13121 * @param {Object} object The object to query.
13122 * @returns {Array} Returns the array of property names and symbols.
13123 */
13124 function getAllKeys(object) {
13125 return _baseGetAllKeys(object, keys_1, _getSymbols);
13126 }
13127
13128 var _getAllKeys = getAllKeys;
13129
13130 /**
13131 * Creates an array of own and inherited enumerable property names and
13132 * symbols of `object`.
13133 *
13134 * @private
13135 * @param {Object} object The object to query.
13136 * @returns {Array} Returns the array of property names and symbols.
13137 */
13138 function getAllKeysIn(object) {
13139 return _baseGetAllKeys(object, keysIn_1, _getSymbolsIn);
13140 }
13141
13142 var _getAllKeysIn = getAllKeysIn;
13143
13144 /* Built-in method references that are verified to be native. */
13145 var DataView = _getNative(_root, 'DataView');
13146
13147 var _DataView = DataView;
13148
13149 /* Built-in method references that are verified to be native. */
13150 var Promise$1 = _getNative(_root, 'Promise');
13151
13152 var _Promise = Promise$1;
13153
13154 /* Built-in method references that are verified to be native. */
13155 var Set$1 = _getNative(_root, 'Set');
13156
13157 var _Set = Set$1;
13158
13159 /* Built-in method references that are verified to be native. */
13160 var WeakMap = _getNative(_root, 'WeakMap');
13161
13162 var _WeakMap = WeakMap;
13163
13164 /** `Object#toString` result references. */
13165 var mapTag$1 = '[object Map]',
13166 objectTag$1 = '[object Object]',
13167 promiseTag = '[object Promise]',
13168 setTag$1 = '[object Set]',
13169 weakMapTag$1 = '[object WeakMap]';
13170
13171 var dataViewTag$1 = '[object DataView]';
13172
13173 /** Used to detect maps, sets, and weakmaps. */
13174 var dataViewCtorString = _toSource(_DataView),
13175 mapCtorString = _toSource(_Map),
13176 promiseCtorString = _toSource(_Promise),
13177 setCtorString = _toSource(_Set),
13178 weakMapCtorString = _toSource(_WeakMap);
13179
13180 /**
13181 * Gets the `toStringTag` of `value`.
13182 *
13183 * @private
13184 * @param {*} value The value to query.
13185 * @returns {string} Returns the `toStringTag`.
13186 */
13187 var getTag = _baseGetTag;
13188
13189 // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
13190 if ((_DataView && getTag(new _DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
13191 (_Map && getTag(new _Map) != mapTag$1) ||
13192 (_Promise && getTag(_Promise.resolve()) != promiseTag) ||
13193 (_Set && getTag(new _Set) != setTag$1) ||
13194 (_WeakMap && getTag(new _WeakMap) != weakMapTag$1)) {
13195 getTag = function(value) {
13196 var result = _baseGetTag(value),
13197 Ctor = result == objectTag$1 ? value.constructor : undefined,
13198 ctorString = Ctor ? _toSource(Ctor) : '';
13199
13200 if (ctorString) {
13201 switch (ctorString) {
13202 case dataViewCtorString: return dataViewTag$1;
13203 case mapCtorString: return mapTag$1;
13204 case promiseCtorString: return promiseTag;
13205 case setCtorString: return setTag$1;
13206 case weakMapCtorString: return weakMapTag$1;
13207 }
13208 }
13209 return result;
13210 };
13211 }
13212
13213 var _getTag = getTag;
13214
13215 /** Used for built-in method references. */
13216 var objectProto$c = Object.prototype;
13217
13218 /** Used to check objects for own properties. */
13219 var hasOwnProperty$a = objectProto$c.hasOwnProperty;
13220
13221 /**
13222 * Initializes an array clone.
13223 *
13224 * @private
13225 * @param {Array} array The array to clone.
13226 * @returns {Array} Returns the initialized clone.
13227 */
13228 function initCloneArray(array) {
13229 var length = array.length,
13230 result = new array.constructor(length);
13231
13232 // Add properties assigned by `RegExp#exec`.
13233 if (length && typeof array[0] == 'string' && hasOwnProperty$a.call(array, 'index')) {
13234 result.index = array.index;
13235 result.input = array.input;
13236 }
13237 return result;
13238 }
13239
13240 var _initCloneArray = initCloneArray;
13241
13242 /** Built-in value references. */
13243 var Uint8Array = _root.Uint8Array;
13244
13245 var _Uint8Array = Uint8Array;
13246
13247 /**
13248 * Creates a clone of `arrayBuffer`.
13249 *
13250 * @private
13251 * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
13252 * @returns {ArrayBuffer} Returns the cloned array buffer.
13253 */
13254 function cloneArrayBuffer(arrayBuffer) {
13255 var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
13256 new _Uint8Array(result).set(new _Uint8Array(arrayBuffer));
13257 return result;
13258 }
13259
13260 var _cloneArrayBuffer = cloneArrayBuffer;
13261
13262 /**
13263 * Creates a clone of `dataView`.
13264 *
13265 * @private
13266 * @param {Object} dataView The data view to clone.
13267 * @param {boolean} [isDeep] Specify a deep clone.
13268 * @returns {Object} Returns the cloned data view.
13269 */
13270 function cloneDataView(dataView, isDeep) {
13271 var buffer = isDeep ? _cloneArrayBuffer(dataView.buffer) : dataView.buffer;
13272 return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
13273 }
13274
13275 var _cloneDataView = cloneDataView;
13276
13277 /** Used to match `RegExp` flags from their coerced string values. */
13278 var reFlags = /\w*$/;
13279
13280 /**
13281 * Creates a clone of `regexp`.
13282 *
13283 * @private
13284 * @param {Object} regexp The regexp to clone.
13285 * @returns {Object} Returns the cloned regexp.
13286 */
13287 function cloneRegExp(regexp) {
13288 var result = new regexp.constructor(regexp.source, reFlags.exec(regexp));
13289 result.lastIndex = regexp.lastIndex;
13290 return result;
13291 }
13292
13293 var _cloneRegExp = cloneRegExp;
13294
13295 /** Used to convert symbols to primitives and strings. */
13296 var symbolProto = _Symbol ? _Symbol.prototype : undefined,
13297 symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
13298
13299 /**
13300 * Creates a clone of the `symbol` object.
13301 *
13302 * @private
13303 * @param {Object} symbol The symbol object to clone.
13304 * @returns {Object} Returns the cloned symbol object.
13305 */
13306 function cloneSymbol(symbol) {
13307 return symbolValueOf ? Object(symbolValueOf.call(symbol)) : {};
13308 }
13309
13310 var _cloneSymbol = cloneSymbol;
13311
13312 /**
13313 * Creates a clone of `typedArray`.
13314 *
13315 * @private
13316 * @param {Object} typedArray The typed array to clone.
13317 * @param {boolean} [isDeep] Specify a deep clone.
13318 * @returns {Object} Returns the cloned typed array.
13319 */
13320 function cloneTypedArray(typedArray, isDeep) {
13321 var buffer = isDeep ? _cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
13322 return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
13323 }
13324
13325 var _cloneTypedArray = cloneTypedArray;
13326
13327 /** `Object#toString` result references. */
13328 var boolTag$1 = '[object Boolean]',
13329 dateTag$1 = '[object Date]',
13330 mapTag$2 = '[object Map]',
13331 numberTag$1 = '[object Number]',
13332 regexpTag$1 = '[object RegExp]',
13333 setTag$2 = '[object Set]',
13334 stringTag$1 = '[object String]',
13335 symbolTag = '[object Symbol]';
13336
13337 var arrayBufferTag$1 = '[object ArrayBuffer]',
13338 dataViewTag$2 = '[object DataView]',
13339 float32Tag$1 = '[object Float32Array]',
13340 float64Tag$1 = '[object Float64Array]',
13341 int8Tag$1 = '[object Int8Array]',
13342 int16Tag$1 = '[object Int16Array]',
13343 int32Tag$1 = '[object Int32Array]',
13344 uint8Tag$1 = '[object Uint8Array]',
13345 uint8ClampedTag$1 = '[object Uint8ClampedArray]',
13346 uint16Tag$1 = '[object Uint16Array]',
13347 uint32Tag$1 = '[object Uint32Array]';
13348
13349 /**
13350 * Initializes an object clone based on its `toStringTag`.
13351 *
13352 * **Note:** This function only supports cloning values with tags of
13353 * `Boolean`, `Date`, `Error`, `Map`, `Number`, `RegExp`, `Set`, or `String`.
13354 *
13355 * @private
13356 * @param {Object} object The object to clone.
13357 * @param {string} tag The `toStringTag` of the object to clone.
13358 * @param {boolean} [isDeep] Specify a deep clone.
13359 * @returns {Object} Returns the initialized clone.
13360 */
13361 function initCloneByTag(object, tag, isDeep) {
13362 var Ctor = object.constructor;
13363 switch (tag) {
13364 case arrayBufferTag$1:
13365 return _cloneArrayBuffer(object);
13366
13367 case boolTag$1:
13368 case dateTag$1:
13369 return new Ctor(+object);
13370
13371 case dataViewTag$2:
13372 return _cloneDataView(object, isDeep);
13373
13374 case float32Tag$1: case float64Tag$1:
13375 case int8Tag$1: case int16Tag$1: case int32Tag$1:
13376 case uint8Tag$1: case uint8ClampedTag$1: case uint16Tag$1: case uint32Tag$1:
13377 return _cloneTypedArray(object, isDeep);
13378
13379 case mapTag$2:
13380 return new Ctor;
13381
13382 case numberTag$1:
13383 case stringTag$1:
13384 return new Ctor(object);
13385
13386 case regexpTag$1:
13387 return _cloneRegExp(object);
13388
13389 case setTag$2:
13390 return new Ctor;
13391
13392 case symbolTag:
13393 return _cloneSymbol(object);
13394 }
13395 }
13396
13397 var _initCloneByTag = initCloneByTag;
13398
13399 /** Built-in value references. */
13400 var objectCreate = Object.create;
13401
13402 /**
13403 * The base implementation of `_.create` without support for assigning
13404 * properties to the created object.
13405 *
13406 * @private
13407 * @param {Object} proto The object to inherit from.
13408 * @returns {Object} Returns the new object.
13409 */
13410 var baseCreate = (function() {
13411 function object() {}
13412 return function(proto) {
13413 if (!isObject_1(proto)) {
13414 return {};
13415 }
13416 if (objectCreate) {
13417 return objectCreate(proto);
13418 }
13419 object.prototype = proto;
13420 var result = new object;
13421 object.prototype = undefined;
13422 return result;
13423 };
13424 }());
13425
13426 var _baseCreate = baseCreate;
13427
13428 /**
13429 * Initializes an object clone.
13430 *
13431 * @private
13432 * @param {Object} object The object to clone.
13433 * @returns {Object} Returns the initialized clone.
13434 */
13435 function initCloneObject(object) {
13436 return (typeof object.constructor == 'function' && !_isPrototype(object))
13437 ? _baseCreate(_getPrototype(object))
13438 : {};
13439 }
13440
13441 var _initCloneObject = initCloneObject;
13442
13443 /** `Object#toString` result references. */
13444 var mapTag$3 = '[object Map]';
13445
13446 /**
13447 * The base implementation of `_.isMap` without Node.js optimizations.
13448 *
13449 * @private
13450 * @param {*} value The value to check.
13451 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13452 */
13453 function baseIsMap(value) {
13454 return isObjectLike_1(value) && _getTag(value) == mapTag$3;
13455 }
13456
13457 var _baseIsMap = baseIsMap;
13458
13459 /* Node.js helper references. */
13460 var nodeIsMap = _nodeUtil && _nodeUtil.isMap;
13461
13462 /**
13463 * Checks if `value` is classified as a `Map` object.
13464 *
13465 * @static
13466 * @memberOf _
13467 * @since 4.3.0
13468 * @category Lang
13469 * @param {*} value The value to check.
13470 * @returns {boolean} Returns `true` if `value` is a map, else `false`.
13471 * @example
13472 *
13473 * _.isMap(new Map);
13474 * // => true
13475 *
13476 * _.isMap(new WeakMap);
13477 * // => false
13478 */
13479 var isMap = nodeIsMap ? _baseUnary(nodeIsMap) : _baseIsMap;
13480
13481 var isMap_1 = isMap;
13482
13483 /** `Object#toString` result references. */
13484 var setTag$3 = '[object Set]';
13485
13486 /**
13487 * The base implementation of `_.isSet` without Node.js optimizations.
13488 *
13489 * @private
13490 * @param {*} value The value to check.
13491 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13492 */
13493 function baseIsSet(value) {
13494 return isObjectLike_1(value) && _getTag(value) == setTag$3;
13495 }
13496
13497 var _baseIsSet = baseIsSet;
13498
13499 /* Node.js helper references. */
13500 var nodeIsSet = _nodeUtil && _nodeUtil.isSet;
13501
13502 /**
13503 * Checks if `value` is classified as a `Set` object.
13504 *
13505 * @static
13506 * @memberOf _
13507 * @since 4.3.0
13508 * @category Lang
13509 * @param {*} value The value to check.
13510 * @returns {boolean} Returns `true` if `value` is a set, else `false`.
13511 * @example
13512 *
13513 * _.isSet(new Set);
13514 * // => true
13515 *
13516 * _.isSet(new WeakSet);
13517 * // => false
13518 */
13519 var isSet = nodeIsSet ? _baseUnary(nodeIsSet) : _baseIsSet;
13520
13521 var isSet_1 = isSet;
13522
13523 /** Used to compose bitmasks for cloning. */
13524 var CLONE_DEEP_FLAG = 1,
13525 CLONE_FLAT_FLAG = 2,
13526 CLONE_SYMBOLS_FLAG = 4;
13527
13528 /** `Object#toString` result references. */
13529 var argsTag$2 = '[object Arguments]',
13530 arrayTag$1 = '[object Array]',
13531 boolTag$2 = '[object Boolean]',
13532 dateTag$2 = '[object Date]',
13533 errorTag$1 = '[object Error]',
13534 funcTag$2 = '[object Function]',
13535 genTag$1 = '[object GeneratorFunction]',
13536 mapTag$4 = '[object Map]',
13537 numberTag$2 = '[object Number]',
13538 objectTag$2 = '[object Object]',
13539 regexpTag$2 = '[object RegExp]',
13540 setTag$4 = '[object Set]',
13541 stringTag$2 = '[object String]',
13542 symbolTag$1 = '[object Symbol]',
13543 weakMapTag$2 = '[object WeakMap]';
13544
13545 var arrayBufferTag$2 = '[object ArrayBuffer]',
13546 dataViewTag$3 = '[object DataView]',
13547 float32Tag$2 = '[object Float32Array]',
13548 float64Tag$2 = '[object Float64Array]',
13549 int8Tag$2 = '[object Int8Array]',
13550 int16Tag$2 = '[object Int16Array]',
13551 int32Tag$2 = '[object Int32Array]',
13552 uint8Tag$2 = '[object Uint8Array]',
13553 uint8ClampedTag$2 = '[object Uint8ClampedArray]',
13554 uint16Tag$2 = '[object Uint16Array]',
13555 uint32Tag$2 = '[object Uint32Array]';
13556
13557 /** Used to identify `toStringTag` values supported by `_.clone`. */
13558 var cloneableTags = {};
13559 cloneableTags[argsTag$2] = cloneableTags[arrayTag$1] =
13560 cloneableTags[arrayBufferTag$2] = cloneableTags[dataViewTag$3] =
13561 cloneableTags[boolTag$2] = cloneableTags[dateTag$2] =
13562 cloneableTags[float32Tag$2] = cloneableTags[float64Tag$2] =
13563 cloneableTags[int8Tag$2] = cloneableTags[int16Tag$2] =
13564 cloneableTags[int32Tag$2] = cloneableTags[mapTag$4] =
13565 cloneableTags[numberTag$2] = cloneableTags[objectTag$2] =
13566 cloneableTags[regexpTag$2] = cloneableTags[setTag$4] =
13567 cloneableTags[stringTag$2] = cloneableTags[symbolTag$1] =
13568 cloneableTags[uint8Tag$2] = cloneableTags[uint8ClampedTag$2] =
13569 cloneableTags[uint16Tag$2] = cloneableTags[uint32Tag$2] = true;
13570 cloneableTags[errorTag$1] = cloneableTags[funcTag$2] =
13571 cloneableTags[weakMapTag$2] = false;
13572
13573 /**
13574 * The base implementation of `_.clone` and `_.cloneDeep` which tracks
13575 * traversed objects.
13576 *
13577 * @private
13578 * @param {*} value The value to clone.
13579 * @param {boolean} bitmask The bitmask flags.
13580 * 1 - Deep clone
13581 * 2 - Flatten inherited properties
13582 * 4 - Clone symbols
13583 * @param {Function} [customizer] The function to customize cloning.
13584 * @param {string} [key] The key of `value`.
13585 * @param {Object} [object] The parent object of `value`.
13586 * @param {Object} [stack] Tracks traversed objects and their clone counterparts.
13587 * @returns {*} Returns the cloned value.
13588 */
13589 function baseClone(value, bitmask, customizer, key, object, stack) {
13590 var result,
13591 isDeep = bitmask & CLONE_DEEP_FLAG,
13592 isFlat = bitmask & CLONE_FLAT_FLAG,
13593 isFull = bitmask & CLONE_SYMBOLS_FLAG;
13594
13595 if (customizer) {
13596 result = object ? customizer(value, key, object, stack) : customizer(value);
13597 }
13598 if (result !== undefined) {
13599 return result;
13600 }
13601 if (!isObject_1(value)) {
13602 return value;
13603 }
13604 var isArr = isArray_1(value);
13605 if (isArr) {
13606 result = _initCloneArray(value);
13607 if (!isDeep) {
13608 return _copyArray(value, result);
13609 }
13610 } else {
13611 var tag = _getTag(value),
13612 isFunc = tag == funcTag$2 || tag == genTag$1;
13613
13614 if (isBuffer_1$1(value)) {
13615 return _cloneBuffer(value, isDeep);
13616 }
13617 if (tag == objectTag$2 || tag == argsTag$2 || (isFunc && !object)) {
13618 result = (isFlat || isFunc) ? {} : _initCloneObject(value);
13619 if (!isDeep) {
13620 return isFlat
13621 ? _copySymbolsIn(value, _baseAssignIn(result, value))
13622 : _copySymbols(value, _baseAssign(result, value));
13623 }
13624 } else {
13625 if (!cloneableTags[tag]) {
13626 return object ? value : {};
13627 }
13628 result = _initCloneByTag(value, tag, isDeep);
13629 }
13630 }
13631 // Check for circular references and return its corresponding clone.
13632 stack || (stack = new _Stack);
13633 var stacked = stack.get(value);
13634 if (stacked) {
13635 return stacked;
13636 }
13637 stack.set(value, result);
13638
13639 if (isSet_1(value)) {
13640 value.forEach(function(subValue) {
13641 result.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
13642 });
13643 } else if (isMap_1(value)) {
13644 value.forEach(function(subValue, key) {
13645 result.set(key, baseClone(subValue, bitmask, customizer, key, value, stack));
13646 });
13647 }
13648
13649 var keysFunc = isFull
13650 ? (isFlat ? _getAllKeysIn : _getAllKeys)
13651 : (isFlat ? keysIn : keys_1);
13652
13653 var props = isArr ? undefined : keysFunc(value);
13654 _arrayEach(props || value, function(subValue, key) {
13655 if (props) {
13656 key = subValue;
13657 subValue = value[key];
13658 }
13659 // Recursively populate clone (susceptible to call stack limits).
13660 _assignValue(result, key, baseClone(subValue, bitmask, customizer, key, value, stack));
13661 });
13662 return result;
13663 }
13664
13665 var _baseClone = baseClone;
13666
13667 /** Used to compose bitmasks for cloning. */
13668 var CLONE_DEEP_FLAG$1 = 1,
13669 CLONE_SYMBOLS_FLAG$1 = 4;
13670
13671 /**
13672 * This method is like `_.clone` except that it recursively clones `value`.
13673 *
13674 * @static
13675 * @memberOf _
13676 * @since 1.0.0
13677 * @category Lang
13678 * @param {*} value The value to recursively clone.
13679 * @returns {*} Returns the deep cloned value.
13680 * @see _.clone
13681 * @example
13682 *
13683 * var objects = [{ 'a': 1 }, { 'b': 2 }];
13684 *
13685 * var deep = _.cloneDeep(objects);
13686 * console.log(deep[0] === objects[0]);
13687 * // => false
13688 */
13689 function cloneDeep(value) {
13690 return _baseClone(value, CLONE_DEEP_FLAG$1 | CLONE_SYMBOLS_FLAG$1);
13691 }
13692
13693 var cloneDeep_1 = cloneDeep;
13694
13695 //
13696
13697 function createLocalVue(_Vue) {
13698 if ( _Vue === void 0 ) _Vue = Vue;
13699
13700 var instance = _Vue.extend();
13701
13702 // clone global APIs
13703 Object.keys(_Vue).forEach(function (key) {
13704 if (!instance.hasOwnProperty(key)) {
13705 var original = _Vue[key];
13706 // cloneDeep can fail when cloning Vue instances
13707 // cloneDeep checks that the instance has a Symbol
13708 // which errors in Vue < 2.17 (https://github.com/vuejs/vue/pull/7878)
13709 try {
13710 instance[key] =
13711 typeof original === 'object' ? cloneDeep_1(original) : original;
13712 } catch (e) {
13713 instance[key] = original;
13714 }
13715 }
13716 });
13717
13718 // config is not enumerable
13719 instance.config = cloneDeep_1(Vue.config);
13720
13721 instance.config.errorHandler = Vue.config.errorHandler;
13722
13723 // option merge strategies need to be exposed by reference
13724 // so that merge strats registered by plugins can work properly
13725 instance.config.optionMergeStrategies = Vue.config.optionMergeStrategies;
13726
13727 // make sure all extends are based on this instance.
13728 // this is important so that global components registered by plugins,
13729 // e.g. router-link are created using the correct base constructor
13730 instance.options._base = instance;
13731
13732 // compat for vue-router < 2.7.1 where it does not allow multiple installs
13733 if (instance._installedPlugins && instance._installedPlugins.length) {
13734 instance._installedPlugins.length = 0;
13735 }
13736 var use = instance.use;
13737 instance.use = function (plugin) {
13738 var rest = [], len = arguments.length - 1;
13739 while ( len-- > 0 ) rest[ len ] = arguments[ len + 1 ];
13740
13741 if (plugin.installed === true) {
13742 plugin.installed = false;
13743 }
13744 if (plugin.install && plugin.install.installed === true) {
13745 plugin.install.installed = false;
13746 }
13747 use.call.apply(use, [ instance, plugin ].concat( rest ));
13748 };
13749 return instance
13750 }
13751
13752 //
13753
13754 function isValidSlot(slot) {
13755 return isVueComponent(slot) || typeof slot === 'string'
13756 }
13757
13758 function requiresTemplateCompiler(slot) {
13759 if (typeof slot === 'string' && !vueTemplateCompiler.compileToFunctions) {
13760 throwError(
13761 "vueTemplateCompiler is undefined, you must pass " +
13762 "precompiled components if vue-template-compiler is " +
13763 "undefined"
13764 );
13765 }
13766 }
13767
13768 function validateSlots(slots) {
13769 Object.keys(slots).forEach(function (key) {
13770 var slot = Array.isArray(slots[key]) ? slots[key] : [slots[key]];
13771
13772 slot.forEach(function (slotValue) {
13773 if (!isValidSlot(slotValue)) {
13774 throwError(
13775 "slots[key] must be a Component, string or an array " +
13776 "of Components"
13777 );
13778 }
13779 requiresTemplateCompiler(slotValue);
13780 });
13781 });
13782 }
13783
13784 function vueExtendUnsupportedOption(option) {
13785 return (
13786 "options." + option + " is not supported for " +
13787 "components created with Vue.extend in Vue < 2.3. " +
13788 "You can set " + option + " to false to mount the component."
13789 )
13790 }
13791 // these options aren't supported if Vue is version < 2.3
13792 // for components using Vue.extend. This is due to a bug
13793 // that means the mixins we use to add properties are not applied
13794 // correctly
13795 var UNSUPPORTED_VERSION_OPTIONS = ['mocks', 'stubs', 'localVue'];
13796
13797 function validateOptions(options, component) {
13798 if (
13799 options.attachTo &&
13800 !isHTMLElement(options.attachTo) &&
13801 !isDomSelector(options.attachTo)
13802 ) {
13803 throwError(
13804 "options.attachTo should be a valid HTMLElement or CSS selector string"
13805 );
13806 }
13807 if ('attachToDocument' in options) {
13808 warnDeprecated(
13809 "options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release"
13810 );
13811 }
13812 if (options.parentComponent && !isPlainObject(options.parentComponent)) {
13813 throwError(
13814 "options.parentComponent should be a valid Vue component options object"
13815 );
13816 }
13817
13818 if (!isFunctionalComponent(component) && options.context) {
13819 throwError(
13820 "mount.context can only be used when mounting a functional component"
13821 );
13822 }
13823
13824 if (options.context && !isPlainObject(options.context)) {
13825 throwError('mount.context must be an object');
13826 }
13827
13828 if (VUE_VERSION < 2.3 && isConstructor(component)) {
13829 UNSUPPORTED_VERSION_OPTIONS.forEach(function (option) {
13830 if (options[option]) {
13831 throwError(vueExtendUnsupportedOption(option));
13832 }
13833 });
13834 }
13835
13836 if (options.slots) {
13837 compileTemplateForSlots(options.slots);
13838 // validate slots outside of the createSlots function so
13839 // that we can throw an error without it being caught by
13840 // the Vue error handler
13841 // $FlowIgnore
13842 validateSlots(options.slots);
13843 }
13844 }
13845
13846 Vue.config.productionTip = false;
13847 Vue.config.devtools = false;
13848
13849 function mount(component, options) {
13850 if ( options === void 0 ) options = {};
13851
13852 warnIfNoWindow();
13853
13854 polyfill();
13855
13856 addGlobalErrorHandler(Vue);
13857
13858 var _Vue = createLocalVue(options.localVue);
13859
13860 var mergedOptions = mergeOptions(options, config);
13861
13862 validateOptions(mergedOptions, component);
13863
13864 var parentVm = createInstance(component, mergedOptions, _Vue);
13865
13866 var el =
13867 options.attachTo || (options.attachToDocument ? createElement() : undefined);
13868 var vm = parentVm.$mount(el);
13869
13870 component._Ctor = {};
13871
13872 throwIfInstancesThrew(vm);
13873
13874 var wrapperOptions = {
13875 attachedToDocument: !!el
13876 };
13877
13878 var root = parentVm.$options._isFunctionalContainer
13879 ? vm._vnode
13880 : vm.$children[0];
13881
13882 return createWrapper(root, wrapperOptions)
13883 }
13884
13885 //
13886
13887
13888 function shallowMount(
13889 component,
13890 options
13891 ) {
13892 if ( options === void 0 ) options = {};
13893
13894 return mount(component, Object.assign({}, options,
13895 {shouldProxy: true}))
13896 }
13897
13898 //
13899 var toTypes = [String, Object];
13900 var eventTypes = [String, Array];
13901
13902 var RouterLinkStub = {
13903 name: 'RouterLinkStub',
13904 props: {
13905 to: {
13906 type: toTypes,
13907 required: true
13908 },
13909 tag: {
13910 type: String,
13911 default: 'a'
13912 },
13913 exact: Boolean,
13914 append: Boolean,
13915 replace: Boolean,
13916 activeClass: String,
13917 exactActiveClass: String,
13918 event: {
13919 type: eventTypes,
13920 default: 'click'
13921 }
13922 },
13923 render: function render(h) {
13924 return h(this.tag, undefined, this.$slots.default)
13925 }
13926 };
13927
13928 function shallow(component, options) {
13929 warn(
13930 "shallow has been renamed to shallowMount. shallow " +
13931 "will be removed in 1.0.0, use shallowMount instead"
13932 );
13933 return shallowMount(component, options)
13934 }
13935
13936 exports.RouterLinkStub = RouterLinkStub;
13937 exports.Wrapper = Wrapper;
13938 exports.WrapperArray = WrapperArray;
13939 exports.config = config;
13940 exports.createLocalVue = createLocalVue;
13941 exports.createWrapper = createWrapper;
13942 exports.enableAutoDestroy = enableAutoDestroy;
13943 exports.mount = mount;
13944 exports.resetAutoDestroyState = resetAutoDestroyState;
13945 exports.shallow = shallow;
13946 exports.shallowMount = shallowMount;
13947
13948 Object.defineProperty(exports, '__esModule', { value: true });
13949
13950})));