Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
YUI.add('moodle-atto_html-beautify', function (Y, NAME) {
2
 
3
// JSBeautify adds itself to the exports object if one exists.
4
// Define exports here and it will work as if by magic.
5
// This is safe to put in a function and will not be exported to the global
6
// namespace. Note, we'll have to remove this when YUI supports, and we move to ES6.
7
var exports = {};
8
 
9
var define = null; // Remove require.js support in this context.
10
 
11
// JSBeautify calls require() in order to get the existing exported modules.
12
var require = function() {
13
    return exports;
14
};
15
require();
16
 
17
// Actually define beautify in our namespace.
18
Y.namespace('M.atto_html').beautify = exports;
19
/* AUTO-GENERATED. DO NOT MODIFY. */
20
/*
21
 
22
  The MIT License (MIT)
23
 
24
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
25
 
26
  Permission is hereby granted, free of charge, to any person
27
  obtaining a copy of this software and associated documentation files
28
  (the "Software"), to deal in the Software without restriction,
29
  including without limitation the rights to use, copy, modify, merge,
30
  publish, distribute, sublicense, and/or sell copies of the Software,
31
  and to permit persons to whom the Software is furnished to do so,
32
  subject to the following conditions:
33
 
34
  The above copyright notice and this permission notice shall be
35
  included in all copies or substantial portions of the Software.
36
 
37
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
41
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
42
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
43
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
44
  SOFTWARE.
45
 
46
 JS Beautifier
47
---------------
48
 
49
 
50
  Written by Einar Lielmanis, <einar@beautifier.io>
51
      https://beautifier.io/
52
 
53
  Originally converted to javascript by Vital, <vital76@gmail.com>
54
  "End braces on own line" added by Chris J. Shull, <chrisjshull@gmail.com>
55
  Parsing improvements for brace-less statements by Liam Newman <bitwiseman@beautifier.io>
56
 
57
 
58
  Usage:
59
    js_beautify(js_source_text);
60
    js_beautify(js_source_text, options);
61
 
62
  The options are:
63
    indent_size (default 4)          - indentation size,
64
    indent_char (default space)      - character to indent with,
65
    preserve_newlines (default true) - whether existing line breaks should be preserved,
66
    max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk,
67
 
68
    jslint_happy (default false) - if true, then jslint-stricter mode is enforced.
69
 
70
            jslint_happy        !jslint_happy
71
            ---------------------------------
72
            function ()         function()
73
 
74
            switch () {         switch() {
75
            case 1:               case 1:
76
              break;                break;
77
            }                   }
78
 
79
    space_after_anon_function (default false) - should the space before an anonymous function's parens be added, "function()" vs "function ()",
80
          NOTE: This option is overridden by jslint_happy (i.e. if jslint_happy is true, space_after_anon_function is true by design)
81
 
82
    brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none" | any of the former + ",preserve-inline"
83
            put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
84
            preserve-inline will try to preserve inline blocks of curly braces
85
 
86
    space_before_conditional (default true) - should the space before conditional statement be added, "if(true)" vs "if (true)",
87
 
88
    unescape_strings (default false) - should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65"
89
 
90
    wrap_line_length (default unlimited) - lines should wrap at next opportunity after this number of characters.
91
          NOTE: This is not a hard limit. Lines will continue until a point where a newline would
92
                be preserved if it were present.
93
 
94
    end_with_newline (default false)  - end output with a newline
95
 
96
 
97
    e.g
98
 
99
    js_beautify(js_source_text, {
100
      'indent_size': 1,
101
      'indent_char': '\t'
102
    });
103
 
104
*/
105
 
106
(function() {
107
 
108
/* GENERATED_BUILD_OUTPUT */
109
var legacy_beautify_js;
110
/******/ (function() { // webpackBootstrap
111
/******/ 	"use strict";
112
/******/ 	var __webpack_modules__ = ([
113
/* 0 */
114
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
115
 
116
/*jshint node:true */
117
/*
118
 
119
  The MIT License (MIT)
120
 
121
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
122
 
123
  Permission is hereby granted, free of charge, to any person
124
  obtaining a copy of this software and associated documentation files
125
  (the "Software"), to deal in the Software without restriction,
126
  including without limitation the rights to use, copy, modify, merge,
127
  publish, distribute, sublicense, and/or sell copies of the Software,
128
  and to permit persons to whom the Software is furnished to do so,
129
  subject to the following conditions:
130
 
131
  The above copyright notice and this permission notice shall be
132
  included in all copies or substantial portions of the Software.
133
 
134
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
135
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
136
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
137
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
138
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
139
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
140
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
141
  SOFTWARE.
142
*/
143
 
144
 
145
 
146
var Beautifier = (__webpack_require__(1).Beautifier),
147
  Options = (__webpack_require__(5).Options);
148
 
149
function js_beautify(js_source_text, options) {
150
  var beautifier = new Beautifier(js_source_text, options);
151
  return beautifier.beautify();
152
}
153
 
154
module.exports = js_beautify;
155
module.exports.defaultOptions = function() {
156
  return new Options();
157
};
158
 
159
 
160
/***/ }),
161
/* 1 */
162
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
163
 
164
/*jshint node:true */
165
/*
166
 
167
  The MIT License (MIT)
168
 
169
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
170
 
171
  Permission is hereby granted, free of charge, to any person
172
  obtaining a copy of this software and associated documentation files
173
  (the "Software"), to deal in the Software without restriction,
174
  including without limitation the rights to use, copy, modify, merge,
175
  publish, distribute, sublicense, and/or sell copies of the Software,
176
  and to permit persons to whom the Software is furnished to do so,
177
  subject to the following conditions:
178
 
179
  The above copyright notice and this permission notice shall be
180
  included in all copies or substantial portions of the Software.
181
 
182
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
183
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
184
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
185
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
186
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
187
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
188
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
189
  SOFTWARE.
190
*/
191
 
192
 
193
 
194
var Output = (__webpack_require__(2).Output);
195
var Token = (__webpack_require__(3).Token);
196
var acorn = __webpack_require__(4);
197
var Options = (__webpack_require__(5).Options);
198
var Tokenizer = (__webpack_require__(7).Tokenizer);
199
var line_starters = (__webpack_require__(7).line_starters);
200
var positionable_operators = (__webpack_require__(7).positionable_operators);
201
var TOKEN = (__webpack_require__(7).TOKEN);
202
 
203
 
204
function in_array(what, arr) {
205
  return arr.indexOf(what) !== -1;
206
}
207
 
208
function ltrim(s) {
209
  return s.replace(/^\s+/g, '');
210
}
211
 
212
function generateMapFromStrings(list) {
213
  var result = {};
214
  for (var x = 0; x < list.length; x++) {
215
    // make the mapped names underscored instead of dash
216
    result[list[x].replace(/-/g, '_')] = list[x];
217
  }
218
  return result;
219
}
220
 
221
function reserved_word(token, word) {
222
  return token && token.type === TOKEN.RESERVED && token.text === word;
223
}
224
 
225
function reserved_array(token, words) {
226
  return token && token.type === TOKEN.RESERVED && in_array(token.text, words);
227
}
228
// Unsure of what they mean, but they work. Worth cleaning up in future.
229
var special_words = ['case', 'return', 'do', 'if', 'throw', 'else', 'await', 'break', 'continue', 'async'];
230
 
231
var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
232
 
233
// Generate map from array
234
var OPERATOR_POSITION = generateMapFromStrings(validPositionValues);
235
 
236
var OPERATOR_POSITION_BEFORE_OR_PRESERVE = [OPERATOR_POSITION.before_newline, OPERATOR_POSITION.preserve_newline];
237
 
238
var MODE = {
239
  BlockStatement: 'BlockStatement', // 'BLOCK'
240
  Statement: 'Statement', // 'STATEMENT'
241
  ObjectLiteral: 'ObjectLiteral', // 'OBJECT',
242
  ArrayLiteral: 'ArrayLiteral', //'[EXPRESSION]',
243
  ForInitializer: 'ForInitializer', //'(FOR-EXPRESSION)',
244
  Conditional: 'Conditional', //'(COND-EXPRESSION)',
245
  Expression: 'Expression' //'(EXPRESSION)'
246
};
247
 
248
function remove_redundant_indentation(output, frame) {
249
  // This implementation is effective but has some issues:
250
  //     - can cause line wrap to happen too soon due to indent removal
251
  //           after wrap points are calculated
252
  // These issues are minor compared to ugly indentation.
253
 
254
  if (frame.multiline_frame ||
255
    frame.mode === MODE.ForInitializer ||
256
    frame.mode === MODE.Conditional) {
257
    return;
258
  }
259
 
260
  // remove one indent from each line inside this section
261
  output.remove_indent(frame.start_line_index);
262
}
263
 
264
// we could use just string.split, but
265
// IE doesn't like returning empty strings
266
function split_linebreaks(s) {
267
  //return s.split(/\x0d\x0a|\x0a/);
268
 
269
  s = s.replace(acorn.allLineBreaks, '\n');
270
  var out = [],
271
    idx = s.indexOf("\n");
272
  while (idx !== -1) {
273
    out.push(s.substring(0, idx));
274
    s = s.substring(idx + 1);
275
    idx = s.indexOf("\n");
276
  }
277
  if (s.length) {
278
    out.push(s);
279
  }
280
  return out;
281
}
282
 
283
function is_array(mode) {
284
  return mode === MODE.ArrayLiteral;
285
}
286
 
287
function is_expression(mode) {
288
  return in_array(mode, [MODE.Expression, MODE.ForInitializer, MODE.Conditional]);
289
}
290
 
291
function all_lines_start_with(lines, c) {
292
  for (var i = 0; i < lines.length; i++) {
293
    var line = lines[i].trim();
294
    if (line.charAt(0) !== c) {
295
      return false;
296
    }
297
  }
298
  return true;
299
}
300
 
301
function each_line_matches_indent(lines, indent) {
302
  var i = 0,
303
    len = lines.length,
304
    line;
305
  for (; i < len; i++) {
306
    line = lines[i];
307
    // allow empty lines to pass through
308
    if (line && line.indexOf(indent) !== 0) {
309
      return false;
310
    }
311
  }
312
  return true;
313
}
314
 
315
 
316
function Beautifier(source_text, options) {
317
  options = options || {};
318
  this._source_text = source_text || '';
319
 
320
  this._output = null;
321
  this._tokens = null;
322
  this._last_last_text = null;
323
  this._flags = null;
324
  this._previous_flags = null;
325
 
326
  this._flag_store = null;
327
  this._options = new Options(options);
328
}
329
 
330
Beautifier.prototype.create_flags = function(flags_base, mode) {
331
  var next_indent_level = 0;
332
  if (flags_base) {
333
    next_indent_level = flags_base.indentation_level;
334
    if (!this._output.just_added_newline() &&
335
      flags_base.line_indent_level > next_indent_level) {
336
      next_indent_level = flags_base.line_indent_level;
337
    }
338
  }
339
 
340
  var next_flags = {
341
    mode: mode,
342
    parent: flags_base,
343
    last_token: flags_base ? flags_base.last_token : new Token(TOKEN.START_BLOCK, ''), // last token text
344
    last_word: flags_base ? flags_base.last_word : '', // last TOKEN.WORD passed
345
    declaration_statement: false,
346
    declaration_assignment: false,
347
    multiline_frame: false,
348
    inline_frame: false,
349
    if_block: false,
350
    else_block: false,
351
    class_start_block: false, // class A { INSIDE HERE } or class B extends C { INSIDE HERE }
352
    do_block: false,
353
    do_while: false,
354
    import_block: false,
355
    in_case_statement: false, // switch(..){ INSIDE HERE }
356
    in_case: false, // we're on the exact line with "case 0:"
357
    case_body: false, // the indented case-action block
358
    case_block: false, // the indented case-action block is wrapped with {}
359
    indentation_level: next_indent_level,
360
    alignment: 0,
361
    line_indent_level: flags_base ? flags_base.line_indent_level : next_indent_level,
362
    start_line_index: this._output.get_line_number(),
363
    ternary_depth: 0
364
  };
365
  return next_flags;
366
};
367
 
368
Beautifier.prototype._reset = function(source_text) {
369
  var baseIndentString = source_text.match(/^[\t ]*/)[0];
370
 
371
  this._last_last_text = ''; // pre-last token text
372
  this._output = new Output(this._options, baseIndentString);
373
 
374
  // If testing the ignore directive, start with output disable set to true
375
  this._output.raw = this._options.test_output_raw;
376
 
377
 
378
  // Stack of parsing/formatting states, including MODE.
379
  // We tokenize, parse, and output in an almost purely a forward-only stream of token input
380
  // and formatted output.  This makes the beautifier less accurate than full parsers
381
  // but also far more tolerant of syntax errors.
382
  //
383
  // For example, the default mode is MODE.BlockStatement. If we see a '{' we push a new frame of type
384
  // MODE.BlockStatement on the the stack, even though it could be object literal.  If we later
385
  // encounter a ":", we'll switch to to MODE.ObjectLiteral.  If we then see a ";",
386
  // most full parsers would die, but the beautifier gracefully falls back to
387
  // MODE.BlockStatement and continues on.
388
  this._flag_store = [];
389
  this.set_mode(MODE.BlockStatement);
390
  var tokenizer = new Tokenizer(source_text, this._options);
391
  this._tokens = tokenizer.tokenize();
392
  return source_text;
393
};
394
 
395
Beautifier.prototype.beautify = function() {
396
  // if disabled, return the input unchanged.
397
  if (this._options.disabled) {
398
    return this._source_text;
399
  }
400
 
401
  var sweet_code;
402
  var source_text = this._reset(this._source_text);
403
 
404
  var eol = this._options.eol;
405
  if (this._options.eol === 'auto') {
406
    eol = '\n';
407
    if (source_text && acorn.lineBreak.test(source_text || '')) {
408
      eol = source_text.match(acorn.lineBreak)[0];
409
    }
410
  }
411
 
412
  var current_token = this._tokens.next();
413
  while (current_token) {
414
    this.handle_token(current_token);
415
 
416
    this._last_last_text = this._flags.last_token.text;
417
    this._flags.last_token = current_token;
418
 
419
    current_token = this._tokens.next();
420
  }
421
 
422
  sweet_code = this._output.get_code(eol);
423
 
424
  return sweet_code;
425
};
426
 
427
Beautifier.prototype.handle_token = function(current_token, preserve_statement_flags) {
428
  if (current_token.type === TOKEN.START_EXPR) {
429
    this.handle_start_expr(current_token);
430
  } else if (current_token.type === TOKEN.END_EXPR) {
431
    this.handle_end_expr(current_token);
432
  } else if (current_token.type === TOKEN.START_BLOCK) {
433
    this.handle_start_block(current_token);
434
  } else if (current_token.type === TOKEN.END_BLOCK) {
435
    this.handle_end_block(current_token);
436
  } else if (current_token.type === TOKEN.WORD) {
437
    this.handle_word(current_token);
438
  } else if (current_token.type === TOKEN.RESERVED) {
439
    this.handle_word(current_token);
440
  } else if (current_token.type === TOKEN.SEMICOLON) {
441
    this.handle_semicolon(current_token);
442
  } else if (current_token.type === TOKEN.STRING) {
443
    this.handle_string(current_token);
444
  } else if (current_token.type === TOKEN.EQUALS) {
445
    this.handle_equals(current_token);
446
  } else if (current_token.type === TOKEN.OPERATOR) {
447
    this.handle_operator(current_token);
448
  } else if (current_token.type === TOKEN.COMMA) {
449
    this.handle_comma(current_token);
450
  } else if (current_token.type === TOKEN.BLOCK_COMMENT) {
451
    this.handle_block_comment(current_token, preserve_statement_flags);
452
  } else if (current_token.type === TOKEN.COMMENT) {
453
    this.handle_comment(current_token, preserve_statement_flags);
454
  } else if (current_token.type === TOKEN.DOT) {
455
    this.handle_dot(current_token);
456
  } else if (current_token.type === TOKEN.EOF) {
457
    this.handle_eof(current_token);
458
  } else if (current_token.type === TOKEN.UNKNOWN) {
459
    this.handle_unknown(current_token, preserve_statement_flags);
460
  } else {
461
    this.handle_unknown(current_token, preserve_statement_flags);
462
  }
463
};
464
 
465
Beautifier.prototype.handle_whitespace_and_comments = function(current_token, preserve_statement_flags) {
466
  var newlines = current_token.newlines;
467
  var keep_whitespace = this._options.keep_array_indentation && is_array(this._flags.mode);
468
 
469
  if (current_token.comments_before) {
470
    var comment_token = current_token.comments_before.next();
471
    while (comment_token) {
472
      // The cleanest handling of inline comments is to treat them as though they aren't there.
473
      // Just continue formatting and the behavior should be logical.
474
      // Also ignore unknown tokens.  Again, this should result in better behavior.
475
      this.handle_whitespace_and_comments(comment_token, preserve_statement_flags);
476
      this.handle_token(comment_token, preserve_statement_flags);
477
      comment_token = current_token.comments_before.next();
478
    }
479
  }
480
 
481
  if (keep_whitespace) {
482
    for (var i = 0; i < newlines; i += 1) {
483
      this.print_newline(i > 0, preserve_statement_flags);
484
    }
485
  } else {
486
    if (this._options.max_preserve_newlines && newlines > this._options.max_preserve_newlines) {
487
      newlines = this._options.max_preserve_newlines;
488
    }
489
 
490
    if (this._options.preserve_newlines) {
491
      if (newlines > 1) {
492
        this.print_newline(false, preserve_statement_flags);
493
        for (var j = 1; j < newlines; j += 1) {
494
          this.print_newline(true, preserve_statement_flags);
495
        }
496
      }
497
    }
498
  }
499
 
500
};
501
 
502
var newline_restricted_tokens = ['async', 'break', 'continue', 'return', 'throw', 'yield'];
503
 
504
Beautifier.prototype.allow_wrap_or_preserved_newline = function(current_token, force_linewrap) {
505
  force_linewrap = (force_linewrap === undefined) ? false : force_linewrap;
506
 
507
  // Never wrap the first token on a line
508
  if (this._output.just_added_newline()) {
509
    return;
510
  }
511
 
512
  var shouldPreserveOrForce = (this._options.preserve_newlines && current_token.newlines) || force_linewrap;
513
  var operatorLogicApplies = in_array(this._flags.last_token.text, positionable_operators) ||
514
    in_array(current_token.text, positionable_operators);
515
 
516
  if (operatorLogicApplies) {
517
    var shouldPrintOperatorNewline = (
518
        in_array(this._flags.last_token.text, positionable_operators) &&
519
        in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)
520
      ) ||
521
      in_array(current_token.text, positionable_operators);
522
    shouldPreserveOrForce = shouldPreserveOrForce && shouldPrintOperatorNewline;
523
  }
524
 
525
  if (shouldPreserveOrForce) {
526
    this.print_newline(false, true);
527
  } else if (this._options.wrap_line_length) {
528
    if (reserved_array(this._flags.last_token, newline_restricted_tokens)) {
529
      // These tokens should never have a newline inserted
530
      // between them and the following expression.
531
      return;
532
    }
533
    this._output.set_wrap_point();
534
  }
535
};
536
 
537
Beautifier.prototype.print_newline = function(force_newline, preserve_statement_flags) {
538
  if (!preserve_statement_flags) {
539
    if (this._flags.last_token.text !== ';' && this._flags.last_token.text !== ',' && this._flags.last_token.text !== '=' && (this._flags.last_token.type !== TOKEN.OPERATOR || this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) {
540
      var next_token = this._tokens.peek();
541
      while (this._flags.mode === MODE.Statement &&
542
        !(this._flags.if_block && reserved_word(next_token, 'else')) &&
543
        !this._flags.do_block) {
544
        this.restore_mode();
545
      }
546
    }
547
  }
548
 
549
  if (this._output.add_new_line(force_newline)) {
550
    this._flags.multiline_frame = true;
551
  }
552
};
553
 
554
Beautifier.prototype.print_token_line_indentation = function(current_token) {
555
  if (this._output.just_added_newline()) {
556
    if (this._options.keep_array_indentation &&
557
      current_token.newlines &&
558
      (current_token.text === '[' || is_array(this._flags.mode))) {
559
      this._output.current_line.set_indent(-1);
560
      this._output.current_line.push(current_token.whitespace_before);
561
      this._output.space_before_token = false;
562
    } else if (this._output.set_indent(this._flags.indentation_level, this._flags.alignment)) {
563
      this._flags.line_indent_level = this._flags.indentation_level;
564
    }
565
  }
566
};
567
 
568
Beautifier.prototype.print_token = function(current_token) {
569
  if (this._output.raw) {
570
    this._output.add_raw_token(current_token);
571
    return;
572
  }
573
 
574
  if (this._options.comma_first && current_token.previous && current_token.previous.type === TOKEN.COMMA &&
575
    this._output.just_added_newline()) {
576
    if (this._output.previous_line.last() === ',') {
577
      var popped = this._output.previous_line.pop();
578
      // if the comma was already at the start of the line,
579
      // pull back onto that line and reprint the indentation
580
      if (this._output.previous_line.is_empty()) {
581
        this._output.previous_line.push(popped);
582
        this._output.trim(true);
583
        this._output.current_line.pop();
584
        this._output.trim();
585
      }
586
 
587
      // add the comma in front of the next token
588
      this.print_token_line_indentation(current_token);
589
      this._output.add_token(',');
590
      this._output.space_before_token = true;
591
    }
592
  }
593
 
594
  this.print_token_line_indentation(current_token);
595
  this._output.non_breaking_space = true;
596
  this._output.add_token(current_token.text);
597
  if (this._output.previous_token_wrapped) {
598
    this._flags.multiline_frame = true;
599
  }
600
};
601
 
602
Beautifier.prototype.indent = function() {
603
  this._flags.indentation_level += 1;
604
  this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
605
};
606
 
607
Beautifier.prototype.deindent = function() {
608
  if (this._flags.indentation_level > 0 &&
609
    ((!this._flags.parent) || this._flags.indentation_level > this._flags.parent.indentation_level)) {
610
    this._flags.indentation_level -= 1;
611
    this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
612
  }
613
};
614
 
615
Beautifier.prototype.set_mode = function(mode) {
616
  if (this._flags) {
617
    this._flag_store.push(this._flags);
618
    this._previous_flags = this._flags;
619
  } else {
620
    this._previous_flags = this.create_flags(null, mode);
621
  }
622
 
623
  this._flags = this.create_flags(this._previous_flags, mode);
624
  this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
625
};
626
 
627
 
628
Beautifier.prototype.restore_mode = function() {
629
  if (this._flag_store.length > 0) {
630
    this._previous_flags = this._flags;
631
    this._flags = this._flag_store.pop();
632
    if (this._previous_flags.mode === MODE.Statement) {
633
      remove_redundant_indentation(this._output, this._previous_flags);
634
    }
635
    this._output.set_indent(this._flags.indentation_level, this._flags.alignment);
636
  }
637
};
638
 
639
Beautifier.prototype.start_of_object_property = function() {
640
  return this._flags.parent.mode === MODE.ObjectLiteral && this._flags.mode === MODE.Statement && (
641
    (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || (reserved_array(this._flags.last_token, ['get', 'set'])));
642
};
643
 
644
Beautifier.prototype.start_of_statement = function(current_token) {
645
  var start = false;
646
  start = start || reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN.WORD;
647
  start = start || reserved_word(this._flags.last_token, 'do');
648
  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;
649
  start = start || reserved_word(this._flags.last_token, 'else') &&
650
    !(reserved_word(current_token, 'if') && !current_token.comments_before);
651
  start = start || (this._flags.last_token.type === TOKEN.END_EXPR && (this._previous_flags.mode === MODE.ForInitializer || this._previous_flags.mode === MODE.Conditional));
652
  start = start || (this._flags.last_token.type === TOKEN.WORD && this._flags.mode === MODE.BlockStatement &&
653
    !this._flags.in_case &&
654
    !(current_token.text === '--' || current_token.text === '++') &&
655
    this._last_last_text !== 'function' &&
656
    current_token.type !== TOKEN.WORD && current_token.type !== TOKEN.RESERVED);
657
  start = start || (this._flags.mode === MODE.ObjectLiteral && (
658
    (this._flags.last_token.text === ':' && this._flags.ternary_depth === 0) || reserved_array(this._flags.last_token, ['get', 'set'])));
659
 
660
  if (start) {
661
    this.set_mode(MODE.Statement);
662
    this.indent();
663
 
664
    this.handle_whitespace_and_comments(current_token, true);
665
 
666
    // Issue #276:
667
    // If starting a new statement with [if, for, while, do], push to a new line.
668
    // if (a) if (b) if(c) d(); else e(); else f();
669
    if (!this.start_of_object_property()) {
670
      this.allow_wrap_or_preserved_newline(current_token,
671
        reserved_array(current_token, ['do', 'for', 'if', 'while']));
672
    }
673
    return true;
674
  }
675
  return false;
676
};
677
 
678
Beautifier.prototype.handle_start_expr = function(current_token) {
679
  // The conditional starts the statement if appropriate.
680
  if (!this.start_of_statement(current_token)) {
681
    this.handle_whitespace_and_comments(current_token);
682
  }
683
 
684
  var next_mode = MODE.Expression;
685
  if (current_token.text === '[') {
686
 
687
    if (this._flags.last_token.type === TOKEN.WORD || this._flags.last_token.text === ')') {
688
      // this is array index specifier, break immediately
689
      // a[x], fn()[x]
690
      if (reserved_array(this._flags.last_token, line_starters)) {
691
        this._output.space_before_token = true;
692
      }
693
      this.print_token(current_token);
694
      this.set_mode(next_mode);
695
      this.indent();
696
      if (this._options.space_in_paren) {
697
        this._output.space_before_token = true;
698
      }
699
      return;
700
    }
701
 
702
    next_mode = MODE.ArrayLiteral;
703
    if (is_array(this._flags.mode)) {
704
      if (this._flags.last_token.text === '[' ||
705
        (this._flags.last_token.text === ',' && (this._last_last_text === ']' || this._last_last_text === '}'))) {
706
        // ], [ goes to new line
707
        // }, [ goes to new line
708
        if (!this._options.keep_array_indentation) {
709
          this.print_newline();
710
        }
711
      }
712
    }
713
 
714
    if (!in_array(this._flags.last_token.type, [TOKEN.START_EXPR, TOKEN.END_EXPR, TOKEN.WORD, TOKEN.OPERATOR, TOKEN.DOT])) {
715
      this._output.space_before_token = true;
716
    }
717
  } else {
718
    if (this._flags.last_token.type === TOKEN.RESERVED) {
719
      if (this._flags.last_token.text === 'for') {
720
        this._output.space_before_token = this._options.space_before_conditional;
721
        next_mode = MODE.ForInitializer;
722
      } else if (in_array(this._flags.last_token.text, ['if', 'while', 'switch'])) {
723
        this._output.space_before_token = this._options.space_before_conditional;
724
        next_mode = MODE.Conditional;
725
      } else if (in_array(this._flags.last_word, ['await', 'async'])) {
726
        // Should be a space between await and an IIFE, or async and an arrow function
727
        this._output.space_before_token = true;
728
      } else if (this._flags.last_token.text === 'import' && current_token.whitespace_before === '') {
729
        this._output.space_before_token = false;
730
      } else if (in_array(this._flags.last_token.text, line_starters) || this._flags.last_token.text === 'catch') {
731
        this._output.space_before_token = true;
732
      }
733
    } else if (this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
734
      // Support of this kind of newline preservation.
735
      // a = (b &&
736
      //     (c || d));
737
      if (!this.start_of_object_property()) {
738
        this.allow_wrap_or_preserved_newline(current_token);
739
      }
740
    } else if (this._flags.last_token.type === TOKEN.WORD) {
741
      this._output.space_before_token = false;
742
 
743
      // function name() vs function name ()
744
      // function* name() vs function* name ()
745
      // async name() vs async name ()
746
      // In ES6, you can also define the method properties of an object
747
      // var obj = {a: function() {}}
748
      // It can be abbreviated
749
      // var obj = {a() {}}
750
      // var obj = { a() {}} vs var obj = { a () {}}
751
      // var obj = { * a() {}} vs var obj = { * a () {}}
752
      var peek_back_two = this._tokens.peek(-3);
753
      if (this._options.space_after_named_function && peek_back_two) {
754
        // peek starts at next character so -1 is current token
755
        var peek_back_three = this._tokens.peek(-4);
756
        if (reserved_array(peek_back_two, ['async', 'function']) ||
757
          (peek_back_two.text === '*' && reserved_array(peek_back_three, ['async', 'function']))) {
758
          this._output.space_before_token = true;
759
        } else if (this._flags.mode === MODE.ObjectLiteral) {
760
          if ((peek_back_two.text === '{' || peek_back_two.text === ',') ||
761
            (peek_back_two.text === '*' && (peek_back_three.text === '{' || peek_back_three.text === ','))) {
762
            this._output.space_before_token = true;
763
          }
764
        } else if (this._flags.parent && this._flags.parent.class_start_block) {
765
          this._output.space_before_token = true;
766
        }
767
      }
768
    } else {
769
      // Support preserving wrapped arrow function expressions
770
      // a.b('c',
771
      //     () => d.e
772
      // )
773
      this.allow_wrap_or_preserved_newline(current_token);
774
    }
775
 
776
    // function() vs function ()
777
    // yield*() vs yield* ()
778
    // function*() vs function* ()
779
    if ((this._flags.last_token.type === TOKEN.RESERVED && (this._flags.last_word === 'function' || this._flags.last_word === 'typeof')) ||
780
      (this._flags.last_token.text === '*' &&
781
        (in_array(this._last_last_text, ['function', 'yield']) ||
782
          (this._flags.mode === MODE.ObjectLiteral && in_array(this._last_last_text, ['{', ',']))))) {
783
      this._output.space_before_token = this._options.space_after_anon_function;
784
    }
785
  }
786
 
787
  if (this._flags.last_token.text === ';' || this._flags.last_token.type === TOKEN.START_BLOCK) {
788
    this.print_newline();
789
  } else if (this._flags.last_token.type === TOKEN.END_EXPR || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.END_BLOCK || this._flags.last_token.text === '.' || this._flags.last_token.type === TOKEN.COMMA) {
790
    // do nothing on (( and )( and ][ and ]( and .(
791
    // TODO: Consider whether forcing this is required.  Review failing tests when removed.
792
    this.allow_wrap_or_preserved_newline(current_token, current_token.newlines);
793
  }
794
 
795
  this.print_token(current_token);
796
  this.set_mode(next_mode);
797
  if (this._options.space_in_paren) {
798
    this._output.space_before_token = true;
799
  }
800
 
801
  // In all cases, if we newline while inside an expression it should be indented.
802
  this.indent();
803
};
804
 
805
Beautifier.prototype.handle_end_expr = function(current_token) {
806
  // statements inside expressions are not valid syntax, but...
807
  // statements must all be closed when their container closes
808
  while (this._flags.mode === MODE.Statement) {
809
    this.restore_mode();
810
  }
811
 
812
  this.handle_whitespace_and_comments(current_token);
813
 
814
  if (this._flags.multiline_frame) {
815
    this.allow_wrap_or_preserved_newline(current_token,
816
      current_token.text === ']' && is_array(this._flags.mode) && !this._options.keep_array_indentation);
817
  }
818
 
819
  if (this._options.space_in_paren) {
820
    if (this._flags.last_token.type === TOKEN.START_EXPR && !this._options.space_in_empty_paren) {
821
      // () [] no inner space in empty parens like these, ever, ref #320
822
      this._output.trim();
823
      this._output.space_before_token = false;
824
    } else {
825
      this._output.space_before_token = true;
826
    }
827
  }
828
  this.deindent();
829
  this.print_token(current_token);
830
  this.restore_mode();
831
 
832
  remove_redundant_indentation(this._output, this._previous_flags);
833
 
834
  // do {} while () // no statement required after
835
  if (this._flags.do_while && this._previous_flags.mode === MODE.Conditional) {
836
    this._previous_flags.mode = MODE.Expression;
837
    this._flags.do_block = false;
838
    this._flags.do_while = false;
839
 
840
  }
841
};
842
 
843
Beautifier.prototype.handle_start_block = function(current_token) {
844
  this.handle_whitespace_and_comments(current_token);
845
 
846
  // Check if this is should be treated as a ObjectLiteral
847
  var next_token = this._tokens.peek();
848
  var second_token = this._tokens.peek(1);
849
  if (this._flags.last_word === 'switch' && this._flags.last_token.type === TOKEN.END_EXPR) {
850
    this.set_mode(MODE.BlockStatement);
851
    this._flags.in_case_statement = true;
852
  } else if (this._flags.case_body) {
853
    this.set_mode(MODE.BlockStatement);
854
  } else if (second_token && (
855
      (in_array(second_token.text, [':', ',']) && in_array(next_token.type, [TOKEN.STRING, TOKEN.WORD, TOKEN.RESERVED])) ||
856
      (in_array(next_token.text, ['get', 'set', '...']) && in_array(second_token.type, [TOKEN.WORD, TOKEN.RESERVED]))
857
    )) {
858
    // We don't support TypeScript,but we didn't break it for a very long time.
859
    // We'll try to keep not breaking it.
860
    if (in_array(this._last_last_text, ['class', 'interface']) && !in_array(second_token.text, [':', ','])) {
861
      this.set_mode(MODE.BlockStatement);
862
    } else {
863
      this.set_mode(MODE.ObjectLiteral);
864
    }
865
  } else if (this._flags.last_token.type === TOKEN.OPERATOR && this._flags.last_token.text === '=>') {
866
    // arrow function: (param1, paramN) => { statements }
867
    this.set_mode(MODE.BlockStatement);
868
  } else if (in_array(this._flags.last_token.type, [TOKEN.EQUALS, TOKEN.START_EXPR, TOKEN.COMMA, TOKEN.OPERATOR]) ||
869
    reserved_array(this._flags.last_token, ['return', 'throw', 'import', 'default'])
870
  ) {
871
    // Detecting shorthand function syntax is difficult by scanning forward,
872
    //     so check the surrounding context.
873
    // If the block is being returned, imported, export default, passed as arg,
874
    //     assigned with = or assigned in a nested object, treat as an ObjectLiteral.
875
    this.set_mode(MODE.ObjectLiteral);
876
  } else {
877
    this.set_mode(MODE.BlockStatement);
878
  }
879
 
880
  if (this._flags.last_token) {
881
    if (reserved_array(this._flags.last_token.previous, ['class', 'extends'])) {
882
      this._flags.class_start_block = true;
883
    }
884
  }
885
 
886
  var empty_braces = !next_token.comments_before && next_token.text === '}';
887
  var empty_anonymous_function = empty_braces && this._flags.last_word === 'function' &&
888
    this._flags.last_token.type === TOKEN.END_EXPR;
889
 
890
  if (this._options.brace_preserve_inline) // check for inline, set inline_frame if so
891
  {
892
    // search forward for a newline wanted inside this block
893
    var index = 0;
894
    var check_token = null;
895
    this._flags.inline_frame = true;
896
    do {
897
      index += 1;
898
      check_token = this._tokens.peek(index - 1);
899
      if (check_token.newlines) {
900
        this._flags.inline_frame = false;
901
        break;
902
      }
903
    } while (check_token.type !== TOKEN.EOF &&
904
      !(check_token.type === TOKEN.END_BLOCK && check_token.opened === current_token));
905
  }
906
 
907
  if ((this._options.brace_style === "expand" ||
908
      (this._options.brace_style === "none" && current_token.newlines)) &&
909
    !this._flags.inline_frame) {
910
    if (this._flags.last_token.type !== TOKEN.OPERATOR &&
911
      (empty_anonymous_function ||
912
        this._flags.last_token.type === TOKEN.EQUALS ||
913
        (reserved_array(this._flags.last_token, special_words) && this._flags.last_token.text !== 'else'))) {
914
      this._output.space_before_token = true;
915
    } else {
916
      this.print_newline(false, true);
917
    }
918
  } else { // collapse || inline_frame
919
    if (is_array(this._previous_flags.mode) && (this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.COMMA)) {
920
      if (this._flags.last_token.type === TOKEN.COMMA || this._options.space_in_paren) {
921
        this._output.space_before_token = true;
922
      }
923
 
924
      if (this._flags.last_token.type === TOKEN.COMMA || (this._flags.last_token.type === TOKEN.START_EXPR && this._flags.inline_frame)) {
925
        this.allow_wrap_or_preserved_newline(current_token);
926
        this._previous_flags.multiline_frame = this._previous_flags.multiline_frame || this._flags.multiline_frame;
927
        this._flags.multiline_frame = false;
928
      }
929
    }
930
    if (this._flags.last_token.type !== TOKEN.OPERATOR && this._flags.last_token.type !== TOKEN.START_EXPR) {
931
      if (in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.SEMICOLON]) && !this._flags.inline_frame) {
932
        this.print_newline();
933
      } else {
934
        this._output.space_before_token = true;
935
      }
936
    }
937
  }
938
  this.print_token(current_token);
939
  this.indent();
940
 
941
  // Except for specific cases, open braces are followed by a new line.
942
  if (!empty_braces && !(this._options.brace_preserve_inline && this._flags.inline_frame)) {
943
    this.print_newline();
944
  }
945
};
946
 
947
Beautifier.prototype.handle_end_block = function(current_token) {
948
  // statements must all be closed when their container closes
949
  this.handle_whitespace_and_comments(current_token);
950
 
951
  while (this._flags.mode === MODE.Statement) {
952
    this.restore_mode();
953
  }
954
 
955
  var empty_braces = this._flags.last_token.type === TOKEN.START_BLOCK;
956
 
957
  if (this._flags.inline_frame && !empty_braces) { // try inline_frame (only set if this._options.braces-preserve-inline) first
958
    this._output.space_before_token = true;
959
  } else if (this._options.brace_style === "expand") {
960
    if (!empty_braces) {
961
      this.print_newline();
962
    }
963
  } else {
964
    // skip {}
965
    if (!empty_braces) {
966
      if (is_array(this._flags.mode) && this._options.keep_array_indentation) {
967
        // we REALLY need a newline here, but newliner would skip that
968
        this._options.keep_array_indentation = false;
969
        this.print_newline();
970
        this._options.keep_array_indentation = true;
971
 
972
      } else {
973
        this.print_newline();
974
      }
975
    }
976
  }
977
  this.restore_mode();
978
  this.print_token(current_token);
979
};
980
 
981
Beautifier.prototype.handle_word = function(current_token) {
982
  if (current_token.type === TOKEN.RESERVED) {
983
    if (in_array(current_token.text, ['set', 'get']) && this._flags.mode !== MODE.ObjectLiteral) {
984
      current_token.type = TOKEN.WORD;
985
    } else if (current_token.text === 'import' && in_array(this._tokens.peek().text, ['(', '.'])) {
986
      current_token.type = TOKEN.WORD;
987
    } else if (in_array(current_token.text, ['as', 'from']) && !this._flags.import_block) {
988
      current_token.type = TOKEN.WORD;
989
    } else if (this._flags.mode === MODE.ObjectLiteral) {
990
      var next_token = this._tokens.peek();
991
      if (next_token.text === ':') {
992
        current_token.type = TOKEN.WORD;
993
      }
994
    }
995
  }
996
 
997
  if (this.start_of_statement(current_token)) {
998
    // The conditional starts the statement if appropriate.
999
    if (reserved_array(this._flags.last_token, ['var', 'let', 'const']) && current_token.type === TOKEN.WORD) {
1000
      this._flags.declaration_statement = true;
1001
    }
1002
  } else if (current_token.newlines && !is_expression(this._flags.mode) &&
1003
    (this._flags.last_token.type !== TOKEN.OPERATOR || (this._flags.last_token.text === '--' || this._flags.last_token.text === '++')) &&
1004
    this._flags.last_token.type !== TOKEN.EQUALS &&
1005
    (this._options.preserve_newlines || !reserved_array(this._flags.last_token, ['var', 'let', 'const', 'set', 'get']))) {
1006
    this.handle_whitespace_and_comments(current_token);
1007
    this.print_newline();
1008
  } else {
1009
    this.handle_whitespace_and_comments(current_token);
1010
  }
1011
 
1012
  if (this._flags.do_block && !this._flags.do_while) {
1013
    if (reserved_word(current_token, 'while')) {
1014
      // do {} ## while ()
1015
      this._output.space_before_token = true;
1016
      this.print_token(current_token);
1017
      this._output.space_before_token = true;
1018
      this._flags.do_while = true;
1019
      return;
1020
    } else {
1021
      // do {} should always have while as the next word.
1022
      // if we don't see the expected while, recover
1023
      this.print_newline();
1024
      this._flags.do_block = false;
1025
    }
1026
  }
1027
 
1028
  // if may be followed by else, or not
1029
  // Bare/inline ifs are tricky
1030
  // Need to unwind the modes correctly: if (a) if (b) c(); else d(); else e();
1031
  if (this._flags.if_block) {
1032
    if (!this._flags.else_block && reserved_word(current_token, 'else')) {
1033
      this._flags.else_block = true;
1034
    } else {
1035
      while (this._flags.mode === MODE.Statement) {
1036
        this.restore_mode();
1037
      }
1038
      this._flags.if_block = false;
1039
      this._flags.else_block = false;
1040
    }
1041
  }
1042
 
1043
  if (this._flags.in_case_statement && reserved_array(current_token, ['case', 'default'])) {
1044
    this.print_newline();
1045
    if (!this._flags.case_block && (this._flags.case_body || this._options.jslint_happy)) {
1046
      // switch cases following one another
1047
      this.deindent();
1048
    }
1049
    this._flags.case_body = false;
1050
 
1051
    this.print_token(current_token);
1052
    this._flags.in_case = true;
1053
    return;
1054
  }
1055
 
1056
  if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
1057
    if (!this.start_of_object_property() && !(
1058
        // start of object property is different for numeric values with +/- prefix operators
1059
        in_array(this._flags.last_token.text, ['+', '-']) && this._last_last_text === ':' && this._flags.parent.mode === MODE.ObjectLiteral)) {
1060
      this.allow_wrap_or_preserved_newline(current_token);
1061
    }
1062
  }
1063
 
1064
  if (reserved_word(current_token, 'function')) {
1065
    if (in_array(this._flags.last_token.text, ['}', ';']) ||
1066
      (this._output.just_added_newline() && !(in_array(this._flags.last_token.text, ['(', '[', '{', ':', '=', ',']) || this._flags.last_token.type === TOKEN.OPERATOR))) {
1067
      // make sure there is a nice clean space of at least one blank line
1068
      // before a new function definition
1069
      if (!this._output.just_added_blankline() && !current_token.comments_before) {
1070
        this.print_newline();
1071
        this.print_newline(true);
1072
      }
1073
    }
1074
    if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD) {
1075
      if (reserved_array(this._flags.last_token, ['get', 'set', 'new', 'export']) ||
1076
        reserved_array(this._flags.last_token, newline_restricted_tokens)) {
1077
        this._output.space_before_token = true;
1078
      } else if (reserved_word(this._flags.last_token, 'default') && this._last_last_text === 'export') {
1079
        this._output.space_before_token = true;
1080
      } else if (this._flags.last_token.text === 'declare') {
1081
        // accomodates Typescript declare function formatting
1082
        this._output.space_before_token = true;
1083
      } else {
1084
        this.print_newline();
1085
      }
1086
    } else if (this._flags.last_token.type === TOKEN.OPERATOR || this._flags.last_token.text === '=') {
1087
      // foo = function
1088
      this._output.space_before_token = true;
1089
    } else if (!this._flags.multiline_frame && (is_expression(this._flags.mode) || is_array(this._flags.mode))) {
1090
      // (function
1091
    } else {
1092
      this.print_newline();
1093
    }
1094
 
1095
    this.print_token(current_token);
1096
    this._flags.last_word = current_token.text;
1097
    return;
1098
  }
1099
 
1100
  var prefix = 'NONE';
1101
 
1102
  if (this._flags.last_token.type === TOKEN.END_BLOCK) {
1103
 
1104
    if (this._previous_flags.inline_frame) {
1105
      prefix = 'SPACE';
1106
    } else if (!reserved_array(current_token, ['else', 'catch', 'finally', 'from'])) {
1107
      prefix = 'NEWLINE';
1108
    } else {
1109
      if (this._options.brace_style === "expand" ||
1110
        this._options.brace_style === "end-expand" ||
1111
        (this._options.brace_style === "none" && current_token.newlines)) {
1112
        prefix = 'NEWLINE';
1113
      } else {
1114
        prefix = 'SPACE';
1115
        this._output.space_before_token = true;
1116
      }
1117
    }
1118
  } else if (this._flags.last_token.type === TOKEN.SEMICOLON && this._flags.mode === MODE.BlockStatement) {
1119
    // TODO: Should this be for STATEMENT as well?
1120
    prefix = 'NEWLINE';
1121
  } else if (this._flags.last_token.type === TOKEN.SEMICOLON && is_expression(this._flags.mode)) {
1122
    prefix = 'SPACE';
1123
  } else if (this._flags.last_token.type === TOKEN.STRING) {
1124
    prefix = 'NEWLINE';
1125
  } else if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD ||
1126
    (this._flags.last_token.text === '*' &&
1127
      (in_array(this._last_last_text, ['function', 'yield']) ||
1128
        (this._flags.mode === MODE.ObjectLiteral && in_array(this._last_last_text, ['{', ',']))))) {
1129
    prefix = 'SPACE';
1130
  } else if (this._flags.last_token.type === TOKEN.START_BLOCK) {
1131
    if (this._flags.inline_frame) {
1132
      prefix = 'SPACE';
1133
    } else {
1134
      prefix = 'NEWLINE';
1135
    }
1136
  } else if (this._flags.last_token.type === TOKEN.END_EXPR) {
1137
    this._output.space_before_token = true;
1138
    prefix = 'NEWLINE';
1139
  }
1140
 
1141
  if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ')') {
1142
    if (this._flags.inline_frame || this._flags.last_token.text === 'else' || this._flags.last_token.text === 'export') {
1143
      prefix = 'SPACE';
1144
    } else {
1145
      prefix = 'NEWLINE';
1146
    }
1147
 
1148
  }
1149
 
1150
  if (reserved_array(current_token, ['else', 'catch', 'finally'])) {
1151
    if ((!(this._flags.last_token.type === TOKEN.END_BLOCK && this._previous_flags.mode === MODE.BlockStatement) ||
1152
        this._options.brace_style === "expand" ||
1153
        this._options.brace_style === "end-expand" ||
1154
        (this._options.brace_style === "none" && current_token.newlines)) &&
1155
      !this._flags.inline_frame) {
1156
      this.print_newline();
1157
    } else {
1158
      this._output.trim(true);
1159
      var line = this._output.current_line;
1160
      // If we trimmed and there's something other than a close block before us
1161
      // put a newline back in.  Handles '} // comment' scenario.
1162
      if (line.last() !== '}') {
1163
        this.print_newline();
1164
      }
1165
      this._output.space_before_token = true;
1166
    }
1167
  } else if (prefix === 'NEWLINE') {
1168
    if (reserved_array(this._flags.last_token, special_words)) {
1169
      // no newline between 'return nnn'
1170
      this._output.space_before_token = true;
1171
    } else if (this._flags.last_token.text === 'declare' && reserved_array(current_token, ['var', 'let', 'const'])) {
1172
      // accomodates Typescript declare formatting
1173
      this._output.space_before_token = true;
1174
    } else if (this._flags.last_token.type !== TOKEN.END_EXPR) {
1175
      if ((this._flags.last_token.type !== TOKEN.START_EXPR || !reserved_array(current_token, ['var', 'let', 'const'])) && this._flags.last_token.text !== ':') {
1176
        // no need to force newline on 'var': for (var x = 0...)
1177
        if (reserved_word(current_token, 'if') && reserved_word(current_token.previous, 'else')) {
1178
          // no newline for } else if {
1179
          this._output.space_before_token = true;
1180
        } else {
1181
          this.print_newline();
1182
        }
1183
      }
1184
    } else if (reserved_array(current_token, line_starters) && this._flags.last_token.text !== ')') {
1185
      this.print_newline();
1186
    }
1187
  } else if (this._flags.multiline_frame && is_array(this._flags.mode) && this._flags.last_token.text === ',' && this._last_last_text === '}') {
1188
    this.print_newline(); // }, in lists get a newline treatment
1189
  } else if (prefix === 'SPACE') {
1190
    this._output.space_before_token = true;
1191
  }
1192
  if (current_token.previous && (current_token.previous.type === TOKEN.WORD || current_token.previous.type === TOKEN.RESERVED)) {
1193
    this._output.space_before_token = true;
1194
  }
1195
  this.print_token(current_token);
1196
  this._flags.last_word = current_token.text;
1197
 
1198
  if (current_token.type === TOKEN.RESERVED) {
1199
    if (current_token.text === 'do') {
1200
      this._flags.do_block = true;
1201
    } else if (current_token.text === 'if') {
1202
      this._flags.if_block = true;
1203
    } else if (current_token.text === 'import') {
1204
      this._flags.import_block = true;
1205
    } else if (this._flags.import_block && reserved_word(current_token, 'from')) {
1206
      this._flags.import_block = false;
1207
    }
1208
  }
1209
};
1210
 
1211
Beautifier.prototype.handle_semicolon = function(current_token) {
1212
  if (this.start_of_statement(current_token)) {
1213
    // The conditional starts the statement if appropriate.
1214
    // Semicolon can be the start (and end) of a statement
1215
    this._output.space_before_token = false;
1216
  } else {
1217
    this.handle_whitespace_and_comments(current_token);
1218
  }
1219
 
1220
  var next_token = this._tokens.peek();
1221
  while (this._flags.mode === MODE.Statement &&
1222
    !(this._flags.if_block && reserved_word(next_token, 'else')) &&
1223
    !this._flags.do_block) {
1224
    this.restore_mode();
1225
  }
1226
 
1227
  // hacky but effective for the moment
1228
  if (this._flags.import_block) {
1229
    this._flags.import_block = false;
1230
  }
1231
  this.print_token(current_token);
1232
};
1233
 
1234
Beautifier.prototype.handle_string = function(current_token) {
1235
  if (current_token.text.startsWith("`") && current_token.newlines === 0 && current_token.whitespace_before === '' && (current_token.previous.text === ')' || this._flags.last_token.type === TOKEN.WORD)) {
1236
    //Conditional for detectign backtick strings
1237
  } else if (this.start_of_statement(current_token)) {
1238
    // The conditional starts the statement if appropriate.
1239
    // One difference - strings want at least a space before
1240
    this._output.space_before_token = true;
1241
  } else {
1242
    this.handle_whitespace_and_comments(current_token);
1243
    if (this._flags.last_token.type === TOKEN.RESERVED || this._flags.last_token.type === TOKEN.WORD || this._flags.inline_frame) {
1244
      this._output.space_before_token = true;
1245
    } else if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR || this._flags.last_token.type === TOKEN.EQUALS || this._flags.last_token.type === TOKEN.OPERATOR) {
1246
      if (!this.start_of_object_property()) {
1247
        this.allow_wrap_or_preserved_newline(current_token);
1248
      }
1249
    } else if ((current_token.text.startsWith("`") && this._flags.last_token.type === TOKEN.END_EXPR && (current_token.previous.text === ']' || current_token.previous.text === ')') && current_token.newlines === 0)) {
1250
      this._output.space_before_token = true;
1251
    } else {
1252
      this.print_newline();
1253
    }
1254
  }
1255
  this.print_token(current_token);
1256
};
1257
 
1258
Beautifier.prototype.handle_equals = function(current_token) {
1259
  if (this.start_of_statement(current_token)) {
1260
    // The conditional starts the statement if appropriate.
1261
  } else {
1262
    this.handle_whitespace_and_comments(current_token);
1263
  }
1264
 
1265
  if (this._flags.declaration_statement) {
1266
    // just got an '=' in a var-line, different formatting/line-breaking, etc will now be done
1267
    this._flags.declaration_assignment = true;
1268
  }
1269
  this._output.space_before_token = true;
1270
  this.print_token(current_token);
1271
  this._output.space_before_token = true;
1272
};
1273
 
1274
Beautifier.prototype.handle_comma = function(current_token) {
1275
  this.handle_whitespace_and_comments(current_token, true);
1276
 
1277
  this.print_token(current_token);
1278
  this._output.space_before_token = true;
1279
  if (this._flags.declaration_statement) {
1280
    if (is_expression(this._flags.parent.mode)) {
1281
      // do not break on comma, for(var a = 1, b = 2)
1282
      this._flags.declaration_assignment = false;
1283
    }
1284
 
1285
    if (this._flags.declaration_assignment) {
1286
      this._flags.declaration_assignment = false;
1287
      this.print_newline(false, true);
1288
    } else if (this._options.comma_first) {
1289
      // for comma-first, we want to allow a newline before the comma
1290
      // to turn into a newline after the comma, which we will fixup later
1291
      this.allow_wrap_or_preserved_newline(current_token);
1292
    }
1293
  } else if (this._flags.mode === MODE.ObjectLiteral ||
1294
    (this._flags.mode === MODE.Statement && this._flags.parent.mode === MODE.ObjectLiteral)) {
1295
    if (this._flags.mode === MODE.Statement) {
1296
      this.restore_mode();
1297
    }
1298
 
1299
    if (!this._flags.inline_frame) {
1300
      this.print_newline();
1301
    }
1302
  } else if (this._options.comma_first) {
1303
    // EXPR or DO_BLOCK
1304
    // for comma-first, we want to allow a newline before the comma
1305
    // to turn into a newline after the comma, which we will fixup later
1306
    this.allow_wrap_or_preserved_newline(current_token);
1307
  }
1308
};
1309
 
1310
Beautifier.prototype.handle_operator = function(current_token) {
1311
  var isGeneratorAsterisk = current_token.text === '*' &&
1312
    (reserved_array(this._flags.last_token, ['function', 'yield']) ||
1313
      (in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.COMMA, TOKEN.END_BLOCK, TOKEN.SEMICOLON]))
1314
    );
1315
  var isUnary = in_array(current_token.text, ['-', '+']) && (
1316
    in_array(this._flags.last_token.type, [TOKEN.START_BLOCK, TOKEN.START_EXPR, TOKEN.EQUALS, TOKEN.OPERATOR]) ||
1317
    in_array(this._flags.last_token.text, line_starters) ||
1318
    this._flags.last_token.text === ','
1319
  );
1320
 
1321
  if (this.start_of_statement(current_token)) {
1322
    // The conditional starts the statement if appropriate.
1323
  } else {
1324
    var preserve_statement_flags = !isGeneratorAsterisk;
1325
    this.handle_whitespace_and_comments(current_token, preserve_statement_flags);
1326
  }
1327
 
1328
  // hack for actionscript's import .*;
1329
  if (current_token.text === '*' && this._flags.last_token.type === TOKEN.DOT) {
1330
    this.print_token(current_token);
1331
    return;
1332
  }
1333
 
1334
  if (current_token.text === '::') {
1335
    // no spaces around exotic namespacing syntax operator
1336
    this.print_token(current_token);
1337
    return;
1338
  }
1339
 
1340
  if (in_array(current_token.text, ['-', '+']) && this.start_of_object_property()) {
1341
    // numeric value with +/- symbol in front as a property
1342
    this.print_token(current_token);
1343
    return;
1344
  }
1345
 
1346
  // Allow line wrapping between operators when operator_position is
1347
  //   set to before or preserve
1348
  if (this._flags.last_token.type === TOKEN.OPERATOR && in_array(this._options.operator_position, OPERATOR_POSITION_BEFORE_OR_PRESERVE)) {
1349
    this.allow_wrap_or_preserved_newline(current_token);
1350
  }
1351
 
1352
  if (current_token.text === ':' && this._flags.in_case) {
1353
    this.print_token(current_token);
1354
 
1355
    this._flags.in_case = false;
1356
    this._flags.case_body = true;
1357
    if (this._tokens.peek().type !== TOKEN.START_BLOCK) {
1358
      this.indent();
1359
      this.print_newline();
1360
      this._flags.case_block = false;
1361
    } else {
1362
      this._flags.case_block = true;
1363
      this._output.space_before_token = true;
1364
    }
1365
    return;
1366
  }
1367
 
1368
  var space_before = true;
1369
  var space_after = true;
1370
  var in_ternary = false;
1371
  if (current_token.text === ':') {
1372
    if (this._flags.ternary_depth === 0) {
1373
      // Colon is invalid javascript outside of ternary and object, but do our best to guess what was meant.
1374
      space_before = false;
1375
    } else {
1376
      this._flags.ternary_depth -= 1;
1377
      in_ternary = true;
1378
    }
1379
  } else if (current_token.text === '?') {
1380
    this._flags.ternary_depth += 1;
1381
  }
1382
 
1383
  // let's handle the operator_position option prior to any conflicting logic
1384
  if (!isUnary && !isGeneratorAsterisk && this._options.preserve_newlines && in_array(current_token.text, positionable_operators)) {
1385
    var isColon = current_token.text === ':';
1386
    var isTernaryColon = (isColon && in_ternary);
1387
    var isOtherColon = (isColon && !in_ternary);
1388
 
1389
    switch (this._options.operator_position) {
1390
      case OPERATOR_POSITION.before_newline:
1391
        // if the current token is : and it's not a ternary statement then we set space_before to false
1392
        this._output.space_before_token = !isOtherColon;
1393
 
1394
        this.print_token(current_token);
1395
 
1396
        if (!isColon || isTernaryColon) {
1397
          this.allow_wrap_or_preserved_newline(current_token);
1398
        }
1399
 
1400
        this._output.space_before_token = true;
1401
        return;
1402
 
1403
      case OPERATOR_POSITION.after_newline:
1404
        // if the current token is anything but colon, or (via deduction) it's a colon and in a ternary statement,
1405
        //   then print a newline.
1406
 
1407
        this._output.space_before_token = true;
1408
 
1409
        if (!isColon || isTernaryColon) {
1410
          if (this._tokens.peek().newlines) {
1411
            this.print_newline(false, true);
1412
          } else {
1413
            this.allow_wrap_or_preserved_newline(current_token);
1414
          }
1415
        } else {
1416
          this._output.space_before_token = false;
1417
        }
1418
 
1419
        this.print_token(current_token);
1420
 
1421
        this._output.space_before_token = true;
1422
        return;
1423
 
1424
      case OPERATOR_POSITION.preserve_newline:
1425
        if (!isOtherColon) {
1426
          this.allow_wrap_or_preserved_newline(current_token);
1427
        }
1428
 
1429
        // if we just added a newline, or the current token is : and it's not a ternary statement,
1430
        //   then we set space_before to false
1431
        space_before = !(this._output.just_added_newline() || isOtherColon);
1432
 
1433
        this._output.space_before_token = space_before;
1434
        this.print_token(current_token);
1435
        this._output.space_before_token = true;
1436
        return;
1437
    }
1438
  }
1439
 
1440
  if (isGeneratorAsterisk) {
1441
    this.allow_wrap_or_preserved_newline(current_token);
1442
    space_before = false;
1443
    var next_token = this._tokens.peek();
1444
    space_after = next_token && in_array(next_token.type, [TOKEN.WORD, TOKEN.RESERVED]);
1445
  } else if (current_token.text === '...') {
1446
    this.allow_wrap_or_preserved_newline(current_token);
1447
    space_before = this._flags.last_token.type === TOKEN.START_BLOCK;
1448
    space_after = false;
1449
  } else if (in_array(current_token.text, ['--', '++', '!', '~']) || isUnary) {
1450
    // unary operators (and binary +/- pretending to be unary) special cases
1451
    if (this._flags.last_token.type === TOKEN.COMMA || this._flags.last_token.type === TOKEN.START_EXPR) {
1452
      this.allow_wrap_or_preserved_newline(current_token);
1453
    }
1454
 
1455
    space_before = false;
1456
    space_after = false;
1457
 
1458
    // http://www.ecma-international.org/ecma-262/5.1/#sec-7.9.1
1459
    // if there is a newline between -- or ++ and anything else we should preserve it.
1460
    if (current_token.newlines && (current_token.text === '--' || current_token.text === '++' || current_token.text === '~')) {
1461
      var new_line_needed = reserved_array(this._flags.last_token, special_words) && current_token.newlines;
1462
      if (new_line_needed && (this._previous_flags.if_block || this._previous_flags.else_block)) {
1463
        this.restore_mode();
1464
      }
1465
      this.print_newline(new_line_needed, true);
1466
    }
1467
 
1468
    if (this._flags.last_token.text === ';' && is_expression(this._flags.mode)) {
1469
      // for (;; ++i)
1470
      //        ^^^
1471
      space_before = true;
1472
    }
1473
 
1474
    if (this._flags.last_token.type === TOKEN.RESERVED) {
1475
      space_before = true;
1476
    } else if (this._flags.last_token.type === TOKEN.END_EXPR) {
1477
      space_before = !(this._flags.last_token.text === ']' && (current_token.text === '--' || current_token.text === '++'));
1478
    } else if (this._flags.last_token.type === TOKEN.OPERATOR) {
1479
      // a++ + ++b;
1480
      // a - -b
1481
      space_before = in_array(current_token.text, ['--', '-', '++', '+']) && in_array(this._flags.last_token.text, ['--', '-', '++', '+']);
1482
      // + and - are not unary when preceeded by -- or ++ operator
1483
      // a-- + b
1484
      // a * +b
1485
      // a - -b
1486
      if (in_array(current_token.text, ['+', '-']) && in_array(this._flags.last_token.text, ['--', '++'])) {
1487
        space_after = true;
1488
      }
1489
    }
1490
 
1491
 
1492
    if (((this._flags.mode === MODE.BlockStatement && !this._flags.inline_frame) || this._flags.mode === MODE.Statement) &&
1493
      (this._flags.last_token.text === '{' || this._flags.last_token.text === ';')) {
1494
      // { foo; --i }
1495
      // foo(); --bar;
1496
      this.print_newline();
1497
    }
1498
  }
1499
 
1500
  this._output.space_before_token = this._output.space_before_token || space_before;
1501
  this.print_token(current_token);
1502
  this._output.space_before_token = space_after;
1503
};
1504
 
1505
Beautifier.prototype.handle_block_comment = function(current_token, preserve_statement_flags) {
1506
  if (this._output.raw) {
1507
    this._output.add_raw_token(current_token);
1508
    if (current_token.directives && current_token.directives.preserve === 'end') {
1509
      // If we're testing the raw output behavior, do not allow a directive to turn it off.
1510
      this._output.raw = this._options.test_output_raw;
1511
    }
1512
    return;
1513
  }
1514
 
1515
  if (current_token.directives) {
1516
    this.print_newline(false, preserve_statement_flags);
1517
    this.print_token(current_token);
1518
    if (current_token.directives.preserve === 'start') {
1519
      this._output.raw = true;
1520
    }
1521
    this.print_newline(false, true);
1522
    return;
1523
  }
1524
 
1525
  // inline block
1526
  if (!acorn.newline.test(current_token.text) && !current_token.newlines) {
1527
    this._output.space_before_token = true;
1528
    this.print_token(current_token);
1529
    this._output.space_before_token = true;
1530
    return;
1531
  } else {
1532
    this.print_block_commment(current_token, preserve_statement_flags);
1533
  }
1534
};
1535
 
1536
Beautifier.prototype.print_block_commment = function(current_token, preserve_statement_flags) {
1537
  var lines = split_linebreaks(current_token.text);
1538
  var j; // iterator for this case
1539
  var javadoc = false;
1540
  var starless = false;
1541
  var lastIndent = current_token.whitespace_before;
1542
  var lastIndentLength = lastIndent.length;
1543
 
1544
  // block comment starts with a new line
1545
  this.print_newline(false, preserve_statement_flags);
1546
 
1547
  // first line always indented
1548
  this.print_token_line_indentation(current_token);
1549
  this._output.add_token(lines[0]);
1550
  this.print_newline(false, preserve_statement_flags);
1551
 
1552
 
1553
  if (lines.length > 1) {
1554
    lines = lines.slice(1);
1555
    javadoc = all_lines_start_with(lines, '*');
1556
    starless = each_line_matches_indent(lines, lastIndent);
1557
 
1558
    if (javadoc) {
1559
      this._flags.alignment = 1;
1560
    }
1561
 
1562
    for (j = 0; j < lines.length; j++) {
1563
      if (javadoc) {
1564
        // javadoc: reformat and re-indent
1565
        this.print_token_line_indentation(current_token);
1566
        this._output.add_token(ltrim(lines[j]));
1567
      } else if (starless && lines[j]) {
1568
        // starless: re-indent non-empty content, avoiding trim
1569
        this.print_token_line_indentation(current_token);
1570
        this._output.add_token(lines[j].substring(lastIndentLength));
1571
      } else {
1572
        // normal comments output raw
1573
        this._output.current_line.set_indent(-1);
1574
        this._output.add_token(lines[j]);
1575
      }
1576
 
1577
      // for comments on their own line or  more than one line, make sure there's a new line after
1578
      this.print_newline(false, preserve_statement_flags);
1579
    }
1580
 
1581
    this._flags.alignment = 0;
1582
  }
1583
};
1584
 
1585
 
1586
Beautifier.prototype.handle_comment = function(current_token, preserve_statement_flags) {
1587
  if (current_token.newlines) {
1588
    this.print_newline(false, preserve_statement_flags);
1589
  } else {
1590
    this._output.trim(true);
1591
  }
1592
 
1593
  this._output.space_before_token = true;
1594
  this.print_token(current_token);
1595
  this.print_newline(false, preserve_statement_flags);
1596
};
1597
 
1598
Beautifier.prototype.handle_dot = function(current_token) {
1599
  if (this.start_of_statement(current_token)) {
1600
    // The conditional starts the statement if appropriate.
1601
  } else {
1602
    this.handle_whitespace_and_comments(current_token, true);
1603
  }
1604
 
1605
  if (this._flags.last_token.text.match('^[0-9]+$')) {
1606
    this._output.space_before_token = true;
1607
  }
1608
 
1609
  if (reserved_array(this._flags.last_token, special_words)) {
1610
    this._output.space_before_token = false;
1611
  } else {
1612
    // allow preserved newlines before dots in general
1613
    // force newlines on dots after close paren when break_chained - for bar().baz()
1614
    this.allow_wrap_or_preserved_newline(current_token,
1615
      this._flags.last_token.text === ')' && this._options.break_chained_methods);
1616
  }
1617
 
1618
  // Only unindent chained method dot if this dot starts a new line.
1619
  // Otherwise the automatic extra indentation removal will handle the over indent
1620
  if (this._options.unindent_chained_methods && this._output.just_added_newline()) {
1621
    this.deindent();
1622
  }
1623
 
1624
  this.print_token(current_token);
1625
};
1626
 
1627
Beautifier.prototype.handle_unknown = function(current_token, preserve_statement_flags) {
1628
  this.print_token(current_token);
1629
 
1630
  if (current_token.text[current_token.text.length - 1] === '\n') {
1631
    this.print_newline(false, preserve_statement_flags);
1632
  }
1633
};
1634
 
1635
Beautifier.prototype.handle_eof = function(current_token) {
1636
  // Unwind any open statements
1637
  while (this._flags.mode === MODE.Statement) {
1638
    this.restore_mode();
1639
  }
1640
  this.handle_whitespace_and_comments(current_token);
1641
};
1642
 
1643
module.exports.Beautifier = Beautifier;
1644
 
1645
 
1646
/***/ }),
1647
/* 2 */
1648
/***/ (function(module) {
1649
 
1650
/*jshint node:true */
1651
/*
1652
  The MIT License (MIT)
1653
 
1654
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
1655
 
1656
  Permission is hereby granted, free of charge, to any person
1657
  obtaining a copy of this software and associated documentation files
1658
  (the "Software"), to deal in the Software without restriction,
1659
  including without limitation the rights to use, copy, modify, merge,
1660
  publish, distribute, sublicense, and/or sell copies of the Software,
1661
  and to permit persons to whom the Software is furnished to do so,
1662
  subject to the following conditions:
1663
 
1664
  The above copyright notice and this permission notice shall be
1665
  included in all copies or substantial portions of the Software.
1666
 
1667
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1668
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1669
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1670
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
1671
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
1672
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1673
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1674
  SOFTWARE.
1675
*/
1676
 
1677
 
1678
 
1679
function OutputLine(parent) {
1680
  this.__parent = parent;
1681
  this.__character_count = 0;
1682
  // use indent_count as a marker for this.__lines that have preserved indentation
1683
  this.__indent_count = -1;
1684
  this.__alignment_count = 0;
1685
  this.__wrap_point_index = 0;
1686
  this.__wrap_point_character_count = 0;
1687
  this.__wrap_point_indent_count = -1;
1688
  this.__wrap_point_alignment_count = 0;
1689
 
1690
  this.__items = [];
1691
}
1692
 
1693
OutputLine.prototype.clone_empty = function() {
1694
  var line = new OutputLine(this.__parent);
1695
  line.set_indent(this.__indent_count, this.__alignment_count);
1696
  return line;
1697
};
1698
 
1699
OutputLine.prototype.item = function(index) {
1700
  if (index < 0) {
1701
    return this.__items[this.__items.length + index];
1702
  } else {
1703
    return this.__items[index];
1704
  }
1705
};
1706
 
1707
OutputLine.prototype.has_match = function(pattern) {
1708
  for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
1709
    if (this.__items[lastCheckedOutput].match(pattern)) {
1710
      return true;
1711
    }
1712
  }
1713
  return false;
1714
};
1715
 
1716
OutputLine.prototype.set_indent = function(indent, alignment) {
1717
  if (this.is_empty()) {
1718
    this.__indent_count = indent || 0;
1719
    this.__alignment_count = alignment || 0;
1720
    this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
1721
  }
1722
};
1723
 
1724
OutputLine.prototype._set_wrap_point = function() {
1725
  if (this.__parent.wrap_line_length) {
1726
    this.__wrap_point_index = this.__items.length;
1727
    this.__wrap_point_character_count = this.__character_count;
1728
    this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
1729
    this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
1730
  }
1731
};
1732
 
1733
OutputLine.prototype._should_wrap = function() {
1734
  return this.__wrap_point_index &&
1735
    this.__character_count > this.__parent.wrap_line_length &&
1736
    this.__wrap_point_character_count > this.__parent.next_line.__character_count;
1737
};
1738
 
1739
OutputLine.prototype._allow_wrap = function() {
1740
  if (this._should_wrap()) {
1741
    this.__parent.add_new_line();
1742
    var next = this.__parent.current_line;
1743
    next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
1744
    next.__items = this.__items.slice(this.__wrap_point_index);
1745
    this.__items = this.__items.slice(0, this.__wrap_point_index);
1746
 
1747
    next.__character_count += this.__character_count - this.__wrap_point_character_count;
1748
    this.__character_count = this.__wrap_point_character_count;
1749
 
1750
    if (next.__items[0] === " ") {
1751
      next.__items.splice(0, 1);
1752
      next.__character_count -= 1;
1753
    }
1754
    return true;
1755
  }
1756
  return false;
1757
};
1758
 
1759
OutputLine.prototype.is_empty = function() {
1760
  return this.__items.length === 0;
1761
};
1762
 
1763
OutputLine.prototype.last = function() {
1764
  if (!this.is_empty()) {
1765
    return this.__items[this.__items.length - 1];
1766
  } else {
1767
    return null;
1768
  }
1769
};
1770
 
1771
OutputLine.prototype.push = function(item) {
1772
  this.__items.push(item);
1773
  var last_newline_index = item.lastIndexOf('\n');
1774
  if (last_newline_index !== -1) {
1775
    this.__character_count = item.length - last_newline_index;
1776
  } else {
1777
    this.__character_count += item.length;
1778
  }
1779
};
1780
 
1781
OutputLine.prototype.pop = function() {
1782
  var item = null;
1783
  if (!this.is_empty()) {
1784
    item = this.__items.pop();
1785
    this.__character_count -= item.length;
1786
  }
1787
  return item;
1788
};
1789
 
1790
 
1791
OutputLine.prototype._remove_indent = function() {
1792
  if (this.__indent_count > 0) {
1793
    this.__indent_count -= 1;
1794
    this.__character_count -= this.__parent.indent_size;
1795
  }
1796
};
1797
 
1798
OutputLine.prototype._remove_wrap_indent = function() {
1799
  if (this.__wrap_point_indent_count > 0) {
1800
    this.__wrap_point_indent_count -= 1;
1801
  }
1802
};
1803
OutputLine.prototype.trim = function() {
1804
  while (this.last() === ' ') {
1805
    this.__items.pop();
1806
    this.__character_count -= 1;
1807
  }
1808
};
1809
 
1810
OutputLine.prototype.toString = function() {
1811
  var result = '';
1812
  if (this.is_empty()) {
1813
    if (this.__parent.indent_empty_lines) {
1814
      result = this.__parent.get_indent_string(this.__indent_count);
1815
    }
1816
  } else {
1817
    result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
1818
    result += this.__items.join('');
1819
  }
1820
  return result;
1821
};
1822
 
1823
function IndentStringCache(options, baseIndentString) {
1824
  this.__cache = [''];
1825
  this.__indent_size = options.indent_size;
1826
  this.__indent_string = options.indent_char;
1827
  if (!options.indent_with_tabs) {
1828
    this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
1829
  }
1830
 
1831
  // Set to null to continue support for auto detection of base indent
1832
  baseIndentString = baseIndentString || '';
1833
  if (options.indent_level > 0) {
1834
    baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
1835
  }
1836
 
1837
  this.__base_string = baseIndentString;
1838
  this.__base_string_length = baseIndentString.length;
1839
}
1840
 
1841
IndentStringCache.prototype.get_indent_size = function(indent, column) {
1842
  var result = this.__base_string_length;
1843
  column = column || 0;
1844
  if (indent < 0) {
1845
    result = 0;
1846
  }
1847
  result += indent * this.__indent_size;
1848
  result += column;
1849
  return result;
1850
};
1851
 
1852
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
1853
  var result = this.__base_string;
1854
  column = column || 0;
1855
  if (indent_level < 0) {
1856
    indent_level = 0;
1857
    result = '';
1858
  }
1859
  column += indent_level * this.__indent_size;
1860
  this.__ensure_cache(column);
1861
  result += this.__cache[column];
1862
  return result;
1863
};
1864
 
1865
IndentStringCache.prototype.__ensure_cache = function(column) {
1866
  while (column >= this.__cache.length) {
1867
    this.__add_column();
1868
  }
1869
};
1870
 
1871
IndentStringCache.prototype.__add_column = function() {
1872
  var column = this.__cache.length;
1873
  var indent = 0;
1874
  var result = '';
1875
  if (this.__indent_size && column >= this.__indent_size) {
1876
    indent = Math.floor(column / this.__indent_size);
1877
    column -= indent * this.__indent_size;
1878
    result = new Array(indent + 1).join(this.__indent_string);
1879
  }
1880
  if (column) {
1881
    result += new Array(column + 1).join(' ');
1882
  }
1883
 
1884
  this.__cache.push(result);
1885
};
1886
 
1887
function Output(options, baseIndentString) {
1888
  this.__indent_cache = new IndentStringCache(options, baseIndentString);
1889
  this.raw = false;
1890
  this._end_with_newline = options.end_with_newline;
1891
  this.indent_size = options.indent_size;
1892
  this.wrap_line_length = options.wrap_line_length;
1893
  this.indent_empty_lines = options.indent_empty_lines;
1894
  this.__lines = [];
1895
  this.previous_line = null;
1896
  this.current_line = null;
1897
  this.next_line = new OutputLine(this);
1898
  this.space_before_token = false;
1899
  this.non_breaking_space = false;
1900
  this.previous_token_wrapped = false;
1901
  // initialize
1902
  this.__add_outputline();
1903
}
1904
 
1905
Output.prototype.__add_outputline = function() {
1906
  this.previous_line = this.current_line;
1907
  this.current_line = this.next_line.clone_empty();
1908
  this.__lines.push(this.current_line);
1909
};
1910
 
1911
Output.prototype.get_line_number = function() {
1912
  return this.__lines.length;
1913
};
1914
 
1915
Output.prototype.get_indent_string = function(indent, column) {
1916
  return this.__indent_cache.get_indent_string(indent, column);
1917
};
1918
 
1919
Output.prototype.get_indent_size = function(indent, column) {
1920
  return this.__indent_cache.get_indent_size(indent, column);
1921
};
1922
 
1923
Output.prototype.is_empty = function() {
1924
  return !this.previous_line && this.current_line.is_empty();
1925
};
1926
 
1927
Output.prototype.add_new_line = function(force_newline) {
1928
  // never newline at the start of file
1929
  // otherwise, newline only if we didn't just add one or we're forced
1930
  if (this.is_empty() ||
1931
    (!force_newline && this.just_added_newline())) {
1932
    return false;
1933
  }
1934
 
1935
  // if raw output is enabled, don't print additional newlines,
1936
  // but still return True as though you had
1937
  if (!this.raw) {
1938
    this.__add_outputline();
1939
  }
1940
  return true;
1941
};
1942
 
1943
Output.prototype.get_code = function(eol) {
1944
  this.trim(true);
1945
 
1946
  // handle some edge cases where the last tokens
1947
  // has text that ends with newline(s)
1948
  var last_item = this.current_line.pop();
1949
  if (last_item) {
1950
    if (last_item[last_item.length - 1] === '\n') {
1951
      last_item = last_item.replace(/\n+$/g, '');
1952
    }
1953
    this.current_line.push(last_item);
1954
  }
1955
 
1956
  if (this._end_with_newline) {
1957
    this.__add_outputline();
1958
  }
1959
 
1960
  var sweet_code = this.__lines.join('\n');
1961
 
1962
  if (eol !== '\n') {
1963
    sweet_code = sweet_code.replace(/[\n]/g, eol);
1964
  }
1965
  return sweet_code;
1966
};
1967
 
1968
Output.prototype.set_wrap_point = function() {
1969
  this.current_line._set_wrap_point();
1970
};
1971
 
1972
Output.prototype.set_indent = function(indent, alignment) {
1973
  indent = indent || 0;
1974
  alignment = alignment || 0;
1975
 
1976
  // Next line stores alignment values
1977
  this.next_line.set_indent(indent, alignment);
1978
 
1979
  // Never indent your first output indent at the start of the file
1980
  if (this.__lines.length > 1) {
1981
    this.current_line.set_indent(indent, alignment);
1982
    return true;
1983
  }
1984
 
1985
  this.current_line.set_indent();
1986
  return false;
1987
};
1988
 
1989
Output.prototype.add_raw_token = function(token) {
1990
  for (var x = 0; x < token.newlines; x++) {
1991
    this.__add_outputline();
1992
  }
1993
  this.current_line.set_indent(-1);
1994
  this.current_line.push(token.whitespace_before);
1995
  this.current_line.push(token.text);
1996
  this.space_before_token = false;
1997
  this.non_breaking_space = false;
1998
  this.previous_token_wrapped = false;
1999
};
2000
 
2001
Output.prototype.add_token = function(printable_token) {
2002
  this.__add_space_before_token();
2003
  this.current_line.push(printable_token);
2004
  this.space_before_token = false;
2005
  this.non_breaking_space = false;
2006
  this.previous_token_wrapped = this.current_line._allow_wrap();
2007
};
2008
 
2009
Output.prototype.__add_space_before_token = function() {
2010
  if (this.space_before_token && !this.just_added_newline()) {
2011
    if (!this.non_breaking_space) {
2012
      this.set_wrap_point();
2013
    }
2014
    this.current_line.push(' ');
2015
  }
2016
};
2017
 
2018
Output.prototype.remove_indent = function(index) {
2019
  var output_length = this.__lines.length;
2020
  while (index < output_length) {
2021
    this.__lines[index]._remove_indent();
2022
    index++;
2023
  }
2024
  this.current_line._remove_wrap_indent();
2025
};
2026
 
2027
Output.prototype.trim = function(eat_newlines) {
2028
  eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
2029
 
2030
  this.current_line.trim();
2031
 
2032
  while (eat_newlines && this.__lines.length > 1 &&
2033
    this.current_line.is_empty()) {
2034
    this.__lines.pop();
2035
    this.current_line = this.__lines[this.__lines.length - 1];
2036
    this.current_line.trim();
2037
  }
2038
 
2039
  this.previous_line = this.__lines.length > 1 ?
2040
    this.__lines[this.__lines.length - 2] : null;
2041
};
2042
 
2043
Output.prototype.just_added_newline = function() {
2044
  return this.current_line.is_empty();
2045
};
2046
 
2047
Output.prototype.just_added_blankline = function() {
2048
  return this.is_empty() ||
2049
    (this.current_line.is_empty() && this.previous_line.is_empty());
2050
};
2051
 
2052
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
2053
  var index = this.__lines.length - 2;
2054
  while (index >= 0) {
2055
    var potentialEmptyLine = this.__lines[index];
2056
    if (potentialEmptyLine.is_empty()) {
2057
      break;
2058
    } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
2059
      potentialEmptyLine.item(-1) !== ends_with) {
2060
      this.__lines.splice(index + 1, 0, new OutputLine(this));
2061
      this.previous_line = this.__lines[this.__lines.length - 2];
2062
      break;
2063
    }
2064
    index--;
2065
  }
2066
};
2067
 
2068
module.exports.Output = Output;
2069
 
2070
 
2071
/***/ }),
2072
/* 3 */
2073
/***/ (function(module) {
2074
 
2075
/*jshint node:true */
2076
/*
2077
 
2078
  The MIT License (MIT)
2079
 
2080
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2081
 
2082
  Permission is hereby granted, free of charge, to any person
2083
  obtaining a copy of this software and associated documentation files
2084
  (the "Software"), to deal in the Software without restriction,
2085
  including without limitation the rights to use, copy, modify, merge,
2086
  publish, distribute, sublicense, and/or sell copies of the Software,
2087
  and to permit persons to whom the Software is furnished to do so,
2088
  subject to the following conditions:
2089
 
2090
  The above copyright notice and this permission notice shall be
2091
  included in all copies or substantial portions of the Software.
2092
 
2093
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2094
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2095
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2096
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2097
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2098
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2099
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2100
  SOFTWARE.
2101
*/
2102
 
2103
 
2104
 
2105
function Token(type, text, newlines, whitespace_before) {
2106
  this.type = type;
2107
  this.text = text;
2108
 
2109
  // comments_before are
2110
  // comments that have a new line before them
2111
  // and may or may not have a newline after
2112
  // this is a set of comments before
2113
  this.comments_before = null; /* inline comment*/
2114
 
2115
 
2116
  // this.comments_after =  new TokenStream(); // no new line before and newline after
2117
  this.newlines = newlines || 0;
2118
  this.whitespace_before = whitespace_before || '';
2119
  this.parent = null;
2120
  this.next = null;
2121
  this.previous = null;
2122
  this.opened = null;
2123
  this.closed = null;
2124
  this.directives = null;
2125
}
2126
 
2127
 
2128
module.exports.Token = Token;
2129
 
2130
 
2131
/***/ }),
2132
/* 4 */
2133
/***/ (function(__unused_webpack_module, exports) {
2134
 
2135
/* jshint node: true, curly: false */
2136
// Parts of this section of code is taken from acorn.
2137
//
2138
// Acorn was written by Marijn Haverbeke and released under an MIT
2139
// license. The Unicode regexps (for identifiers and whitespace) were
2140
// taken from [Esprima](http://esprima.org) by Ariya Hidayat.
2141
//
2142
// Git repositories for Acorn are available at
2143
//
2144
//     http://marijnhaverbeke.nl/git/acorn
2145
//     https://github.com/marijnh/acorn.git
2146
 
2147
// ## Character categories
2148
 
2149
 
2150
 
2151
 
2152
// acorn used char codes to squeeze the last bit of performance out
2153
// Beautifier is okay without that, so we're using regex
2154
// permit # (23), $ (36), and @ (64). @ is used in ES7 decorators.
2155
// 65 through 91 are uppercase letters.
2156
// permit _ (95).
2157
// 97 through 123 are lowercase letters.
2158
var baseASCIIidentifierStartChars = "\\x23\\x24\\x40\\x41-\\x5a\\x5f\\x61-\\x7a";
2159
 
2160
// inside an identifier @ is not allowed but 0-9 are.
2161
var baseASCIIidentifierChars = "\\x24\\x30-\\x39\\x41-\\x5a\\x5f\\x61-\\x7a";
2162
 
2163
// Big ugly regular expressions that match characters in the
2164
// whitespace, identifier, and identifier-start categories. These
2165
// are only applied when a character is found to actually have a
2166
// code point above 128.
2167
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";
2168
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";
2169
//var nonASCIIidentifierStart = new RegExp("[" + nonASCIIidentifierStartChars + "]");
2170
//var nonASCIIidentifier = new RegExp("[" + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "]");
2171
 
2172
var unicodeEscapeOrCodePoint = "\\\\u[0-9a-fA-F]{4}|\\\\u\\{[0-9a-fA-F]+\\}";
2173
var identifierStart = "(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierStartChars + nonASCIIidentifierStartChars + "])";
2174
var identifierChars = "(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])*";
2175
 
2176
exports.identifier = new RegExp(identifierStart + identifierChars, 'g');
2177
exports.identifierStart = new RegExp(identifierStart);
2178
exports.identifierMatch = new RegExp("(?:" + unicodeEscapeOrCodePoint + "|[" + baseASCIIidentifierChars + nonASCIIidentifierStartChars + nonASCIIidentifierChars + "])+");
2179
 
2180
var nonASCIIwhitespace = /[\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff]/; // jshint ignore:line
2181
 
2182
// Whether a single character denotes a newline.
2183
 
2184
exports.newline = /[\n\r\u2028\u2029]/;
2185
 
2186
// Matches a whole line break (where CRLF is considered a single
2187
// line break). Used to count lines.
2188
 
2189
// in javascript, these two differ
2190
// in python they are the same, different methods are called on them
2191
exports.lineBreak = new RegExp('\r\n|' + exports.newline.source);
2192
exports.allLineBreaks = new RegExp(exports.lineBreak.source, 'g');
2193
 
2194
 
2195
/***/ }),
2196
/* 5 */
2197
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2198
 
2199
/*jshint node:true */
2200
/*
2201
 
2202
  The MIT License (MIT)
2203
 
2204
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2205
 
2206
  Permission is hereby granted, free of charge, to any person
2207
  obtaining a copy of this software and associated documentation files
2208
  (the "Software"), to deal in the Software without restriction,
2209
  including without limitation the rights to use, copy, modify, merge,
2210
  publish, distribute, sublicense, and/or sell copies of the Software,
2211
  and to permit persons to whom the Software is furnished to do so,
2212
  subject to the following conditions:
2213
 
2214
  The above copyright notice and this permission notice shall be
2215
  included in all copies or substantial portions of the Software.
2216
 
2217
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2218
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2219
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2220
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2221
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2222
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2223
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2224
  SOFTWARE.
2225
*/
2226
 
2227
 
2228
 
2229
var BaseOptions = (__webpack_require__(6).Options);
2230
 
2231
var validPositionValues = ['before-newline', 'after-newline', 'preserve-newline'];
2232
 
2233
function Options(options) {
2234
  BaseOptions.call(this, options, 'js');
2235
 
2236
  // compatibility, re
2237
  var raw_brace_style = this.raw_options.brace_style || null;
2238
  if (raw_brace_style === "expand-strict") { //graceful handling of deprecated option
2239
    this.raw_options.brace_style = "expand";
2240
  } else if (raw_brace_style === "collapse-preserve-inline") { //graceful handling of deprecated option
2241
    this.raw_options.brace_style = "collapse,preserve-inline";
2242
  } else if (this.raw_options.braces_on_own_line !== undefined) { //graceful handling of deprecated option
2243
    this.raw_options.brace_style = this.raw_options.braces_on_own_line ? "expand" : "collapse";
2244
    // } else if (!raw_brace_style) { //Nothing exists to set it
2245
    //   raw_brace_style = "collapse";
2246
  }
2247
 
2248
  //preserve-inline in delimited string will trigger brace_preserve_inline, everything
2249
  //else is considered a brace_style and the last one only will have an effect
2250
 
2251
  var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
2252
 
2253
  this.brace_preserve_inline = false; //Defaults in case one or other was not specified in meta-option
2254
  this.brace_style = "collapse";
2255
 
2256
  for (var bs = 0; bs < brace_style_split.length; bs++) {
2257
    if (brace_style_split[bs] === "preserve-inline") {
2258
      this.brace_preserve_inline = true;
2259
    } else {
2260
      this.brace_style = brace_style_split[bs];
2261
    }
2262
  }
2263
 
2264
  this.unindent_chained_methods = this._get_boolean('unindent_chained_methods');
2265
  this.break_chained_methods = this._get_boolean('break_chained_methods');
2266
  this.space_in_paren = this._get_boolean('space_in_paren');
2267
  this.space_in_empty_paren = this._get_boolean('space_in_empty_paren');
2268
  this.jslint_happy = this._get_boolean('jslint_happy');
2269
  this.space_after_anon_function = this._get_boolean('space_after_anon_function');
2270
  this.space_after_named_function = this._get_boolean('space_after_named_function');
2271
  this.keep_array_indentation = this._get_boolean('keep_array_indentation');
2272
  this.space_before_conditional = this._get_boolean('space_before_conditional', true);
2273
  this.unescape_strings = this._get_boolean('unescape_strings');
2274
  this.e4x = this._get_boolean('e4x');
2275
  this.comma_first = this._get_boolean('comma_first');
2276
  this.operator_position = this._get_selection('operator_position', validPositionValues);
2277
 
2278
  // For testing of beautify preserve:start directive
2279
  this.test_output_raw = this._get_boolean('test_output_raw');
2280
 
2281
  // force this._options.space_after_anon_function to true if this._options.jslint_happy
2282
  if (this.jslint_happy) {
2283
    this.space_after_anon_function = true;
2284
  }
2285
 
2286
}
2287
Options.prototype = new BaseOptions();
2288
 
2289
 
2290
 
2291
module.exports.Options = Options;
2292
 
2293
 
2294
/***/ }),
2295
/* 6 */
2296
/***/ (function(module) {
2297
 
2298
/*jshint node:true */
2299
/*
2300
 
2301
  The MIT License (MIT)
2302
 
2303
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2304
 
2305
  Permission is hereby granted, free of charge, to any person
2306
  obtaining a copy of this software and associated documentation files
2307
  (the "Software"), to deal in the Software without restriction,
2308
  including without limitation the rights to use, copy, modify, merge,
2309
  publish, distribute, sublicense, and/or sell copies of the Software,
2310
  and to permit persons to whom the Software is furnished to do so,
2311
  subject to the following conditions:
2312
 
2313
  The above copyright notice and this permission notice shall be
2314
  included in all copies or substantial portions of the Software.
2315
 
2316
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2317
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2318
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2319
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2320
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2321
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2322
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
  SOFTWARE.
2324
*/
2325
 
2326
 
2327
 
2328
function Options(options, merge_child_field) {
2329
  this.raw_options = _mergeOpts(options, merge_child_field);
2330
 
2331
  // Support passing the source text back with no change
2332
  this.disabled = this._get_boolean('disabled');
2333
 
2334
  this.eol = this._get_characters('eol', 'auto');
2335
  this.end_with_newline = this._get_boolean('end_with_newline');
2336
  this.indent_size = this._get_number('indent_size', 4);
2337
  this.indent_char = this._get_characters('indent_char', ' ');
2338
  this.indent_level = this._get_number('indent_level');
2339
 
2340
  this.preserve_newlines = this._get_boolean('preserve_newlines', true);
2341
  this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
2342
  if (!this.preserve_newlines) {
2343
    this.max_preserve_newlines = 0;
2344
  }
2345
 
2346
  this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
2347
  if (this.indent_with_tabs) {
2348
    this.indent_char = '\t';
2349
 
2350
    // indent_size behavior changed after 1.8.6
2351
    // It used to be that indent_size would be
2352
    // set to 1 for indent_with_tabs. That is no longer needed and
2353
    // actually doesn't make sense - why not use spaces? Further,
2354
    // that might produce unexpected behavior - tabs being used
2355
    // for single-column alignment. So, when indent_with_tabs is true
2356
    // and indent_size is 1, reset indent_size to 4.
2357
    if (this.indent_size === 1) {
2358
      this.indent_size = 4;
2359
    }
2360
  }
2361
 
2362
  // Backwards compat with 1.3.x
2363
  this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
2364
 
2365
  this.indent_empty_lines = this._get_boolean('indent_empty_lines');
2366
 
2367
  // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
2368
  // For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
2369
  // other values ignored
2370
  this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
2371
}
2372
 
2373
Options.prototype._get_array = function(name, default_value) {
2374
  var option_value = this.raw_options[name];
2375
  var result = default_value || [];
2376
  if (typeof option_value === 'object') {
2377
    if (option_value !== null && typeof option_value.concat === 'function') {
2378
      result = option_value.concat();
2379
    }
2380
  } else if (typeof option_value === 'string') {
2381
    result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
2382
  }
2383
  return result;
2384
};
2385
 
2386
Options.prototype._get_boolean = function(name, default_value) {
2387
  var option_value = this.raw_options[name];
2388
  var result = option_value === undefined ? !!default_value : !!option_value;
2389
  return result;
2390
};
2391
 
2392
Options.prototype._get_characters = function(name, default_value) {
2393
  var option_value = this.raw_options[name];
2394
  var result = default_value || '';
2395
  if (typeof option_value === 'string') {
2396
    result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
2397
  }
2398
  return result;
2399
};
2400
 
2401
Options.prototype._get_number = function(name, default_value) {
2402
  var option_value = this.raw_options[name];
2403
  default_value = parseInt(default_value, 10);
2404
  if (isNaN(default_value)) {
2405
    default_value = 0;
2406
  }
2407
  var result = parseInt(option_value, 10);
2408
  if (isNaN(result)) {
2409
    result = default_value;
2410
  }
2411
  return result;
2412
};
2413
 
2414
Options.prototype._get_selection = function(name, selection_list, default_value) {
2415
  var result = this._get_selection_list(name, selection_list, default_value);
2416
  if (result.length !== 1) {
2417
    throw new Error(
2418
      "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
2419
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
2420
  }
2421
 
2422
  return result[0];
2423
};
2424
 
2425
 
2426
Options.prototype._get_selection_list = function(name, selection_list, default_value) {
2427
  if (!selection_list || selection_list.length === 0) {
2428
    throw new Error("Selection list cannot be empty.");
2429
  }
2430
 
2431
  default_value = default_value || [selection_list[0]];
2432
  if (!this._is_valid_selection(default_value, selection_list)) {
2433
    throw new Error("Invalid Default Value!");
2434
  }
2435
 
2436
  var result = this._get_array(name, default_value);
2437
  if (!this._is_valid_selection(result, selection_list)) {
2438
    throw new Error(
2439
      "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
2440
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
2441
  }
2442
 
2443
  return result;
2444
};
2445
 
2446
Options.prototype._is_valid_selection = function(result, selection_list) {
2447
  return result.length && selection_list.length &&
2448
    !result.some(function(item) { return selection_list.indexOf(item) === -1; });
2449
};
2450
 
2451
 
2452
// merges child options up with the parent options object
2453
// Example: obj = {a: 1, b: {a: 2}}
2454
//          mergeOpts(obj, 'b')
2455
//
2456
//          Returns: {a: 2}
2457
function _mergeOpts(allOptions, childFieldName) {
2458
  var finalOpts = {};
2459
  allOptions = _normalizeOpts(allOptions);
2460
  var name;
2461
 
2462
  for (name in allOptions) {
2463
    if (name !== childFieldName) {
2464
      finalOpts[name] = allOptions[name];
2465
    }
2466
  }
2467
 
2468
  //merge in the per type settings for the childFieldName
2469
  if (childFieldName && allOptions[childFieldName]) {
2470
    for (name in allOptions[childFieldName]) {
2471
      finalOpts[name] = allOptions[childFieldName][name];
2472
    }
2473
  }
2474
  return finalOpts;
2475
}
2476
 
2477
function _normalizeOpts(options) {
2478
  var convertedOpts = {};
2479
  var key;
2480
 
2481
  for (key in options) {
2482
    var newKey = key.replace(/-/g, "_");
2483
    convertedOpts[newKey] = options[key];
2484
  }
2485
  return convertedOpts;
2486
}
2487
 
2488
module.exports.Options = Options;
2489
module.exports.normalizeOpts = _normalizeOpts;
2490
module.exports.mergeOpts = _mergeOpts;
2491
 
2492
 
2493
/***/ }),
2494
/* 7 */
2495
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
2496
 
2497
/*jshint node:true */
2498
/*
2499
 
2500
  The MIT License (MIT)
2501
 
2502
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
2503
 
2504
  Permission is hereby granted, free of charge, to any person
2505
  obtaining a copy of this software and associated documentation files
2506
  (the "Software"), to deal in the Software without restriction,
2507
  including without limitation the rights to use, copy, modify, merge,
2508
  publish, distribute, sublicense, and/or sell copies of the Software,
2509
  and to permit persons to whom the Software is furnished to do so,
2510
  subject to the following conditions:
2511
 
2512
  The above copyright notice and this permission notice shall be
2513
  included in all copies or substantial portions of the Software.
2514
 
2515
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
2516
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
2517
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
2518
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
2519
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
2520
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
2521
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2522
  SOFTWARE.
2523
*/
2524
 
2525
 
2526
 
2527
var InputScanner = (__webpack_require__(8).InputScanner);
2528
var BaseTokenizer = (__webpack_require__(9).Tokenizer);
2529
var BASETOKEN = (__webpack_require__(9).TOKEN);
2530
var Directives = (__webpack_require__(13).Directives);
2531
var acorn = __webpack_require__(4);
2532
var Pattern = (__webpack_require__(12).Pattern);
2533
var TemplatablePattern = (__webpack_require__(14).TemplatablePattern);
2534
 
2535
 
2536
function in_array(what, arr) {
2537
  return arr.indexOf(what) !== -1;
2538
}
2539
 
2540
 
2541
var TOKEN = {
2542
  START_EXPR: 'TK_START_EXPR',
2543
  END_EXPR: 'TK_END_EXPR',
2544
  START_BLOCK: 'TK_START_BLOCK',
2545
  END_BLOCK: 'TK_END_BLOCK',
2546
  WORD: 'TK_WORD',
2547
  RESERVED: 'TK_RESERVED',
2548
  SEMICOLON: 'TK_SEMICOLON',
2549
  STRING: 'TK_STRING',
2550
  EQUALS: 'TK_EQUALS',
2551
  OPERATOR: 'TK_OPERATOR',
2552
  COMMA: 'TK_COMMA',
2553
  BLOCK_COMMENT: 'TK_BLOCK_COMMENT',
2554
  COMMENT: 'TK_COMMENT',
2555
  DOT: 'TK_DOT',
2556
  UNKNOWN: 'TK_UNKNOWN',
2557
  START: BASETOKEN.START,
2558
  RAW: BASETOKEN.RAW,
2559
  EOF: BASETOKEN.EOF
2560
};
2561
 
2562
 
2563
var directives_core = new Directives(/\/\*/, /\*\//);
2564
 
2565
var number_pattern = /0[xX][0123456789abcdefABCDEF_]*n?|0[oO][01234567_]*n?|0[bB][01_]*n?|\d[\d_]*n|(?:\.\d[\d_]*|\d[\d_]*\.?[\d_]*)(?:[eE][+-]?[\d_]+)?/;
2566
 
2567
var digit = /[0-9]/;
2568
 
2569
// Dot "." must be distinguished from "..." and decimal
2570
var dot_pattern = /[^\d\.]/;
2571
 
2572
var positionable_operators = (
2573
  ">>> === !== &&= ??= ||= " +
2574
  "<< && >= ** != == <= >> || ?? |> " +
2575
  "< / - + > : & % ? ^ | *").split(' ');
2576
 
2577
// IMPORTANT: this must be sorted longest to shortest or tokenizing many not work.
2578
// Also, you must update possitionable operators separately from punct
2579
var punct =
2580
  ">>>= " +
2581
  "... >>= <<= === >>> !== **= &&= ??= ||= " +
2582
  "=> ^= :: /= << <= == && -= >= >> != -- += ** || ?? ++ %= &= *= |= |> " +
2583
  "= ! ? > < : / ^ - + * & % ~ |";
2584
 
2585
punct = punct.replace(/[-[\]{}()*+?.,\\^$|#]/g, "\\$&");
2586
// ?. but not if followed by a number
2587
punct = '\\?\\.(?!\\d) ' + punct;
2588
punct = punct.replace(/ /g, '|');
2589
 
2590
var punct_pattern = new RegExp(punct);
2591
 
2592
// words which should always start on new line.
2593
var line_starters = 'continue,try,throw,return,var,let,const,if,switch,case,default,for,while,break,function,import,export'.split(',');
2594
var reserved_words = line_starters.concat(['do', 'in', 'of', 'else', 'get', 'set', 'new', 'catch', 'finally', 'typeof', 'yield', 'async', 'await', 'from', 'as', 'class', 'extends']);
2595
var reserved_word_pattern = new RegExp('^(?:' + reserved_words.join('|') + ')$');
2596
 
2597
// var template_pattern = /(?:(?:<\?php|<\?=)[\s\S]*?\?>)|(?:<%[\s\S]*?%>)/g;
2598
 
2599
var in_html_comment;
2600
 
2601
var Tokenizer = function(input_string, options) {
2602
  BaseTokenizer.call(this, input_string, options);
2603
 
2604
  this._patterns.whitespace = this._patterns.whitespace.matching(
2605
    /\u00A0\u1680\u180e\u2000-\u200a\u202f\u205f\u3000\ufeff/.source,
2606
    /\u2028\u2029/.source);
2607
 
2608
  var pattern_reader = new Pattern(this._input);
2609
  var templatable = new TemplatablePattern(this._input)
2610
    .read_options(this._options);
2611
 
2612
  this.__patterns = {
2613
    template: templatable,
2614
    identifier: templatable.starting_with(acorn.identifier).matching(acorn.identifierMatch),
2615
    number: pattern_reader.matching(number_pattern),
2616
    punct: pattern_reader.matching(punct_pattern),
2617
    // comment ends just before nearest linefeed or end of file
2618
    comment: pattern_reader.starting_with(/\/\//).until(/[\n\r\u2028\u2029]/),
2619
    //  /* ... */ comment ends with nearest */ or end of file
2620
    block_comment: pattern_reader.starting_with(/\/\*/).until_after(/\*\//),
2621
    html_comment_start: pattern_reader.matching(/<!--/),
2622
    html_comment_end: pattern_reader.matching(/-->/),
2623
    include: pattern_reader.starting_with(/#include/).until_after(acorn.lineBreak),
2624
    shebang: pattern_reader.starting_with(/#!/).until_after(acorn.lineBreak),
2625
    xml: pattern_reader.matching(/[\s\S]*?<(\/?)([-a-zA-Z:0-9_.]+|{[^}]+?}|!\[CDATA\[[^\]]*?\]\]|)(\s*{[^}]+?}|\s+[-a-zA-Z:0-9_.]+|\s+[-a-zA-Z:0-9_.]+\s*=\s*('[^']*'|"[^"]*"|{([^{}]|{[^}]+?})+?}))*\s*(\/?)\s*>/),
2626
    single_quote: templatable.until(/['\\\n\r\u2028\u2029]/),
2627
    double_quote: templatable.until(/["\\\n\r\u2028\u2029]/),
2628
    template_text: templatable.until(/[`\\$]/),
2629
    template_expression: templatable.until(/[`}\\]/)
2630
  };
2631
 
2632
};
2633
Tokenizer.prototype = new BaseTokenizer();
2634
 
2635
Tokenizer.prototype._is_comment = function(current_token) {
2636
  return current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.BLOCK_COMMENT || current_token.type === TOKEN.UNKNOWN;
2637
};
2638
 
2639
Tokenizer.prototype._is_opening = function(current_token) {
2640
  return current_token.type === TOKEN.START_BLOCK || current_token.type === TOKEN.START_EXPR;
2641
};
2642
 
2643
Tokenizer.prototype._is_closing = function(current_token, open_token) {
2644
  return (current_token.type === TOKEN.END_BLOCK || current_token.type === TOKEN.END_EXPR) &&
2645
    (open_token && (
2646
      (current_token.text === ']' && open_token.text === '[') ||
2647
      (current_token.text === ')' && open_token.text === '(') ||
2648
      (current_token.text === '}' && open_token.text === '{')));
2649
};
2650
 
2651
Tokenizer.prototype._reset = function() {
2652
  in_html_comment = false;
2653
};
2654
 
2655
Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
2656
  var token = null;
2657
  this._readWhitespace();
2658
  var c = this._input.peek();
2659
 
2660
  if (c === null) {
2661
    return this._create_token(TOKEN.EOF, '');
2662
  }
2663
 
2664
  token = token || this._read_non_javascript(c);
2665
  token = token || this._read_string(c);
2666
  token = token || this._read_pair(c, this._input.peek(1)); // Issue #2062 hack for record type '#{'
2667
  token = token || this._read_word(previous_token);
2668
  token = token || this._read_singles(c);
2669
  token = token || this._read_comment(c);
2670
  token = token || this._read_regexp(c, previous_token);
2671
  token = token || this._read_xml(c, previous_token);
2672
  token = token || this._read_punctuation();
2673
  token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
2674
 
2675
  return token;
2676
};
2677
 
2678
Tokenizer.prototype._read_word = function(previous_token) {
2679
  var resulting_string;
2680
  resulting_string = this.__patterns.identifier.read();
2681
  if (resulting_string !== '') {
2682
    resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
2683
    if (!(previous_token.type === TOKEN.DOT ||
2684
        (previous_token.type === TOKEN.RESERVED && (previous_token.text === 'set' || previous_token.text === 'get'))) &&
2685
      reserved_word_pattern.test(resulting_string)) {
2686
      if ((resulting_string === 'in' || resulting_string === 'of') &&
2687
        (previous_token.type === TOKEN.WORD || previous_token.type === TOKEN.STRING)) { // hack for 'in' and 'of' operators
2688
        return this._create_token(TOKEN.OPERATOR, resulting_string);
2689
      }
2690
      return this._create_token(TOKEN.RESERVED, resulting_string);
2691
    }
2692
    return this._create_token(TOKEN.WORD, resulting_string);
2693
  }
2694
 
2695
  resulting_string = this.__patterns.number.read();
2696
  if (resulting_string !== '') {
2697
    return this._create_token(TOKEN.WORD, resulting_string);
2698
  }
2699
};
2700
 
2701
Tokenizer.prototype._read_singles = function(c) {
2702
  var token = null;
2703
  if (c === '(' || c === '[') {
2704
    token = this._create_token(TOKEN.START_EXPR, c);
2705
  } else if (c === ')' || c === ']') {
2706
    token = this._create_token(TOKEN.END_EXPR, c);
2707
  } else if (c === '{') {
2708
    token = this._create_token(TOKEN.START_BLOCK, c);
2709
  } else if (c === '}') {
2710
    token = this._create_token(TOKEN.END_BLOCK, c);
2711
  } else if (c === ';') {
2712
    token = this._create_token(TOKEN.SEMICOLON, c);
2713
  } else if (c === '.' && dot_pattern.test(this._input.peek(1))) {
2714
    token = this._create_token(TOKEN.DOT, c);
2715
  } else if (c === ',') {
2716
    token = this._create_token(TOKEN.COMMA, c);
2717
  }
2718
 
2719
  if (token) {
2720
    this._input.next();
2721
  }
2722
  return token;
2723
};
2724
 
2725
Tokenizer.prototype._read_pair = function(c, d) {
2726
  var token = null;
2727
  if (c === '#' && d === '{') {
2728
    token = this._create_token(TOKEN.START_BLOCK, c + d);
2729
  }
2730
 
2731
  if (token) {
2732
    this._input.next();
2733
    this._input.next();
2734
  }
2735
  return token;
2736
};
2737
 
2738
Tokenizer.prototype._read_punctuation = function() {
2739
  var resulting_string = this.__patterns.punct.read();
2740
 
2741
  if (resulting_string !== '') {
2742
    if (resulting_string === '=') {
2743
      return this._create_token(TOKEN.EQUALS, resulting_string);
2744
    } else if (resulting_string === '?.') {
2745
      return this._create_token(TOKEN.DOT, resulting_string);
2746
    } else {
2747
      return this._create_token(TOKEN.OPERATOR, resulting_string);
2748
    }
2749
  }
2750
};
2751
 
2752
Tokenizer.prototype._read_non_javascript = function(c) {
2753
  var resulting_string = '';
2754
 
2755
  if (c === '#') {
2756
    if (this._is_first_token()) {
2757
      resulting_string = this.__patterns.shebang.read();
2758
 
2759
      if (resulting_string) {
2760
        return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + '\n');
2761
      }
2762
    }
2763
 
2764
    // handles extendscript #includes
2765
    resulting_string = this.__patterns.include.read();
2766
 
2767
    if (resulting_string) {
2768
      return this._create_token(TOKEN.UNKNOWN, resulting_string.trim() + '\n');
2769
    }
2770
 
2771
    c = this._input.next();
2772
 
2773
    // Spidermonkey-specific sharp variables for circular references. Considered obsolete.
2774
    var sharp = '#';
2775
    if (this._input.hasNext() && this._input.testChar(digit)) {
2776
      do {
2777
        c = this._input.next();
2778
        sharp += c;
2779
      } while (this._input.hasNext() && c !== '#' && c !== '=');
2780
      if (c === '#') {
2781
        //
2782
      } else if (this._input.peek() === '[' && this._input.peek(1) === ']') {
2783
        sharp += '[]';
2784
        this._input.next();
2785
        this._input.next();
2786
      } else if (this._input.peek() === '{' && this._input.peek(1) === '}') {
2787
        sharp += '{}';
2788
        this._input.next();
2789
        this._input.next();
2790
      }
2791
      return this._create_token(TOKEN.WORD, sharp);
2792
    }
2793
 
2794
    this._input.back();
2795
 
2796
  } else if (c === '<' && this._is_first_token()) {
2797
    resulting_string = this.__patterns.html_comment_start.read();
2798
    if (resulting_string) {
2799
      while (this._input.hasNext() && !this._input.testChar(acorn.newline)) {
2800
        resulting_string += this._input.next();
2801
      }
2802
      in_html_comment = true;
2803
      return this._create_token(TOKEN.COMMENT, resulting_string);
2804
    }
2805
  } else if (in_html_comment && c === '-') {
2806
    resulting_string = this.__patterns.html_comment_end.read();
2807
    if (resulting_string) {
2808
      in_html_comment = false;
2809
      return this._create_token(TOKEN.COMMENT, resulting_string);
2810
    }
2811
  }
2812
 
2813
  return null;
2814
};
2815
 
2816
Tokenizer.prototype._read_comment = function(c) {
2817
  var token = null;
2818
  if (c === '/') {
2819
    var comment = '';
2820
    if (this._input.peek(1) === '*') {
2821
      // peek for comment /* ... */
2822
      comment = this.__patterns.block_comment.read();
2823
      var directives = directives_core.get_directives(comment);
2824
      if (directives && directives.ignore === 'start') {
2825
        comment += directives_core.readIgnored(this._input);
2826
      }
2827
      comment = comment.replace(acorn.allLineBreaks, '\n');
2828
      token = this._create_token(TOKEN.BLOCK_COMMENT, comment);
2829
      token.directives = directives;
2830
    } else if (this._input.peek(1) === '/') {
2831
      // peek for comment // ...
2832
      comment = this.__patterns.comment.read();
2833
      token = this._create_token(TOKEN.COMMENT, comment);
2834
    }
2835
  }
2836
  return token;
2837
};
2838
 
2839
Tokenizer.prototype._read_string = function(c) {
2840
  if (c === '`' || c === "'" || c === '"') {
2841
    var resulting_string = this._input.next();
2842
    this.has_char_escapes = false;
2843
 
2844
    if (c === '`') {
2845
      resulting_string += this._read_string_recursive('`', true, '${');
2846
    } else {
2847
      resulting_string += this._read_string_recursive(c);
2848
    }
2849
 
2850
    if (this.has_char_escapes && this._options.unescape_strings) {
2851
      resulting_string = unescape_string(resulting_string);
2852
    }
2853
 
2854
    if (this._input.peek() === c) {
2855
      resulting_string += this._input.next();
2856
    }
2857
 
2858
    resulting_string = resulting_string.replace(acorn.allLineBreaks, '\n');
2859
 
2860
    return this._create_token(TOKEN.STRING, resulting_string);
2861
  }
2862
 
2863
  return null;
2864
};
2865
 
2866
Tokenizer.prototype._allow_regexp_or_xml = function(previous_token) {
2867
  // regex and xml can only appear in specific locations during parsing
2868
  return (previous_token.type === TOKEN.RESERVED && in_array(previous_token.text, ['return', 'case', 'throw', 'else', 'do', 'typeof', 'yield'])) ||
2869
    (previous_token.type === TOKEN.END_EXPR && previous_token.text === ')' &&
2870
      previous_token.opened.previous.type === TOKEN.RESERVED && in_array(previous_token.opened.previous.text, ['if', 'while', 'for'])) ||
2871
    (in_array(previous_token.type, [TOKEN.COMMENT, TOKEN.START_EXPR, TOKEN.START_BLOCK, TOKEN.START,
2872
      TOKEN.END_BLOCK, TOKEN.OPERATOR, TOKEN.EQUALS, TOKEN.EOF, TOKEN.SEMICOLON, TOKEN.COMMA
2873
    ]));
2874
};
2875
 
2876
Tokenizer.prototype._read_regexp = function(c, previous_token) {
2877
 
2878
  if (c === '/' && this._allow_regexp_or_xml(previous_token)) {
2879
    // handle regexp
2880
    //
2881
    var resulting_string = this._input.next();
2882
    var esc = false;
2883
 
2884
    var in_char_class = false;
2885
    while (this._input.hasNext() &&
2886
      ((esc || in_char_class || this._input.peek() !== c) &&
2887
        !this._input.testChar(acorn.newline))) {
2888
      resulting_string += this._input.peek();
2889
      if (!esc) {
2890
        esc = this._input.peek() === '\\';
2891
        if (this._input.peek() === '[') {
2892
          in_char_class = true;
2893
        } else if (this._input.peek() === ']') {
2894
          in_char_class = false;
2895
        }
2896
      } else {
2897
        esc = false;
2898
      }
2899
      this._input.next();
2900
    }
2901
 
2902
    if (this._input.peek() === c) {
2903
      resulting_string += this._input.next();
2904
 
2905
      // regexps may have modifiers /regexp/MOD , so fetch those, too
2906
      // Only [gim] are valid, but if the user puts in garbage, do what we can to take it.
2907
      resulting_string += this._input.read(acorn.identifier);
2908
    }
2909
    return this._create_token(TOKEN.STRING, resulting_string);
2910
  }
2911
  return null;
2912
};
2913
 
2914
Tokenizer.prototype._read_xml = function(c, previous_token) {
2915
 
2916
  if (this._options.e4x && c === "<" && this._allow_regexp_or_xml(previous_token)) {
2917
    var xmlStr = '';
2918
    var match = this.__patterns.xml.read_match();
2919
    // handle e4x xml literals
2920
    //
2921
    if (match) {
2922
      // Trim root tag to attempt to
2923
      var rootTag = match[2].replace(/^{\s+/, '{').replace(/\s+}$/, '}');
2924
      var isCurlyRoot = rootTag.indexOf('{') === 0;
2925
      var depth = 0;
2926
      while (match) {
2927
        var isEndTag = !!match[1];
2928
        var tagName = match[2];
2929
        var isSingletonTag = (!!match[match.length - 1]) || (tagName.slice(0, 8) === "![CDATA[");
2930
        if (!isSingletonTag &&
2931
          (tagName === rootTag || (isCurlyRoot && tagName.replace(/^{\s+/, '{').replace(/\s+}$/, '}')))) {
2932
          if (isEndTag) {
2933
            --depth;
2934
          } else {
2935
            ++depth;
2936
          }
2937
        }
2938
        xmlStr += match[0];
2939
        if (depth <= 0) {
2940
          break;
2941
        }
2942
        match = this.__patterns.xml.read_match();
2943
      }
2944
      // if we didn't close correctly, keep unformatted.
2945
      if (!match) {
2946
        xmlStr += this._input.match(/[\s\S]*/g)[0];
2947
      }
2948
      xmlStr = xmlStr.replace(acorn.allLineBreaks, '\n');
2949
      return this._create_token(TOKEN.STRING, xmlStr);
2950
    }
2951
  }
2952
 
2953
  return null;
2954
};
2955
 
2956
function unescape_string(s) {
2957
  // You think that a regex would work for this
2958
  // return s.replace(/\\x([0-9a-f]{2})/gi, function(match, val) {
2959
  //         return String.fromCharCode(parseInt(val, 16));
2960
  //     })
2961
  // However, dealing with '\xff', '\\xff', '\\\xff' makes this more fun.
2962
  var out = '',
2963
    escaped = 0;
2964
 
2965
  var input_scan = new InputScanner(s);
2966
  var matched = null;
2967
 
2968
  while (input_scan.hasNext()) {
2969
    // Keep any whitespace, non-slash characters
2970
    // also keep slash pairs.
2971
    matched = input_scan.match(/([\s]|[^\\]|\\\\)+/g);
2972
 
2973
    if (matched) {
2974
      out += matched[0];
2975
    }
2976
 
2977
    if (input_scan.peek() === '\\') {
2978
      input_scan.next();
2979
      if (input_scan.peek() === 'x') {
2980
        matched = input_scan.match(/x([0-9A-Fa-f]{2})/g);
2981
      } else if (input_scan.peek() === 'u') {
2982
        matched = input_scan.match(/u([0-9A-Fa-f]{4})/g);
2983
        if (!matched) {
2984
          matched = input_scan.match(/u\{([0-9A-Fa-f]+)\}/g);
2985
        }
2986
      } else {
2987
        out += '\\';
2988
        if (input_scan.hasNext()) {
2989
          out += input_scan.next();
2990
        }
2991
        continue;
2992
      }
2993
 
2994
      // If there's some error decoding, return the original string
2995
      if (!matched) {
2996
        return s;
2997
      }
2998
 
2999
      escaped = parseInt(matched[1], 16);
3000
 
3001
      if (escaped > 0x7e && escaped <= 0xff && matched[0].indexOf('x') === 0) {
3002
        // we bail out on \x7f..\xff,
3003
        // leaving whole string escaped,
3004
        // as it's probably completely binary
3005
        return s;
3006
      } else if (escaped >= 0x00 && escaped < 0x20) {
3007
        // leave 0x00...0x1f escaped
3008
        out += '\\' + matched[0];
3009
      } else if (escaped > 0x10FFFF) {
3010
        // If the escape sequence is out of bounds, keep the original sequence and continue conversion
3011
        out += '\\' + matched[0];
3012
      } else if (escaped === 0x22 || escaped === 0x27 || escaped === 0x5c) {
3013
        // single-quote, apostrophe, backslash - escape these
3014
        out += '\\' + String.fromCharCode(escaped);
3015
      } else {
3016
        out += String.fromCharCode(escaped);
3017
      }
3018
    }
3019
  }
3020
 
3021
  return out;
3022
}
3023
 
3024
// handle string
3025
//
3026
Tokenizer.prototype._read_string_recursive = function(delimiter, allow_unescaped_newlines, start_sub) {
3027
  var current_char;
3028
  var pattern;
3029
  if (delimiter === '\'') {
3030
    pattern = this.__patterns.single_quote;
3031
  } else if (delimiter === '"') {
3032
    pattern = this.__patterns.double_quote;
3033
  } else if (delimiter === '`') {
3034
    pattern = this.__patterns.template_text;
3035
  } else if (delimiter === '}') {
3036
    pattern = this.__patterns.template_expression;
3037
  }
3038
 
3039
  var resulting_string = pattern.read();
3040
  var next = '';
3041
  while (this._input.hasNext()) {
3042
    next = this._input.next();
3043
    if (next === delimiter ||
3044
      (!allow_unescaped_newlines && acorn.newline.test(next))) {
3045
      this._input.back();
3046
      break;
3047
    } else if (next === '\\' && this._input.hasNext()) {
3048
      current_char = this._input.peek();
3049
 
3050
      if (current_char === 'x' || current_char === 'u') {
3051
        this.has_char_escapes = true;
3052
      } else if (current_char === '\r' && this._input.peek(1) === '\n') {
3053
        this._input.next();
3054
      }
3055
      next += this._input.next();
3056
    } else if (start_sub) {
3057
      if (start_sub === '${' && next === '$' && this._input.peek() === '{') {
3058
        next += this._input.next();
3059
      }
3060
 
3061
      if (start_sub === next) {
3062
        if (delimiter === '`') {
3063
          next += this._read_string_recursive('}', allow_unescaped_newlines, '`');
3064
        } else {
3065
          next += this._read_string_recursive('`', allow_unescaped_newlines, '${');
3066
        }
3067
        if (this._input.hasNext()) {
3068
          next += this._input.next();
3069
        }
3070
      }
3071
    }
3072
    next += pattern.read();
3073
    resulting_string += next;
3074
  }
3075
 
3076
  return resulting_string;
3077
};
3078
 
3079
module.exports.Tokenizer = Tokenizer;
3080
module.exports.TOKEN = TOKEN;
3081
module.exports.positionable_operators = positionable_operators.slice();
3082
module.exports.line_starters = line_starters.slice();
3083
 
3084
 
3085
/***/ }),
3086
/* 8 */
3087
/***/ (function(module) {
3088
 
3089
/*jshint node:true */
3090
/*
3091
 
3092
  The MIT License (MIT)
3093
 
3094
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3095
 
3096
  Permission is hereby granted, free of charge, to any person
3097
  obtaining a copy of this software and associated documentation files
3098
  (the "Software"), to deal in the Software without restriction,
3099
  including without limitation the rights to use, copy, modify, merge,
3100
  publish, distribute, sublicense, and/or sell copies of the Software,
3101
  and to permit persons to whom the Software is furnished to do so,
3102
  subject to the following conditions:
3103
 
3104
  The above copyright notice and this permission notice shall be
3105
  included in all copies or substantial portions of the Software.
3106
 
3107
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3108
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3109
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3110
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3111
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3112
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3113
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3114
  SOFTWARE.
3115
*/
3116
 
3117
 
3118
 
3119
var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
3120
 
3121
function InputScanner(input_string) {
3122
  this.__input = input_string || '';
3123
  this.__input_length = this.__input.length;
3124
  this.__position = 0;
3125
}
3126
 
3127
InputScanner.prototype.restart = function() {
3128
  this.__position = 0;
3129
};
3130
 
3131
InputScanner.prototype.back = function() {
3132
  if (this.__position > 0) {
3133
    this.__position -= 1;
3134
  }
3135
};
3136
 
3137
InputScanner.prototype.hasNext = function() {
3138
  return this.__position < this.__input_length;
3139
};
3140
 
3141
InputScanner.prototype.next = function() {
3142
  var val = null;
3143
  if (this.hasNext()) {
3144
    val = this.__input.charAt(this.__position);
3145
    this.__position += 1;
3146
  }
3147
  return val;
3148
};
3149
 
3150
InputScanner.prototype.peek = function(index) {
3151
  var val = null;
3152
  index = index || 0;
3153
  index += this.__position;
3154
  if (index >= 0 && index < this.__input_length) {
3155
    val = this.__input.charAt(index);
3156
  }
3157
  return val;
3158
};
3159
 
3160
// This is a JavaScript only helper function (not in python)
3161
// Javascript doesn't have a match method
3162
// and not all implementation support "sticky" flag.
3163
// If they do not support sticky then both this.match() and this.test() method
3164
// must get the match and check the index of the match.
3165
// If sticky is supported and set, this method will use it.
3166
// Otherwise it will check that global is set, and fall back to the slower method.
3167
InputScanner.prototype.__match = function(pattern, index) {
3168
  pattern.lastIndex = index;
3169
  var pattern_match = pattern.exec(this.__input);
3170
 
3171
  if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
3172
    if (pattern_match.index !== index) {
3173
      pattern_match = null;
3174
    }
3175
  }
3176
 
3177
  return pattern_match;
3178
};
3179
 
3180
InputScanner.prototype.test = function(pattern, index) {
3181
  index = index || 0;
3182
  index += this.__position;
3183
 
3184
  if (index >= 0 && index < this.__input_length) {
3185
    return !!this.__match(pattern, index);
3186
  } else {
3187
    return false;
3188
  }
3189
};
3190
 
3191
InputScanner.prototype.testChar = function(pattern, index) {
3192
  // test one character regex match
3193
  var val = this.peek(index);
3194
  pattern.lastIndex = 0;
3195
  return val !== null && pattern.test(val);
3196
};
3197
 
3198
InputScanner.prototype.match = function(pattern) {
3199
  var pattern_match = this.__match(pattern, this.__position);
3200
  if (pattern_match) {
3201
    this.__position += pattern_match[0].length;
3202
  } else {
3203
    pattern_match = null;
3204
  }
3205
  return pattern_match;
3206
};
3207
 
3208
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
3209
  var val = '';
3210
  var match;
3211
  if (starting_pattern) {
3212
    match = this.match(starting_pattern);
3213
    if (match) {
3214
      val += match[0];
3215
    }
3216
  }
3217
  if (until_pattern && (match || !starting_pattern)) {
3218
    val += this.readUntil(until_pattern, until_after);
3219
  }
3220
  return val;
3221
};
3222
 
3223
InputScanner.prototype.readUntil = function(pattern, until_after) {
3224
  var val = '';
3225
  var match_index = this.__position;
3226
  pattern.lastIndex = this.__position;
3227
  var pattern_match = pattern.exec(this.__input);
3228
  if (pattern_match) {
3229
    match_index = pattern_match.index;
3230
    if (until_after) {
3231
      match_index += pattern_match[0].length;
3232
    }
3233
  } else {
3234
    match_index = this.__input_length;
3235
  }
3236
 
3237
  val = this.__input.substring(this.__position, match_index);
3238
  this.__position = match_index;
3239
  return val;
3240
};
3241
 
3242
InputScanner.prototype.readUntilAfter = function(pattern) {
3243
  return this.readUntil(pattern, true);
3244
};
3245
 
3246
InputScanner.prototype.get_regexp = function(pattern, match_from) {
3247
  var result = null;
3248
  var flags = 'g';
3249
  if (match_from && regexp_has_sticky) {
3250
    flags = 'y';
3251
  }
3252
  // strings are converted to regexp
3253
  if (typeof pattern === "string" && pattern !== '') {
3254
    // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
3255
    result = new RegExp(pattern, flags);
3256
  } else if (pattern) {
3257
    result = new RegExp(pattern.source, flags);
3258
  }
3259
  return result;
3260
};
3261
 
3262
InputScanner.prototype.get_literal_regexp = function(literal_string) {
3263
  return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
3264
};
3265
 
3266
/* css beautifier legacy helpers */
3267
InputScanner.prototype.peekUntilAfter = function(pattern) {
3268
  var start = this.__position;
3269
  var val = this.readUntilAfter(pattern);
3270
  this.__position = start;
3271
  return val;
3272
};
3273
 
3274
InputScanner.prototype.lookBack = function(testVal) {
3275
  var start = this.__position - 1;
3276
  return start >= testVal.length && this.__input.substring(start - testVal.length, start)
3277
    .toLowerCase() === testVal;
3278
};
3279
 
3280
module.exports.InputScanner = InputScanner;
3281
 
3282
 
3283
/***/ }),
3284
/* 9 */
3285
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
3286
 
3287
/*jshint node:true */
3288
/*
3289
 
3290
  The MIT License (MIT)
3291
 
3292
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3293
 
3294
  Permission is hereby granted, free of charge, to any person
3295
  obtaining a copy of this software and associated documentation files
3296
  (the "Software"), to deal in the Software without restriction,
3297
  including without limitation the rights to use, copy, modify, merge,
3298
  publish, distribute, sublicense, and/or sell copies of the Software,
3299
  and to permit persons to whom the Software is furnished to do so,
3300
  subject to the following conditions:
3301
 
3302
  The above copyright notice and this permission notice shall be
3303
  included in all copies or substantial portions of the Software.
3304
 
3305
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3306
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3307
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3308
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3309
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3310
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3311
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3312
  SOFTWARE.
3313
*/
3314
 
3315
 
3316
 
3317
var InputScanner = (__webpack_require__(8).InputScanner);
3318
var Token = (__webpack_require__(3).Token);
3319
var TokenStream = (__webpack_require__(10).TokenStream);
3320
var WhitespacePattern = (__webpack_require__(11).WhitespacePattern);
3321
 
3322
var TOKEN = {
3323
  START: 'TK_START',
3324
  RAW: 'TK_RAW',
3325
  EOF: 'TK_EOF'
3326
};
3327
 
3328
var Tokenizer = function(input_string, options) {
3329
  this._input = new InputScanner(input_string);
3330
  this._options = options || {};
3331
  this.__tokens = null;
3332
 
3333
  this._patterns = {};
3334
  this._patterns.whitespace = new WhitespacePattern(this._input);
3335
};
3336
 
3337
Tokenizer.prototype.tokenize = function() {
3338
  this._input.restart();
3339
  this.__tokens = new TokenStream();
3340
 
3341
  this._reset();
3342
 
3343
  var current;
3344
  var previous = new Token(TOKEN.START, '');
3345
  var open_token = null;
3346
  var open_stack = [];
3347
  var comments = new TokenStream();
3348
 
3349
  while (previous.type !== TOKEN.EOF) {
3350
    current = this._get_next_token(previous, open_token);
3351
    while (this._is_comment(current)) {
3352
      comments.add(current);
3353
      current = this._get_next_token(previous, open_token);
3354
    }
3355
 
3356
    if (!comments.isEmpty()) {
3357
      current.comments_before = comments;
3358
      comments = new TokenStream();
3359
    }
3360
 
3361
    current.parent = open_token;
3362
 
3363
    if (this._is_opening(current)) {
3364
      open_stack.push(open_token);
3365
      open_token = current;
3366
    } else if (open_token && this._is_closing(current, open_token)) {
3367
      current.opened = open_token;
3368
      open_token.closed = current;
3369
      open_token = open_stack.pop();
3370
      current.parent = open_token;
3371
    }
3372
 
3373
    current.previous = previous;
3374
    previous.next = current;
3375
 
3376
    this.__tokens.add(current);
3377
    previous = current;
3378
  }
3379
 
3380
  return this.__tokens;
3381
};
3382
 
3383
 
3384
Tokenizer.prototype._is_first_token = function() {
3385
  return this.__tokens.isEmpty();
3386
};
3387
 
3388
Tokenizer.prototype._reset = function() {};
3389
 
3390
Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
3391
  this._readWhitespace();
3392
  var resulting_string = this._input.read(/.+/g);
3393
  if (resulting_string) {
3394
    return this._create_token(TOKEN.RAW, resulting_string);
3395
  } else {
3396
    return this._create_token(TOKEN.EOF, '');
3397
  }
3398
};
3399
 
3400
Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
3401
  return false;
3402
};
3403
 
3404
Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
3405
  return false;
3406
};
3407
 
3408
Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
3409
  return false;
3410
};
3411
 
3412
Tokenizer.prototype._create_token = function(type, text) {
3413
  var token = new Token(type, text,
3414
    this._patterns.whitespace.newline_count,
3415
    this._patterns.whitespace.whitespace_before_token);
3416
  return token;
3417
};
3418
 
3419
Tokenizer.prototype._readWhitespace = function() {
3420
  return this._patterns.whitespace.read();
3421
};
3422
 
3423
 
3424
 
3425
module.exports.Tokenizer = Tokenizer;
3426
module.exports.TOKEN = TOKEN;
3427
 
3428
 
3429
/***/ }),
3430
/* 10 */
3431
/***/ (function(module) {
3432
 
3433
/*jshint node:true */
3434
/*
3435
 
3436
  The MIT License (MIT)
3437
 
3438
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3439
 
3440
  Permission is hereby granted, free of charge, to any person
3441
  obtaining a copy of this software and associated documentation files
3442
  (the "Software"), to deal in the Software without restriction,
3443
  including without limitation the rights to use, copy, modify, merge,
3444
  publish, distribute, sublicense, and/or sell copies of the Software,
3445
  and to permit persons to whom the Software is furnished to do so,
3446
  subject to the following conditions:
3447
 
3448
  The above copyright notice and this permission notice shall be
3449
  included in all copies or substantial portions of the Software.
3450
 
3451
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3452
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3453
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3454
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3455
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3456
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3457
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3458
  SOFTWARE.
3459
*/
3460
 
3461
 
3462
 
3463
function TokenStream(parent_token) {
3464
  // private
3465
  this.__tokens = [];
3466
  this.__tokens_length = this.__tokens.length;
3467
  this.__position = 0;
3468
  this.__parent_token = parent_token;
3469
}
3470
 
3471
TokenStream.prototype.restart = function() {
3472
  this.__position = 0;
3473
};
3474
 
3475
TokenStream.prototype.isEmpty = function() {
3476
  return this.__tokens_length === 0;
3477
};
3478
 
3479
TokenStream.prototype.hasNext = function() {
3480
  return this.__position < this.__tokens_length;
3481
};
3482
 
3483
TokenStream.prototype.next = function() {
3484
  var val = null;
3485
  if (this.hasNext()) {
3486
    val = this.__tokens[this.__position];
3487
    this.__position += 1;
3488
  }
3489
  return val;
3490
};
3491
 
3492
TokenStream.prototype.peek = function(index) {
3493
  var val = null;
3494
  index = index || 0;
3495
  index += this.__position;
3496
  if (index >= 0 && index < this.__tokens_length) {
3497
    val = this.__tokens[index];
3498
  }
3499
  return val;
3500
};
3501
 
3502
TokenStream.prototype.add = function(token) {
3503
  if (this.__parent_token) {
3504
    token.parent = this.__parent_token;
3505
  }
3506
  this.__tokens.push(token);
3507
  this.__tokens_length += 1;
3508
};
3509
 
3510
module.exports.TokenStream = TokenStream;
3511
 
3512
 
3513
/***/ }),
3514
/* 11 */
3515
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
3516
 
3517
/*jshint node:true */
3518
/*
3519
 
3520
  The MIT License (MIT)
3521
 
3522
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3523
 
3524
  Permission is hereby granted, free of charge, to any person
3525
  obtaining a copy of this software and associated documentation files
3526
  (the "Software"), to deal in the Software without restriction,
3527
  including without limitation the rights to use, copy, modify, merge,
3528
  publish, distribute, sublicense, and/or sell copies of the Software,
3529
  and to permit persons to whom the Software is furnished to do so,
3530
  subject to the following conditions:
3531
 
3532
  The above copyright notice and this permission notice shall be
3533
  included in all copies or substantial portions of the Software.
3534
 
3535
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3536
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3537
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3538
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3539
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3540
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3541
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3542
  SOFTWARE.
3543
*/
3544
 
3545
 
3546
 
3547
var Pattern = (__webpack_require__(12).Pattern);
3548
 
3549
function WhitespacePattern(input_scanner, parent) {
3550
  Pattern.call(this, input_scanner, parent);
3551
  if (parent) {
3552
    this._line_regexp = this._input.get_regexp(parent._line_regexp);
3553
  } else {
3554
    this.__set_whitespace_patterns('', '');
3555
  }
3556
 
3557
  this.newline_count = 0;
3558
  this.whitespace_before_token = '';
3559
}
3560
WhitespacePattern.prototype = new Pattern();
3561
 
3562
WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
3563
  whitespace_chars += '\\t ';
3564
  newline_chars += '\\n\\r';
3565
 
3566
  this._match_pattern = this._input.get_regexp(
3567
    '[' + whitespace_chars + newline_chars + ']+', true);
3568
  this._newline_regexp = this._input.get_regexp(
3569
    '\\r\\n|[' + newline_chars + ']');
3570
};
3571
 
3572
WhitespacePattern.prototype.read = function() {
3573
  this.newline_count = 0;
3574
  this.whitespace_before_token = '';
3575
 
3576
  var resulting_string = this._input.read(this._match_pattern);
3577
  if (resulting_string === ' ') {
3578
    this.whitespace_before_token = ' ';
3579
  } else if (resulting_string) {
3580
    var matches = this.__split(this._newline_regexp, resulting_string);
3581
    this.newline_count = matches.length - 1;
3582
    this.whitespace_before_token = matches[this.newline_count];
3583
  }
3584
 
3585
  return resulting_string;
3586
};
3587
 
3588
WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
3589
  var result = this._create();
3590
  result.__set_whitespace_patterns(whitespace_chars, newline_chars);
3591
  result._update();
3592
  return result;
3593
};
3594
 
3595
WhitespacePattern.prototype._create = function() {
3596
  return new WhitespacePattern(this._input, this);
3597
};
3598
 
3599
WhitespacePattern.prototype.__split = function(regexp, input_string) {
3600
  regexp.lastIndex = 0;
3601
  var start_index = 0;
3602
  var result = [];
3603
  var next_match = regexp.exec(input_string);
3604
  while (next_match) {
3605
    result.push(input_string.substring(start_index, next_match.index));
3606
    start_index = next_match.index + next_match[0].length;
3607
    next_match = regexp.exec(input_string);
3608
  }
3609
 
3610
  if (start_index < input_string.length) {
3611
    result.push(input_string.substring(start_index, input_string.length));
3612
  } else {
3613
    result.push('');
3614
  }
3615
 
3616
  return result;
3617
};
3618
 
3619
 
3620
 
3621
module.exports.WhitespacePattern = WhitespacePattern;
3622
 
3623
 
3624
/***/ }),
3625
/* 12 */
3626
/***/ (function(module) {
3627
 
3628
/*jshint node:true */
3629
/*
3630
 
3631
  The MIT License (MIT)
3632
 
3633
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3634
 
3635
  Permission is hereby granted, free of charge, to any person
3636
  obtaining a copy of this software and associated documentation files
3637
  (the "Software"), to deal in the Software without restriction,
3638
  including without limitation the rights to use, copy, modify, merge,
3639
  publish, distribute, sublicense, and/or sell copies of the Software,
3640
  and to permit persons to whom the Software is furnished to do so,
3641
  subject to the following conditions:
3642
 
3643
  The above copyright notice and this permission notice shall be
3644
  included in all copies or substantial portions of the Software.
3645
 
3646
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3647
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3648
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3649
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3650
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3651
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3652
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3653
  SOFTWARE.
3654
*/
3655
 
3656
 
3657
 
3658
function Pattern(input_scanner, parent) {
3659
  this._input = input_scanner;
3660
  this._starting_pattern = null;
3661
  this._match_pattern = null;
3662
  this._until_pattern = null;
3663
  this._until_after = false;
3664
 
3665
  if (parent) {
3666
    this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
3667
    this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
3668
    this._until_pattern = this._input.get_regexp(parent._until_pattern);
3669
    this._until_after = parent._until_after;
3670
  }
3671
}
3672
 
3673
Pattern.prototype.read = function() {
3674
  var result = this._input.read(this._starting_pattern);
3675
  if (!this._starting_pattern || result) {
3676
    result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
3677
  }
3678
  return result;
3679
};
3680
 
3681
Pattern.prototype.read_match = function() {
3682
  return this._input.match(this._match_pattern);
3683
};
3684
 
3685
Pattern.prototype.until_after = function(pattern) {
3686
  var result = this._create();
3687
  result._until_after = true;
3688
  result._until_pattern = this._input.get_regexp(pattern);
3689
  result._update();
3690
  return result;
3691
};
3692
 
3693
Pattern.prototype.until = function(pattern) {
3694
  var result = this._create();
3695
  result._until_after = false;
3696
  result._until_pattern = this._input.get_regexp(pattern);
3697
  result._update();
3698
  return result;
3699
};
3700
 
3701
Pattern.prototype.starting_with = function(pattern) {
3702
  var result = this._create();
3703
  result._starting_pattern = this._input.get_regexp(pattern, true);
3704
  result._update();
3705
  return result;
3706
};
3707
 
3708
Pattern.prototype.matching = function(pattern) {
3709
  var result = this._create();
3710
  result._match_pattern = this._input.get_regexp(pattern, true);
3711
  result._update();
3712
  return result;
3713
};
3714
 
3715
Pattern.prototype._create = function() {
3716
  return new Pattern(this._input, this);
3717
};
3718
 
3719
Pattern.prototype._update = function() {};
3720
 
3721
module.exports.Pattern = Pattern;
3722
 
3723
 
3724
/***/ }),
3725
/* 13 */
3726
/***/ (function(module) {
3727
 
3728
/*jshint node:true */
3729
/*
3730
 
3731
  The MIT License (MIT)
3732
 
3733
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3734
 
3735
  Permission is hereby granted, free of charge, to any person
3736
  obtaining a copy of this software and associated documentation files
3737
  (the "Software"), to deal in the Software without restriction,
3738
  including without limitation the rights to use, copy, modify, merge,
3739
  publish, distribute, sublicense, and/or sell copies of the Software,
3740
  and to permit persons to whom the Software is furnished to do so,
3741
  subject to the following conditions:
3742
 
3743
  The above copyright notice and this permission notice shall be
3744
  included in all copies or substantial portions of the Software.
3745
 
3746
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3747
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3748
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3749
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3750
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3751
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3752
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3753
  SOFTWARE.
3754
*/
3755
 
3756
 
3757
 
3758
function Directives(start_block_pattern, end_block_pattern) {
3759
  start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
3760
  end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
3761
  this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
3762
  this.__directive_pattern = / (\w+)[:](\w+)/g;
3763
 
3764
  this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
3765
}
3766
 
3767
Directives.prototype.get_directives = function(text) {
3768
  if (!text.match(this.__directives_block_pattern)) {
3769
    return null;
3770
  }
3771
 
3772
  var directives = {};
3773
  this.__directive_pattern.lastIndex = 0;
3774
  var directive_match = this.__directive_pattern.exec(text);
3775
 
3776
  while (directive_match) {
3777
    directives[directive_match[1]] = directive_match[2];
3778
    directive_match = this.__directive_pattern.exec(text);
3779
  }
3780
 
3781
  return directives;
3782
};
3783
 
3784
Directives.prototype.readIgnored = function(input) {
3785
  return input.readUntilAfter(this.__directives_end_ignore_pattern);
3786
};
3787
 
3788
 
3789
module.exports.Directives = Directives;
3790
 
3791
 
3792
/***/ }),
3793
/* 14 */
3794
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
3795
 
3796
/*jshint node:true */
3797
/*
3798
 
3799
  The MIT License (MIT)
3800
 
3801
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
3802
 
3803
  Permission is hereby granted, free of charge, to any person
3804
  obtaining a copy of this software and associated documentation files
3805
  (the "Software"), to deal in the Software without restriction,
3806
  including without limitation the rights to use, copy, modify, merge,
3807
  publish, distribute, sublicense, and/or sell copies of the Software,
3808
  and to permit persons to whom the Software is furnished to do so,
3809
  subject to the following conditions:
3810
 
3811
  The above copyright notice and this permission notice shall be
3812
  included in all copies or substantial portions of the Software.
3813
 
3814
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
3815
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
3816
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
3817
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
3818
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
3819
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
3820
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3821
  SOFTWARE.
3822
*/
3823
 
3824
 
3825
 
3826
var Pattern = (__webpack_require__(12).Pattern);
3827
 
3828
 
3829
var template_names = {
3830
  django: false,
3831
  erb: false,
3832
  handlebars: false,
3833
  php: false,
3834
  smarty: false,
3835
  angular: false
3836
};
3837
 
3838
// This lets templates appear anywhere we would do a readUntil
3839
// The cost is higher but it is pay to play.
3840
function TemplatablePattern(input_scanner, parent) {
3841
  Pattern.call(this, input_scanner, parent);
3842
  this.__template_pattern = null;
3843
  this._disabled = Object.assign({}, template_names);
3844
  this._excluded = Object.assign({}, template_names);
3845
 
3846
  if (parent) {
3847
    this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
3848
    this._excluded = Object.assign(this._excluded, parent._excluded);
3849
    this._disabled = Object.assign(this._disabled, parent._disabled);
3850
  }
3851
  var pattern = new Pattern(input_scanner);
3852
  this.__patterns = {
3853
    handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
3854
    handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
3855
    handlebars: pattern.starting_with(/{{/).until_after(/}}/),
3856
    php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
3857
    erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
3858
    // django coflicts with handlebars a bit.
3859
    django: pattern.starting_with(/{%/).until_after(/%}/),
3860
    django_value: pattern.starting_with(/{{/).until_after(/}}/),
3861
    django_comment: pattern.starting_with(/{#/).until_after(/#}/),
3862
    smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
3863
    smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
3864
    smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
3865
  };
3866
}
3867
TemplatablePattern.prototype = new Pattern();
3868
 
3869
TemplatablePattern.prototype._create = function() {
3870
  return new TemplatablePattern(this._input, this);
3871
};
3872
 
3873
TemplatablePattern.prototype._update = function() {
3874
  this.__set_templated_pattern();
3875
};
3876
 
3877
TemplatablePattern.prototype.disable = function(language) {
3878
  var result = this._create();
3879
  result._disabled[language] = true;
3880
  result._update();
3881
  return result;
3882
};
3883
 
3884
TemplatablePattern.prototype.read_options = function(options) {
3885
  var result = this._create();
3886
  for (var language in template_names) {
3887
    result._disabled[language] = options.templating.indexOf(language) === -1;
3888
  }
3889
  result._update();
3890
  return result;
3891
};
3892
 
3893
TemplatablePattern.prototype.exclude = function(language) {
3894
  var result = this._create();
3895
  result._excluded[language] = true;
3896
  result._update();
3897
  return result;
3898
};
3899
 
3900
TemplatablePattern.prototype.read = function() {
3901
  var result = '';
3902
  if (this._match_pattern) {
3903
    result = this._input.read(this._starting_pattern);
3904
  } else {
3905
    result = this._input.read(this._starting_pattern, this.__template_pattern);
3906
  }
3907
  var next = this._read_template();
3908
  while (next) {
3909
    if (this._match_pattern) {
3910
      next += this._input.read(this._match_pattern);
3911
    } else {
3912
      next += this._input.readUntil(this.__template_pattern);
3913
    }
3914
    result += next;
3915
    next = this._read_template();
3916
  }
3917
 
3918
  if (this._until_after) {
3919
    result += this._input.readUntilAfter(this._until_pattern);
3920
  }
3921
  return result;
3922
};
3923
 
3924
TemplatablePattern.prototype.__set_templated_pattern = function() {
3925
  var items = [];
3926
 
3927
  if (!this._disabled.php) {
3928
    items.push(this.__patterns.php._starting_pattern.source);
3929
  }
3930
  if (!this._disabled.handlebars) {
3931
    items.push(this.__patterns.handlebars._starting_pattern.source);
3932
  }
3933
  if (!this._disabled.erb) {
3934
    items.push(this.__patterns.erb._starting_pattern.source);
3935
  }
3936
  if (!this._disabled.django) {
3937
    items.push(this.__patterns.django._starting_pattern.source);
3938
    // The starting pattern for django is more complex because it has different
3939
    // patterns for value, comment, and other sections
3940
    items.push(this.__patterns.django_value._starting_pattern.source);
3941
    items.push(this.__patterns.django_comment._starting_pattern.source);
3942
  }
3943
  if (!this._disabled.smarty) {
3944
    items.push(this.__patterns.smarty._starting_pattern.source);
3945
  }
3946
 
3947
  if (this._until_pattern) {
3948
    items.push(this._until_pattern.source);
3949
  }
3950
  this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
3951
};
3952
 
3953
TemplatablePattern.prototype._read_template = function() {
3954
  var resulting_string = '';
3955
  var c = this._input.peek();
3956
  if (c === '<') {
3957
    var peek1 = this._input.peek(1);
3958
    //if we're in a comment, do something special
3959
    // We treat all comments as literals, even more than preformatted tags
3960
    // we just look for the appropriate close tag
3961
    if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
3962
      resulting_string = resulting_string ||
3963
        this.__patterns.php.read();
3964
    }
3965
    if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
3966
      resulting_string = resulting_string ||
3967
        this.__patterns.erb.read();
3968
    }
3969
  } else if (c === '{') {
3970
    if (!this._disabled.handlebars && !this._excluded.handlebars) {
3971
      resulting_string = resulting_string ||
3972
        this.__patterns.handlebars_comment.read();
3973
      resulting_string = resulting_string ||
3974
        this.__patterns.handlebars_unescaped.read();
3975
      resulting_string = resulting_string ||
3976
        this.__patterns.handlebars.read();
3977
    }
3978
    if (!this._disabled.django) {
3979
      // django coflicts with handlebars a bit.
3980
      if (!this._excluded.django && !this._excluded.handlebars) {
3981
        resulting_string = resulting_string ||
3982
          this.__patterns.django_value.read();
3983
      }
3984
      if (!this._excluded.django) {
3985
        resulting_string = resulting_string ||
3986
          this.__patterns.django_comment.read();
3987
        resulting_string = resulting_string ||
3988
          this.__patterns.django.read();
3989
      }
3990
    }
3991
    if (!this._disabled.smarty) {
3992
      // smarty cannot be enabled with django or handlebars enabled
3993
      if (this._disabled.django && this._disabled.handlebars) {
3994
        resulting_string = resulting_string ||
3995
          this.__patterns.smarty_comment.read();
3996
        resulting_string = resulting_string ||
3997
          this.__patterns.smarty_literal.read();
3998
        resulting_string = resulting_string ||
3999
          this.__patterns.smarty.read();
4000
      }
4001
    }
4002
  }
4003
  return resulting_string;
4004
};
4005
 
4006
 
4007
module.exports.TemplatablePattern = TemplatablePattern;
4008
 
4009
 
4010
/***/ })
4011
/******/ 	]);
4012
/************************************************************************/
4013
/******/ 	// The module cache
4014
/******/ 	var __webpack_module_cache__ = {};
4015
/******/
4016
/******/ 	// The require function
4017
/******/ 	function __webpack_require__(moduleId) {
4018
/******/ 		// Check if module is in cache
4019
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
4020
/******/ 		if (cachedModule !== undefined) {
4021
/******/ 			return cachedModule.exports;
4022
/******/ 		}
4023
/******/ 		// Create a new module (and put it into the cache)
4024
/******/ 		var module = __webpack_module_cache__[moduleId] = {
4025
/******/ 			// no module.id needed
4026
/******/ 			// no module.loaded needed
4027
/******/ 			exports: {}
4028
/******/ 		};
4029
/******/
4030
/******/ 		// Execute the module function
4031
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
4032
/******/
4033
/******/ 		// Return the exports of the module
4034
/******/ 		return module.exports;
4035
/******/ 	}
4036
/******/
4037
/************************************************************************/
4038
/******/
4039
/******/ 	// startup
4040
/******/ 	// Load entry module and return exports
4041
/******/ 	// This entry module is referenced by other modules so it can't be inlined
4042
/******/ 	var __webpack_exports__ = __webpack_require__(0);
4043
/******/ 	legacy_beautify_js = __webpack_exports__;
4044
/******/
4045
/******/ })()
4046
;
4047
var js_beautify = legacy_beautify_js;
4048
/* Footer */
4049
if (typeof define === "function" && define.amd) {
4050
    // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
4051
    define([], function() {
4052
        return { js_beautify: js_beautify };
4053
    });
4054
} else if (typeof exports !== "undefined") {
4055
    // Add support for CommonJS. Just put this file somewhere on your require.paths
4056
    // and you will be able to `var js_beautify = require("beautify").js_beautify`.
4057
    exports.js_beautify = js_beautify;
4058
} else if (typeof window !== "undefined") {
4059
    // If we're running a web page and don't have either of the above, add our one global
4060
    window.js_beautify = js_beautify;
4061
} else if (typeof global !== "undefined") {
4062
    // If we don't even have window, try global.
4063
    global.js_beautify = js_beautify;
4064
}
4065
 
4066
}());
4067
 
4068
/* AUTO-GENERATED. DO NOT MODIFY. */
4069
/*
4070
 
4071
  The MIT License (MIT)
4072
 
4073
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
4074
 
4075
  Permission is hereby granted, free of charge, to any person
4076
  obtaining a copy of this software and associated documentation files
4077
  (the "Software"), to deal in the Software without restriction,
4078
  including without limitation the rights to use, copy, modify, merge,
4079
  publish, distribute, sublicense, and/or sell copies of the Software,
4080
  and to permit persons to whom the Software is furnished to do so,
4081
  subject to the following conditions:
4082
 
4083
  The above copyright notice and this permission notice shall be
4084
  included in all copies or substantial portions of the Software.
4085
 
4086
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4087
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4088
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4089
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
4090
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4091
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4092
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4093
  SOFTWARE.
4094
 
4095
 
4096
 CSS Beautifier
4097
---------------
4098
 
4099
    Written by Harutyun Amirjanyan, (amirjanyan@gmail.com)
4100
 
4101
    Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io>
4102
        https://beautifier.io/
4103
 
4104
    Usage:
4105
        css_beautify(source_text);
4106
        css_beautify(source_text, options);
4107
 
4108
    The options are (default in brackets):
4109
        indent_size (4)                         — indentation size,
4110
        indent_char (space)                     — character to indent with,
4111
        selector_separator_newline (true)       - separate selectors with newline or
4112
                                                  not (e.g. "a,\nbr" or "a, br")
4113
        end_with_newline (false)                - end with a newline
4114
        newline_between_rules (true)            - add a new line after every css rule
4115
        space_around_selector_separator (false) - ensure space around selector separators:
4116
                                                  '>', '+', '~' (e.g. "a>b" -> "a > b")
4117
    e.g
4118
 
4119
    css_beautify(css_source_text, {
4120
      'indent_size': 1,
4121
      'indent_char': '\t',
4122
      'selector_separator': ' ',
4123
      'end_with_newline': false,
4124
      'newline_between_rules': true,
4125
      'space_around_selector_separator': true
4126
    });
4127
*/
4128
 
4129
// http://www.w3.org/TR/CSS21/syndata.html#tokenization
4130
// http://www.w3.org/TR/css3-syntax/
4131
 
4132
(function() {
4133
 
4134
/* GENERATED_BUILD_OUTPUT */
4135
var legacy_beautify_css;
4136
/******/ (function() { // webpackBootstrap
4137
/******/ 	"use strict";
4138
/******/ 	var __webpack_modules__ = ([
4139
/* 0 */,
4140
/* 1 */,
4141
/* 2 */
4142
/***/ (function(module) {
4143
 
4144
/*jshint node:true */
4145
/*
4146
  The MIT License (MIT)
4147
 
4148
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
4149
 
4150
  Permission is hereby granted, free of charge, to any person
4151
  obtaining a copy of this software and associated documentation files
4152
  (the "Software"), to deal in the Software without restriction,
4153
  including without limitation the rights to use, copy, modify, merge,
4154
  publish, distribute, sublicense, and/or sell copies of the Software,
4155
  and to permit persons to whom the Software is furnished to do so,
4156
  subject to the following conditions:
4157
 
4158
  The above copyright notice and this permission notice shall be
4159
  included in all copies or substantial portions of the Software.
4160
 
4161
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4162
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4163
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4164
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
4165
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4166
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4167
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4168
  SOFTWARE.
4169
*/
4170
 
4171
 
4172
 
4173
function OutputLine(parent) {
4174
  this.__parent = parent;
4175
  this.__character_count = 0;
4176
  // use indent_count as a marker for this.__lines that have preserved indentation
4177
  this.__indent_count = -1;
4178
  this.__alignment_count = 0;
4179
  this.__wrap_point_index = 0;
4180
  this.__wrap_point_character_count = 0;
4181
  this.__wrap_point_indent_count = -1;
4182
  this.__wrap_point_alignment_count = 0;
4183
 
4184
  this.__items = [];
4185
}
4186
 
4187
OutputLine.prototype.clone_empty = function() {
4188
  var line = new OutputLine(this.__parent);
4189
  line.set_indent(this.__indent_count, this.__alignment_count);
4190
  return line;
4191
};
4192
 
4193
OutputLine.prototype.item = function(index) {
4194
  if (index < 0) {
4195
    return this.__items[this.__items.length + index];
4196
  } else {
4197
    return this.__items[index];
4198
  }
4199
};
4200
 
4201
OutputLine.prototype.has_match = function(pattern) {
4202
  for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
4203
    if (this.__items[lastCheckedOutput].match(pattern)) {
4204
      return true;
4205
    }
4206
  }
4207
  return false;
4208
};
4209
 
4210
OutputLine.prototype.set_indent = function(indent, alignment) {
4211
  if (this.is_empty()) {
4212
    this.__indent_count = indent || 0;
4213
    this.__alignment_count = alignment || 0;
4214
    this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
4215
  }
4216
};
4217
 
4218
OutputLine.prototype._set_wrap_point = function() {
4219
  if (this.__parent.wrap_line_length) {
4220
    this.__wrap_point_index = this.__items.length;
4221
    this.__wrap_point_character_count = this.__character_count;
4222
    this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
4223
    this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
4224
  }
4225
};
4226
 
4227
OutputLine.prototype._should_wrap = function() {
4228
  return this.__wrap_point_index &&
4229
    this.__character_count > this.__parent.wrap_line_length &&
4230
    this.__wrap_point_character_count > this.__parent.next_line.__character_count;
4231
};
4232
 
4233
OutputLine.prototype._allow_wrap = function() {
4234
  if (this._should_wrap()) {
4235
    this.__parent.add_new_line();
4236
    var next = this.__parent.current_line;
4237
    next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
4238
    next.__items = this.__items.slice(this.__wrap_point_index);
4239
    this.__items = this.__items.slice(0, this.__wrap_point_index);
4240
 
4241
    next.__character_count += this.__character_count - this.__wrap_point_character_count;
4242
    this.__character_count = this.__wrap_point_character_count;
4243
 
4244
    if (next.__items[0] === " ") {
4245
      next.__items.splice(0, 1);
4246
      next.__character_count -= 1;
4247
    }
4248
    return true;
4249
  }
4250
  return false;
4251
};
4252
 
4253
OutputLine.prototype.is_empty = function() {
4254
  return this.__items.length === 0;
4255
};
4256
 
4257
OutputLine.prototype.last = function() {
4258
  if (!this.is_empty()) {
4259
    return this.__items[this.__items.length - 1];
4260
  } else {
4261
    return null;
4262
  }
4263
};
4264
 
4265
OutputLine.prototype.push = function(item) {
4266
  this.__items.push(item);
4267
  var last_newline_index = item.lastIndexOf('\n');
4268
  if (last_newline_index !== -1) {
4269
    this.__character_count = item.length - last_newline_index;
4270
  } else {
4271
    this.__character_count += item.length;
4272
  }
4273
};
4274
 
4275
OutputLine.prototype.pop = function() {
4276
  var item = null;
4277
  if (!this.is_empty()) {
4278
    item = this.__items.pop();
4279
    this.__character_count -= item.length;
4280
  }
4281
  return item;
4282
};
4283
 
4284
 
4285
OutputLine.prototype._remove_indent = function() {
4286
  if (this.__indent_count > 0) {
4287
    this.__indent_count -= 1;
4288
    this.__character_count -= this.__parent.indent_size;
4289
  }
4290
};
4291
 
4292
OutputLine.prototype._remove_wrap_indent = function() {
4293
  if (this.__wrap_point_indent_count > 0) {
4294
    this.__wrap_point_indent_count -= 1;
4295
  }
4296
};
4297
OutputLine.prototype.trim = function() {
4298
  while (this.last() === ' ') {
4299
    this.__items.pop();
4300
    this.__character_count -= 1;
4301
  }
4302
};
4303
 
4304
OutputLine.prototype.toString = function() {
4305
  var result = '';
4306
  if (this.is_empty()) {
4307
    if (this.__parent.indent_empty_lines) {
4308
      result = this.__parent.get_indent_string(this.__indent_count);
4309
    }
4310
  } else {
4311
    result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
4312
    result += this.__items.join('');
4313
  }
4314
  return result;
4315
};
4316
 
4317
function IndentStringCache(options, baseIndentString) {
4318
  this.__cache = [''];
4319
  this.__indent_size = options.indent_size;
4320
  this.__indent_string = options.indent_char;
4321
  if (!options.indent_with_tabs) {
4322
    this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
4323
  }
4324
 
4325
  // Set to null to continue support for auto detection of base indent
4326
  baseIndentString = baseIndentString || '';
4327
  if (options.indent_level > 0) {
4328
    baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
4329
  }
4330
 
4331
  this.__base_string = baseIndentString;
4332
  this.__base_string_length = baseIndentString.length;
4333
}
4334
 
4335
IndentStringCache.prototype.get_indent_size = function(indent, column) {
4336
  var result = this.__base_string_length;
4337
  column = column || 0;
4338
  if (indent < 0) {
4339
    result = 0;
4340
  }
4341
  result += indent * this.__indent_size;
4342
  result += column;
4343
  return result;
4344
};
4345
 
4346
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
4347
  var result = this.__base_string;
4348
  column = column || 0;
4349
  if (indent_level < 0) {
4350
    indent_level = 0;
4351
    result = '';
4352
  }
4353
  column += indent_level * this.__indent_size;
4354
  this.__ensure_cache(column);
4355
  result += this.__cache[column];
4356
  return result;
4357
};
4358
 
4359
IndentStringCache.prototype.__ensure_cache = function(column) {
4360
  while (column >= this.__cache.length) {
4361
    this.__add_column();
4362
  }
4363
};
4364
 
4365
IndentStringCache.prototype.__add_column = function() {
4366
  var column = this.__cache.length;
4367
  var indent = 0;
4368
  var result = '';
4369
  if (this.__indent_size && column >= this.__indent_size) {
4370
    indent = Math.floor(column / this.__indent_size);
4371
    column -= indent * this.__indent_size;
4372
    result = new Array(indent + 1).join(this.__indent_string);
4373
  }
4374
  if (column) {
4375
    result += new Array(column + 1).join(' ');
4376
  }
4377
 
4378
  this.__cache.push(result);
4379
};
4380
 
4381
function Output(options, baseIndentString) {
4382
  this.__indent_cache = new IndentStringCache(options, baseIndentString);
4383
  this.raw = false;
4384
  this._end_with_newline = options.end_with_newline;
4385
  this.indent_size = options.indent_size;
4386
  this.wrap_line_length = options.wrap_line_length;
4387
  this.indent_empty_lines = options.indent_empty_lines;
4388
  this.__lines = [];
4389
  this.previous_line = null;
4390
  this.current_line = null;
4391
  this.next_line = new OutputLine(this);
4392
  this.space_before_token = false;
4393
  this.non_breaking_space = false;
4394
  this.previous_token_wrapped = false;
4395
  // initialize
4396
  this.__add_outputline();
4397
}
4398
 
4399
Output.prototype.__add_outputline = function() {
4400
  this.previous_line = this.current_line;
4401
  this.current_line = this.next_line.clone_empty();
4402
  this.__lines.push(this.current_line);
4403
};
4404
 
4405
Output.prototype.get_line_number = function() {
4406
  return this.__lines.length;
4407
};
4408
 
4409
Output.prototype.get_indent_string = function(indent, column) {
4410
  return this.__indent_cache.get_indent_string(indent, column);
4411
};
4412
 
4413
Output.prototype.get_indent_size = function(indent, column) {
4414
  return this.__indent_cache.get_indent_size(indent, column);
4415
};
4416
 
4417
Output.prototype.is_empty = function() {
4418
  return !this.previous_line && this.current_line.is_empty();
4419
};
4420
 
4421
Output.prototype.add_new_line = function(force_newline) {
4422
  // never newline at the start of file
4423
  // otherwise, newline only if we didn't just add one or we're forced
4424
  if (this.is_empty() ||
4425
    (!force_newline && this.just_added_newline())) {
4426
    return false;
4427
  }
4428
 
4429
  // if raw output is enabled, don't print additional newlines,
4430
  // but still return True as though you had
4431
  if (!this.raw) {
4432
    this.__add_outputline();
4433
  }
4434
  return true;
4435
};
4436
 
4437
Output.prototype.get_code = function(eol) {
4438
  this.trim(true);
4439
 
4440
  // handle some edge cases where the last tokens
4441
  // has text that ends with newline(s)
4442
  var last_item = this.current_line.pop();
4443
  if (last_item) {
4444
    if (last_item[last_item.length - 1] === '\n') {
4445
      last_item = last_item.replace(/\n+$/g, '');
4446
    }
4447
    this.current_line.push(last_item);
4448
  }
4449
 
4450
  if (this._end_with_newline) {
4451
    this.__add_outputline();
4452
  }
4453
 
4454
  var sweet_code = this.__lines.join('\n');
4455
 
4456
  if (eol !== '\n') {
4457
    sweet_code = sweet_code.replace(/[\n]/g, eol);
4458
  }
4459
  return sweet_code;
4460
};
4461
 
4462
Output.prototype.set_wrap_point = function() {
4463
  this.current_line._set_wrap_point();
4464
};
4465
 
4466
Output.prototype.set_indent = function(indent, alignment) {
4467
  indent = indent || 0;
4468
  alignment = alignment || 0;
4469
 
4470
  // Next line stores alignment values
4471
  this.next_line.set_indent(indent, alignment);
4472
 
4473
  // Never indent your first output indent at the start of the file
4474
  if (this.__lines.length > 1) {
4475
    this.current_line.set_indent(indent, alignment);
4476
    return true;
4477
  }
4478
 
4479
  this.current_line.set_indent();
4480
  return false;
4481
};
4482
 
4483
Output.prototype.add_raw_token = function(token) {
4484
  for (var x = 0; x < token.newlines; x++) {
4485
    this.__add_outputline();
4486
  }
4487
  this.current_line.set_indent(-1);
4488
  this.current_line.push(token.whitespace_before);
4489
  this.current_line.push(token.text);
4490
  this.space_before_token = false;
4491
  this.non_breaking_space = false;
4492
  this.previous_token_wrapped = false;
4493
};
4494
 
4495
Output.prototype.add_token = function(printable_token) {
4496
  this.__add_space_before_token();
4497
  this.current_line.push(printable_token);
4498
  this.space_before_token = false;
4499
  this.non_breaking_space = false;
4500
  this.previous_token_wrapped = this.current_line._allow_wrap();
4501
};
4502
 
4503
Output.prototype.__add_space_before_token = function() {
4504
  if (this.space_before_token && !this.just_added_newline()) {
4505
    if (!this.non_breaking_space) {
4506
      this.set_wrap_point();
4507
    }
4508
    this.current_line.push(' ');
4509
  }
4510
};
4511
 
4512
Output.prototype.remove_indent = function(index) {
4513
  var output_length = this.__lines.length;
4514
  while (index < output_length) {
4515
    this.__lines[index]._remove_indent();
4516
    index++;
4517
  }
4518
  this.current_line._remove_wrap_indent();
4519
};
4520
 
4521
Output.prototype.trim = function(eat_newlines) {
4522
  eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
4523
 
4524
  this.current_line.trim();
4525
 
4526
  while (eat_newlines && this.__lines.length > 1 &&
4527
    this.current_line.is_empty()) {
4528
    this.__lines.pop();
4529
    this.current_line = this.__lines[this.__lines.length - 1];
4530
    this.current_line.trim();
4531
  }
4532
 
4533
  this.previous_line = this.__lines.length > 1 ?
4534
    this.__lines[this.__lines.length - 2] : null;
4535
};
4536
 
4537
Output.prototype.just_added_newline = function() {
4538
  return this.current_line.is_empty();
4539
};
4540
 
4541
Output.prototype.just_added_blankline = function() {
4542
  return this.is_empty() ||
4543
    (this.current_line.is_empty() && this.previous_line.is_empty());
4544
};
4545
 
4546
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
4547
  var index = this.__lines.length - 2;
4548
  while (index >= 0) {
4549
    var potentialEmptyLine = this.__lines[index];
4550
    if (potentialEmptyLine.is_empty()) {
4551
      break;
4552
    } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
4553
      potentialEmptyLine.item(-1) !== ends_with) {
4554
      this.__lines.splice(index + 1, 0, new OutputLine(this));
4555
      this.previous_line = this.__lines[this.__lines.length - 2];
4556
      break;
4557
    }
4558
    index--;
4559
  }
4560
};
4561
 
4562
module.exports.Output = Output;
4563
 
4564
 
4565
/***/ }),
4566
/* 3 */,
4567
/* 4 */,
4568
/* 5 */,
4569
/* 6 */
4570
/***/ (function(module) {
4571
 
4572
/*jshint node:true */
4573
/*
4574
 
4575
  The MIT License (MIT)
4576
 
4577
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
4578
 
4579
  Permission is hereby granted, free of charge, to any person
4580
  obtaining a copy of this software and associated documentation files
4581
  (the "Software"), to deal in the Software without restriction,
4582
  including without limitation the rights to use, copy, modify, merge,
4583
  publish, distribute, sublicense, and/or sell copies of the Software,
4584
  and to permit persons to whom the Software is furnished to do so,
4585
  subject to the following conditions:
4586
 
4587
  The above copyright notice and this permission notice shall be
4588
  included in all copies or substantial portions of the Software.
4589
 
4590
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4591
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4592
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4593
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
4594
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4595
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4596
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4597
  SOFTWARE.
4598
*/
4599
 
4600
 
4601
 
4602
function Options(options, merge_child_field) {
4603
  this.raw_options = _mergeOpts(options, merge_child_field);
4604
 
4605
  // Support passing the source text back with no change
4606
  this.disabled = this._get_boolean('disabled');
4607
 
4608
  this.eol = this._get_characters('eol', 'auto');
4609
  this.end_with_newline = this._get_boolean('end_with_newline');
4610
  this.indent_size = this._get_number('indent_size', 4);
4611
  this.indent_char = this._get_characters('indent_char', ' ');
4612
  this.indent_level = this._get_number('indent_level');
4613
 
4614
  this.preserve_newlines = this._get_boolean('preserve_newlines', true);
4615
  this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
4616
  if (!this.preserve_newlines) {
4617
    this.max_preserve_newlines = 0;
4618
  }
4619
 
4620
  this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
4621
  if (this.indent_with_tabs) {
4622
    this.indent_char = '\t';
4623
 
4624
    // indent_size behavior changed after 1.8.6
4625
    // It used to be that indent_size would be
4626
    // set to 1 for indent_with_tabs. That is no longer needed and
4627
    // actually doesn't make sense - why not use spaces? Further,
4628
    // that might produce unexpected behavior - tabs being used
4629
    // for single-column alignment. So, when indent_with_tabs is true
4630
    // and indent_size is 1, reset indent_size to 4.
4631
    if (this.indent_size === 1) {
4632
      this.indent_size = 4;
4633
    }
4634
  }
4635
 
4636
  // Backwards compat with 1.3.x
4637
  this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
4638
 
4639
  this.indent_empty_lines = this._get_boolean('indent_empty_lines');
4640
 
4641
  // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
4642
  // For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
4643
  // other values ignored
4644
  this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
4645
}
4646
 
4647
Options.prototype._get_array = function(name, default_value) {
4648
  var option_value = this.raw_options[name];
4649
  var result = default_value || [];
4650
  if (typeof option_value === 'object') {
4651
    if (option_value !== null && typeof option_value.concat === 'function') {
4652
      result = option_value.concat();
4653
    }
4654
  } else if (typeof option_value === 'string') {
4655
    result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
4656
  }
4657
  return result;
4658
};
4659
 
4660
Options.prototype._get_boolean = function(name, default_value) {
4661
  var option_value = this.raw_options[name];
4662
  var result = option_value === undefined ? !!default_value : !!option_value;
4663
  return result;
4664
};
4665
 
4666
Options.prototype._get_characters = function(name, default_value) {
4667
  var option_value = this.raw_options[name];
4668
  var result = default_value || '';
4669
  if (typeof option_value === 'string') {
4670
    result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
4671
  }
4672
  return result;
4673
};
4674
 
4675
Options.prototype._get_number = function(name, default_value) {
4676
  var option_value = this.raw_options[name];
4677
  default_value = parseInt(default_value, 10);
4678
  if (isNaN(default_value)) {
4679
    default_value = 0;
4680
  }
4681
  var result = parseInt(option_value, 10);
4682
  if (isNaN(result)) {
4683
    result = default_value;
4684
  }
4685
  return result;
4686
};
4687
 
4688
Options.prototype._get_selection = function(name, selection_list, default_value) {
4689
  var result = this._get_selection_list(name, selection_list, default_value);
4690
  if (result.length !== 1) {
4691
    throw new Error(
4692
      "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
4693
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
4694
  }
4695
 
4696
  return result[0];
4697
};
4698
 
4699
 
4700
Options.prototype._get_selection_list = function(name, selection_list, default_value) {
4701
  if (!selection_list || selection_list.length === 0) {
4702
    throw new Error("Selection list cannot be empty.");
4703
  }
4704
 
4705
  default_value = default_value || [selection_list[0]];
4706
  if (!this._is_valid_selection(default_value, selection_list)) {
4707
    throw new Error("Invalid Default Value!");
4708
  }
4709
 
4710
  var result = this._get_array(name, default_value);
4711
  if (!this._is_valid_selection(result, selection_list)) {
4712
    throw new Error(
4713
      "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
4714
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
4715
  }
4716
 
4717
  return result;
4718
};
4719
 
4720
Options.prototype._is_valid_selection = function(result, selection_list) {
4721
  return result.length && selection_list.length &&
4722
    !result.some(function(item) { return selection_list.indexOf(item) === -1; });
4723
};
4724
 
4725
 
4726
// merges child options up with the parent options object
4727
// Example: obj = {a: 1, b: {a: 2}}
4728
//          mergeOpts(obj, 'b')
4729
//
4730
//          Returns: {a: 2}
4731
function _mergeOpts(allOptions, childFieldName) {
4732
  var finalOpts = {};
4733
  allOptions = _normalizeOpts(allOptions);
4734
  var name;
4735
 
4736
  for (name in allOptions) {
4737
    if (name !== childFieldName) {
4738
      finalOpts[name] = allOptions[name];
4739
    }
4740
  }
4741
 
4742
  //merge in the per type settings for the childFieldName
4743
  if (childFieldName && allOptions[childFieldName]) {
4744
    for (name in allOptions[childFieldName]) {
4745
      finalOpts[name] = allOptions[childFieldName][name];
4746
    }
4747
  }
4748
  return finalOpts;
4749
}
4750
 
4751
function _normalizeOpts(options) {
4752
  var convertedOpts = {};
4753
  var key;
4754
 
4755
  for (key in options) {
4756
    var newKey = key.replace(/-/g, "_");
4757
    convertedOpts[newKey] = options[key];
4758
  }
4759
  return convertedOpts;
4760
}
4761
 
4762
module.exports.Options = Options;
4763
module.exports.normalizeOpts = _normalizeOpts;
4764
module.exports.mergeOpts = _mergeOpts;
4765
 
4766
 
4767
/***/ }),
4768
/* 7 */,
4769
/* 8 */
4770
/***/ (function(module) {
4771
 
4772
/*jshint node:true */
4773
/*
4774
 
4775
  The MIT License (MIT)
4776
 
4777
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
4778
 
4779
  Permission is hereby granted, free of charge, to any person
4780
  obtaining a copy of this software and associated documentation files
4781
  (the "Software"), to deal in the Software without restriction,
4782
  including without limitation the rights to use, copy, modify, merge,
4783
  publish, distribute, sublicense, and/or sell copies of the Software,
4784
  and to permit persons to whom the Software is furnished to do so,
4785
  subject to the following conditions:
4786
 
4787
  The above copyright notice and this permission notice shall be
4788
  included in all copies or substantial portions of the Software.
4789
 
4790
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4791
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4792
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4793
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
4794
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4795
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4796
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4797
  SOFTWARE.
4798
*/
4799
 
4800
 
4801
 
4802
var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
4803
 
4804
function InputScanner(input_string) {
4805
  this.__input = input_string || '';
4806
  this.__input_length = this.__input.length;
4807
  this.__position = 0;
4808
}
4809
 
4810
InputScanner.prototype.restart = function() {
4811
  this.__position = 0;
4812
};
4813
 
4814
InputScanner.prototype.back = function() {
4815
  if (this.__position > 0) {
4816
    this.__position -= 1;
4817
  }
4818
};
4819
 
4820
InputScanner.prototype.hasNext = function() {
4821
  return this.__position < this.__input_length;
4822
};
4823
 
4824
InputScanner.prototype.next = function() {
4825
  var val = null;
4826
  if (this.hasNext()) {
4827
    val = this.__input.charAt(this.__position);
4828
    this.__position += 1;
4829
  }
4830
  return val;
4831
};
4832
 
4833
InputScanner.prototype.peek = function(index) {
4834
  var val = null;
4835
  index = index || 0;
4836
  index += this.__position;
4837
  if (index >= 0 && index < this.__input_length) {
4838
    val = this.__input.charAt(index);
4839
  }
4840
  return val;
4841
};
4842
 
4843
// This is a JavaScript only helper function (not in python)
4844
// Javascript doesn't have a match method
4845
// and not all implementation support "sticky" flag.
4846
// If they do not support sticky then both this.match() and this.test() method
4847
// must get the match and check the index of the match.
4848
// If sticky is supported and set, this method will use it.
4849
// Otherwise it will check that global is set, and fall back to the slower method.
4850
InputScanner.prototype.__match = function(pattern, index) {
4851
  pattern.lastIndex = index;
4852
  var pattern_match = pattern.exec(this.__input);
4853
 
4854
  if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
4855
    if (pattern_match.index !== index) {
4856
      pattern_match = null;
4857
    }
4858
  }
4859
 
4860
  return pattern_match;
4861
};
4862
 
4863
InputScanner.prototype.test = function(pattern, index) {
4864
  index = index || 0;
4865
  index += this.__position;
4866
 
4867
  if (index >= 0 && index < this.__input_length) {
4868
    return !!this.__match(pattern, index);
4869
  } else {
4870
    return false;
4871
  }
4872
};
4873
 
4874
InputScanner.prototype.testChar = function(pattern, index) {
4875
  // test one character regex match
4876
  var val = this.peek(index);
4877
  pattern.lastIndex = 0;
4878
  return val !== null && pattern.test(val);
4879
};
4880
 
4881
InputScanner.prototype.match = function(pattern) {
4882
  var pattern_match = this.__match(pattern, this.__position);
4883
  if (pattern_match) {
4884
    this.__position += pattern_match[0].length;
4885
  } else {
4886
    pattern_match = null;
4887
  }
4888
  return pattern_match;
4889
};
4890
 
4891
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
4892
  var val = '';
4893
  var match;
4894
  if (starting_pattern) {
4895
    match = this.match(starting_pattern);
4896
    if (match) {
4897
      val += match[0];
4898
    }
4899
  }
4900
  if (until_pattern && (match || !starting_pattern)) {
4901
    val += this.readUntil(until_pattern, until_after);
4902
  }
4903
  return val;
4904
};
4905
 
4906
InputScanner.prototype.readUntil = function(pattern, until_after) {
4907
  var val = '';
4908
  var match_index = this.__position;
4909
  pattern.lastIndex = this.__position;
4910
  var pattern_match = pattern.exec(this.__input);
4911
  if (pattern_match) {
4912
    match_index = pattern_match.index;
4913
    if (until_after) {
4914
      match_index += pattern_match[0].length;
4915
    }
4916
  } else {
4917
    match_index = this.__input_length;
4918
  }
4919
 
4920
  val = this.__input.substring(this.__position, match_index);
4921
  this.__position = match_index;
4922
  return val;
4923
};
4924
 
4925
InputScanner.prototype.readUntilAfter = function(pattern) {
4926
  return this.readUntil(pattern, true);
4927
};
4928
 
4929
InputScanner.prototype.get_regexp = function(pattern, match_from) {
4930
  var result = null;
4931
  var flags = 'g';
4932
  if (match_from && regexp_has_sticky) {
4933
    flags = 'y';
4934
  }
4935
  // strings are converted to regexp
4936
  if (typeof pattern === "string" && pattern !== '') {
4937
    // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
4938
    result = new RegExp(pattern, flags);
4939
  } else if (pattern) {
4940
    result = new RegExp(pattern.source, flags);
4941
  }
4942
  return result;
4943
};
4944
 
4945
InputScanner.prototype.get_literal_regexp = function(literal_string) {
4946
  return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
4947
};
4948
 
4949
/* css beautifier legacy helpers */
4950
InputScanner.prototype.peekUntilAfter = function(pattern) {
4951
  var start = this.__position;
4952
  var val = this.readUntilAfter(pattern);
4953
  this.__position = start;
4954
  return val;
4955
};
4956
 
4957
InputScanner.prototype.lookBack = function(testVal) {
4958
  var start = this.__position - 1;
4959
  return start >= testVal.length && this.__input.substring(start - testVal.length, start)
4960
    .toLowerCase() === testVal;
4961
};
4962
 
4963
module.exports.InputScanner = InputScanner;
4964
 
4965
 
4966
/***/ }),
4967
/* 9 */,
4968
/* 10 */,
4969
/* 11 */,
4970
/* 12 */,
4971
/* 13 */
4972
/***/ (function(module) {
4973
 
4974
/*jshint node:true */
4975
/*
4976
 
4977
  The MIT License (MIT)
4978
 
4979
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
4980
 
4981
  Permission is hereby granted, free of charge, to any person
4982
  obtaining a copy of this software and associated documentation files
4983
  (the "Software"), to deal in the Software without restriction,
4984
  including without limitation the rights to use, copy, modify, merge,
4985
  publish, distribute, sublicense, and/or sell copies of the Software,
4986
  and to permit persons to whom the Software is furnished to do so,
4987
  subject to the following conditions:
4988
 
4989
  The above copyright notice and this permission notice shall be
4990
  included in all copies or substantial portions of the Software.
4991
 
4992
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
4993
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
4994
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
4995
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
4996
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
4997
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
4998
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
4999
  SOFTWARE.
5000
*/
5001
 
5002
 
5003
 
5004
function Directives(start_block_pattern, end_block_pattern) {
5005
  start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
5006
  end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
5007
  this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
5008
  this.__directive_pattern = / (\w+)[:](\w+)/g;
5009
 
5010
  this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
5011
}
5012
 
5013
Directives.prototype.get_directives = function(text) {
5014
  if (!text.match(this.__directives_block_pattern)) {
5015
    return null;
5016
  }
5017
 
5018
  var directives = {};
5019
  this.__directive_pattern.lastIndex = 0;
5020
  var directive_match = this.__directive_pattern.exec(text);
5021
 
5022
  while (directive_match) {
5023
    directives[directive_match[1]] = directive_match[2];
5024
    directive_match = this.__directive_pattern.exec(text);
5025
  }
5026
 
5027
  return directives;
5028
};
5029
 
5030
Directives.prototype.readIgnored = function(input) {
5031
  return input.readUntilAfter(this.__directives_end_ignore_pattern);
5032
};
5033
 
5034
 
5035
module.exports.Directives = Directives;
5036
 
5037
 
5038
/***/ }),
5039
/* 14 */,
5040
/* 15 */
5041
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
5042
 
5043
/*jshint node:true */
5044
/*
5045
 
5046
  The MIT License (MIT)
5047
 
5048
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
5049
 
5050
  Permission is hereby granted, free of charge, to any person
5051
  obtaining a copy of this software and associated documentation files
5052
  (the "Software"), to deal in the Software without restriction,
5053
  including without limitation the rights to use, copy, modify, merge,
5054
  publish, distribute, sublicense, and/or sell copies of the Software,
5055
  and to permit persons to whom the Software is furnished to do so,
5056
  subject to the following conditions:
5057
 
5058
  The above copyright notice and this permission notice shall be
5059
  included in all copies or substantial portions of the Software.
5060
 
5061
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5062
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5063
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5064
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5065
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5066
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5067
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5068
  SOFTWARE.
5069
*/
5070
 
5071
 
5072
 
5073
var Beautifier = (__webpack_require__(16).Beautifier),
5074
  Options = (__webpack_require__(17).Options);
5075
 
5076
function css_beautify(source_text, options) {
5077
  var beautifier = new Beautifier(source_text, options);
5078
  return beautifier.beautify();
5079
}
5080
 
5081
module.exports = css_beautify;
5082
module.exports.defaultOptions = function() {
5083
  return new Options();
5084
};
5085
 
5086
 
5087
/***/ }),
5088
/* 16 */
5089
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
5090
 
5091
/*jshint node:true */
5092
/*
5093
 
5094
  The MIT License (MIT)
5095
 
5096
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
5097
 
5098
  Permission is hereby granted, free of charge, to any person
5099
  obtaining a copy of this software and associated documentation files
5100
  (the "Software"), to deal in the Software without restriction,
5101
  including without limitation the rights to use, copy, modify, merge,
5102
  publish, distribute, sublicense, and/or sell copies of the Software,
5103
  and to permit persons to whom the Software is furnished to do so,
5104
  subject to the following conditions:
5105
 
5106
  The above copyright notice and this permission notice shall be
5107
  included in all copies or substantial portions of the Software.
5108
 
5109
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5110
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5111
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5112
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5113
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5114
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5115
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5116
  SOFTWARE.
5117
*/
5118
 
5119
 
5120
 
5121
var Options = (__webpack_require__(17).Options);
5122
var Output = (__webpack_require__(2).Output);
5123
var InputScanner = (__webpack_require__(8).InputScanner);
5124
var Directives = (__webpack_require__(13).Directives);
5125
 
5126
var directives_core = new Directives(/\/\*/, /\*\//);
5127
 
5128
var lineBreak = /\r\n|[\r\n]/;
5129
var allLineBreaks = /\r\n|[\r\n]/g;
5130
 
5131
// tokenizer
5132
var whitespaceChar = /\s/;
5133
var whitespacePattern = /(?:\s|\n)+/g;
5134
var block_comment_pattern = /\/\*(?:[\s\S]*?)((?:\*\/)|$)/g;
5135
var comment_pattern = /\/\/(?:[^\n\r\u2028\u2029]*)/g;
5136
 
5137
function Beautifier(source_text, options) {
5138
  this._source_text = source_text || '';
5139
  // Allow the setting of language/file-type specific options
5140
  // with inheritance of overall settings
5141
  this._options = new Options(options);
5142
  this._ch = null;
5143
  this._input = null;
5144
 
5145
  // https://developer.mozilla.org/en-US/docs/Web/CSS/At-rule
5146
  this.NESTED_AT_RULE = {
5147
    "page": true,
5148
    "font-face": true,
5149
    "keyframes": true,
5150
    // also in CONDITIONAL_GROUP_RULE below
5151
    "media": true,
5152
    "supports": true,
5153
    "document": true
5154
  };
5155
  this.CONDITIONAL_GROUP_RULE = {
5156
    "media": true,
5157
    "supports": true,
5158
    "document": true
5159
  };
5160
  this.NON_SEMICOLON_NEWLINE_PROPERTY = [
5161
    "grid-template-areas",
5162
    "grid-template"
5163
  ];
5164
 
5165
}
5166
 
5167
Beautifier.prototype.eatString = function(endChars) {
5168
  var result = '';
5169
  this._ch = this._input.next();
5170
  while (this._ch) {
5171
    result += this._ch;
5172
    if (this._ch === "\\") {
5173
      result += this._input.next();
5174
    } else if (endChars.indexOf(this._ch) !== -1 || this._ch === "\n") {
5175
      break;
5176
    }
5177
    this._ch = this._input.next();
5178
  }
5179
  return result;
5180
};
5181
 
5182
// Skips any white space in the source text from the current position.
5183
// When allowAtLeastOneNewLine is true, will output new lines for each
5184
// newline character found; if the user has preserve_newlines off, only
5185
// the first newline will be output
5186
Beautifier.prototype.eatWhitespace = function(allowAtLeastOneNewLine) {
5187
  var result = whitespaceChar.test(this._input.peek());
5188
  var newline_count = 0;
5189
  while (whitespaceChar.test(this._input.peek())) {
5190
    this._ch = this._input.next();
5191
    if (allowAtLeastOneNewLine && this._ch === '\n') {
5192
      if (newline_count === 0 || newline_count < this._options.max_preserve_newlines) {
5193
        newline_count++;
5194
        this._output.add_new_line(true);
5195
      }
5196
    }
5197
  }
5198
  return result;
5199
};
5200
 
5201
// Nested pseudo-class if we are insideRule
5202
// and the next special character found opens
5203
// a new block
5204
Beautifier.prototype.foundNestedPseudoClass = function() {
5205
  var openParen = 0;
5206
  var i = 1;
5207
  var ch = this._input.peek(i);
5208
  while (ch) {
5209
    if (ch === "{") {
5210
      return true;
5211
    } else if (ch === '(') {
5212
      // pseudoclasses can contain ()
5213
      openParen += 1;
5214
    } else if (ch === ')') {
5215
      if (openParen === 0) {
5216
        return false;
5217
      }
5218
      openParen -= 1;
5219
    } else if (ch === ";" || ch === "}") {
5220
      return false;
5221
    }
5222
    i++;
5223
    ch = this._input.peek(i);
5224
  }
5225
  return false;
5226
};
5227
 
5228
Beautifier.prototype.print_string = function(output_string) {
5229
  this._output.set_indent(this._indentLevel);
5230
  this._output.non_breaking_space = true;
5231
  this._output.add_token(output_string);
5232
};
5233
 
5234
Beautifier.prototype.preserveSingleSpace = function(isAfterSpace) {
5235
  if (isAfterSpace) {
5236
    this._output.space_before_token = true;
5237
  }
5238
};
5239
 
5240
Beautifier.prototype.indent = function() {
5241
  this._indentLevel++;
5242
};
5243
 
5244
Beautifier.prototype.outdent = function() {
5245
  if (this._indentLevel > 0) {
5246
    this._indentLevel--;
5247
  }
5248
};
5249
 
5250
/*_____________________--------------------_____________________*/
5251
 
5252
Beautifier.prototype.beautify = function() {
5253
  if (this._options.disabled) {
5254
    return this._source_text;
5255
  }
5256
 
5257
  var source_text = this._source_text;
5258
  var eol = this._options.eol;
5259
  if (eol === 'auto') {
5260
    eol = '\n';
5261
    if (source_text && lineBreak.test(source_text || '')) {
5262
      eol = source_text.match(lineBreak)[0];
5263
    }
5264
  }
5265
 
5266
 
5267
  // HACK: newline parsing inconsistent. This brute force normalizes the this._input.
5268
  source_text = source_text.replace(allLineBreaks, '\n');
5269
 
5270
  // reset
5271
  var baseIndentString = source_text.match(/^[\t ]*/)[0];
5272
 
5273
  this._output = new Output(this._options, baseIndentString);
5274
  this._input = new InputScanner(source_text);
5275
  this._indentLevel = 0;
5276
  this._nestedLevel = 0;
5277
 
5278
  this._ch = null;
5279
  var parenLevel = 0;
5280
 
5281
  var insideRule = false;
5282
  // This is the value side of a property value pair (blue in the following ex)
5283
  // label { content: blue }
5284
  var insidePropertyValue = false;
5285
  var enteringConditionalGroup = false;
5286
  var insideNonNestedAtRule = false;
5287
  var insideScssMap = false;
5288
  var topCharacter = this._ch;
5289
  var insideNonSemiColonValues = false;
5290
  var whitespace;
5291
  var isAfterSpace;
5292
  var previous_ch;
5293
 
5294
  while (true) {
5295
    whitespace = this._input.read(whitespacePattern);
5296
    isAfterSpace = whitespace !== '';
5297
    previous_ch = topCharacter;
5298
    this._ch = this._input.next();
5299
    if (this._ch === '\\' && this._input.hasNext()) {
5300
      this._ch += this._input.next();
5301
    }
5302
    topCharacter = this._ch;
5303
 
5304
    if (!this._ch) {
5305
      break;
5306
    } else if (this._ch === '/' && this._input.peek() === '*') {
5307
      // /* css comment */
5308
      // Always start block comments on a new line.
5309
      // This handles scenarios where a block comment immediately
5310
      // follows a property definition on the same line or where
5311
      // minified code is being beautified.
5312
      this._output.add_new_line();
5313
      this._input.back();
5314
 
5315
      var comment = this._input.read(block_comment_pattern);
5316
 
5317
      // Handle ignore directive
5318
      var directives = directives_core.get_directives(comment);
5319
      if (directives && directives.ignore === 'start') {
5320
        comment += directives_core.readIgnored(this._input);
5321
      }
5322
 
5323
      this.print_string(comment);
5324
 
5325
      // Ensures any new lines following the comment are preserved
5326
      this.eatWhitespace(true);
5327
 
5328
      // Block comments are followed by a new line so they don't
5329
      // share a line with other properties
5330
      this._output.add_new_line();
5331
    } else if (this._ch === '/' && this._input.peek() === '/') {
5332
      // // single line comment
5333
      // Preserves the space before a comment
5334
      // on the same line as a rule
5335
      this._output.space_before_token = true;
5336
      this._input.back();
5337
      this.print_string(this._input.read(comment_pattern));
5338
 
5339
      // Ensures any new lines following the comment are preserved
5340
      this.eatWhitespace(true);
5341
    } else if (this._ch === '$') {
5342
      this.preserveSingleSpace(isAfterSpace);
5343
 
5344
      this.print_string(this._ch);
5345
 
5346
      // strip trailing space, if present, for hash property checks
5347
      var variable = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
5348
 
5349
      if (variable.match(/[ :]$/)) {
5350
        // we have a variable or pseudo-class, add it and insert one space before continuing
5351
        variable = this.eatString(": ").replace(/\s+$/, '');
5352
        this.print_string(variable);
5353
        this._output.space_before_token = true;
5354
      }
5355
 
5356
      // might be sass variable
5357
      if (parenLevel === 0 && variable.indexOf(':') !== -1) {
5358
        insidePropertyValue = true;
5359
        this.indent();
5360
      }
5361
    } else if (this._ch === '@') {
5362
      this.preserveSingleSpace(isAfterSpace);
5363
 
5364
      // deal with less property mixins @{...}
5365
      if (this._input.peek() === '{') {
5366
        this.print_string(this._ch + this.eatString('}'));
5367
      } else {
5368
        this.print_string(this._ch);
5369
 
5370
        // strip trailing space, if present, for hash property checks
5371
        var variableOrRule = this._input.peekUntilAfter(/[: ,;{}()[\]\/='"]/g);
5372
 
5373
        if (variableOrRule.match(/[ :]$/)) {
5374
          // we have a variable or pseudo-class, add it and insert one space before continuing
5375
          variableOrRule = this.eatString(": ").replace(/\s+$/, '');
5376
          this.print_string(variableOrRule);
5377
          this._output.space_before_token = true;
5378
        }
5379
 
5380
        // might be less variable
5381
        if (parenLevel === 0 && variableOrRule.indexOf(':') !== -1) {
5382
          insidePropertyValue = true;
5383
          this.indent();
5384
 
5385
          // might be a nesting at-rule
5386
        } else if (variableOrRule in this.NESTED_AT_RULE) {
5387
          this._nestedLevel += 1;
5388
          if (variableOrRule in this.CONDITIONAL_GROUP_RULE) {
5389
            enteringConditionalGroup = true;
5390
          }
5391
 
5392
          // might be a non-nested at-rule
5393
        } else if (parenLevel === 0 && !insidePropertyValue) {
5394
          insideNonNestedAtRule = true;
5395
        }
5396
      }
5397
    } else if (this._ch === '#' && this._input.peek() === '{') {
5398
      this.preserveSingleSpace(isAfterSpace);
5399
      this.print_string(this._ch + this.eatString('}'));
5400
    } else if (this._ch === '{') {
5401
      if (insidePropertyValue) {
5402
        insidePropertyValue = false;
5403
        this.outdent();
5404
      }
5405
 
5406
      // non nested at rule becomes nested
5407
      insideNonNestedAtRule = false;
5408
 
5409
      // when entering conditional groups, only rulesets are allowed
5410
      if (enteringConditionalGroup) {
5411
        enteringConditionalGroup = false;
5412
        insideRule = (this._indentLevel >= this._nestedLevel);
5413
      } else {
5414
        // otherwise, declarations are also allowed
5415
        insideRule = (this._indentLevel >= this._nestedLevel - 1);
5416
      }
5417
      if (this._options.newline_between_rules && insideRule) {
5418
        if (this._output.previous_line && this._output.previous_line.item(-1) !== '{') {
5419
          this._output.ensure_empty_line_above('/', ',');
5420
        }
5421
      }
5422
 
5423
      this._output.space_before_token = true;
5424
 
5425
      // The difference in print_string and indent order is necessary to indent the '{' correctly
5426
      if (this._options.brace_style === 'expand') {
5427
        this._output.add_new_line();
5428
        this.print_string(this._ch);
5429
        this.indent();
5430
        this._output.set_indent(this._indentLevel);
5431
      } else {
5432
        // inside mixin and first param is object
5433
        if (previous_ch === '(') {
5434
          this._output.space_before_token = false;
5435
        } else if (previous_ch !== ',') {
5436
          this.indent();
5437
        }
5438
        this.print_string(this._ch);
5439
      }
5440
 
5441
      this.eatWhitespace(true);
5442
      this._output.add_new_line();
5443
    } else if (this._ch === '}') {
5444
      this.outdent();
5445
      this._output.add_new_line();
5446
      if (previous_ch === '{') {
5447
        this._output.trim(true);
5448
      }
5449
 
5450
      if (insidePropertyValue) {
5451
        this.outdent();
5452
        insidePropertyValue = false;
5453
      }
5454
      this.print_string(this._ch);
5455
      insideRule = false;
5456
      if (this._nestedLevel) {
5457
        this._nestedLevel--;
5458
      }
5459
 
5460
      this.eatWhitespace(true);
5461
      this._output.add_new_line();
5462
 
5463
      if (this._options.newline_between_rules && !this._output.just_added_blankline()) {
5464
        if (this._input.peek() !== '}') {
5465
          this._output.add_new_line(true);
5466
        }
5467
      }
5468
      if (this._input.peek() === ')') {
5469
        this._output.trim(true);
5470
        if (this._options.brace_style === "expand") {
5471
          this._output.add_new_line(true);
5472
        }
5473
      }
5474
    } else if (this._ch === ":") {
5475
 
5476
      for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
5477
        if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
5478
          insideNonSemiColonValues = true;
5479
          break;
5480
        }
5481
      }
5482
 
5483
      if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideNonNestedAtRule && parenLevel === 0) {
5484
        // 'property: value' delimiter
5485
        // which could be in a conditional group query
5486
 
5487
        this.print_string(':');
5488
        if (!insidePropertyValue) {
5489
          insidePropertyValue = true;
5490
          this._output.space_before_token = true;
5491
          this.eatWhitespace(true);
5492
          this.indent();
5493
        }
5494
      } else {
5495
        // sass/less parent reference don't use a space
5496
        // sass nested pseudo-class don't use a space
5497
 
5498
        // preserve space before pseudoclasses/pseudoelements, as it means "in any child"
5499
        if (this._input.lookBack(" ")) {
5500
          this._output.space_before_token = true;
5501
        }
5502
        if (this._input.peek() === ":") {
5503
          // pseudo-element
5504
          this._ch = this._input.next();
5505
          this.print_string("::");
5506
        } else {
5507
          // pseudo-class
5508
          this.print_string(':');
5509
        }
5510
      }
5511
    } else if (this._ch === '"' || this._ch === '\'') {
5512
      var preserveQuoteSpace = previous_ch === '"' || previous_ch === '\'';
5513
      this.preserveSingleSpace(preserveQuoteSpace || isAfterSpace);
5514
      this.print_string(this._ch + this.eatString(this._ch));
5515
      this.eatWhitespace(true);
5516
    } else if (this._ch === ';') {
5517
      insideNonSemiColonValues = false;
5518
      if (parenLevel === 0) {
5519
        if (insidePropertyValue) {
5520
          this.outdent();
5521
          insidePropertyValue = false;
5522
        }
5523
        insideNonNestedAtRule = false;
5524
        this.print_string(this._ch);
5525
        this.eatWhitespace(true);
5526
 
5527
        // This maintains single line comments on the same
5528
        // line. Block comments are also affected, but
5529
        // a new line is always output before one inside
5530
        // that section
5531
        if (this._input.peek() !== '/') {
5532
          this._output.add_new_line();
5533
        }
5534
      } else {
5535
        this.print_string(this._ch);
5536
        this.eatWhitespace(true);
5537
        this._output.space_before_token = true;
5538
      }
5539
    } else if (this._ch === '(') { // may be a url
5540
      if (this._input.lookBack("url")) {
5541
        this.print_string(this._ch);
5542
        this.eatWhitespace();
5543
        parenLevel++;
5544
        this.indent();
5545
        this._ch = this._input.next();
5546
        if (this._ch === ')' || this._ch === '"' || this._ch === '\'') {
5547
          this._input.back();
5548
        } else if (this._ch) {
5549
          this.print_string(this._ch + this.eatString(')'));
5550
          if (parenLevel) {
5551
            parenLevel--;
5552
            this.outdent();
5553
          }
5554
        }
5555
      } else {
5556
        var space_needed = false;
5557
        if (this._input.lookBack("with")) {
5558
          // look back is not an accurate solution, we need tokens to confirm without whitespaces
5559
          space_needed = true;
5560
        }
5561
        this.preserveSingleSpace(isAfterSpace || space_needed);
5562
        this.print_string(this._ch);
5563
 
5564
        // handle scss/sass map
5565
        if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
5566
          this._output.add_new_line();
5567
          insideScssMap = true;
5568
        } else {
5569
          this.eatWhitespace();
5570
          parenLevel++;
5571
          this.indent();
5572
        }
5573
      }
5574
    } else if (this._ch === ')') {
5575
      if (parenLevel) {
5576
        parenLevel--;
5577
        this.outdent();
5578
      }
5579
      if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
5580
        insideScssMap = false;
5581
        this.outdent();
5582
        this._output.add_new_line();
5583
      }
5584
      this.print_string(this._ch);
5585
    } else if (this._ch === ',') {
5586
      this.print_string(this._ch);
5587
      this.eatWhitespace(true);
5588
      if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideNonNestedAtRule) {
5589
        this._output.add_new_line();
5590
      } else {
5591
        this._output.space_before_token = true;
5592
      }
5593
    } else if ((this._ch === '>' || this._ch === '+' || this._ch === '~') && !insidePropertyValue && parenLevel === 0) {
5594
      //handle combinator spacing
5595
      if (this._options.space_around_combinator) {
5596
        this._output.space_before_token = true;
5597
        this.print_string(this._ch);
5598
        this._output.space_before_token = true;
5599
      } else {
5600
        this.print_string(this._ch);
5601
        this.eatWhitespace();
5602
        // squash extra whitespace
5603
        if (this._ch && whitespaceChar.test(this._ch)) {
5604
          this._ch = '';
5605
        }
5606
      }
5607
    } else if (this._ch === ']') {
5608
      this.print_string(this._ch);
5609
    } else if (this._ch === '[') {
5610
      this.preserveSingleSpace(isAfterSpace);
5611
      this.print_string(this._ch);
5612
    } else if (this._ch === '=') { // no whitespace before or after
5613
      this.eatWhitespace();
5614
      this.print_string('=');
5615
      if (whitespaceChar.test(this._ch)) {
5616
        this._ch = '';
5617
      }
5618
    } else if (this._ch === '!' && !this._input.lookBack("\\")) { // !important
5619
      this._output.space_before_token = true;
5620
      this.print_string(this._ch);
5621
    } else {
5622
      var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
5623
      this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
5624
      this.print_string(this._ch);
5625
 
5626
      if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
5627
        this._output.add_new_line();
5628
      }
5629
    }
5630
  }
5631
 
5632
  var sweetCode = this._output.get_code(eol);
5633
 
5634
  return sweetCode;
5635
};
5636
 
5637
module.exports.Beautifier = Beautifier;
5638
 
5639
 
5640
/***/ }),
5641
/* 17 */
5642
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
5643
 
5644
/*jshint node:true */
5645
/*
5646
 
5647
  The MIT License (MIT)
5648
 
5649
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
5650
 
5651
  Permission is hereby granted, free of charge, to any person
5652
  obtaining a copy of this software and associated documentation files
5653
  (the "Software"), to deal in the Software without restriction,
5654
  including without limitation the rights to use, copy, modify, merge,
5655
  publish, distribute, sublicense, and/or sell copies of the Software,
5656
  and to permit persons to whom the Software is furnished to do so,
5657
  subject to the following conditions:
5658
 
5659
  The above copyright notice and this permission notice shall be
5660
  included in all copies or substantial portions of the Software.
5661
 
5662
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5663
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5664
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5665
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5666
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5667
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5668
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5669
  SOFTWARE.
5670
*/
5671
 
5672
 
5673
 
5674
var BaseOptions = (__webpack_require__(6).Options);
5675
 
5676
function Options(options) {
5677
  BaseOptions.call(this, options, 'css');
5678
 
5679
  this.selector_separator_newline = this._get_boolean('selector_separator_newline', true);
5680
  this.newline_between_rules = this._get_boolean('newline_between_rules', true);
5681
  var space_around_selector_separator = this._get_boolean('space_around_selector_separator');
5682
  this.space_around_combinator = this._get_boolean('space_around_combinator') || space_around_selector_separator;
5683
 
5684
  var brace_style_split = this._get_selection_list('brace_style', ['collapse', 'expand', 'end-expand', 'none', 'preserve-inline']);
5685
  this.brace_style = 'collapse';
5686
  for (var bs = 0; bs < brace_style_split.length; bs++) {
5687
    if (brace_style_split[bs] !== 'expand') {
5688
      // default to collapse, as only collapse|expand is implemented for now
5689
      this.brace_style = 'collapse';
5690
    } else {
5691
      this.brace_style = brace_style_split[bs];
5692
    }
5693
  }
5694
}
5695
Options.prototype = new BaseOptions();
5696
 
5697
 
5698
 
5699
module.exports.Options = Options;
5700
 
5701
 
5702
/***/ })
5703
/******/ 	]);
5704
/************************************************************************/
5705
/******/ 	// The module cache
5706
/******/ 	var __webpack_module_cache__ = {};
5707
/******/
5708
/******/ 	// The require function
5709
/******/ 	function __webpack_require__(moduleId) {
5710
/******/ 		// Check if module is in cache
5711
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
5712
/******/ 		if (cachedModule !== undefined) {
5713
/******/ 			return cachedModule.exports;
5714
/******/ 		}
5715
/******/ 		// Create a new module (and put it into the cache)
5716
/******/ 		var module = __webpack_module_cache__[moduleId] = {
5717
/******/ 			// no module.id needed
5718
/******/ 			// no module.loaded needed
5719
/******/ 			exports: {}
5720
/******/ 		};
5721
/******/
5722
/******/ 		// Execute the module function
5723
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
5724
/******/
5725
/******/ 		// Return the exports of the module
5726
/******/ 		return module.exports;
5727
/******/ 	}
5728
/******/
5729
/************************************************************************/
5730
/******/
5731
/******/ 	// startup
5732
/******/ 	// Load entry module and return exports
5733
/******/ 	// This entry module is referenced by other modules so it can't be inlined
5734
/******/ 	var __webpack_exports__ = __webpack_require__(15);
5735
/******/ 	legacy_beautify_css = __webpack_exports__;
5736
/******/
5737
/******/ })()
5738
;
5739
var css_beautify = legacy_beautify_css;
5740
/* Footer */
5741
if (typeof define === "function" && define.amd) {
5742
    // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
5743
    define([], function() {
5744
        return {
5745
            css_beautify: css_beautify
5746
        };
5747
    });
5748
} else if (typeof exports !== "undefined") {
5749
    // Add support for CommonJS. Just put this file somewhere on your require.paths
5750
    // and you will be able to `var html_beautify = require("beautify").html_beautify`.
5751
    exports.css_beautify = css_beautify;
5752
} else if (typeof window !== "undefined") {
5753
    // If we're running a web page and don't have either of the above, add our one global
5754
    window.css_beautify = css_beautify;
5755
} else if (typeof global !== "undefined") {
5756
    // If we don't even have window, try global.
5757
    global.css_beautify = css_beautify;
5758
}
5759
 
5760
}());
5761
/* AUTO-GENERATED. DO NOT MODIFY. */
5762
/*
5763
 
5764
  The MIT License (MIT)
5765
 
5766
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
5767
 
5768
  Permission is hereby granted, free of charge, to any person
5769
  obtaining a copy of this software and associated documentation files
5770
  (the "Software"), to deal in the Software without restriction,
5771
  including without limitation the rights to use, copy, modify, merge,
5772
  publish, distribute, sublicense, and/or sell copies of the Software,
5773
  and to permit persons to whom the Software is furnished to do so,
5774
  subject to the following conditions:
5775
 
5776
  The above copyright notice and this permission notice shall be
5777
  included in all copies or substantial portions of the Software.
5778
 
5779
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5780
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5781
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5782
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5783
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5784
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5785
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5786
  SOFTWARE.
5787
 
5788
 
5789
 Style HTML
5790
---------------
5791
 
5792
  Written by Nochum Sossonko, (nsossonko@hotmail.com)
5793
 
5794
  Based on code initially developed by: Einar Lielmanis, <einar@beautifier.io>
5795
    https://beautifier.io/
5796
 
5797
  Usage:
5798
    style_html(html_source);
5799
 
5800
    style_html(html_source, options);
5801
 
5802
  The options are:
5803
    indent_inner_html (default false)  — indent <head> and <body> sections,
5804
    indent_size (default 4)          — indentation size,
5805
    indent_char (default space)      — character to indent with,
5806
    wrap_line_length (default 250)            -  maximum amount of characters per line (0 = disable)
5807
    brace_style (default "collapse") - "collapse" | "expand" | "end-expand" | "none"
5808
            put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are.
5809
    inline (defaults to inline tags) - list of tags to be considered inline tags
5810
    unformatted (defaults to inline tags) - list of tags, that shouldn't be reformatted
5811
    content_unformatted (defaults to ["pre", "textarea"] tags) - list of tags, whose content shouldn't be reformatted
5812
    indent_scripts (default normal)  - "keep"|"separate"|"normal"
5813
    preserve_newlines (default true) - whether existing line breaks before elements should be preserved
5814
                                        Only works before elements, not inside tags or for text.
5815
    max_preserve_newlines (default unlimited) - maximum number of line breaks to be preserved in one chunk
5816
    indent_handlebars (default false) - format and indent {{#foo}} and {{/foo}}
5817
    end_with_newline (false)          - end with a newline
5818
    extra_liners (default [head,body,/html]) -List of tags that should have an extra newline before them.
5819
 
5820
    e.g.
5821
 
5822
    style_html(html_source, {
5823
      'indent_inner_html': false,
5824
      'indent_size': 2,
5825
      'indent_char': ' ',
5826
      'wrap_line_length': 78,
5827
      'brace_style': 'expand',
5828
      'preserve_newlines': true,
5829
      'max_preserve_newlines': 5,
5830
      'indent_handlebars': false,
5831
      'extra_liners': ['/html']
5832
    });
5833
*/
5834
 
5835
(function() {
5836
 
5837
/* GENERATED_BUILD_OUTPUT */
5838
var legacy_beautify_html;
5839
/******/ (function() { // webpackBootstrap
5840
/******/ 	"use strict";
5841
/******/ 	var __webpack_modules__ = ([
5842
/* 0 */,
5843
/* 1 */,
5844
/* 2 */
5845
/***/ (function(module) {
5846
 
5847
/*jshint node:true */
5848
/*
5849
  The MIT License (MIT)
5850
 
5851
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
5852
 
5853
  Permission is hereby granted, free of charge, to any person
5854
  obtaining a copy of this software and associated documentation files
5855
  (the "Software"), to deal in the Software without restriction,
5856
  including without limitation the rights to use, copy, modify, merge,
5857
  publish, distribute, sublicense, and/or sell copies of the Software,
5858
  and to permit persons to whom the Software is furnished to do so,
5859
  subject to the following conditions:
5860
 
5861
  The above copyright notice and this permission notice shall be
5862
  included in all copies or substantial portions of the Software.
5863
 
5864
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
5865
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
5866
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
5867
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
5868
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
5869
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
5870
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
5871
  SOFTWARE.
5872
*/
5873
 
5874
 
5875
 
5876
function OutputLine(parent) {
5877
  this.__parent = parent;
5878
  this.__character_count = 0;
5879
  // use indent_count as a marker for this.__lines that have preserved indentation
5880
  this.__indent_count = -1;
5881
  this.__alignment_count = 0;
5882
  this.__wrap_point_index = 0;
5883
  this.__wrap_point_character_count = 0;
5884
  this.__wrap_point_indent_count = -1;
5885
  this.__wrap_point_alignment_count = 0;
5886
 
5887
  this.__items = [];
5888
}
5889
 
5890
OutputLine.prototype.clone_empty = function() {
5891
  var line = new OutputLine(this.__parent);
5892
  line.set_indent(this.__indent_count, this.__alignment_count);
5893
  return line;
5894
};
5895
 
5896
OutputLine.prototype.item = function(index) {
5897
  if (index < 0) {
5898
    return this.__items[this.__items.length + index];
5899
  } else {
5900
    return this.__items[index];
5901
  }
5902
};
5903
 
5904
OutputLine.prototype.has_match = function(pattern) {
5905
  for (var lastCheckedOutput = this.__items.length - 1; lastCheckedOutput >= 0; lastCheckedOutput--) {
5906
    if (this.__items[lastCheckedOutput].match(pattern)) {
5907
      return true;
5908
    }
5909
  }
5910
  return false;
5911
};
5912
 
5913
OutputLine.prototype.set_indent = function(indent, alignment) {
5914
  if (this.is_empty()) {
5915
    this.__indent_count = indent || 0;
5916
    this.__alignment_count = alignment || 0;
5917
    this.__character_count = this.__parent.get_indent_size(this.__indent_count, this.__alignment_count);
5918
  }
5919
};
5920
 
5921
OutputLine.prototype._set_wrap_point = function() {
5922
  if (this.__parent.wrap_line_length) {
5923
    this.__wrap_point_index = this.__items.length;
5924
    this.__wrap_point_character_count = this.__character_count;
5925
    this.__wrap_point_indent_count = this.__parent.next_line.__indent_count;
5926
    this.__wrap_point_alignment_count = this.__parent.next_line.__alignment_count;
5927
  }
5928
};
5929
 
5930
OutputLine.prototype._should_wrap = function() {
5931
  return this.__wrap_point_index &&
5932
    this.__character_count > this.__parent.wrap_line_length &&
5933
    this.__wrap_point_character_count > this.__parent.next_line.__character_count;
5934
};
5935
 
5936
OutputLine.prototype._allow_wrap = function() {
5937
  if (this._should_wrap()) {
5938
    this.__parent.add_new_line();
5939
    var next = this.__parent.current_line;
5940
    next.set_indent(this.__wrap_point_indent_count, this.__wrap_point_alignment_count);
5941
    next.__items = this.__items.slice(this.__wrap_point_index);
5942
    this.__items = this.__items.slice(0, this.__wrap_point_index);
5943
 
5944
    next.__character_count += this.__character_count - this.__wrap_point_character_count;
5945
    this.__character_count = this.__wrap_point_character_count;
5946
 
5947
    if (next.__items[0] === " ") {
5948
      next.__items.splice(0, 1);
5949
      next.__character_count -= 1;
5950
    }
5951
    return true;
5952
  }
5953
  return false;
5954
};
5955
 
5956
OutputLine.prototype.is_empty = function() {
5957
  return this.__items.length === 0;
5958
};
5959
 
5960
OutputLine.prototype.last = function() {
5961
  if (!this.is_empty()) {
5962
    return this.__items[this.__items.length - 1];
5963
  } else {
5964
    return null;
5965
  }
5966
};
5967
 
5968
OutputLine.prototype.push = function(item) {
5969
  this.__items.push(item);
5970
  var last_newline_index = item.lastIndexOf('\n');
5971
  if (last_newline_index !== -1) {
5972
    this.__character_count = item.length - last_newline_index;
5973
  } else {
5974
    this.__character_count += item.length;
5975
  }
5976
};
5977
 
5978
OutputLine.prototype.pop = function() {
5979
  var item = null;
5980
  if (!this.is_empty()) {
5981
    item = this.__items.pop();
5982
    this.__character_count -= item.length;
5983
  }
5984
  return item;
5985
};
5986
 
5987
 
5988
OutputLine.prototype._remove_indent = function() {
5989
  if (this.__indent_count > 0) {
5990
    this.__indent_count -= 1;
5991
    this.__character_count -= this.__parent.indent_size;
5992
  }
5993
};
5994
 
5995
OutputLine.prototype._remove_wrap_indent = function() {
5996
  if (this.__wrap_point_indent_count > 0) {
5997
    this.__wrap_point_indent_count -= 1;
5998
  }
5999
};
6000
OutputLine.prototype.trim = function() {
6001
  while (this.last() === ' ') {
6002
    this.__items.pop();
6003
    this.__character_count -= 1;
6004
  }
6005
};
6006
 
6007
OutputLine.prototype.toString = function() {
6008
  var result = '';
6009
  if (this.is_empty()) {
6010
    if (this.__parent.indent_empty_lines) {
6011
      result = this.__parent.get_indent_string(this.__indent_count);
6012
    }
6013
  } else {
6014
    result = this.__parent.get_indent_string(this.__indent_count, this.__alignment_count);
6015
    result += this.__items.join('');
6016
  }
6017
  return result;
6018
};
6019
 
6020
function IndentStringCache(options, baseIndentString) {
6021
  this.__cache = [''];
6022
  this.__indent_size = options.indent_size;
6023
  this.__indent_string = options.indent_char;
6024
  if (!options.indent_with_tabs) {
6025
    this.__indent_string = new Array(options.indent_size + 1).join(options.indent_char);
6026
  }
6027
 
6028
  // Set to null to continue support for auto detection of base indent
6029
  baseIndentString = baseIndentString || '';
6030
  if (options.indent_level > 0) {
6031
    baseIndentString = new Array(options.indent_level + 1).join(this.__indent_string);
6032
  }
6033
 
6034
  this.__base_string = baseIndentString;
6035
  this.__base_string_length = baseIndentString.length;
6036
}
6037
 
6038
IndentStringCache.prototype.get_indent_size = function(indent, column) {
6039
  var result = this.__base_string_length;
6040
  column = column || 0;
6041
  if (indent < 0) {
6042
    result = 0;
6043
  }
6044
  result += indent * this.__indent_size;
6045
  result += column;
6046
  return result;
6047
};
6048
 
6049
IndentStringCache.prototype.get_indent_string = function(indent_level, column) {
6050
  var result = this.__base_string;
6051
  column = column || 0;
6052
  if (indent_level < 0) {
6053
    indent_level = 0;
6054
    result = '';
6055
  }
6056
  column += indent_level * this.__indent_size;
6057
  this.__ensure_cache(column);
6058
  result += this.__cache[column];
6059
  return result;
6060
};
6061
 
6062
IndentStringCache.prototype.__ensure_cache = function(column) {
6063
  while (column >= this.__cache.length) {
6064
    this.__add_column();
6065
  }
6066
};
6067
 
6068
IndentStringCache.prototype.__add_column = function() {
6069
  var column = this.__cache.length;
6070
  var indent = 0;
6071
  var result = '';
6072
  if (this.__indent_size && column >= this.__indent_size) {
6073
    indent = Math.floor(column / this.__indent_size);
6074
    column -= indent * this.__indent_size;
6075
    result = new Array(indent + 1).join(this.__indent_string);
6076
  }
6077
  if (column) {
6078
    result += new Array(column + 1).join(' ');
6079
  }
6080
 
6081
  this.__cache.push(result);
6082
};
6083
 
6084
function Output(options, baseIndentString) {
6085
  this.__indent_cache = new IndentStringCache(options, baseIndentString);
6086
  this.raw = false;
6087
  this._end_with_newline = options.end_with_newline;
6088
  this.indent_size = options.indent_size;
6089
  this.wrap_line_length = options.wrap_line_length;
6090
  this.indent_empty_lines = options.indent_empty_lines;
6091
  this.__lines = [];
6092
  this.previous_line = null;
6093
  this.current_line = null;
6094
  this.next_line = new OutputLine(this);
6095
  this.space_before_token = false;
6096
  this.non_breaking_space = false;
6097
  this.previous_token_wrapped = false;
6098
  // initialize
6099
  this.__add_outputline();
6100
}
6101
 
6102
Output.prototype.__add_outputline = function() {
6103
  this.previous_line = this.current_line;
6104
  this.current_line = this.next_line.clone_empty();
6105
  this.__lines.push(this.current_line);
6106
};
6107
 
6108
Output.prototype.get_line_number = function() {
6109
  return this.__lines.length;
6110
};
6111
 
6112
Output.prototype.get_indent_string = function(indent, column) {
6113
  return this.__indent_cache.get_indent_string(indent, column);
6114
};
6115
 
6116
Output.prototype.get_indent_size = function(indent, column) {
6117
  return this.__indent_cache.get_indent_size(indent, column);
6118
};
6119
 
6120
Output.prototype.is_empty = function() {
6121
  return !this.previous_line && this.current_line.is_empty();
6122
};
6123
 
6124
Output.prototype.add_new_line = function(force_newline) {
6125
  // never newline at the start of file
6126
  // otherwise, newline only if we didn't just add one or we're forced
6127
  if (this.is_empty() ||
6128
    (!force_newline && this.just_added_newline())) {
6129
    return false;
6130
  }
6131
 
6132
  // if raw output is enabled, don't print additional newlines,
6133
  // but still return True as though you had
6134
  if (!this.raw) {
6135
    this.__add_outputline();
6136
  }
6137
  return true;
6138
};
6139
 
6140
Output.prototype.get_code = function(eol) {
6141
  this.trim(true);
6142
 
6143
  // handle some edge cases where the last tokens
6144
  // has text that ends with newline(s)
6145
  var last_item = this.current_line.pop();
6146
  if (last_item) {
6147
    if (last_item[last_item.length - 1] === '\n') {
6148
      last_item = last_item.replace(/\n+$/g, '');
6149
    }
6150
    this.current_line.push(last_item);
6151
  }
6152
 
6153
  if (this._end_with_newline) {
6154
    this.__add_outputline();
6155
  }
6156
 
6157
  var sweet_code = this.__lines.join('\n');
6158
 
6159
  if (eol !== '\n') {
6160
    sweet_code = sweet_code.replace(/[\n]/g, eol);
6161
  }
6162
  return sweet_code;
6163
};
6164
 
6165
Output.prototype.set_wrap_point = function() {
6166
  this.current_line._set_wrap_point();
6167
};
6168
 
6169
Output.prototype.set_indent = function(indent, alignment) {
6170
  indent = indent || 0;
6171
  alignment = alignment || 0;
6172
 
6173
  // Next line stores alignment values
6174
  this.next_line.set_indent(indent, alignment);
6175
 
6176
  // Never indent your first output indent at the start of the file
6177
  if (this.__lines.length > 1) {
6178
    this.current_line.set_indent(indent, alignment);
6179
    return true;
6180
  }
6181
 
6182
  this.current_line.set_indent();
6183
  return false;
6184
};
6185
 
6186
Output.prototype.add_raw_token = function(token) {
6187
  for (var x = 0; x < token.newlines; x++) {
6188
    this.__add_outputline();
6189
  }
6190
  this.current_line.set_indent(-1);
6191
  this.current_line.push(token.whitespace_before);
6192
  this.current_line.push(token.text);
6193
  this.space_before_token = false;
6194
  this.non_breaking_space = false;
6195
  this.previous_token_wrapped = false;
6196
};
6197
 
6198
Output.prototype.add_token = function(printable_token) {
6199
  this.__add_space_before_token();
6200
  this.current_line.push(printable_token);
6201
  this.space_before_token = false;
6202
  this.non_breaking_space = false;
6203
  this.previous_token_wrapped = this.current_line._allow_wrap();
6204
};
6205
 
6206
Output.prototype.__add_space_before_token = function() {
6207
  if (this.space_before_token && !this.just_added_newline()) {
6208
    if (!this.non_breaking_space) {
6209
      this.set_wrap_point();
6210
    }
6211
    this.current_line.push(' ');
6212
  }
6213
};
6214
 
6215
Output.prototype.remove_indent = function(index) {
6216
  var output_length = this.__lines.length;
6217
  while (index < output_length) {
6218
    this.__lines[index]._remove_indent();
6219
    index++;
6220
  }
6221
  this.current_line._remove_wrap_indent();
6222
};
6223
 
6224
Output.prototype.trim = function(eat_newlines) {
6225
  eat_newlines = (eat_newlines === undefined) ? false : eat_newlines;
6226
 
6227
  this.current_line.trim();
6228
 
6229
  while (eat_newlines && this.__lines.length > 1 &&
6230
    this.current_line.is_empty()) {
6231
    this.__lines.pop();
6232
    this.current_line = this.__lines[this.__lines.length - 1];
6233
    this.current_line.trim();
6234
  }
6235
 
6236
  this.previous_line = this.__lines.length > 1 ?
6237
    this.__lines[this.__lines.length - 2] : null;
6238
};
6239
 
6240
Output.prototype.just_added_newline = function() {
6241
  return this.current_line.is_empty();
6242
};
6243
 
6244
Output.prototype.just_added_blankline = function() {
6245
  return this.is_empty() ||
6246
    (this.current_line.is_empty() && this.previous_line.is_empty());
6247
};
6248
 
6249
Output.prototype.ensure_empty_line_above = function(starts_with, ends_with) {
6250
  var index = this.__lines.length - 2;
6251
  while (index >= 0) {
6252
    var potentialEmptyLine = this.__lines[index];
6253
    if (potentialEmptyLine.is_empty()) {
6254
      break;
6255
    } else if (potentialEmptyLine.item(0).indexOf(starts_with) !== 0 &&
6256
      potentialEmptyLine.item(-1) !== ends_with) {
6257
      this.__lines.splice(index + 1, 0, new OutputLine(this));
6258
      this.previous_line = this.__lines[this.__lines.length - 2];
6259
      break;
6260
    }
6261
    index--;
6262
  }
6263
};
6264
 
6265
module.exports.Output = Output;
6266
 
6267
 
6268
/***/ }),
6269
/* 3 */
6270
/***/ (function(module) {
6271
 
6272
/*jshint node:true */
6273
/*
6274
 
6275
  The MIT License (MIT)
6276
 
6277
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6278
 
6279
  Permission is hereby granted, free of charge, to any person
6280
  obtaining a copy of this software and associated documentation files
6281
  (the "Software"), to deal in the Software without restriction,
6282
  including without limitation the rights to use, copy, modify, merge,
6283
  publish, distribute, sublicense, and/or sell copies of the Software,
6284
  and to permit persons to whom the Software is furnished to do so,
6285
  subject to the following conditions:
6286
 
6287
  The above copyright notice and this permission notice shall be
6288
  included in all copies or substantial portions of the Software.
6289
 
6290
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6291
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6292
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6293
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6294
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6295
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6296
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6297
  SOFTWARE.
6298
*/
6299
 
6300
 
6301
 
6302
function Token(type, text, newlines, whitespace_before) {
6303
  this.type = type;
6304
  this.text = text;
6305
 
6306
  // comments_before are
6307
  // comments that have a new line before them
6308
  // and may or may not have a newline after
6309
  // this is a set of comments before
6310
  this.comments_before = null; /* inline comment*/
6311
 
6312
 
6313
  // this.comments_after =  new TokenStream(); // no new line before and newline after
6314
  this.newlines = newlines || 0;
6315
  this.whitespace_before = whitespace_before || '';
6316
  this.parent = null;
6317
  this.next = null;
6318
  this.previous = null;
6319
  this.opened = null;
6320
  this.closed = null;
6321
  this.directives = null;
6322
}
6323
 
6324
 
6325
module.exports.Token = Token;
6326
 
6327
 
6328
/***/ }),
6329
/* 4 */,
6330
/* 5 */,
6331
/* 6 */
6332
/***/ (function(module) {
6333
 
6334
/*jshint node:true */
6335
/*
6336
 
6337
  The MIT License (MIT)
6338
 
6339
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6340
 
6341
  Permission is hereby granted, free of charge, to any person
6342
  obtaining a copy of this software and associated documentation files
6343
  (the "Software"), to deal in the Software without restriction,
6344
  including without limitation the rights to use, copy, modify, merge,
6345
  publish, distribute, sublicense, and/or sell copies of the Software,
6346
  and to permit persons to whom the Software is furnished to do so,
6347
  subject to the following conditions:
6348
 
6349
  The above copyright notice and this permission notice shall be
6350
  included in all copies or substantial portions of the Software.
6351
 
6352
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6353
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6354
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6355
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6356
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6357
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6358
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6359
  SOFTWARE.
6360
*/
6361
 
6362
 
6363
 
6364
function Options(options, merge_child_field) {
6365
  this.raw_options = _mergeOpts(options, merge_child_field);
6366
 
6367
  // Support passing the source text back with no change
6368
  this.disabled = this._get_boolean('disabled');
6369
 
6370
  this.eol = this._get_characters('eol', 'auto');
6371
  this.end_with_newline = this._get_boolean('end_with_newline');
6372
  this.indent_size = this._get_number('indent_size', 4);
6373
  this.indent_char = this._get_characters('indent_char', ' ');
6374
  this.indent_level = this._get_number('indent_level');
6375
 
6376
  this.preserve_newlines = this._get_boolean('preserve_newlines', true);
6377
  this.max_preserve_newlines = this._get_number('max_preserve_newlines', 32786);
6378
  if (!this.preserve_newlines) {
6379
    this.max_preserve_newlines = 0;
6380
  }
6381
 
6382
  this.indent_with_tabs = this._get_boolean('indent_with_tabs', this.indent_char === '\t');
6383
  if (this.indent_with_tabs) {
6384
    this.indent_char = '\t';
6385
 
6386
    // indent_size behavior changed after 1.8.6
6387
    // It used to be that indent_size would be
6388
    // set to 1 for indent_with_tabs. That is no longer needed and
6389
    // actually doesn't make sense - why not use spaces? Further,
6390
    // that might produce unexpected behavior - tabs being used
6391
    // for single-column alignment. So, when indent_with_tabs is true
6392
    // and indent_size is 1, reset indent_size to 4.
6393
    if (this.indent_size === 1) {
6394
      this.indent_size = 4;
6395
    }
6396
  }
6397
 
6398
  // Backwards compat with 1.3.x
6399
  this.wrap_line_length = this._get_number('wrap_line_length', this._get_number('max_char'));
6400
 
6401
  this.indent_empty_lines = this._get_boolean('indent_empty_lines');
6402
 
6403
  // valid templating languages ['django', 'erb', 'handlebars', 'php', 'smarty', 'angular']
6404
  // For now, 'auto' = all off for javascript, all except angular on for html (and inline javascript/css).
6405
  // other values ignored
6406
  this.templating = this._get_selection_list('templating', ['auto', 'none', 'angular', 'django', 'erb', 'handlebars', 'php', 'smarty'], ['auto']);
6407
}
6408
 
6409
Options.prototype._get_array = function(name, default_value) {
6410
  var option_value = this.raw_options[name];
6411
  var result = default_value || [];
6412
  if (typeof option_value === 'object') {
6413
    if (option_value !== null && typeof option_value.concat === 'function') {
6414
      result = option_value.concat();
6415
    }
6416
  } else if (typeof option_value === 'string') {
6417
    result = option_value.split(/[^a-zA-Z0-9_\/\-]+/);
6418
  }
6419
  return result;
6420
};
6421
 
6422
Options.prototype._get_boolean = function(name, default_value) {
6423
  var option_value = this.raw_options[name];
6424
  var result = option_value === undefined ? !!default_value : !!option_value;
6425
  return result;
6426
};
6427
 
6428
Options.prototype._get_characters = function(name, default_value) {
6429
  var option_value = this.raw_options[name];
6430
  var result = default_value || '';
6431
  if (typeof option_value === 'string') {
6432
    result = option_value.replace(/\\r/, '\r').replace(/\\n/, '\n').replace(/\\t/, '\t');
6433
  }
6434
  return result;
6435
};
6436
 
6437
Options.prototype._get_number = function(name, default_value) {
6438
  var option_value = this.raw_options[name];
6439
  default_value = parseInt(default_value, 10);
6440
  if (isNaN(default_value)) {
6441
    default_value = 0;
6442
  }
6443
  var result = parseInt(option_value, 10);
6444
  if (isNaN(result)) {
6445
    result = default_value;
6446
  }
6447
  return result;
6448
};
6449
 
6450
Options.prototype._get_selection = function(name, selection_list, default_value) {
6451
  var result = this._get_selection_list(name, selection_list, default_value);
6452
  if (result.length !== 1) {
6453
    throw new Error(
6454
      "Invalid Option Value: The option '" + name + "' can only be one of the following values:\n" +
6455
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
6456
  }
6457
 
6458
  return result[0];
6459
};
6460
 
6461
 
6462
Options.prototype._get_selection_list = function(name, selection_list, default_value) {
6463
  if (!selection_list || selection_list.length === 0) {
6464
    throw new Error("Selection list cannot be empty.");
6465
  }
6466
 
6467
  default_value = default_value || [selection_list[0]];
6468
  if (!this._is_valid_selection(default_value, selection_list)) {
6469
    throw new Error("Invalid Default Value!");
6470
  }
6471
 
6472
  var result = this._get_array(name, default_value);
6473
  if (!this._is_valid_selection(result, selection_list)) {
6474
    throw new Error(
6475
      "Invalid Option Value: The option '" + name + "' can contain only the following values:\n" +
6476
      selection_list + "\nYou passed in: '" + this.raw_options[name] + "'");
6477
  }
6478
 
6479
  return result;
6480
};
6481
 
6482
Options.prototype._is_valid_selection = function(result, selection_list) {
6483
  return result.length && selection_list.length &&
6484
    !result.some(function(item) { return selection_list.indexOf(item) === -1; });
6485
};
6486
 
6487
 
6488
// merges child options up with the parent options object
6489
// Example: obj = {a: 1, b: {a: 2}}
6490
//          mergeOpts(obj, 'b')
6491
//
6492
//          Returns: {a: 2}
6493
function _mergeOpts(allOptions, childFieldName) {
6494
  var finalOpts = {};
6495
  allOptions = _normalizeOpts(allOptions);
6496
  var name;
6497
 
6498
  for (name in allOptions) {
6499
    if (name !== childFieldName) {
6500
      finalOpts[name] = allOptions[name];
6501
    }
6502
  }
6503
 
6504
  //merge in the per type settings for the childFieldName
6505
  if (childFieldName && allOptions[childFieldName]) {
6506
    for (name in allOptions[childFieldName]) {
6507
      finalOpts[name] = allOptions[childFieldName][name];
6508
    }
6509
  }
6510
  return finalOpts;
6511
}
6512
 
6513
function _normalizeOpts(options) {
6514
  var convertedOpts = {};
6515
  var key;
6516
 
6517
  for (key in options) {
6518
    var newKey = key.replace(/-/g, "_");
6519
    convertedOpts[newKey] = options[key];
6520
  }
6521
  return convertedOpts;
6522
}
6523
 
6524
module.exports.Options = Options;
6525
module.exports.normalizeOpts = _normalizeOpts;
6526
module.exports.mergeOpts = _mergeOpts;
6527
 
6528
 
6529
/***/ }),
6530
/* 7 */,
6531
/* 8 */
6532
/***/ (function(module) {
6533
 
6534
/*jshint node:true */
6535
/*
6536
 
6537
  The MIT License (MIT)
6538
 
6539
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6540
 
6541
  Permission is hereby granted, free of charge, to any person
6542
  obtaining a copy of this software and associated documentation files
6543
  (the "Software"), to deal in the Software without restriction,
6544
  including without limitation the rights to use, copy, modify, merge,
6545
  publish, distribute, sublicense, and/or sell copies of the Software,
6546
  and to permit persons to whom the Software is furnished to do so,
6547
  subject to the following conditions:
6548
 
6549
  The above copyright notice and this permission notice shall be
6550
  included in all copies or substantial portions of the Software.
6551
 
6552
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6553
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6554
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6555
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6556
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6557
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6558
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6559
  SOFTWARE.
6560
*/
6561
 
6562
 
6563
 
6564
var regexp_has_sticky = RegExp.prototype.hasOwnProperty('sticky');
6565
 
6566
function InputScanner(input_string) {
6567
  this.__input = input_string || '';
6568
  this.__input_length = this.__input.length;
6569
  this.__position = 0;
6570
}
6571
 
6572
InputScanner.prototype.restart = function() {
6573
  this.__position = 0;
6574
};
6575
 
6576
InputScanner.prototype.back = function() {
6577
  if (this.__position > 0) {
6578
    this.__position -= 1;
6579
  }
6580
};
6581
 
6582
InputScanner.prototype.hasNext = function() {
6583
  return this.__position < this.__input_length;
6584
};
6585
 
6586
InputScanner.prototype.next = function() {
6587
  var val = null;
6588
  if (this.hasNext()) {
6589
    val = this.__input.charAt(this.__position);
6590
    this.__position += 1;
6591
  }
6592
  return val;
6593
};
6594
 
6595
InputScanner.prototype.peek = function(index) {
6596
  var val = null;
6597
  index = index || 0;
6598
  index += this.__position;
6599
  if (index >= 0 && index < this.__input_length) {
6600
    val = this.__input.charAt(index);
6601
  }
6602
  return val;
6603
};
6604
 
6605
// This is a JavaScript only helper function (not in python)
6606
// Javascript doesn't have a match method
6607
// and not all implementation support "sticky" flag.
6608
// If they do not support sticky then both this.match() and this.test() method
6609
// must get the match and check the index of the match.
6610
// If sticky is supported and set, this method will use it.
6611
// Otherwise it will check that global is set, and fall back to the slower method.
6612
InputScanner.prototype.__match = function(pattern, index) {
6613
  pattern.lastIndex = index;
6614
  var pattern_match = pattern.exec(this.__input);
6615
 
6616
  if (pattern_match && !(regexp_has_sticky && pattern.sticky)) {
6617
    if (pattern_match.index !== index) {
6618
      pattern_match = null;
6619
    }
6620
  }
6621
 
6622
  return pattern_match;
6623
};
6624
 
6625
InputScanner.prototype.test = function(pattern, index) {
6626
  index = index || 0;
6627
  index += this.__position;
6628
 
6629
  if (index >= 0 && index < this.__input_length) {
6630
    return !!this.__match(pattern, index);
6631
  } else {
6632
    return false;
6633
  }
6634
};
6635
 
6636
InputScanner.prototype.testChar = function(pattern, index) {
6637
  // test one character regex match
6638
  var val = this.peek(index);
6639
  pattern.lastIndex = 0;
6640
  return val !== null && pattern.test(val);
6641
};
6642
 
6643
InputScanner.prototype.match = function(pattern) {
6644
  var pattern_match = this.__match(pattern, this.__position);
6645
  if (pattern_match) {
6646
    this.__position += pattern_match[0].length;
6647
  } else {
6648
    pattern_match = null;
6649
  }
6650
  return pattern_match;
6651
};
6652
 
6653
InputScanner.prototype.read = function(starting_pattern, until_pattern, until_after) {
6654
  var val = '';
6655
  var match;
6656
  if (starting_pattern) {
6657
    match = this.match(starting_pattern);
6658
    if (match) {
6659
      val += match[0];
6660
    }
6661
  }
6662
  if (until_pattern && (match || !starting_pattern)) {
6663
    val += this.readUntil(until_pattern, until_after);
6664
  }
6665
  return val;
6666
};
6667
 
6668
InputScanner.prototype.readUntil = function(pattern, until_after) {
6669
  var val = '';
6670
  var match_index = this.__position;
6671
  pattern.lastIndex = this.__position;
6672
  var pattern_match = pattern.exec(this.__input);
6673
  if (pattern_match) {
6674
    match_index = pattern_match.index;
6675
    if (until_after) {
6676
      match_index += pattern_match[0].length;
6677
    }
6678
  } else {
6679
    match_index = this.__input_length;
6680
  }
6681
 
6682
  val = this.__input.substring(this.__position, match_index);
6683
  this.__position = match_index;
6684
  return val;
6685
};
6686
 
6687
InputScanner.prototype.readUntilAfter = function(pattern) {
6688
  return this.readUntil(pattern, true);
6689
};
6690
 
6691
InputScanner.prototype.get_regexp = function(pattern, match_from) {
6692
  var result = null;
6693
  var flags = 'g';
6694
  if (match_from && regexp_has_sticky) {
6695
    flags = 'y';
6696
  }
6697
  // strings are converted to regexp
6698
  if (typeof pattern === "string" && pattern !== '') {
6699
    // result = new RegExp(pattern.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), flags);
6700
    result = new RegExp(pattern, flags);
6701
  } else if (pattern) {
6702
    result = new RegExp(pattern.source, flags);
6703
  }
6704
  return result;
6705
};
6706
 
6707
InputScanner.prototype.get_literal_regexp = function(literal_string) {
6708
  return RegExp(literal_string.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'));
6709
};
6710
 
6711
/* css beautifier legacy helpers */
6712
InputScanner.prototype.peekUntilAfter = function(pattern) {
6713
  var start = this.__position;
6714
  var val = this.readUntilAfter(pattern);
6715
  this.__position = start;
6716
  return val;
6717
};
6718
 
6719
InputScanner.prototype.lookBack = function(testVal) {
6720
  var start = this.__position - 1;
6721
  return start >= testVal.length && this.__input.substring(start - testVal.length, start)
6722
    .toLowerCase() === testVal;
6723
};
6724
 
6725
module.exports.InputScanner = InputScanner;
6726
 
6727
 
6728
/***/ }),
6729
/* 9 */
6730
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
6731
 
6732
/*jshint node:true */
6733
/*
6734
 
6735
  The MIT License (MIT)
6736
 
6737
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6738
 
6739
  Permission is hereby granted, free of charge, to any person
6740
  obtaining a copy of this software and associated documentation files
6741
  (the "Software"), to deal in the Software without restriction,
6742
  including without limitation the rights to use, copy, modify, merge,
6743
  publish, distribute, sublicense, and/or sell copies of the Software,
6744
  and to permit persons to whom the Software is furnished to do so,
6745
  subject to the following conditions:
6746
 
6747
  The above copyright notice and this permission notice shall be
6748
  included in all copies or substantial portions of the Software.
6749
 
6750
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6751
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6752
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6753
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6754
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6755
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6756
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6757
  SOFTWARE.
6758
*/
6759
 
6760
 
6761
 
6762
var InputScanner = (__webpack_require__(8).InputScanner);
6763
var Token = (__webpack_require__(3).Token);
6764
var TokenStream = (__webpack_require__(10).TokenStream);
6765
var WhitespacePattern = (__webpack_require__(11).WhitespacePattern);
6766
 
6767
var TOKEN = {
6768
  START: 'TK_START',
6769
  RAW: 'TK_RAW',
6770
  EOF: 'TK_EOF'
6771
};
6772
 
6773
var Tokenizer = function(input_string, options) {
6774
  this._input = new InputScanner(input_string);
6775
  this._options = options || {};
6776
  this.__tokens = null;
6777
 
6778
  this._patterns = {};
6779
  this._patterns.whitespace = new WhitespacePattern(this._input);
6780
};
6781
 
6782
Tokenizer.prototype.tokenize = function() {
6783
  this._input.restart();
6784
  this.__tokens = new TokenStream();
6785
 
6786
  this._reset();
6787
 
6788
  var current;
6789
  var previous = new Token(TOKEN.START, '');
6790
  var open_token = null;
6791
  var open_stack = [];
6792
  var comments = new TokenStream();
6793
 
6794
  while (previous.type !== TOKEN.EOF) {
6795
    current = this._get_next_token(previous, open_token);
6796
    while (this._is_comment(current)) {
6797
      comments.add(current);
6798
      current = this._get_next_token(previous, open_token);
6799
    }
6800
 
6801
    if (!comments.isEmpty()) {
6802
      current.comments_before = comments;
6803
      comments = new TokenStream();
6804
    }
6805
 
6806
    current.parent = open_token;
6807
 
6808
    if (this._is_opening(current)) {
6809
      open_stack.push(open_token);
6810
      open_token = current;
6811
    } else if (open_token && this._is_closing(current, open_token)) {
6812
      current.opened = open_token;
6813
      open_token.closed = current;
6814
      open_token = open_stack.pop();
6815
      current.parent = open_token;
6816
    }
6817
 
6818
    current.previous = previous;
6819
    previous.next = current;
6820
 
6821
    this.__tokens.add(current);
6822
    previous = current;
6823
  }
6824
 
6825
  return this.__tokens;
6826
};
6827
 
6828
 
6829
Tokenizer.prototype._is_first_token = function() {
6830
  return this.__tokens.isEmpty();
6831
};
6832
 
6833
Tokenizer.prototype._reset = function() {};
6834
 
6835
Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
6836
  this._readWhitespace();
6837
  var resulting_string = this._input.read(/.+/g);
6838
  if (resulting_string) {
6839
    return this._create_token(TOKEN.RAW, resulting_string);
6840
  } else {
6841
    return this._create_token(TOKEN.EOF, '');
6842
  }
6843
};
6844
 
6845
Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
6846
  return false;
6847
};
6848
 
6849
Tokenizer.prototype._is_opening = function(current_token) { // jshint unused:false
6850
  return false;
6851
};
6852
 
6853
Tokenizer.prototype._is_closing = function(current_token, open_token) { // jshint unused:false
6854
  return false;
6855
};
6856
 
6857
Tokenizer.prototype._create_token = function(type, text) {
6858
  var token = new Token(type, text,
6859
    this._patterns.whitespace.newline_count,
6860
    this._patterns.whitespace.whitespace_before_token);
6861
  return token;
6862
};
6863
 
6864
Tokenizer.prototype._readWhitespace = function() {
6865
  return this._patterns.whitespace.read();
6866
};
6867
 
6868
 
6869
 
6870
module.exports.Tokenizer = Tokenizer;
6871
module.exports.TOKEN = TOKEN;
6872
 
6873
 
6874
/***/ }),
6875
/* 10 */
6876
/***/ (function(module) {
6877
 
6878
/*jshint node:true */
6879
/*
6880
 
6881
  The MIT License (MIT)
6882
 
6883
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6884
 
6885
  Permission is hereby granted, free of charge, to any person
6886
  obtaining a copy of this software and associated documentation files
6887
  (the "Software"), to deal in the Software without restriction,
6888
  including without limitation the rights to use, copy, modify, merge,
6889
  publish, distribute, sublicense, and/or sell copies of the Software,
6890
  and to permit persons to whom the Software is furnished to do so,
6891
  subject to the following conditions:
6892
 
6893
  The above copyright notice and this permission notice shall be
6894
  included in all copies or substantial portions of the Software.
6895
 
6896
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6897
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6898
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6899
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6900
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6901
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6902
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6903
  SOFTWARE.
6904
*/
6905
 
6906
 
6907
 
6908
function TokenStream(parent_token) {
6909
  // private
6910
  this.__tokens = [];
6911
  this.__tokens_length = this.__tokens.length;
6912
  this.__position = 0;
6913
  this.__parent_token = parent_token;
6914
}
6915
 
6916
TokenStream.prototype.restart = function() {
6917
  this.__position = 0;
6918
};
6919
 
6920
TokenStream.prototype.isEmpty = function() {
6921
  return this.__tokens_length === 0;
6922
};
6923
 
6924
TokenStream.prototype.hasNext = function() {
6925
  return this.__position < this.__tokens_length;
6926
};
6927
 
6928
TokenStream.prototype.next = function() {
6929
  var val = null;
6930
  if (this.hasNext()) {
6931
    val = this.__tokens[this.__position];
6932
    this.__position += 1;
6933
  }
6934
  return val;
6935
};
6936
 
6937
TokenStream.prototype.peek = function(index) {
6938
  var val = null;
6939
  index = index || 0;
6940
  index += this.__position;
6941
  if (index >= 0 && index < this.__tokens_length) {
6942
    val = this.__tokens[index];
6943
  }
6944
  return val;
6945
};
6946
 
6947
TokenStream.prototype.add = function(token) {
6948
  if (this.__parent_token) {
6949
    token.parent = this.__parent_token;
6950
  }
6951
  this.__tokens.push(token);
6952
  this.__tokens_length += 1;
6953
};
6954
 
6955
module.exports.TokenStream = TokenStream;
6956
 
6957
 
6958
/***/ }),
6959
/* 11 */
6960
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
6961
 
6962
/*jshint node:true */
6963
/*
6964
 
6965
  The MIT License (MIT)
6966
 
6967
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
6968
 
6969
  Permission is hereby granted, free of charge, to any person
6970
  obtaining a copy of this software and associated documentation files
6971
  (the "Software"), to deal in the Software without restriction,
6972
  including without limitation the rights to use, copy, modify, merge,
6973
  publish, distribute, sublicense, and/or sell copies of the Software,
6974
  and to permit persons to whom the Software is furnished to do so,
6975
  subject to the following conditions:
6976
 
6977
  The above copyright notice and this permission notice shall be
6978
  included in all copies or substantial portions of the Software.
6979
 
6980
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
6981
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6982
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
6983
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
6984
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
6985
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
6986
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
6987
  SOFTWARE.
6988
*/
6989
 
6990
 
6991
 
6992
var Pattern = (__webpack_require__(12).Pattern);
6993
 
6994
function WhitespacePattern(input_scanner, parent) {
6995
  Pattern.call(this, input_scanner, parent);
6996
  if (parent) {
6997
    this._line_regexp = this._input.get_regexp(parent._line_regexp);
6998
  } else {
6999
    this.__set_whitespace_patterns('', '');
7000
  }
7001
 
7002
  this.newline_count = 0;
7003
  this.whitespace_before_token = '';
7004
}
7005
WhitespacePattern.prototype = new Pattern();
7006
 
7007
WhitespacePattern.prototype.__set_whitespace_patterns = function(whitespace_chars, newline_chars) {
7008
  whitespace_chars += '\\t ';
7009
  newline_chars += '\\n\\r';
7010
 
7011
  this._match_pattern = this._input.get_regexp(
7012
    '[' + whitespace_chars + newline_chars + ']+', true);
7013
  this._newline_regexp = this._input.get_regexp(
7014
    '\\r\\n|[' + newline_chars + ']');
7015
};
7016
 
7017
WhitespacePattern.prototype.read = function() {
7018
  this.newline_count = 0;
7019
  this.whitespace_before_token = '';
7020
 
7021
  var resulting_string = this._input.read(this._match_pattern);
7022
  if (resulting_string === ' ') {
7023
    this.whitespace_before_token = ' ';
7024
  } else if (resulting_string) {
7025
    var matches = this.__split(this._newline_regexp, resulting_string);
7026
    this.newline_count = matches.length - 1;
7027
    this.whitespace_before_token = matches[this.newline_count];
7028
  }
7029
 
7030
  return resulting_string;
7031
};
7032
 
7033
WhitespacePattern.prototype.matching = function(whitespace_chars, newline_chars) {
7034
  var result = this._create();
7035
  result.__set_whitespace_patterns(whitespace_chars, newline_chars);
7036
  result._update();
7037
  return result;
7038
};
7039
 
7040
WhitespacePattern.prototype._create = function() {
7041
  return new WhitespacePattern(this._input, this);
7042
};
7043
 
7044
WhitespacePattern.prototype.__split = function(regexp, input_string) {
7045
  regexp.lastIndex = 0;
7046
  var start_index = 0;
7047
  var result = [];
7048
  var next_match = regexp.exec(input_string);
7049
  while (next_match) {
7050
    result.push(input_string.substring(start_index, next_match.index));
7051
    start_index = next_match.index + next_match[0].length;
7052
    next_match = regexp.exec(input_string);
7053
  }
7054
 
7055
  if (start_index < input_string.length) {
7056
    result.push(input_string.substring(start_index, input_string.length));
7057
  } else {
7058
    result.push('');
7059
  }
7060
 
7061
  return result;
7062
};
7063
 
7064
 
7065
 
7066
module.exports.WhitespacePattern = WhitespacePattern;
7067
 
7068
 
7069
/***/ }),
7070
/* 12 */
7071
/***/ (function(module) {
7072
 
7073
/*jshint node:true */
7074
/*
7075
 
7076
  The MIT License (MIT)
7077
 
7078
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7079
 
7080
  Permission is hereby granted, free of charge, to any person
7081
  obtaining a copy of this software and associated documentation files
7082
  (the "Software"), to deal in the Software without restriction,
7083
  including without limitation the rights to use, copy, modify, merge,
7084
  publish, distribute, sublicense, and/or sell copies of the Software,
7085
  and to permit persons to whom the Software is furnished to do so,
7086
  subject to the following conditions:
7087
 
7088
  The above copyright notice and this permission notice shall be
7089
  included in all copies or substantial portions of the Software.
7090
 
7091
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7092
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7093
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7094
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
7095
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
7096
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7097
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7098
  SOFTWARE.
7099
*/
7100
 
7101
 
7102
 
7103
function Pattern(input_scanner, parent) {
7104
  this._input = input_scanner;
7105
  this._starting_pattern = null;
7106
  this._match_pattern = null;
7107
  this._until_pattern = null;
7108
  this._until_after = false;
7109
 
7110
  if (parent) {
7111
    this._starting_pattern = this._input.get_regexp(parent._starting_pattern, true);
7112
    this._match_pattern = this._input.get_regexp(parent._match_pattern, true);
7113
    this._until_pattern = this._input.get_regexp(parent._until_pattern);
7114
    this._until_after = parent._until_after;
7115
  }
7116
}
7117
 
7118
Pattern.prototype.read = function() {
7119
  var result = this._input.read(this._starting_pattern);
7120
  if (!this._starting_pattern || result) {
7121
    result += this._input.read(this._match_pattern, this._until_pattern, this._until_after);
7122
  }
7123
  return result;
7124
};
7125
 
7126
Pattern.prototype.read_match = function() {
7127
  return this._input.match(this._match_pattern);
7128
};
7129
 
7130
Pattern.prototype.until_after = function(pattern) {
7131
  var result = this._create();
7132
  result._until_after = true;
7133
  result._until_pattern = this._input.get_regexp(pattern);
7134
  result._update();
7135
  return result;
7136
};
7137
 
7138
Pattern.prototype.until = function(pattern) {
7139
  var result = this._create();
7140
  result._until_after = false;
7141
  result._until_pattern = this._input.get_regexp(pattern);
7142
  result._update();
7143
  return result;
7144
};
7145
 
7146
Pattern.prototype.starting_with = function(pattern) {
7147
  var result = this._create();
7148
  result._starting_pattern = this._input.get_regexp(pattern, true);
7149
  result._update();
7150
  return result;
7151
};
7152
 
7153
Pattern.prototype.matching = function(pattern) {
7154
  var result = this._create();
7155
  result._match_pattern = this._input.get_regexp(pattern, true);
7156
  result._update();
7157
  return result;
7158
};
7159
 
7160
Pattern.prototype._create = function() {
7161
  return new Pattern(this._input, this);
7162
};
7163
 
7164
Pattern.prototype._update = function() {};
7165
 
7166
module.exports.Pattern = Pattern;
7167
 
7168
 
7169
/***/ }),
7170
/* 13 */
7171
/***/ (function(module) {
7172
 
7173
/*jshint node:true */
7174
/*
7175
 
7176
  The MIT License (MIT)
7177
 
7178
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7179
 
7180
  Permission is hereby granted, free of charge, to any person
7181
  obtaining a copy of this software and associated documentation files
7182
  (the "Software"), to deal in the Software without restriction,
7183
  including without limitation the rights to use, copy, modify, merge,
7184
  publish, distribute, sublicense, and/or sell copies of the Software,
7185
  and to permit persons to whom the Software is furnished to do so,
7186
  subject to the following conditions:
7187
 
7188
  The above copyright notice and this permission notice shall be
7189
  included in all copies or substantial portions of the Software.
7190
 
7191
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7192
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7193
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7194
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
7195
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
7196
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7197
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7198
  SOFTWARE.
7199
*/
7200
 
7201
 
7202
 
7203
function Directives(start_block_pattern, end_block_pattern) {
7204
  start_block_pattern = typeof start_block_pattern === 'string' ? start_block_pattern : start_block_pattern.source;
7205
  end_block_pattern = typeof end_block_pattern === 'string' ? end_block_pattern : end_block_pattern.source;
7206
  this.__directives_block_pattern = new RegExp(start_block_pattern + / beautify( \w+[:]\w+)+ /.source + end_block_pattern, 'g');
7207
  this.__directive_pattern = / (\w+)[:](\w+)/g;
7208
 
7209
  this.__directives_end_ignore_pattern = new RegExp(start_block_pattern + /\sbeautify\signore:end\s/.source + end_block_pattern, 'g');
7210
}
7211
 
7212
Directives.prototype.get_directives = function(text) {
7213
  if (!text.match(this.__directives_block_pattern)) {
7214
    return null;
7215
  }
7216
 
7217
  var directives = {};
7218
  this.__directive_pattern.lastIndex = 0;
7219
  var directive_match = this.__directive_pattern.exec(text);
7220
 
7221
  while (directive_match) {
7222
    directives[directive_match[1]] = directive_match[2];
7223
    directive_match = this.__directive_pattern.exec(text);
7224
  }
7225
 
7226
  return directives;
7227
};
7228
 
7229
Directives.prototype.readIgnored = function(input) {
7230
  return input.readUntilAfter(this.__directives_end_ignore_pattern);
7231
};
7232
 
7233
 
7234
module.exports.Directives = Directives;
7235
 
7236
 
7237
/***/ }),
7238
/* 14 */
7239
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
7240
 
7241
/*jshint node:true */
7242
/*
7243
 
7244
  The MIT License (MIT)
7245
 
7246
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7247
 
7248
  Permission is hereby granted, free of charge, to any person
7249
  obtaining a copy of this software and associated documentation files
7250
  (the "Software"), to deal in the Software without restriction,
7251
  including without limitation the rights to use, copy, modify, merge,
7252
  publish, distribute, sublicense, and/or sell copies of the Software,
7253
  and to permit persons to whom the Software is furnished to do so,
7254
  subject to the following conditions:
7255
 
7256
  The above copyright notice and this permission notice shall be
7257
  included in all copies or substantial portions of the Software.
7258
 
7259
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7260
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7261
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7262
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
7263
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
7264
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7265
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7266
  SOFTWARE.
7267
*/
7268
 
7269
 
7270
 
7271
var Pattern = (__webpack_require__(12).Pattern);
7272
 
7273
 
7274
var template_names = {
7275
  django: false,
7276
  erb: false,
7277
  handlebars: false,
7278
  php: false,
7279
  smarty: false,
7280
  angular: false
7281
};
7282
 
7283
// This lets templates appear anywhere we would do a readUntil
7284
// The cost is higher but it is pay to play.
7285
function TemplatablePattern(input_scanner, parent) {
7286
  Pattern.call(this, input_scanner, parent);
7287
  this.__template_pattern = null;
7288
  this._disabled = Object.assign({}, template_names);
7289
  this._excluded = Object.assign({}, template_names);
7290
 
7291
  if (parent) {
7292
    this.__template_pattern = this._input.get_regexp(parent.__template_pattern);
7293
    this._excluded = Object.assign(this._excluded, parent._excluded);
7294
    this._disabled = Object.assign(this._disabled, parent._disabled);
7295
  }
7296
  var pattern = new Pattern(input_scanner);
7297
  this.__patterns = {
7298
    handlebars_comment: pattern.starting_with(/{{!--/).until_after(/--}}/),
7299
    handlebars_unescaped: pattern.starting_with(/{{{/).until_after(/}}}/),
7300
    handlebars: pattern.starting_with(/{{/).until_after(/}}/),
7301
    php: pattern.starting_with(/<\?(?:[= ]|php)/).until_after(/\?>/),
7302
    erb: pattern.starting_with(/<%[^%]/).until_after(/[^%]%>/),
7303
    // django coflicts with handlebars a bit.
7304
    django: pattern.starting_with(/{%/).until_after(/%}/),
7305
    django_value: pattern.starting_with(/{{/).until_after(/}}/),
7306
    django_comment: pattern.starting_with(/{#/).until_after(/#}/),
7307
    smarty: pattern.starting_with(/{(?=[^}{\s\n])/).until_after(/[^\s\n]}/),
7308
    smarty_comment: pattern.starting_with(/{\*/).until_after(/\*}/),
7309
    smarty_literal: pattern.starting_with(/{literal}/).until_after(/{\/literal}/)
7310
  };
7311
}
7312
TemplatablePattern.prototype = new Pattern();
7313
 
7314
TemplatablePattern.prototype._create = function() {
7315
  return new TemplatablePattern(this._input, this);
7316
};
7317
 
7318
TemplatablePattern.prototype._update = function() {
7319
  this.__set_templated_pattern();
7320
};
7321
 
7322
TemplatablePattern.prototype.disable = function(language) {
7323
  var result = this._create();
7324
  result._disabled[language] = true;
7325
  result._update();
7326
  return result;
7327
};
7328
 
7329
TemplatablePattern.prototype.read_options = function(options) {
7330
  var result = this._create();
7331
  for (var language in template_names) {
7332
    result._disabled[language] = options.templating.indexOf(language) === -1;
7333
  }
7334
  result._update();
7335
  return result;
7336
};
7337
 
7338
TemplatablePattern.prototype.exclude = function(language) {
7339
  var result = this._create();
7340
  result._excluded[language] = true;
7341
  result._update();
7342
  return result;
7343
};
7344
 
7345
TemplatablePattern.prototype.read = function() {
7346
  var result = '';
7347
  if (this._match_pattern) {
7348
    result = this._input.read(this._starting_pattern);
7349
  } else {
7350
    result = this._input.read(this._starting_pattern, this.__template_pattern);
7351
  }
7352
  var next = this._read_template();
7353
  while (next) {
7354
    if (this._match_pattern) {
7355
      next += this._input.read(this._match_pattern);
7356
    } else {
7357
      next += this._input.readUntil(this.__template_pattern);
7358
    }
7359
    result += next;
7360
    next = this._read_template();
7361
  }
7362
 
7363
  if (this._until_after) {
7364
    result += this._input.readUntilAfter(this._until_pattern);
7365
  }
7366
  return result;
7367
};
7368
 
7369
TemplatablePattern.prototype.__set_templated_pattern = function() {
7370
  var items = [];
7371
 
7372
  if (!this._disabled.php) {
7373
    items.push(this.__patterns.php._starting_pattern.source);
7374
  }
7375
  if (!this._disabled.handlebars) {
7376
    items.push(this.__patterns.handlebars._starting_pattern.source);
7377
  }
7378
  if (!this._disabled.erb) {
7379
    items.push(this.__patterns.erb._starting_pattern.source);
7380
  }
7381
  if (!this._disabled.django) {
7382
    items.push(this.__patterns.django._starting_pattern.source);
7383
    // The starting pattern for django is more complex because it has different
7384
    // patterns for value, comment, and other sections
7385
    items.push(this.__patterns.django_value._starting_pattern.source);
7386
    items.push(this.__patterns.django_comment._starting_pattern.source);
7387
  }
7388
  if (!this._disabled.smarty) {
7389
    items.push(this.__patterns.smarty._starting_pattern.source);
7390
  }
7391
 
7392
  if (this._until_pattern) {
7393
    items.push(this._until_pattern.source);
7394
  }
7395
  this.__template_pattern = this._input.get_regexp('(?:' + items.join('|') + ')');
7396
};
7397
 
7398
TemplatablePattern.prototype._read_template = function() {
7399
  var resulting_string = '';
7400
  var c = this._input.peek();
7401
  if (c === '<') {
7402
    var peek1 = this._input.peek(1);
7403
    //if we're in a comment, do something special
7404
    // We treat all comments as literals, even more than preformatted tags
7405
    // we just look for the appropriate close tag
7406
    if (!this._disabled.php && !this._excluded.php && peek1 === '?') {
7407
      resulting_string = resulting_string ||
7408
        this.__patterns.php.read();
7409
    }
7410
    if (!this._disabled.erb && !this._excluded.erb && peek1 === '%') {
7411
      resulting_string = resulting_string ||
7412
        this.__patterns.erb.read();
7413
    }
7414
  } else if (c === '{') {
7415
    if (!this._disabled.handlebars && !this._excluded.handlebars) {
7416
      resulting_string = resulting_string ||
7417
        this.__patterns.handlebars_comment.read();
7418
      resulting_string = resulting_string ||
7419
        this.__patterns.handlebars_unescaped.read();
7420
      resulting_string = resulting_string ||
7421
        this.__patterns.handlebars.read();
7422
    }
7423
    if (!this._disabled.django) {
7424
      // django coflicts with handlebars a bit.
7425
      if (!this._excluded.django && !this._excluded.handlebars) {
7426
        resulting_string = resulting_string ||
7427
          this.__patterns.django_value.read();
7428
      }
7429
      if (!this._excluded.django) {
7430
        resulting_string = resulting_string ||
7431
          this.__patterns.django_comment.read();
7432
        resulting_string = resulting_string ||
7433
          this.__patterns.django.read();
7434
      }
7435
    }
7436
    if (!this._disabled.smarty) {
7437
      // smarty cannot be enabled with django or handlebars enabled
7438
      if (this._disabled.django && this._disabled.handlebars) {
7439
        resulting_string = resulting_string ||
7440
          this.__patterns.smarty_comment.read();
7441
        resulting_string = resulting_string ||
7442
          this.__patterns.smarty_literal.read();
7443
        resulting_string = resulting_string ||
7444
          this.__patterns.smarty.read();
7445
      }
7446
    }
7447
  }
7448
  return resulting_string;
7449
};
7450
 
7451
 
7452
module.exports.TemplatablePattern = TemplatablePattern;
7453
 
7454
 
7455
/***/ }),
7456
/* 15 */,
7457
/* 16 */,
7458
/* 17 */,
7459
/* 18 */
7460
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
7461
 
7462
/*jshint node:true */
7463
/*
7464
 
7465
  The MIT License (MIT)
7466
 
7467
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7468
 
7469
  Permission is hereby granted, free of charge, to any person
7470
  obtaining a copy of this software and associated documentation files
7471
  (the "Software"), to deal in the Software without restriction,
7472
  including without limitation the rights to use, copy, modify, merge,
7473
  publish, distribute, sublicense, and/or sell copies of the Software,
7474
  and to permit persons to whom the Software is furnished to do so,
7475
  subject to the following conditions:
7476
 
7477
  The above copyright notice and this permission notice shall be
7478
  included in all copies or substantial portions of the Software.
7479
 
7480
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7481
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7482
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7483
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
7484
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
7485
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7486
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7487
  SOFTWARE.
7488
*/
7489
 
7490
 
7491
 
7492
var Beautifier = (__webpack_require__(19).Beautifier),
7493
  Options = (__webpack_require__(20).Options);
7494
 
7495
function style_html(html_source, options, js_beautify, css_beautify) {
7496
  var beautifier = new Beautifier(html_source, options, js_beautify, css_beautify);
7497
  return beautifier.beautify();
7498
}
7499
 
7500
module.exports = style_html;
7501
module.exports.defaultOptions = function() {
7502
  return new Options();
7503
};
7504
 
7505
 
7506
/***/ }),
7507
/* 19 */
7508
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
7509
 
7510
/*jshint node:true */
7511
/*
7512
 
7513
  The MIT License (MIT)
7514
 
7515
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
7516
 
7517
  Permission is hereby granted, free of charge, to any person
7518
  obtaining a copy of this software and associated documentation files
7519
  (the "Software"), to deal in the Software without restriction,
7520
  including without limitation the rights to use, copy, modify, merge,
7521
  publish, distribute, sublicense, and/or sell copies of the Software,
7522
  and to permit persons to whom the Software is furnished to do so,
7523
  subject to the following conditions:
7524
 
7525
  The above copyright notice and this permission notice shall be
7526
  included in all copies or substantial portions of the Software.
7527
 
7528
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7529
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7530
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
7531
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
7532
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
7533
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
7534
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
7535
  SOFTWARE.
7536
*/
7537
 
7538
 
7539
 
7540
var Options = (__webpack_require__(20).Options);
7541
var Output = (__webpack_require__(2).Output);
7542
var Tokenizer = (__webpack_require__(21).Tokenizer);
7543
var TOKEN = (__webpack_require__(21).TOKEN);
7544
 
7545
var lineBreak = /\r\n|[\r\n]/;
7546
var allLineBreaks = /\r\n|[\r\n]/g;
7547
 
7548
var Printer = function(options, base_indent_string) { //handles input/output and some other printing functions
7549
 
7550
  this.indent_level = 0;
7551
  this.alignment_size = 0;
7552
  this.max_preserve_newlines = options.max_preserve_newlines;
7553
  this.preserve_newlines = options.preserve_newlines;
7554
 
7555
  this._output = new Output(options, base_indent_string);
7556
 
7557
};
7558
 
7559
Printer.prototype.current_line_has_match = function(pattern) {
7560
  return this._output.current_line.has_match(pattern);
7561
};
7562
 
7563
Printer.prototype.set_space_before_token = function(value, non_breaking) {
7564
  this._output.space_before_token = value;
7565
  this._output.non_breaking_space = non_breaking;
7566
};
7567
 
7568
Printer.prototype.set_wrap_point = function() {
7569
  this._output.set_indent(this.indent_level, this.alignment_size);
7570
  this._output.set_wrap_point();
7571
};
7572
 
7573
 
7574
Printer.prototype.add_raw_token = function(token) {
7575
  this._output.add_raw_token(token);
7576
};
7577
 
7578
Printer.prototype.print_preserved_newlines = function(raw_token) {
7579
  var newlines = 0;
7580
  if (raw_token.type !== TOKEN.TEXT && raw_token.previous.type !== TOKEN.TEXT) {
7581
    newlines = raw_token.newlines ? 1 : 0;
7582
  }
7583
 
7584
  if (this.preserve_newlines) {
7585
    newlines = raw_token.newlines < this.max_preserve_newlines + 1 ? raw_token.newlines : this.max_preserve_newlines + 1;
7586
  }
7587
  for (var n = 0; n < newlines; n++) {
7588
    this.print_newline(n > 0);
7589
  }
7590
 
7591
  return newlines !== 0;
7592
};
7593
 
7594
Printer.prototype.traverse_whitespace = function(raw_token) {
7595
  if (raw_token.whitespace_before || raw_token.newlines) {
7596
    if (!this.print_preserved_newlines(raw_token)) {
7597
      this._output.space_before_token = true;
7598
    }
7599
    return true;
7600
  }
7601
  return false;
7602
};
7603
 
7604
Printer.prototype.previous_token_wrapped = function() {
7605
  return this._output.previous_token_wrapped;
7606
};
7607
 
7608
Printer.prototype.print_newline = function(force) {
7609
  this._output.add_new_line(force);
7610
};
7611
 
7612
Printer.prototype.print_token = function(token) {
7613
  if (token.text) {
7614
    this._output.set_indent(this.indent_level, this.alignment_size);
7615
    this._output.add_token(token.text);
7616
  }
7617
};
7618
 
7619
Printer.prototype.indent = function() {
7620
  this.indent_level++;
7621
};
7622
 
7623
Printer.prototype.deindent = function() {
7624
  if (this.indent_level > 0) {
7625
    this.indent_level--;
7626
    this._output.set_indent(this.indent_level, this.alignment_size);
7627
  }
7628
};
7629
 
7630
Printer.prototype.get_full_indent = function(level) {
7631
  level = this.indent_level + (level || 0);
7632
  if (level < 1) {
7633
    return '';
7634
  }
7635
 
7636
  return this._output.get_indent_string(level);
7637
};
7638
 
7639
var get_type_attribute = function(start_token) {
7640
  var result = null;
7641
  var raw_token = start_token.next;
7642
 
7643
  // Search attributes for a type attribute
7644
  while (raw_token.type !== TOKEN.EOF && start_token.closed !== raw_token) {
7645
    if (raw_token.type === TOKEN.ATTRIBUTE && raw_token.text === 'type') {
7646
      if (raw_token.next && raw_token.next.type === TOKEN.EQUALS &&
7647
        raw_token.next.next && raw_token.next.next.type === TOKEN.VALUE) {
7648
        result = raw_token.next.next.text;
7649
      }
7650
      break;
7651
    }
7652
    raw_token = raw_token.next;
7653
  }
7654
 
7655
  return result;
7656
};
7657
 
7658
var get_custom_beautifier_name = function(tag_check, raw_token) {
7659
  var typeAttribute = null;
7660
  var result = null;
7661
 
7662
  if (!raw_token.closed) {
7663
    return null;
7664
  }
7665
 
7666
  if (tag_check === 'script') {
7667
    typeAttribute = 'text/javascript';
7668
  } else if (tag_check === 'style') {
7669
    typeAttribute = 'text/css';
7670
  }
7671
 
7672
  typeAttribute = get_type_attribute(raw_token) || typeAttribute;
7673
 
7674
  // For script and style tags that have a type attribute, only enable custom beautifiers for matching values
7675
  // For those without a type attribute use default;
7676
  if (typeAttribute.search('text/css') > -1) {
7677
    result = 'css';
7678
  } else if (typeAttribute.search(/module|((text|application|dojo)\/(x-)?(javascript|ecmascript|jscript|livescript|(ld\+)?json|method|aspect))/) > -1) {
7679
    result = 'javascript';
7680
  } else if (typeAttribute.search(/(text|application|dojo)\/(x-)?(html)/) > -1) {
7681
    result = 'html';
7682
  } else if (typeAttribute.search(/test\/null/) > -1) {
7683
    // Test only mime-type for testing the beautifier when null is passed as beautifing function
7684
    result = 'null';
7685
  }
7686
 
7687
  return result;
7688
};
7689
 
7690
function in_array(what, arr) {
7691
  return arr.indexOf(what) !== -1;
7692
}
7693
 
7694
function TagFrame(parent, parser_token, indent_level) {
7695
  this.parent = parent || null;
7696
  this.tag = parser_token ? parser_token.tag_name : '';
7697
  this.indent_level = indent_level || 0;
7698
  this.parser_token = parser_token || null;
7699
}
7700
 
7701
function TagStack(printer) {
7702
  this._printer = printer;
7703
  this._current_frame = null;
7704
}
7705
 
7706
TagStack.prototype.get_parser_token = function() {
7707
  return this._current_frame ? this._current_frame.parser_token : null;
7708
};
7709
 
7710
TagStack.prototype.record_tag = function(parser_token) { //function to record a tag and its parent in this.tags Object
7711
  var new_frame = new TagFrame(this._current_frame, parser_token, this._printer.indent_level);
7712
  this._current_frame = new_frame;
7713
};
7714
 
7715
TagStack.prototype._try_pop_frame = function(frame) { //function to retrieve the opening tag to the corresponding closer
7716
  var parser_token = null;
7717
 
7718
  if (frame) {
7719
    parser_token = frame.parser_token;
7720
    this._printer.indent_level = frame.indent_level;
7721
    this._current_frame = frame.parent;
7722
  }
7723
 
7724
  return parser_token;
7725
};
7726
 
7727
TagStack.prototype._get_frame = function(tag_list, stop_list) { //function to retrieve the opening tag to the corresponding closer
7728
  var frame = this._current_frame;
7729
 
7730
  while (frame) { //till we reach '' (the initial value);
7731
    if (tag_list.indexOf(frame.tag) !== -1) { //if this is it use it
7732
      break;
7733
    } else if (stop_list && stop_list.indexOf(frame.tag) !== -1) {
7734
      frame = null;
7735
      break;
7736
    }
7737
    frame = frame.parent;
7738
  }
7739
 
7740
  return frame;
7741
};
7742
 
7743
TagStack.prototype.try_pop = function(tag, stop_list) { //function to retrieve the opening tag to the corresponding closer
7744
  var frame = this._get_frame([tag], stop_list);
7745
  return this._try_pop_frame(frame);
7746
};
7747
 
7748
TagStack.prototype.indent_to_tag = function(tag_list) {
7749
  var frame = this._get_frame(tag_list);
7750
  if (frame) {
7751
    this._printer.indent_level = frame.indent_level;
7752
  }
7753
};
7754
 
7755
function Beautifier(source_text, options, js_beautify, css_beautify) {
7756
  //Wrapper function to invoke all the necessary constructors and deal with the output.
7757
  this._source_text = source_text || '';
7758
  options = options || {};
7759
  this._js_beautify = js_beautify;
7760
  this._css_beautify = css_beautify;
7761
  this._tag_stack = null;
7762
 
7763
  // Allow the setting of language/file-type specific options
7764
  // with inheritance of overall settings
7765
  var optionHtml = new Options(options, 'html');
7766
 
7767
  this._options = optionHtml;
7768
 
7769
  this._is_wrap_attributes_force = this._options.wrap_attributes.substr(0, 'force'.length) === 'force';
7770
  this._is_wrap_attributes_force_expand_multiline = (this._options.wrap_attributes === 'force-expand-multiline');
7771
  this._is_wrap_attributes_force_aligned = (this._options.wrap_attributes === 'force-aligned');
7772
  this._is_wrap_attributes_aligned_multiple = (this._options.wrap_attributes === 'aligned-multiple');
7773
  this._is_wrap_attributes_preserve = this._options.wrap_attributes.substr(0, 'preserve'.length) === 'preserve';
7774
  this._is_wrap_attributes_preserve_aligned = (this._options.wrap_attributes === 'preserve-aligned');
7775
}
7776
 
7777
Beautifier.prototype.beautify = function() {
7778
 
7779
  // if disabled, return the input unchanged.
7780
  if (this._options.disabled) {
7781
    return this._source_text;
7782
  }
7783
 
7784
  var source_text = this._source_text;
7785
  var eol = this._options.eol;
7786
  if (this._options.eol === 'auto') {
7787
    eol = '\n';
7788
    if (source_text && lineBreak.test(source_text)) {
7789
      eol = source_text.match(lineBreak)[0];
7790
    }
7791
  }
7792
 
7793
  // HACK: newline parsing inconsistent. This brute force normalizes the input.
7794
  source_text = source_text.replace(allLineBreaks, '\n');
7795
 
7796
  var baseIndentString = source_text.match(/^[\t ]*/)[0];
7797
 
7798
  var last_token = {
7799
    text: '',
7800
    type: ''
7801
  };
7802
 
7803
  var last_tag_token = new TagOpenParserToken();
7804
 
7805
  var printer = new Printer(this._options, baseIndentString);
7806
  var tokens = new Tokenizer(source_text, this._options).tokenize();
7807
 
7808
  this._tag_stack = new TagStack(printer);
7809
 
7810
  var parser_token = null;
7811
  var raw_token = tokens.next();
7812
  while (raw_token.type !== TOKEN.EOF) {
7813
 
7814
    if (raw_token.type === TOKEN.TAG_OPEN || raw_token.type === TOKEN.COMMENT) {
7815
      parser_token = this._handle_tag_open(printer, raw_token, last_tag_token, last_token, tokens);
7816
      last_tag_token = parser_token;
7817
    } else if ((raw_token.type === TOKEN.ATTRIBUTE || raw_token.type === TOKEN.EQUALS || raw_token.type === TOKEN.VALUE) ||
7818
      (raw_token.type === TOKEN.TEXT && !last_tag_token.tag_complete)) {
7819
      parser_token = this._handle_inside_tag(printer, raw_token, last_tag_token, last_token);
7820
    } else if (raw_token.type === TOKEN.TAG_CLOSE) {
7821
      parser_token = this._handle_tag_close(printer, raw_token, last_tag_token);
7822
    } else if (raw_token.type === TOKEN.TEXT) {
7823
      parser_token = this._handle_text(printer, raw_token, last_tag_token);
7824
    } else if (raw_token.type === TOKEN.CONTROL_FLOW_OPEN) {
7825
      parser_token = this._handle_control_flow_open(printer, raw_token);
7826
    } else if (raw_token.type === TOKEN.CONTROL_FLOW_CLOSE) {
7827
      parser_token = this._handle_control_flow_close(printer, raw_token);
7828
    } else {
7829
      // This should never happen, but if it does. Print the raw token
7830
      printer.add_raw_token(raw_token);
7831
    }
7832
 
7833
    last_token = parser_token;
7834
 
7835
    raw_token = tokens.next();
7836
  }
7837
  var sweet_code = printer._output.get_code(eol);
7838
 
7839
  return sweet_code;
7840
};
7841
 
7842
Beautifier.prototype._handle_control_flow_open = function(printer, raw_token) {
7843
  var parser_token = {
7844
    text: raw_token.text,
7845
    type: raw_token.type
7846
  };
7847
  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7848
  if (raw_token.newlines) {
7849
    printer.print_preserved_newlines(raw_token);
7850
  } else {
7851
    printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7852
  }
7853
  printer.print_token(raw_token);
7854
  printer.indent();
7855
  return parser_token;
7856
};
7857
 
7858
Beautifier.prototype._handle_control_flow_close = function(printer, raw_token) {
7859
  var parser_token = {
7860
    text: raw_token.text,
7861
    type: raw_token.type
7862
  };
7863
 
7864
  printer.deindent();
7865
  if (raw_token.newlines) {
7866
    printer.print_preserved_newlines(raw_token);
7867
  } else {
7868
    printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7869
  }
7870
  printer.print_token(raw_token);
7871
  return parser_token;
7872
};
7873
 
7874
Beautifier.prototype._handle_tag_close = function(printer, raw_token, last_tag_token) {
7875
  var parser_token = {
7876
    text: raw_token.text,
7877
    type: raw_token.type
7878
  };
7879
  printer.alignment_size = 0;
7880
  last_tag_token.tag_complete = true;
7881
 
7882
  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7883
  if (last_tag_token.is_unformatted) {
7884
    printer.add_raw_token(raw_token);
7885
  } else {
7886
    if (last_tag_token.tag_start_char === '<') {
7887
      printer.set_space_before_token(raw_token.text[0] === '/', true); // space before />, no space before >
7888
      if (this._is_wrap_attributes_force_expand_multiline && last_tag_token.has_wrapped_attrs) {
7889
        printer.print_newline(false);
7890
      }
7891
    }
7892
    printer.print_token(raw_token);
7893
 
7894
  }
7895
 
7896
  if (last_tag_token.indent_content &&
7897
    !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7898
    printer.indent();
7899
 
7900
    // only indent once per opened tag
7901
    last_tag_token.indent_content = false;
7902
  }
7903
 
7904
  if (!last_tag_token.is_inline_element &&
7905
    !(last_tag_token.is_unformatted || last_tag_token.is_content_unformatted)) {
7906
    printer.set_wrap_point();
7907
  }
7908
 
7909
  return parser_token;
7910
};
7911
 
7912
Beautifier.prototype._handle_inside_tag = function(printer, raw_token, last_tag_token, last_token) {
7913
  var wrapped = last_tag_token.has_wrapped_attrs;
7914
  var parser_token = {
7915
    text: raw_token.text,
7916
    type: raw_token.type
7917
  };
7918
 
7919
  printer.set_space_before_token(raw_token.newlines || raw_token.whitespace_before !== '', true);
7920
  if (last_tag_token.is_unformatted) {
7921
    printer.add_raw_token(raw_token);
7922
  } else if (last_tag_token.tag_start_char === '{' && raw_token.type === TOKEN.TEXT) {
7923
    // For the insides of handlebars allow newlines or a single space between open and contents
7924
    if (printer.print_preserved_newlines(raw_token)) {
7925
      raw_token.newlines = 0;
7926
      printer.add_raw_token(raw_token);
7927
    } else {
7928
      printer.print_token(raw_token);
7929
    }
7930
  } else {
7931
    if (raw_token.type === TOKEN.ATTRIBUTE) {
7932
      printer.set_space_before_token(true);
7933
    } else if (raw_token.type === TOKEN.EQUALS) { //no space before =
7934
      printer.set_space_before_token(false);
7935
    } else if (raw_token.type === TOKEN.VALUE && raw_token.previous.type === TOKEN.EQUALS) { //no space before value
7936
      printer.set_space_before_token(false);
7937
    }
7938
 
7939
    if (raw_token.type === TOKEN.ATTRIBUTE && last_tag_token.tag_start_char === '<') {
7940
      if (this._is_wrap_attributes_preserve || this._is_wrap_attributes_preserve_aligned) {
7941
        printer.traverse_whitespace(raw_token);
7942
        wrapped = wrapped || raw_token.newlines !== 0;
7943
      }
7944
 
7945
      // Wrap for 'force' options, and if the number of attributes is at least that specified in 'wrap_attributes_min_attrs':
7946
      // 1. always wrap the second and beyond attributes
7947
      // 2. wrap the first attribute only if 'force-expand-multiline' is specified
7948
      if (this._is_wrap_attributes_force &&
7949
        last_tag_token.attr_count >= this._options.wrap_attributes_min_attrs &&
7950
        (last_token.type !== TOKEN.TAG_OPEN || // ie. second attribute and beyond
7951
          this._is_wrap_attributes_force_expand_multiline)) {
7952
        printer.print_newline(false);
7953
        wrapped = true;
7954
      }
7955
    }
7956
    printer.print_token(raw_token);
7957
    wrapped = wrapped || printer.previous_token_wrapped();
7958
    last_tag_token.has_wrapped_attrs = wrapped;
7959
  }
7960
  return parser_token;
7961
};
7962
 
7963
Beautifier.prototype._handle_text = function(printer, raw_token, last_tag_token) {
7964
  var parser_token = {
7965
    text: raw_token.text,
7966
    type: 'TK_CONTENT'
7967
  };
7968
  if (last_tag_token.custom_beautifier_name) { //check if we need to format javascript
7969
    this._print_custom_beatifier_text(printer, raw_token, last_tag_token);
7970
  } else if (last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) {
7971
    printer.add_raw_token(raw_token);
7972
  } else {
7973
    printer.traverse_whitespace(raw_token);
7974
    printer.print_token(raw_token);
7975
  }
7976
  return parser_token;
7977
};
7978
 
7979
Beautifier.prototype._print_custom_beatifier_text = function(printer, raw_token, last_tag_token) {
7980
  var local = this;
7981
  if (raw_token.text !== '') {
7982
 
7983
    var text = raw_token.text,
7984
      _beautifier,
7985
      script_indent_level = 1,
7986
      pre = '',
7987
      post = '';
7988
    if (last_tag_token.custom_beautifier_name === 'javascript' && typeof this._js_beautify === 'function') {
7989
      _beautifier = this._js_beautify;
7990
    } else if (last_tag_token.custom_beautifier_name === 'css' && typeof this._css_beautify === 'function') {
7991
      _beautifier = this._css_beautify;
7992
    } else if (last_tag_token.custom_beautifier_name === 'html') {
7993
      _beautifier = function(html_source, options) {
7994
        var beautifier = new Beautifier(html_source, options, local._js_beautify, local._css_beautify);
7995
        return beautifier.beautify();
7996
      };
7997
    }
7998
 
7999
    if (this._options.indent_scripts === "keep") {
8000
      script_indent_level = 0;
8001
    } else if (this._options.indent_scripts === "separate") {
8002
      script_indent_level = -printer.indent_level;
8003
    }
8004
 
8005
    var indentation = printer.get_full_indent(script_indent_level);
8006
 
8007
    // if there is at least one empty line at the end of this text, strip it
8008
    // we'll be adding one back after the text but before the containing tag.
8009
    text = text.replace(/\n[ \t]*$/, '');
8010
 
8011
    // Handle the case where content is wrapped in a comment or cdata.
8012
    if (last_tag_token.custom_beautifier_name !== 'html' &&
8013
      text[0] === '<' && text.match(/^(<!--|<!\[CDATA\[)/)) {
8014
      var matched = /^(<!--[^\n]*|<!\[CDATA\[)(\n?)([ \t\n]*)([\s\S]*)(-->|]]>)$/.exec(text);
8015
 
8016
      // if we start to wrap but don't finish, print raw
8017
      if (!matched) {
8018
        printer.add_raw_token(raw_token);
8019
        return;
8020
      }
8021
 
8022
      pre = indentation + matched[1] + '\n';
8023
      text = matched[4];
8024
      if (matched[5]) {
8025
        post = indentation + matched[5];
8026
      }
8027
 
8028
      // if there is at least one empty line at the end of this text, strip it
8029
      // we'll be adding one back after the text but before the containing tag.
8030
      text = text.replace(/\n[ \t]*$/, '');
8031
 
8032
      if (matched[2] || matched[3].indexOf('\n') !== -1) {
8033
        // if the first line of the non-comment text has spaces
8034
        // use that as the basis for indenting in null case.
8035
        matched = matched[3].match(/[ \t]+$/);
8036
        if (matched) {
8037
          raw_token.whitespace_before = matched[0];
8038
        }
8039
      }
8040
    }
8041
 
8042
    if (text) {
8043
      if (_beautifier) {
8044
 
8045
        // call the Beautifier if avaliable
8046
        var Child_options = function() {
8047
          this.eol = '\n';
8048
        };
8049
        Child_options.prototype = this._options.raw_options;
8050
        var child_options = new Child_options();
8051
        text = _beautifier(indentation + text, child_options);
8052
      } else {
8053
        // simply indent the string otherwise
8054
        var white = raw_token.whitespace_before;
8055
        if (white) {
8056
          text = text.replace(new RegExp('\n(' + white + ')?', 'g'), '\n');
8057
        }
8058
 
8059
        text = indentation + text.replace(/\n/g, '\n' + indentation);
8060
      }
8061
    }
8062
 
8063
    if (pre) {
8064
      if (!text) {
8065
        text = pre + post;
8066
      } else {
8067
        text = pre + text + '\n' + post;
8068
      }
8069
    }
8070
 
8071
    printer.print_newline(false);
8072
    if (text) {
8073
      raw_token.text = text;
8074
      raw_token.whitespace_before = '';
8075
      raw_token.newlines = 0;
8076
      printer.add_raw_token(raw_token);
8077
      printer.print_newline(true);
8078
    }
8079
  }
8080
};
8081
 
8082
Beautifier.prototype._handle_tag_open = function(printer, raw_token, last_tag_token, last_token, tokens) {
8083
  var parser_token = this._get_tag_open_token(raw_token);
8084
 
8085
  if ((last_tag_token.is_unformatted || last_tag_token.is_content_unformatted) &&
8086
    !last_tag_token.is_empty_element &&
8087
    raw_token.type === TOKEN.TAG_OPEN && !parser_token.is_start_tag) {
8088
    // End element tags for unformatted or content_unformatted elements
8089
    // are printed raw to keep any newlines inside them exactly the same.
8090
    printer.add_raw_token(raw_token);
8091
    parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name);
8092
  } else {
8093
    printer.traverse_whitespace(raw_token);
8094
    this._set_tag_position(printer, raw_token, parser_token, last_tag_token, last_token);
8095
    if (!parser_token.is_inline_element) {
8096
      printer.set_wrap_point();
8097
    }
8098
    printer.print_token(raw_token);
8099
  }
8100
 
8101
  // count the number of attributes
8102
  if (parser_token.is_start_tag && this._is_wrap_attributes_force) {
8103
    var peek_index = 0;
8104
    var peek_token;
8105
    do {
8106
      peek_token = tokens.peek(peek_index);
8107
      if (peek_token.type === TOKEN.ATTRIBUTE) {
8108
        parser_token.attr_count += 1;
8109
      }
8110
      peek_index += 1;
8111
    } while (peek_token.type !== TOKEN.EOF && peek_token.type !== TOKEN.TAG_CLOSE);
8112
  }
8113
 
8114
  //indent attributes an auto, forced, aligned or forced-align line-wrap
8115
  if (this._is_wrap_attributes_force_aligned || this._is_wrap_attributes_aligned_multiple || this._is_wrap_attributes_preserve_aligned) {
8116
    parser_token.alignment_size = raw_token.text.length + 1;
8117
  }
8118
 
8119
  if (!parser_token.tag_complete && !parser_token.is_unformatted) {
8120
    printer.alignment_size = parser_token.alignment_size;
8121
  }
8122
 
8123
  return parser_token;
8124
};
8125
 
8126
var TagOpenParserToken = function(parent, raw_token) {
8127
  this.parent = parent || null;
8128
  this.text = '';
8129
  this.type = 'TK_TAG_OPEN';
8130
  this.tag_name = '';
8131
  this.is_inline_element = false;
8132
  this.is_unformatted = false;
8133
  this.is_content_unformatted = false;
8134
  this.is_empty_element = false;
8135
  this.is_start_tag = false;
8136
  this.is_end_tag = false;
8137
  this.indent_content = false;
8138
  this.multiline_content = false;
8139
  this.custom_beautifier_name = null;
8140
  this.start_tag_token = null;
8141
  this.attr_count = 0;
8142
  this.has_wrapped_attrs = false;
8143
  this.alignment_size = 0;
8144
  this.tag_complete = false;
8145
  this.tag_start_char = '';
8146
  this.tag_check = '';
8147
 
8148
  if (!raw_token) {
8149
    this.tag_complete = true;
8150
  } else {
8151
    var tag_check_match;
8152
 
8153
    this.tag_start_char = raw_token.text[0];
8154
    this.text = raw_token.text;
8155
 
8156
    if (this.tag_start_char === '<') {
8157
      tag_check_match = raw_token.text.match(/^<([^\s>]*)/);
8158
      this.tag_check = tag_check_match ? tag_check_match[1] : '';
8159
    } else {
8160
      tag_check_match = raw_token.text.match(/^{{~?(?:[\^]|#\*?)?([^\s}]+)/);
8161
      this.tag_check = tag_check_match ? tag_check_match[1] : '';
8162
 
8163
      // handle "{{#> myPartial}}" or "{{~#> myPartial}}"
8164
      if ((raw_token.text.startsWith('{{#>') || raw_token.text.startsWith('{{~#>')) && this.tag_check[0] === '>') {
8165
        if (this.tag_check === '>' && raw_token.next !== null) {
8166
          this.tag_check = raw_token.next.text.split(' ')[0];
8167
        } else {
8168
          this.tag_check = raw_token.text.split('>')[1];
8169
        }
8170
      }
8171
    }
8172
 
8173
    this.tag_check = this.tag_check.toLowerCase();
8174
 
8175
    if (raw_token.type === TOKEN.COMMENT) {
8176
      this.tag_complete = true;
8177
    }
8178
 
8179
    this.is_start_tag = this.tag_check.charAt(0) !== '/';
8180
    this.tag_name = !this.is_start_tag ? this.tag_check.substr(1) : this.tag_check;
8181
    this.is_end_tag = !this.is_start_tag ||
8182
      (raw_token.closed && raw_token.closed.text === '/>');
8183
 
8184
    // if whitespace handler ~ included (i.e. {{~#if true}}), handlebars tags start at pos 3 not pos 2
8185
    var handlebar_starts = 2;
8186
    if (this.tag_start_char === '{' && this.text.length >= 3) {
8187
      if (this.text.charAt(2) === '~') {
8188
        handlebar_starts = 3;
8189
      }
8190
    }
8191
 
8192
    // handlebars tags that don't start with # or ^ are single_tags, and so also start and end.
8193
    this.is_end_tag = this.is_end_tag ||
8194
      (this.tag_start_char === '{' && (this.text.length < 3 || (/[^#\^]/.test(this.text.charAt(handlebar_starts)))));
8195
  }
8196
};
8197
 
8198
Beautifier.prototype._get_tag_open_token = function(raw_token) { //function to get a full tag and parse its type
8199
  var parser_token = new TagOpenParserToken(this._tag_stack.get_parser_token(), raw_token);
8200
 
8201
  parser_token.alignment_size = this._options.wrap_attributes_indent_size;
8202
 
8203
  parser_token.is_end_tag = parser_token.is_end_tag ||
8204
    in_array(parser_token.tag_check, this._options.void_elements);
8205
 
8206
  parser_token.is_empty_element = parser_token.tag_complete ||
8207
    (parser_token.is_start_tag && parser_token.is_end_tag);
8208
 
8209
  parser_token.is_unformatted = !parser_token.tag_complete && in_array(parser_token.tag_check, this._options.unformatted);
8210
  parser_token.is_content_unformatted = !parser_token.is_empty_element && in_array(parser_token.tag_check, this._options.content_unformatted);
8211
  parser_token.is_inline_element = in_array(parser_token.tag_name, this._options.inline) || (this._options.inline_custom_elements && parser_token.tag_name.includes("-")) || parser_token.tag_start_char === '{';
8212
 
8213
  return parser_token;
8214
};
8215
 
8216
Beautifier.prototype._set_tag_position = function(printer, raw_token, parser_token, last_tag_token, last_token) {
8217
 
8218
  if (!parser_token.is_empty_element) {
8219
    if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
8220
      parser_token.start_tag_token = this._tag_stack.try_pop(parser_token.tag_name); //remove it and all ancestors
8221
    } else { // it's a start-tag
8222
      // check if this tag is starting an element that has optional end element
8223
      // and do an ending needed
8224
      if (this._do_optional_end_element(parser_token)) {
8225
        if (!parser_token.is_inline_element) {
8226
          printer.print_newline(false);
8227
        }
8228
      }
8229
 
8230
      this._tag_stack.record_tag(parser_token); //push it on the tag stack
8231
 
8232
      if ((parser_token.tag_name === 'script' || parser_token.tag_name === 'style') &&
8233
        !(parser_token.is_unformatted || parser_token.is_content_unformatted)) {
8234
        parser_token.custom_beautifier_name = get_custom_beautifier_name(parser_token.tag_check, raw_token);
8235
      }
8236
    }
8237
  }
8238
 
8239
  if (in_array(parser_token.tag_check, this._options.extra_liners)) { //check if this double needs an extra line
8240
    printer.print_newline(false);
8241
    if (!printer._output.just_added_blankline()) {
8242
      printer.print_newline(true);
8243
    }
8244
  }
8245
 
8246
  if (parser_token.is_empty_element) { //if this tag name is a single tag type (either in the list or has a closing /)
8247
 
8248
    // if you hit an else case, reset the indent level if you are inside an:
8249
    // 'if', 'unless', or 'each' block.
8250
    if (parser_token.tag_start_char === '{' && parser_token.tag_check === 'else') {
8251
      this._tag_stack.indent_to_tag(['if', 'unless', 'each']);
8252
      parser_token.indent_content = true;
8253
      // Don't add a newline if opening {{#if}} tag is on the current line
8254
      var foundIfOnCurrentLine = printer.current_line_has_match(/{{#if/);
8255
      if (!foundIfOnCurrentLine) {
8256
        printer.print_newline(false);
8257
      }
8258
    }
8259
 
8260
    // Don't add a newline before elements that should remain where they are.
8261
    if (parser_token.tag_name === '!--' && last_token.type === TOKEN.TAG_CLOSE &&
8262
      last_tag_token.is_end_tag && parser_token.text.indexOf('\n') === -1) {
8263
      //Do nothing. Leave comments on same line.
8264
    } else {
8265
      if (!(parser_token.is_inline_element || parser_token.is_unformatted)) {
8266
        printer.print_newline(false);
8267
      }
8268
      this._calcluate_parent_multiline(printer, parser_token);
8269
    }
8270
  } else if (parser_token.is_end_tag) { //this tag is a double tag so check for tag-ending
8271
    var do_end_expand = false;
8272
 
8273
    // deciding whether a block is multiline should not be this hard
8274
    do_end_expand = parser_token.start_tag_token && parser_token.start_tag_token.multiline_content;
8275
    do_end_expand = do_end_expand || (!parser_token.is_inline_element &&
8276
      !(last_tag_token.is_inline_element || last_tag_token.is_unformatted) &&
8277
      !(last_token.type === TOKEN.TAG_CLOSE && parser_token.start_tag_token === last_tag_token) &&
8278
      last_token.type !== 'TK_CONTENT'
8279
    );
8280
 
8281
    if (parser_token.is_content_unformatted || parser_token.is_unformatted) {
8282
      do_end_expand = false;
8283
    }
8284
 
8285
    if (do_end_expand) {
8286
      printer.print_newline(false);
8287
    }
8288
  } else { // it's a start-tag
8289
    parser_token.indent_content = !parser_token.custom_beautifier_name;
8290
 
8291
    if (parser_token.tag_start_char === '<') {
8292
      if (parser_token.tag_name === 'html') {
8293
        parser_token.indent_content = this._options.indent_inner_html;
8294
      } else if (parser_token.tag_name === 'head') {
8295
        parser_token.indent_content = this._options.indent_head_inner_html;
8296
      } else if (parser_token.tag_name === 'body') {
8297
        parser_token.indent_content = this._options.indent_body_inner_html;
8298
      }
8299
    }
8300
 
8301
    if (!(parser_token.is_inline_element || parser_token.is_unformatted) &&
8302
      (last_token.type !== 'TK_CONTENT' || parser_token.is_content_unformatted)) {
8303
      printer.print_newline(false);
8304
    }
8305
 
8306
    this._calcluate_parent_multiline(printer, parser_token);
8307
  }
8308
};
8309
 
8310
Beautifier.prototype._calcluate_parent_multiline = function(printer, parser_token) {
8311
  if (parser_token.parent && printer._output.just_added_newline() &&
8312
    !((parser_token.is_inline_element || parser_token.is_unformatted) && parser_token.parent.is_inline_element)) {
8313
    parser_token.parent.multiline_content = true;
8314
  }
8315
};
8316
 
8317
//To be used for <p> tag special case:
8318
var p_closers = ['address', 'article', 'aside', 'blockquote', 'details', 'div', 'dl', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'header', 'hr', 'main', 'menu', 'nav', 'ol', 'p', 'pre', 'section', 'table', 'ul'];
8319
var p_parent_excludes = ['a', 'audio', 'del', 'ins', 'map', 'noscript', 'video'];
8320
 
8321
Beautifier.prototype._do_optional_end_element = function(parser_token) {
8322
  var result = null;
8323
  // NOTE: cases of "if there is no more content in the parent element"
8324
  // are handled automatically by the beautifier.
8325
  // It assumes parent or ancestor close tag closes all children.
8326
  // https://www.w3.org/TR/html5/syntax.html#optional-tags
8327
  if (parser_token.is_empty_element || !parser_token.is_start_tag || !parser_token.parent) {
8328
    return;
8329
 
8330
  }
8331
 
8332
  if (parser_token.tag_name === 'body') {
8333
    // A head element’s end tag may be omitted if the head element is not immediately followed by a space character or a comment.
8334
    result = result || this._tag_stack.try_pop('head');
8335
 
8336
    //} else if (parser_token.tag_name === 'body') {
8337
    // DONE: A body element’s end tag may be omitted if the body element is not immediately followed by a comment.
8338
 
8339
  } else if (parser_token.tag_name === 'li') {
8340
    // 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.
8341
    result = result || this._tag_stack.try_pop('li', ['ol', 'ul', 'menu']);
8342
 
8343
  } else if (parser_token.tag_name === 'dd' || parser_token.tag_name === 'dt') {
8344
    // 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.
8345
    // A dt element’s end tag may be omitted if the dt element is immediately followed by another dt element or a dd element.
8346
    result = result || this._tag_stack.try_pop('dt', ['dl']);
8347
    result = result || this._tag_stack.try_pop('dd', ['dl']);
8348
 
8349
 
8350
  } else if (parser_token.parent.tag_name === 'p' && p_closers.indexOf(parser_token.tag_name) !== -1) {
8351
    // IMPORTANT: this else-if works because p_closers has no overlap with any other element we look for in this method
8352
    // check for 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.
8353
    // To do this right, this needs to be coded as an inclusion of the inverse of the exclusion above.
8354
    // But to start with (if we ignore "autonomous custom elements") the exclusion would be fine.
8355
    var p_parent = parser_token.parent.parent;
8356
    if (!p_parent || p_parent_excludes.indexOf(p_parent.tag_name) === -1) {
8357
      result = result || this._tag_stack.try_pop('p');
8358
    }
8359
  } else if (parser_token.tag_name === 'rp' || parser_token.tag_name === 'rt') {
8360
    // 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.
8361
    // 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.
8362
    result = result || this._tag_stack.try_pop('rt', ['ruby', 'rtc']);
8363
    result = result || this._tag_stack.try_pop('rp', ['ruby', 'rtc']);
8364
 
8365
  } else if (parser_token.tag_name === 'optgroup') {
8366
    // 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.
8367
    // 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.
8368
    result = result || this._tag_stack.try_pop('optgroup', ['select']);
8369
    //result = result || this._tag_stack.try_pop('option', ['select']);
8370
 
8371
  } else if (parser_token.tag_name === 'option') {
8372
    // 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.
8373
    result = result || this._tag_stack.try_pop('option', ['select', 'datalist', 'optgroup']);
8374
 
8375
  } else if (parser_token.tag_name === 'colgroup') {
8376
    // 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.
8377
    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8378
    result = result || this._tag_stack.try_pop('caption', ['table']);
8379
 
8380
  } else if (parser_token.tag_name === 'thead') {
8381
    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8382
    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8383
    result = result || this._tag_stack.try_pop('caption', ['table']);
8384
    result = result || this._tag_stack.try_pop('colgroup', ['table']);
8385
 
8386
    //} else if (parser_token.tag_name === 'caption') {
8387
    // 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.
8388
 
8389
  } else if (parser_token.tag_name === 'tbody' || parser_token.tag_name === 'tfoot') {
8390
    // A thead element’s end tag may be omitted if the thead element is immediately followed by a tbody or tfoot element.
8391
    // 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.
8392
    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8393
    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8394
    result = result || this._tag_stack.try_pop('caption', ['table']);
8395
    result = result || this._tag_stack.try_pop('colgroup', ['table']);
8396
    result = result || this._tag_stack.try_pop('thead', ['table']);
8397
    result = result || this._tag_stack.try_pop('tbody', ['table']);
8398
 
8399
    //} else if (parser_token.tag_name === 'tfoot') {
8400
    // DONE: A tfoot element’s end tag may be omitted if there is no more content in the parent element.
8401
 
8402
  } else if (parser_token.tag_name === 'tr') {
8403
    // 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.
8404
    // A colgroup element's end tag may be ommitted if a thead, tfoot, tbody, or tr element is started.
8405
    // A caption element's end tag may be ommitted if a colgroup, thead, tfoot, tbody, or tr element is started.
8406
    result = result || this._tag_stack.try_pop('caption', ['table']);
8407
    result = result || this._tag_stack.try_pop('colgroup', ['table']);
8408
    result = result || this._tag_stack.try_pop('tr', ['table', 'thead', 'tbody', 'tfoot']);
8409
 
8410
  } else if (parser_token.tag_name === 'th' || parser_token.tag_name === 'td') {
8411
    // 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.
8412
    // 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.
8413
    result = result || this._tag_stack.try_pop('td', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8414
    result = result || this._tag_stack.try_pop('th', ['table', 'thead', 'tbody', 'tfoot', 'tr']);
8415
  }
8416
 
8417
  // Start element omission not handled currently
8418
  // 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.
8419
  // 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.)
8420
  // 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.)
8421
 
8422
  // Fix up the parent of the parser token
8423
  parser_token.parent = this._tag_stack.get_parser_token();
8424
 
8425
  return result;
8426
};
8427
 
8428
module.exports.Beautifier = Beautifier;
8429
 
8430
 
8431
/***/ }),
8432
/* 20 */
8433
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
8434
 
8435
/*jshint node:true */
8436
/*
8437
 
8438
  The MIT License (MIT)
8439
 
8440
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
8441
 
8442
  Permission is hereby granted, free of charge, to any person
8443
  obtaining a copy of this software and associated documentation files
8444
  (the "Software"), to deal in the Software without restriction,
8445
  including without limitation the rights to use, copy, modify, merge,
8446
  publish, distribute, sublicense, and/or sell copies of the Software,
8447
  and to permit persons to whom the Software is furnished to do so,
8448
  subject to the following conditions:
8449
 
8450
  The above copyright notice and this permission notice shall be
8451
  included in all copies or substantial portions of the Software.
8452
 
8453
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
8454
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8455
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
8456
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
8457
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
8458
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8459
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8460
  SOFTWARE.
8461
*/
8462
 
8463
 
8464
 
8465
var BaseOptions = (__webpack_require__(6).Options);
8466
 
8467
function Options(options) {
8468
  BaseOptions.call(this, options, 'html');
8469
  if (this.templating.length === 1 && this.templating[0] === 'auto') {
8470
    this.templating = ['django', 'erb', 'handlebars', 'php'];
8471
  }
8472
 
8473
  this.indent_inner_html = this._get_boolean('indent_inner_html');
8474
  this.indent_body_inner_html = this._get_boolean('indent_body_inner_html', true);
8475
  this.indent_head_inner_html = this._get_boolean('indent_head_inner_html', true);
8476
 
8477
  this.indent_handlebars = this._get_boolean('indent_handlebars', true);
8478
  this.wrap_attributes = this._get_selection('wrap_attributes',
8479
    ['auto', 'force', 'force-aligned', 'force-expand-multiline', 'aligned-multiple', 'preserve', 'preserve-aligned']);
8480
  this.wrap_attributes_min_attrs = this._get_number('wrap_attributes_min_attrs', 2);
8481
  this.wrap_attributes_indent_size = this._get_number('wrap_attributes_indent_size', this.indent_size);
8482
  this.extra_liners = this._get_array('extra_liners', ['head', 'body', '/html']);
8483
 
8484
  // Block vs inline elements
8485
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Block-level_elements
8486
  // https://developer.mozilla.org/en-US/docs/Web/HTML/Inline_elements
8487
  // https://www.w3.org/TR/html5/dom.html#phrasing-content
8488
  this.inline = this._get_array('inline', [
8489
    'a', 'abbr', 'area', 'audio', 'b', 'bdi', 'bdo', 'br', 'button', 'canvas', 'cite',
8490
    'code', 'data', 'datalist', 'del', 'dfn', 'em', 'embed', 'i', 'iframe', 'img',
8491
    'input', 'ins', 'kbd', 'keygen', 'label', 'map', 'mark', 'math', 'meter', 'noscript',
8492
    'object', 'output', 'progress', 'q', 'ruby', 's', 'samp', /* 'script', */ 'select', 'small',
8493
    'span', 'strong', 'sub', 'sup', 'svg', 'template', 'textarea', 'time', 'u', 'var',
8494
    'video', 'wbr', 'text',
8495
    // obsolete inline tags
8496
    'acronym', 'big', 'strike', 'tt'
8497
  ]);
8498
  this.inline_custom_elements = this._get_boolean('inline_custom_elements', true);
8499
  this.void_elements = this._get_array('void_elements', [
8500
    // HTLM void elements - aka self-closing tags - aka singletons
8501
    // https://www.w3.org/html/wg/drafts/html/master/syntax.html#void-elements
8502
    'area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
8503
    'link', 'menuitem', 'meta', 'param', 'source', 'track', 'wbr',
8504
    // NOTE: Optional tags are too complex for a simple list
8505
    // they are hard coded in _do_optional_end_element
8506
 
8507
    // Doctype and xml elements
8508
    '!doctype', '?xml',
8509
 
8510
    // obsolete tags
8511
    // basefont: https://www.computerhope.com/jargon/h/html-basefont-tag.htm
8512
    // isndex: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/isindex
8513
    'basefont', 'isindex'
8514
  ]);
8515
  this.unformatted = this._get_array('unformatted', []);
8516
  this.content_unformatted = this._get_array('content_unformatted', [
8517
    'pre', 'textarea'
8518
  ]);
8519
  this.unformatted_content_delimiter = this._get_characters('unformatted_content_delimiter');
8520
  this.indent_scripts = this._get_selection('indent_scripts', ['normal', 'keep', 'separate']);
8521
 
8522
}
8523
Options.prototype = new BaseOptions();
8524
 
8525
 
8526
 
8527
module.exports.Options = Options;
8528
 
8529
 
8530
/***/ }),
8531
/* 21 */
8532
/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
8533
 
8534
/*jshint node:true */
8535
/*
8536
 
8537
  The MIT License (MIT)
8538
 
8539
  Copyright (c) 2007-2018 Einar Lielmanis, Liam Newman, and contributors.
8540
 
8541
  Permission is hereby granted, free of charge, to any person
8542
  obtaining a copy of this software and associated documentation files
8543
  (the "Software"), to deal in the Software without restriction,
8544
  including without limitation the rights to use, copy, modify, merge,
8545
  publish, distribute, sublicense, and/or sell copies of the Software,
8546
  and to permit persons to whom the Software is furnished to do so,
8547
  subject to the following conditions:
8548
 
8549
  The above copyright notice and this permission notice shall be
8550
  included in all copies or substantial portions of the Software.
8551
 
8552
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
8553
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8554
  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
8555
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
8556
  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
8557
  ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
8558
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
8559
  SOFTWARE.
8560
*/
8561
 
8562
 
8563
 
8564
var BaseTokenizer = (__webpack_require__(9).Tokenizer);
8565
var BASETOKEN = (__webpack_require__(9).TOKEN);
8566
var Directives = (__webpack_require__(13).Directives);
8567
var TemplatablePattern = (__webpack_require__(14).TemplatablePattern);
8568
var Pattern = (__webpack_require__(12).Pattern);
8569
 
8570
var TOKEN = {
8571
  TAG_OPEN: 'TK_TAG_OPEN',
8572
  TAG_CLOSE: 'TK_TAG_CLOSE',
8573
  CONTROL_FLOW_OPEN: 'TK_CONTROL_FLOW_OPEN',
8574
  CONTROL_FLOW_CLOSE: 'TK_CONTROL_FLOW_CLOSE',
8575
  ATTRIBUTE: 'TK_ATTRIBUTE',
8576
  EQUALS: 'TK_EQUALS',
8577
  VALUE: 'TK_VALUE',
8578
  COMMENT: 'TK_COMMENT',
8579
  TEXT: 'TK_TEXT',
8580
  UNKNOWN: 'TK_UNKNOWN',
8581
  START: BASETOKEN.START,
8582
  RAW: BASETOKEN.RAW,
8583
  EOF: BASETOKEN.EOF
8584
};
8585
 
8586
var directives_core = new Directives(/<\!--/, /-->/);
8587
 
8588
var Tokenizer = function(input_string, options) {
8589
  BaseTokenizer.call(this, input_string, options);
8590
  this._current_tag_name = '';
8591
 
8592
  // Words end at whitespace or when a tag starts
8593
  // if we are indenting handlebars, they are considered tags
8594
  var templatable_reader = new TemplatablePattern(this._input).read_options(this._options);
8595
  var pattern_reader = new Pattern(this._input);
8596
 
8597
  this.__patterns = {
8598
    word: templatable_reader.until(/[\n\r\t <]/),
8599
    word_control_flow_close_excluded: templatable_reader.until(/[\n\r\t <}]/),
8600
    single_quote: templatable_reader.until_after(/'/),
8601
    double_quote: templatable_reader.until_after(/"/),
8602
    attribute: templatable_reader.until(/[\n\r\t =>]|\/>/),
8603
    element_name: templatable_reader.until(/[\n\r\t >\/]/),
8604
 
8605
    angular_control_flow_start: pattern_reader.matching(/\@[a-zA-Z]+[^({]*[({]/),
8606
    handlebars_comment: pattern_reader.starting_with(/{{!--/).until_after(/--}}/),
8607
    handlebars: pattern_reader.starting_with(/{{/).until_after(/}}/),
8608
    handlebars_open: pattern_reader.until(/[\n\r\t }]/),
8609
    handlebars_raw_close: pattern_reader.until(/}}/),
8610
    comment: pattern_reader.starting_with(/<!--/).until_after(/-->/),
8611
    cdata: pattern_reader.starting_with(/<!\[CDATA\[/).until_after(/]]>/),
8612
    // https://en.wikipedia.org/wiki/Conditional_comment
8613
    conditional_comment: pattern_reader.starting_with(/<!\[/).until_after(/]>/),
8614
    processing: pattern_reader.starting_with(/<\?/).until_after(/\?>/)
8615
  };
8616
 
8617
  if (this._options.indent_handlebars) {
8618
    this.__patterns.word = this.__patterns.word.exclude('handlebars');
8619
    this.__patterns.word_control_flow_close_excluded = this.__patterns.word_control_flow_close_excluded.exclude('handlebars');
8620
  }
8621
 
8622
  this._unformatted_content_delimiter = null;
8623
 
8624
  if (this._options.unformatted_content_delimiter) {
8625
    var literal_regexp = this._input.get_literal_regexp(this._options.unformatted_content_delimiter);
8626
    this.__patterns.unformatted_content_delimiter =
8627
      pattern_reader.matching(literal_regexp)
8628
      .until_after(literal_regexp);
8629
  }
8630
};
8631
Tokenizer.prototype = new BaseTokenizer();
8632
 
8633
Tokenizer.prototype._is_comment = function(current_token) { // jshint unused:false
8634
  return false; //current_token.type === TOKEN.COMMENT || current_token.type === TOKEN.UNKNOWN;
8635
};
8636
 
8637
Tokenizer.prototype._is_opening = function(current_token) {
8638
  return current_token.type === TOKEN.TAG_OPEN || current_token.type === TOKEN.CONTROL_FLOW_OPEN;
8639
};
8640
 
8641
Tokenizer.prototype._is_closing = function(current_token, open_token) {
8642
  return (current_token.type === TOKEN.TAG_CLOSE &&
8643
    (open_token && (
8644
      ((current_token.text === '>' || current_token.text === '/>') && open_token.text[0] === '<') ||
8645
      (current_token.text === '}}' && open_token.text[0] === '{' && open_token.text[1] === '{')))
8646
  ) || (current_token.type === TOKEN.CONTROL_FLOW_CLOSE &&
8647
    (current_token.text === '}' && open_token.text.endsWith('{')));
8648
};
8649
 
8650
Tokenizer.prototype._reset = function() {
8651
  this._current_tag_name = '';
8652
};
8653
 
8654
Tokenizer.prototype._get_next_token = function(previous_token, open_token) { // jshint unused:false
8655
  var token = null;
8656
  this._readWhitespace();
8657
  var c = this._input.peek();
8658
 
8659
  if (c === null) {
8660
    return this._create_token(TOKEN.EOF, '');
8661
  }
8662
 
8663
  token = token || this._read_open_handlebars(c, open_token);
8664
  token = token || this._read_attribute(c, previous_token, open_token);
8665
  token = token || this._read_close(c, open_token);
8666
  token = token || this._read_control_flows(c, open_token);
8667
  token = token || this._read_raw_content(c, previous_token, open_token);
8668
  token = token || this._read_content_word(c, open_token);
8669
  token = token || this._read_comment_or_cdata(c);
8670
  token = token || this._read_processing(c);
8671
  token = token || this._read_open(c, open_token);
8672
  token = token || this._create_token(TOKEN.UNKNOWN, this._input.next());
8673
 
8674
  return token;
8675
};
8676
 
8677
Tokenizer.prototype._read_comment_or_cdata = function(c) { // jshint unused:false
8678
  var token = null;
8679
  var resulting_string = null;
8680
  var directives = null;
8681
 
8682
  if (c === '<') {
8683
    var peek1 = this._input.peek(1);
8684
    // We treat all comments as literals, even more than preformatted tags
8685
    // we only look for the appropriate closing marker
8686
    if (peek1 === '!') {
8687
      resulting_string = this.__patterns.comment.read();
8688
 
8689
      // only process directive on html comments
8690
      if (resulting_string) {
8691
        directives = directives_core.get_directives(resulting_string);
8692
        if (directives && directives.ignore === 'start') {
8693
          resulting_string += directives_core.readIgnored(this._input);
8694
        }
8695
      } else {
8696
        resulting_string = this.__patterns.cdata.read();
8697
      }
8698
    }
8699
 
8700
    if (resulting_string) {
8701
      token = this._create_token(TOKEN.COMMENT, resulting_string);
8702
      token.directives = directives;
8703
    }
8704
  }
8705
 
8706
  return token;
8707
};
8708
 
8709
Tokenizer.prototype._read_processing = function(c) { // jshint unused:false
8710
  var token = null;
8711
  var resulting_string = null;
8712
  var directives = null;
8713
 
8714
  if (c === '<') {
8715
    var peek1 = this._input.peek(1);
8716
    if (peek1 === '!' || peek1 === '?') {
8717
      resulting_string = this.__patterns.conditional_comment.read();
8718
      resulting_string = resulting_string || this.__patterns.processing.read();
8719
    }
8720
 
8721
    if (resulting_string) {
8722
      token = this._create_token(TOKEN.COMMENT, resulting_string);
8723
      token.directives = directives;
8724
    }
8725
  }
8726
 
8727
  return token;
8728
};
8729
 
8730
Tokenizer.prototype._read_open = function(c, open_token) {
8731
  var resulting_string = null;
8732
  var token = null;
8733
  if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
8734
    if (c === '<') {
8735
 
8736
      resulting_string = this._input.next();
8737
      if (this._input.peek() === '/') {
8738
        resulting_string += this._input.next();
8739
      }
8740
      resulting_string += this.__patterns.element_name.read();
8741
      token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
8742
    }
8743
  }
8744
  return token;
8745
};
8746
 
8747
Tokenizer.prototype._read_open_handlebars = function(c, open_token) {
8748
  var resulting_string = null;
8749
  var token = null;
8750
  if (!open_token || open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
8751
    if (this._options.indent_handlebars && c === '{' && this._input.peek(1) === '{') {
8752
      if (this._input.peek(2) === '!') {
8753
        resulting_string = this.__patterns.handlebars_comment.read();
8754
        resulting_string = resulting_string || this.__patterns.handlebars.read();
8755
        token = this._create_token(TOKEN.COMMENT, resulting_string);
8756
      } else {
8757
        resulting_string = this.__patterns.handlebars_open.read();
8758
        token = this._create_token(TOKEN.TAG_OPEN, resulting_string);
8759
      }
8760
    }
8761
  }
8762
  return token;
8763
};
8764
 
8765
Tokenizer.prototype._read_control_flows = function(c, open_token) {
8766
  var resulting_string = '';
8767
  var token = null;
8768
  // Only check for control flows if angular templating is set AND indenting is set
8769
  if (!this._options.templating.includes('angular') || !this._options.indent_handlebars) {
8770
    return token;
8771
  }
8772
 
8773
  if (c === '@') {
8774
    resulting_string = this.__patterns.angular_control_flow_start.read();
8775
    if (resulting_string === '') {
8776
      return token;
8777
    }
8778
 
8779
    var opening_parentheses_count = resulting_string.endsWith('(') ? 1 : 0;
8780
    var closing_parentheses_count = 0;
8781
    // The opening brace of the control flow is where the number of opening and closing parentheses equal
8782
    // e.g. @if({value: true} !== null) {
8783
    while (!(resulting_string.endsWith('{') && opening_parentheses_count === closing_parentheses_count)) {
8784
      var next_char = this._input.next();
8785
      if (next_char === null) {
8786
        break;
8787
      } else if (next_char === '(') {
8788
        opening_parentheses_count++;
8789
      } else if (next_char === ')') {
8790
        closing_parentheses_count++;
8791
      }
8792
      resulting_string += next_char;
8793
    }
8794
    token = this._create_token(TOKEN.CONTROL_FLOW_OPEN, resulting_string);
8795
  } else if (c === '}' && open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN) {
8796
    resulting_string = this._input.next();
8797
    token = this._create_token(TOKEN.CONTROL_FLOW_CLOSE, resulting_string);
8798
  }
8799
  return token;
8800
};
8801
 
8802
 
8803
Tokenizer.prototype._read_close = function(c, open_token) {
8804
  var resulting_string = null;
8805
  var token = null;
8806
  if (open_token && open_token.type === TOKEN.TAG_OPEN) {
8807
    if (open_token.text[0] === '<' && (c === '>' || (c === '/' && this._input.peek(1) === '>'))) {
8808
      resulting_string = this._input.next();
8809
      if (c === '/') { //  for close tag "/>"
8810
        resulting_string += this._input.next();
8811
      }
8812
      token = this._create_token(TOKEN.TAG_CLOSE, resulting_string);
8813
    } else if (open_token.text[0] === '{' && c === '}' && this._input.peek(1) === '}') {
8814
      this._input.next();
8815
      this._input.next();
8816
      token = this._create_token(TOKEN.TAG_CLOSE, '}}');
8817
    }
8818
  }
8819
 
8820
  return token;
8821
};
8822
 
8823
Tokenizer.prototype._read_attribute = function(c, previous_token, open_token) {
8824
  var token = null;
8825
  var resulting_string = '';
8826
  if (open_token && open_token.text[0] === '<') {
8827
 
8828
    if (c === '=') {
8829
      token = this._create_token(TOKEN.EQUALS, this._input.next());
8830
    } else if (c === '"' || c === "'") {
8831
      var content = this._input.next();
8832
      if (c === '"') {
8833
        content += this.__patterns.double_quote.read();
8834
      } else {
8835
        content += this.__patterns.single_quote.read();
8836
      }
8837
      token = this._create_token(TOKEN.VALUE, content);
8838
    } else {
8839
      resulting_string = this.__patterns.attribute.read();
8840
 
8841
      if (resulting_string) {
8842
        if (previous_token.type === TOKEN.EQUALS) {
8843
          token = this._create_token(TOKEN.VALUE, resulting_string);
8844
        } else {
8845
          token = this._create_token(TOKEN.ATTRIBUTE, resulting_string);
8846
        }
8847
      }
8848
    }
8849
  }
8850
  return token;
8851
};
8852
 
8853
Tokenizer.prototype._is_content_unformatted = function(tag_name) {
8854
  // void_elements have no content and so cannot have unformatted content
8855
  // script and style tags should always be read as unformatted content
8856
  // finally content_unformatted and unformatted element contents are unformatted
8857
  return this._options.void_elements.indexOf(tag_name) === -1 &&
8858
    (this._options.content_unformatted.indexOf(tag_name) !== -1 ||
8859
      this._options.unformatted.indexOf(tag_name) !== -1);
8860
};
8861
 
8862
 
8863
Tokenizer.prototype._read_raw_content = function(c, previous_token, open_token) { // jshint unused:false
8864
  var resulting_string = '';
8865
  if (open_token && open_token.text[0] === '{') {
8866
    resulting_string = this.__patterns.handlebars_raw_close.read();
8867
  } else if (previous_token.type === TOKEN.TAG_CLOSE &&
8868
    previous_token.opened.text[0] === '<' && previous_token.text[0] !== '/') {
8869
    // ^^ empty tag has no content
8870
    var tag_name = previous_token.opened.text.substr(1).toLowerCase();
8871
    if (tag_name === 'script' || tag_name === 'style') {
8872
      // Script and style tags are allowed to have comments wrapping their content
8873
      // or just have regular content.
8874
      var token = this._read_comment_or_cdata(c);
8875
      if (token) {
8876
        token.type = TOKEN.TEXT;
8877
        return token;
8878
      }
8879
      resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
8880
    } else if (this._is_content_unformatted(tag_name)) {
8881
 
8882
      resulting_string = this._input.readUntil(new RegExp('</' + tag_name + '[\\n\\r\\t ]*?>', 'ig'));
8883
    }
8884
  }
8885
 
8886
  if (resulting_string) {
8887
    return this._create_token(TOKEN.TEXT, resulting_string);
8888
  }
8889
 
8890
  return null;
8891
};
8892
 
8893
Tokenizer.prototype._read_content_word = function(c, open_token) {
8894
  var resulting_string = '';
8895
  if (this._options.unformatted_content_delimiter) {
8896
    if (c === this._options.unformatted_content_delimiter[0]) {
8897
      resulting_string = this.__patterns.unformatted_content_delimiter.read();
8898
    }
8899
  }
8900
 
8901
  if (!resulting_string) {
8902
    resulting_string = (open_token && open_token.type === TOKEN.CONTROL_FLOW_OPEN) ? this.__patterns.word_control_flow_close_excluded.read() : this.__patterns.word.read();
8903
  }
8904
  if (resulting_string) {
8905
    return this._create_token(TOKEN.TEXT, resulting_string);
8906
  }
8907
};
8908
 
8909
module.exports.Tokenizer = Tokenizer;
8910
module.exports.TOKEN = TOKEN;
8911
 
8912
 
8913
/***/ })
8914
/******/ 	]);
8915
/************************************************************************/
8916
/******/ 	// The module cache
8917
/******/ 	var __webpack_module_cache__ = {};
8918
/******/
8919
/******/ 	// The require function
8920
/******/ 	function __webpack_require__(moduleId) {
8921
/******/ 		// Check if module is in cache
8922
/******/ 		var cachedModule = __webpack_module_cache__[moduleId];
8923
/******/ 		if (cachedModule !== undefined) {
8924
/******/ 			return cachedModule.exports;
8925
/******/ 		}
8926
/******/ 		// Create a new module (and put it into the cache)
8927
/******/ 		var module = __webpack_module_cache__[moduleId] = {
8928
/******/ 			// no module.id needed
8929
/******/ 			// no module.loaded needed
8930
/******/ 			exports: {}
8931
/******/ 		};
8932
/******/
8933
/******/ 		// Execute the module function
8934
/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
8935
/******/
8936
/******/ 		// Return the exports of the module
8937
/******/ 		return module.exports;
8938
/******/ 	}
8939
/******/
8940
/************************************************************************/
8941
/******/
8942
/******/ 	// startup
8943
/******/ 	// Load entry module and return exports
8944
/******/ 	// This entry module is referenced by other modules so it can't be inlined
8945
/******/ 	var __webpack_exports__ = __webpack_require__(18);
8946
/******/ 	legacy_beautify_html = __webpack_exports__;
8947
/******/
8948
/******/ })()
8949
;
8950
var style_html = legacy_beautify_html;
8951
/* Footer */
8952
if (typeof define === "function" && define.amd) {
8953
    // Add support for AMD ( https://github.com/amdjs/amdjs-api/wiki/AMD#defineamd-property- )
8954
    define(["require", "./beautify", "./beautify-css"], function(requireamd) {
8955
        var js_beautify = requireamd("./beautify");
8956
        var css_beautify = requireamd("./beautify-css");
8957
 
8958
        return {
8959
            html_beautify: function(html_source, options) {
8960
                return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
8961
            }
8962
        };
8963
    });
8964
} else if (typeof exports !== "undefined") {
8965
    // Add support for CommonJS. Just put this file somewhere on your require.paths
8966
    // and you will be able to `var html_beautify = require("beautify").html_beautify`.
8967
    var js_beautify = require('./beautify.js');
8968
    var css_beautify = require('./beautify-css.js');
8969
 
8970
    exports.html_beautify = function(html_source, options) {
8971
        return style_html(html_source, options, js_beautify.js_beautify, css_beautify.css_beautify);
8972
    };
8973
} else if (typeof window !== "undefined") {
8974
    // If we're running a web page and don't have either of the above, add our one global
8975
    window.html_beautify = function(html_source, options) {
8976
        return style_html(html_source, options, window.js_beautify, window.css_beautify);
8977
    };
8978
} else if (typeof global !== "undefined") {
8979
    // If we don't even have window, try global.
8980
    global.html_beautify = function(html_source, options) {
8981
        return style_html(html_source, options, global.js_beautify, global.css_beautify);
8982
    };
8983
}
8984
 
8985
}());
8986
 
8987
 
8988
}, '@VERSION@');