├── CHANGELOG.md ├── LICENSE ├── README.md ├── SourceMap ├── LICENSE ├── source-map.js └── source-map │ ├── array-set.js │ ├── base64-vlq.js │ ├── base64.js │ ├── binary-search.js │ ├── source-map-consumer.js │ ├── source-map-generator.js │ ├── source-node.js │ └── util.js ├── UglifyJS ├── LICENSE └── uglifyjs.js ├── main.js ├── package.json ├── styles ├── images │ └── jscompiler.svg └── main.css └── templates └── .jscompiler.json /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ## [2.1.1] - 2016-11-27 6 | ### Fixed 7 | - Auto compile on save now compiles only current file, even if options exists. 8 | - Fixes for quick option generation; now the only required field is "inputs", inferring all the other fields with their default values. 9 | 10 | ## [2.1.0] - 2015-07-08 11 | ### Added 12 | - Optional auto compile feature. 13 | 14 | ## [2.0.1] - 2015-05-28 15 | ### Fixed 16 | - Fixed critical bug when compiling without options, which caused mangling and map generation not being considered by default. 17 | 18 | ## [2.0.0] - 2015-03-09 19 | ### Fixed 20 | - Fixed last critical bugs (I hope). Official v2.0.0 release. 21 | 22 | ## [1.9.9] - 2015-03-08 23 | ### Added 24 | - Support native brackets preferences, which are now the default (See README for more details). 25 | - Full code cleanup and optimization. 26 | 27 | ## [1.9.6][unreleased] 28 | ### Added 29 | - Optional precompile, for special javascript cases. 30 | 31 | ## [1.9.5] - 2015-03-05 32 | ### Added 33 | - New icon, proposed by mrmckeb, more intuitive and unique, with different states. 34 | 35 | ## Fixed 36 | - Source map comment link was pointing to the wrong place if the generated result is not on the same folder. 37 | 38 | ## [1.9.4] - 2015-02-24 39 | ### Added 40 | - Multiple outputs can be generated at once. 41 | 42 | ### Changed 43 | - Default template now generates the base code for multiple outputs support. 44 | 45 | ## [1.9.3][unreleased] 46 | ### Fixed 47 | - Fixed source map comment code on generated code. 48 | 49 | ## [1.9.2] - 2014-11-17 50 | ### Added 51 | - Optional map. 52 | 53 | ### Fixed 54 | - Fixed source map generator (First public release). 55 | 56 | ## [1.9.1][unreleased] 57 | ### Added 58 | - Optional mangle. 59 | 60 | ## [1.9.0] - 2014-11-12 61 | (Begins roadmap to 2.0.0) 62 | 63 | ### Added 64 | - Customize compilation with options. 65 | - Editable default options template. 66 | 67 | ## [1.2.0] - 2014-11-04 68 | ### Added 69 | - Added progress panel to track compilation progress. 70 | 71 | ## [1.1.0][unreleased] 72 | ### Added 73 | - Added source map generator (Unreleased due crashing error). 74 | 75 | ## [1.0.2] - 2014-07-10 76 | ### Fixed 77 | - Fixed potential error handling on file write. 78 | 79 | ## [1.0.1] - 2014-07-05 80 | ### Added 81 | - Initial commit. 82 | 83 | ### Changed 84 | - Moved Uglify.js to an external file. 85 | 86 | ## [1.0.0] - 2014-07-05 87 | ### Added 88 | - First public release. 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Karl Tayfer 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # JSCompiler2 for [Brackets](https://github.com/adobe/brackets) 2 | 3 | JSCompiler2 is a tool for [Brackets](https://github.com/adobe/brackets) that allows you to compress and mangle your JavaScript code into one minified file, powered by [UglifyJS2](https://github.com/mishoo/UglifyJS2) 4 | 5 | ## Features 6 | 7 | - Doesn't require previous configurations for quick first use. 8 | - Customize advanced compilation options. 9 | - Compile multiple javascripts into one output. 10 | - Generate multiple outputs at once. 11 | - Works even offline. 12 | 13 | ## Usage 14 | 15 | Simply press the "Compress JavaScript" button on the sidebar, or go to `File > Compress JavaScript`, and your code will be compressed into a `{filename}.min.js` file. 16 | 17 | Optionally, you can toggle "Compress JavaScript on Save" by going to `File > Compress JavaScript on Save`, and your code will be compressed automatically. This options is off by default. 18 | 19 | ### The custom options file 20 | 21 | You can go to `File > Compress JavaScript: Options` to open your custom options. If you have no custom options yet, you will be asked to choose one of this types of custom options: 22 | 23 | - **Project**: Bracket's default. This will add your options to the default `.brackets.json` file along with all the other options shared inside your current project. Your options will be inside an object with the indentifier `jscompiler`. 24 | 25 | - **Portable**: This will add your options to a `.jscompiler.json` file inside the current directory, which can be compatible with other compilers that use the same standard, and allows you to create multiple compilable projects inside your main project. On contrast, the current open file on your editor must be inside the same directory of the options file at the moment of compiling, or it will be ignored. 26 | 27 | When the compilation starts, JSCompiler will give priority to any `.jscompiler.json` in the current folder, as this option will allow you to have custom sub-projects inside your main project. Then, it will search for any global options in the current project inside `.brackets.json`. If no option is found anywhere, it will attempt to compile then the current file, if it is a Javascript file. 28 | 29 | ### Custom options 30 | 31 | In your options file, you can customize next values: 32 | 33 | - **Inputs**: An array of javascript files to be compressed into the minified file. 34 | - **Output**: The name of the resulting minified file. 35 | - **GenerateMap**: A boolean value. If this is false, the source map for the code won't be generated. 36 | - **Mangle**: A boolean value. If this is false, the code won't be mangled. 37 | - **Isolate**: A boolean value. If this is true, the resulting code will be isolated so it won't affect or be affected by other scripts. 38 | - **Precompile**: A boolean value. If this is true, the resulting code will be precompiled before it is parsed. This option is hidden by default, and should be used only if your code really requires it, as the resulting source map won't be able to point to the original source files. 39 | 40 | If the isolate option is true, the resulting code will be wrapped with the next code: 41 | 42 | ```javascript 43 | (function(window, undefined){ 44 | // Your compiled code 45 | }(window)); 46 | ``` 47 | 48 | You can create multiple outputs by adding more JSON objects to the main **outputs** array. 49 | 50 | Also, you can customize the default template for new projects at `File > Compress JavaScript: Options template`. Careful! This is only for advanced users. Updates will restore the template to prevent unexpected crashes. 51 | 52 | ## Special thanks 53 | 54 | To Steffen Bruchmann and Peter Flynn, who helped me a lot on my first steps with brackets extension development. 55 | 56 | Also to miladd3, elegos, mrmckeb, kevinmerckx and bbak for their support and ideas through GitHub. 57 | 58 | To mrmckeb for the new compiler icon. 59 | 60 | And to randdusing and henrylavoo for the auto-compile on save feature. 61 | -------------------------------------------------------------------------------- /SourceMap/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Copyright (c) 2009-2011, Mozilla Foundation and contributors 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | * Neither the names of the Mozilla Foundation nor the names of project 16 | contributors may be used to endorse or promote products derived from this 17 | software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /SourceMap/source-map.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2009-2011 Mozilla Foundation and contributors 3 | * Licensed under the New BSD license. See LICENSE.txt or: 4 | * http://opensource.org/licenses/BSD-3-Clause 5 | */ 6 | define(function (require, exports, module) { 7 | exports.SourceMapGenerator = require('./source-map/source-map-generator').SourceMapGenerator; 8 | exports.SourceMapConsumer = require('./source-map/source-map-consumer').SourceMapConsumer; 9 | exports.SourceNode = require('./source-map/source-node').SourceNode; 10 | }); -------------------------------------------------------------------------------- /SourceMap/source-map/array-set.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | var util = require('./util'); 13 | 14 | /** 15 | * A data structure which is a combination of an array and a set. Adding a new 16 | * member is O(1), testing for membership is O(1), and finding the index of an 17 | * element is O(1). Removing elements from the set is not supported. Only 18 | * strings are supported for membership. 19 | */ 20 | function ArraySet() { 21 | this._array = []; 22 | this._set = {}; 23 | } 24 | 25 | /** 26 | * Static method for creating ArraySet instances from an existing array. 27 | */ 28 | ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { 29 | var set = new ArraySet(); 30 | for (var i = 0, len = aArray.length; i < len; i++) { 31 | set.add(aArray[i], aAllowDuplicates); 32 | } 33 | return set; 34 | }; 35 | 36 | /** 37 | * Add the given string to this set. 38 | * 39 | * @param String aStr 40 | */ 41 | ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { 42 | var isDuplicate = this.has(aStr); 43 | var idx = this._array.length; 44 | if (!isDuplicate || aAllowDuplicates) { 45 | this._array.push(aStr); 46 | } 47 | if (!isDuplicate) { 48 | this._set[util.toSetString(aStr)] = idx; 49 | } 50 | }; 51 | 52 | /** 53 | * Is the given string a member of this set? 54 | * 55 | * @param String aStr 56 | */ 57 | ArraySet.prototype.has = function ArraySet_has(aStr) { 58 | return Object.prototype.hasOwnProperty.call(this._set, 59 | util.toSetString(aStr)); 60 | }; 61 | 62 | /** 63 | * What is the index of the given string in the array? 64 | * 65 | * @param String aStr 66 | */ 67 | ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { 68 | if (this.has(aStr)) { 69 | return this._set[util.toSetString(aStr)]; 70 | } 71 | throw new Error('"' + aStr + '" is not in the set.'); 72 | }; 73 | 74 | /** 75 | * What is the element at the given index? 76 | * 77 | * @param Number aIdx 78 | */ 79 | ArraySet.prototype.at = function ArraySet_at(aIdx) { 80 | if (aIdx >= 0 && aIdx < this._array.length) { 81 | return this._array[aIdx]; 82 | } 83 | throw new Error('No element indexed by ' + aIdx); 84 | }; 85 | 86 | /** 87 | * Returns the array representation of this set (which has the proper indices 88 | * indicated by indexOf). Note that this is a copy of the internal array used 89 | * for storing the members so that no one can mess with internal state. 90 | */ 91 | ArraySet.prototype.toArray = function ArraySet_toArray() { 92 | return this._array.slice(); 93 | }; 94 | 95 | exports.ArraySet = ArraySet; 96 | 97 | }); 98 | -------------------------------------------------------------------------------- /SourceMap/source-map/base64-vlq.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | * 7 | * Based on the Base 64 VLQ implementation in Closure Compiler: 8 | * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java 9 | * 10 | * Copyright 2011 The Closure Compiler Authors. All rights reserved. 11 | * Redistribution and use in source and binary forms, with or without 12 | * modification, are permitted provided that the following conditions are 13 | * met: 14 | * 15 | * * Redistributions of source code must retain the above copyright 16 | * notice, this list of conditions and the following disclaimer. 17 | * * Redistributions in binary form must reproduce the above 18 | * copyright notice, this list of conditions and the following 19 | * disclaimer in the documentation and/or other materials provided 20 | * with the distribution. 21 | * * Neither the name of Google Inc. nor the names of its 22 | * contributors may be used to endorse or promote products derived 23 | * from this software without specific prior written permission. 24 | * 25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 26 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 27 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 28 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 29 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 30 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 31 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 32 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 33 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 34 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 35 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 36 | */ 37 | if (typeof define !== 'function') { 38 | var define = require('amdefine')(module, require); 39 | } 40 | define(function (require, exports, module) { 41 | 42 | var base64 = require('./base64'); 43 | 44 | // A single base 64 digit can contain 6 bits of data. For the base 64 variable 45 | // length quantities we use in the source map spec, the first bit is the sign, 46 | // the next four bits are the actual value, and the 6th bit is the 47 | // continuation bit. The continuation bit tells us whether there are more 48 | // digits in this value following this digit. 49 | // 50 | // Continuation 51 | // | Sign 52 | // | | 53 | // V V 54 | // 101011 55 | 56 | var VLQ_BASE_SHIFT = 5; 57 | 58 | // binary: 100000 59 | var VLQ_BASE = 1 << VLQ_BASE_SHIFT; 60 | 61 | // binary: 011111 62 | var VLQ_BASE_MASK = VLQ_BASE - 1; 63 | 64 | // binary: 100000 65 | var VLQ_CONTINUATION_BIT = VLQ_BASE; 66 | 67 | /** 68 | * Converts from a two-complement value to a value where the sign bit is 69 | * is placed in the least significant bit. For example, as decimals: 70 | * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) 71 | * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) 72 | */ 73 | function toVLQSigned(aValue) { 74 | return aValue < 0 75 | ? ((-aValue) << 1) + 1 76 | : (aValue << 1) + 0; 77 | } 78 | 79 | /** 80 | * Converts to a two-complement value from a value where the sign bit is 81 | * is placed in the least significant bit. For example, as decimals: 82 | * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 83 | * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 84 | */ 85 | function fromVLQSigned(aValue) { 86 | var isNegative = (aValue & 1) === 1; 87 | var shifted = aValue >> 1; 88 | return isNegative 89 | ? -shifted 90 | : shifted; 91 | } 92 | 93 | /** 94 | * Returns the base 64 VLQ encoded value. 95 | */ 96 | exports.encode = function base64VLQ_encode(aValue) { 97 | var encoded = ""; 98 | var digit; 99 | 100 | var vlq = toVLQSigned(aValue); 101 | 102 | do { 103 | digit = vlq & VLQ_BASE_MASK; 104 | vlq >>>= VLQ_BASE_SHIFT; 105 | if (vlq > 0) { 106 | // There are still more digits in this value, so we must make sure the 107 | // continuation bit is marked. 108 | digit |= VLQ_CONTINUATION_BIT; 109 | } 110 | encoded += base64.encode(digit); 111 | } while (vlq > 0); 112 | 113 | return encoded; 114 | }; 115 | 116 | /** 117 | * Decodes the next base 64 VLQ value from the given string and returns the 118 | * value and the rest of the string via the out parameter. 119 | */ 120 | exports.decode = function base64VLQ_decode(aStr, aOutParam) { 121 | var i = 0; 122 | var strLen = aStr.length; 123 | var result = 0; 124 | var shift = 0; 125 | var continuation, digit; 126 | 127 | do { 128 | if (i >= strLen) { 129 | throw new Error("Expected more digits in base 64 VLQ value."); 130 | } 131 | digit = base64.decode(aStr.charAt(i++)); 132 | continuation = !!(digit & VLQ_CONTINUATION_BIT); 133 | digit &= VLQ_BASE_MASK; 134 | result = result + (digit << shift); 135 | shift += VLQ_BASE_SHIFT; 136 | } while (continuation); 137 | 138 | aOutParam.value = fromVLQSigned(result); 139 | aOutParam.rest = aStr.slice(i); 140 | }; 141 | 142 | }); 143 | -------------------------------------------------------------------------------- /SourceMap/source-map/base64.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | var charToIntMap = {}; 13 | var intToCharMap = {}; 14 | 15 | 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' 16 | .split('') 17 | .forEach(function (ch, index) { 18 | charToIntMap[ch] = index; 19 | intToCharMap[index] = ch; 20 | }); 21 | 22 | /** 23 | * Encode an integer in the range of 0 to 63 to a single base 64 digit. 24 | */ 25 | exports.encode = function base64_encode(aNumber) { 26 | if (aNumber in intToCharMap) { 27 | return intToCharMap[aNumber]; 28 | } 29 | throw new TypeError("Must be between 0 and 63: " + aNumber); 30 | }; 31 | 32 | /** 33 | * Decode a single base 64 digit to an integer. 34 | */ 35 | exports.decode = function base64_decode(aChar) { 36 | if (aChar in charToIntMap) { 37 | return charToIntMap[aChar]; 38 | } 39 | throw new TypeError("Not a valid base 64 digit: " + aChar); 40 | }; 41 | 42 | }); 43 | -------------------------------------------------------------------------------- /SourceMap/source-map/binary-search.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | /** 13 | * Recursive implementation of binary search. 14 | * 15 | * @param aLow Indices here and lower do not contain the needle. 16 | * @param aHigh Indices here and higher do not contain the needle. 17 | * @param aNeedle The element being searched for. 18 | * @param aHaystack The non-empty array being searched. 19 | * @param aCompare Function which takes two elements and returns -1, 0, or 1. 20 | */ 21 | function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { 22 | // This function terminates when one of the following is true: 23 | // 24 | // 1. We find the exact element we are looking for. 25 | // 26 | // 2. We did not find the exact element, but we can return the next 27 | // closest element that is less than that element. 28 | // 29 | // 3. We did not find the exact element, and there is no next-closest 30 | // element which is less than the one we are searching for, so we 31 | // return null. 32 | var mid = Math.floor((aHigh - aLow) / 2) + aLow; 33 | var cmp = aCompare(aNeedle, aHaystack[mid], true); 34 | if (cmp === 0) { 35 | // Found the element we are looking for. 36 | return aHaystack[mid]; 37 | } 38 | else if (cmp > 0) { 39 | // aHaystack[mid] is greater than our needle. 40 | if (aHigh - mid > 1) { 41 | // The element is in the upper half. 42 | return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); 43 | } 44 | // We did not find an exact match, return the next closest one 45 | // (termination case 2). 46 | return aHaystack[mid]; 47 | } 48 | else { 49 | // aHaystack[mid] is less than our needle. 50 | if (mid - aLow > 1) { 51 | // The element is in the lower half. 52 | return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); 53 | } 54 | // The exact needle element was not found in this haystack. Determine if 55 | // we are in termination case (2) or (3) and return the appropriate thing. 56 | return aLow < 0 57 | ? null 58 | : aHaystack[aLow]; 59 | } 60 | } 61 | 62 | /** 63 | * This is an implementation of binary search which will always try and return 64 | * the next lowest value checked if there is no exact hit. This is because 65 | * mappings between original and generated line/col pairs are single points, 66 | * and there is an implicit region between each of them, so a miss just means 67 | * that you aren't on the very start of a region. 68 | * 69 | * @param aNeedle The element you are looking for. 70 | * @param aHaystack The array that is being searched. 71 | * @param aCompare A function which takes the needle and an element in the 72 | * array and returns -1, 0, or 1 depending on whether the needle is less 73 | * than, equal to, or greater than the element, respectively. 74 | */ 75 | exports.search = function search(aNeedle, aHaystack, aCompare) { 76 | return aHaystack.length > 0 77 | ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) 78 | : null; 79 | }; 80 | 81 | }); 82 | -------------------------------------------------------------------------------- /SourceMap/source-map/source-map-consumer.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | var util = require('./util'); 13 | var binarySearch = require('./binary-search'); 14 | var ArraySet = require('./array-set').ArraySet; 15 | var base64VLQ = require('./base64-vlq'); 16 | 17 | /** 18 | * A SourceMapConsumer instance represents a parsed source map which we can 19 | * query for information about the original file positions by giving it a file 20 | * position in the generated source. 21 | * 22 | * The only parameter is the raw source map (either as a JSON string, or 23 | * already parsed to an object). According to the spec, source maps have the 24 | * following attributes: 25 | * 26 | * - version: Which version of the source map spec this map is following. 27 | * - sources: An array of URLs to the original source files. 28 | * - names: An array of identifiers which can be referrenced by individual mappings. 29 | * - sourceRoot: Optional. The URL root from which all sources are relative. 30 | * - sourcesContent: Optional. An array of contents of the original source files. 31 | * - mappings: A string of base64 VLQs which contain the actual mappings. 32 | * - file: Optional. The generated file this source map is associated with. 33 | * 34 | * Here is an example source map, taken from the source map spec[0]: 35 | * 36 | * { 37 | * version : 3, 38 | * file: "out.js", 39 | * sourceRoot : "", 40 | * sources: ["foo.js", "bar.js"], 41 | * names: ["src", "maps", "are", "fun"], 42 | * mappings: "AA,AB;;ABCDE;" 43 | * } 44 | * 45 | * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# 46 | */ 47 | function SourceMapConsumer(aSourceMap) { 48 | var sourceMap = aSourceMap; 49 | if (typeof aSourceMap === 'string') { 50 | sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); 51 | } 52 | 53 | var version = util.getArg(sourceMap, 'version'); 54 | var sources = util.getArg(sourceMap, 'sources'); 55 | // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which 56 | // requires the array) to play nice here. 57 | var names = util.getArg(sourceMap, 'names', []); 58 | var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); 59 | var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); 60 | var mappings = util.getArg(sourceMap, 'mappings'); 61 | var file = util.getArg(sourceMap, 'file', null); 62 | 63 | // Once again, Sass deviates from the spec and supplies the version as a 64 | // string rather than a number, so we use loose equality checking here. 65 | if (version != this._version) { 66 | throw new Error('Unsupported version: ' + version); 67 | } 68 | 69 | // Pass `true` below to allow duplicate names and sources. While source maps 70 | // are intended to be compressed and deduplicated, the TypeScript compiler 71 | // sometimes generates source maps with duplicates in them. See Github issue 72 | // #72 and bugzil.la/889492. 73 | this._names = ArraySet.fromArray(names, true); 74 | this._sources = ArraySet.fromArray(sources, true); 75 | 76 | this.sourceRoot = sourceRoot; 77 | this.sourcesContent = sourcesContent; 78 | this._mappings = mappings; 79 | this.file = file; 80 | } 81 | 82 | /** 83 | * Create a SourceMapConsumer from a SourceMapGenerator. 84 | * 85 | * @param SourceMapGenerator aSourceMap 86 | * The source map that will be consumed. 87 | * @returns SourceMapConsumer 88 | */ 89 | SourceMapConsumer.fromSourceMap = 90 | function SourceMapConsumer_fromSourceMap(aSourceMap) { 91 | var smc = Object.create(SourceMapConsumer.prototype); 92 | 93 | smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); 94 | smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); 95 | smc.sourceRoot = aSourceMap._sourceRoot; 96 | smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), 97 | smc.sourceRoot); 98 | smc.file = aSourceMap._file; 99 | 100 | smc.__generatedMappings = aSourceMap._mappings.slice() 101 | .sort(util.compareByGeneratedPositions); 102 | smc.__originalMappings = aSourceMap._mappings.slice() 103 | .sort(util.compareByOriginalPositions); 104 | 105 | return smc; 106 | }; 107 | 108 | /** 109 | * The version of the source mapping spec that we are consuming. 110 | */ 111 | SourceMapConsumer.prototype._version = 3; 112 | 113 | /** 114 | * The list of original sources. 115 | */ 116 | Object.defineProperty(SourceMapConsumer.prototype, 'sources', { 117 | get: function () { 118 | return this._sources.toArray().map(function (s) { 119 | return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s; 120 | }, this); 121 | } 122 | }); 123 | 124 | // `__generatedMappings` and `__originalMappings` are arrays that hold the 125 | // parsed mapping coordinates from the source map's "mappings" attribute. They 126 | // are lazily instantiated, accessed via the `_generatedMappings` and 127 | // `_originalMappings` getters respectively, and we only parse the mappings 128 | // and create these arrays once queried for a source location. We jump through 129 | // these hoops because there can be many thousands of mappings, and parsing 130 | // them is expensive, so we only want to do it if we must. 131 | // 132 | // Each object in the arrays is of the form: 133 | // 134 | // { 135 | // generatedLine: The line number in the generated code, 136 | // generatedColumn: The column number in the generated code, 137 | // source: The path to the original source file that generated this 138 | // chunk of code, 139 | // originalLine: The line number in the original source that 140 | // corresponds to this chunk of generated code, 141 | // originalColumn: The column number in the original source that 142 | // corresponds to this chunk of generated code, 143 | // name: The name of the original symbol which generated this chunk of 144 | // code. 145 | // } 146 | // 147 | // All properties except for `generatedLine` and `generatedColumn` can be 148 | // `null`. 149 | // 150 | // `_generatedMappings` is ordered by the generated positions. 151 | // 152 | // `_originalMappings` is ordered by the original positions. 153 | 154 | SourceMapConsumer.prototype.__generatedMappings = null; 155 | Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { 156 | get: function () { 157 | if (!this.__generatedMappings) { 158 | this.__generatedMappings = []; 159 | this.__originalMappings = []; 160 | this._parseMappings(this._mappings, this.sourceRoot); 161 | } 162 | 163 | return this.__generatedMappings; 164 | } 165 | }); 166 | 167 | SourceMapConsumer.prototype.__originalMappings = null; 168 | Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { 169 | get: function () { 170 | if (!this.__originalMappings) { 171 | this.__generatedMappings = []; 172 | this.__originalMappings = []; 173 | this._parseMappings(this._mappings, this.sourceRoot); 174 | } 175 | 176 | return this.__originalMappings; 177 | } 178 | }); 179 | 180 | SourceMapConsumer.prototype._nextCharIsMappingSeparator = 181 | function SourceMapConsumer_nextCharIsMappingSeparator(aStr) { 182 | var c = aStr.charAt(0); 183 | return c === ";" || c === ","; 184 | }; 185 | 186 | /** 187 | * Parse the mappings in a string in to a data structure which we can easily 188 | * query (the ordered arrays in the `this.__generatedMappings` and 189 | * `this.__originalMappings` properties). 190 | */ 191 | SourceMapConsumer.prototype._parseMappings = 192 | function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { 193 | var generatedLine = 1; 194 | var previousGeneratedColumn = 0; 195 | var previousOriginalLine = 0; 196 | var previousOriginalColumn = 0; 197 | var previousSource = 0; 198 | var previousName = 0; 199 | var str = aStr; 200 | var temp = {}; 201 | var mapping; 202 | 203 | while (str.length > 0) { 204 | if (str.charAt(0) === ';') { 205 | generatedLine++; 206 | str = str.slice(1); 207 | previousGeneratedColumn = 0; 208 | } 209 | else if (str.charAt(0) === ',') { 210 | str = str.slice(1); 211 | } 212 | else { 213 | mapping = {}; 214 | mapping.generatedLine = generatedLine; 215 | 216 | // Generated column. 217 | base64VLQ.decode(str, temp); 218 | mapping.generatedColumn = previousGeneratedColumn + temp.value; 219 | previousGeneratedColumn = mapping.generatedColumn; 220 | str = temp.rest; 221 | 222 | if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { 223 | // Original source. 224 | base64VLQ.decode(str, temp); 225 | mapping.source = this._sources.at(previousSource + temp.value); 226 | previousSource += temp.value; 227 | str = temp.rest; 228 | if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { 229 | throw new Error('Found a source, but no line and column'); 230 | } 231 | 232 | // Original line. 233 | base64VLQ.decode(str, temp); 234 | mapping.originalLine = previousOriginalLine + temp.value; 235 | previousOriginalLine = mapping.originalLine; 236 | // Lines are stored 0-based 237 | mapping.originalLine += 1; 238 | str = temp.rest; 239 | if (str.length === 0 || this._nextCharIsMappingSeparator(str)) { 240 | throw new Error('Found a source and line, but no column'); 241 | } 242 | 243 | // Original column. 244 | base64VLQ.decode(str, temp); 245 | mapping.originalColumn = previousOriginalColumn + temp.value; 246 | previousOriginalColumn = mapping.originalColumn; 247 | str = temp.rest; 248 | 249 | if (str.length > 0 && !this._nextCharIsMappingSeparator(str)) { 250 | // Original name. 251 | base64VLQ.decode(str, temp); 252 | mapping.name = this._names.at(previousName + temp.value); 253 | previousName += temp.value; 254 | str = temp.rest; 255 | } 256 | } 257 | 258 | this.__generatedMappings.push(mapping); 259 | if (typeof mapping.originalLine === 'number') { 260 | this.__originalMappings.push(mapping); 261 | } 262 | } 263 | } 264 | 265 | this.__generatedMappings.sort(util.compareByGeneratedPositions); 266 | this.__originalMappings.sort(util.compareByOriginalPositions); 267 | }; 268 | 269 | /** 270 | * Find the mapping that best matches the hypothetical "needle" mapping that 271 | * we are searching for in the given "haystack" of mappings. 272 | */ 273 | SourceMapConsumer.prototype._findMapping = 274 | function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, 275 | aColumnName, aComparator) { 276 | // To return the position we are searching for, we must first find the 277 | // mapping for the given position and then return the opposite position it 278 | // points to. Because the mappings are sorted, we can use binary search to 279 | // find the best mapping. 280 | 281 | if (aNeedle[aLineName] <= 0) { 282 | throw new TypeError('Line must be greater than or equal to 1, got ' 283 | + aNeedle[aLineName]); 284 | } 285 | if (aNeedle[aColumnName] < 0) { 286 | throw new TypeError('Column must be greater than or equal to 0, got ' 287 | + aNeedle[aColumnName]); 288 | } 289 | 290 | return binarySearch.search(aNeedle, aMappings, aComparator); 291 | }; 292 | 293 | /** 294 | * Returns the original source, line, and column information for the generated 295 | * source's line and column positions provided. The only argument is an object 296 | * with the following properties: 297 | * 298 | * - line: The line number in the generated source. 299 | * - column: The column number in the generated source. 300 | * 301 | * and an object is returned with the following properties: 302 | * 303 | * - source: The original source file, or null. 304 | * - line: The line number in the original source, or null. 305 | * - column: The column number in the original source, or null. 306 | * - name: The original identifier, or null. 307 | */ 308 | SourceMapConsumer.prototype.originalPositionFor = 309 | function SourceMapConsumer_originalPositionFor(aArgs) { 310 | var needle = { 311 | generatedLine: util.getArg(aArgs, 'line'), 312 | generatedColumn: util.getArg(aArgs, 'column') 313 | }; 314 | 315 | var mapping = this._findMapping(needle, 316 | this._generatedMappings, 317 | "generatedLine", 318 | "generatedColumn", 319 | util.compareByGeneratedPositions); 320 | 321 | if (mapping && mapping.generatedLine === needle.generatedLine) { 322 | var source = util.getArg(mapping, 'source', null); 323 | if (source != null && this.sourceRoot != null) { 324 | source = util.join(this.sourceRoot, source); 325 | } 326 | return { 327 | source: source, 328 | line: util.getArg(mapping, 'originalLine', null), 329 | column: util.getArg(mapping, 'originalColumn', null), 330 | name: util.getArg(mapping, 'name', null) 331 | }; 332 | } 333 | 334 | return { 335 | source: null, 336 | line: null, 337 | column: null, 338 | name: null 339 | }; 340 | }; 341 | 342 | /** 343 | * Returns the original source content. The only argument is the url of the 344 | * original source file. Returns null if no original source content is 345 | * availible. 346 | */ 347 | SourceMapConsumer.prototype.sourceContentFor = 348 | function SourceMapConsumer_sourceContentFor(aSource) { 349 | if (!this.sourcesContent) { 350 | return null; 351 | } 352 | 353 | if (this.sourceRoot != null) { 354 | aSource = util.relative(this.sourceRoot, aSource); 355 | } 356 | 357 | if (this._sources.has(aSource)) { 358 | return this.sourcesContent[this._sources.indexOf(aSource)]; 359 | } 360 | 361 | var url; 362 | if (this.sourceRoot != null 363 | && (url = util.urlParse(this.sourceRoot))) { 364 | // XXX: file:// URIs and absolute paths lead to unexpected behavior for 365 | // many users. We can help them out when they expect file:// URIs to 366 | // behave like it would if they were running a local HTTP server. See 367 | // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. 368 | var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); 369 | if (url.scheme == "file" 370 | && this._sources.has(fileUriAbsPath)) { 371 | return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] 372 | } 373 | 374 | if ((!url.path || url.path == "/") 375 | && this._sources.has("/" + aSource)) { 376 | return this.sourcesContent[this._sources.indexOf("/" + aSource)]; 377 | } 378 | } 379 | 380 | throw new Error('"' + aSource + '" is not in the SourceMap.'); 381 | }; 382 | 383 | /** 384 | * Returns the generated line and column information for the original source, 385 | * line, and column positions provided. The only argument is an object with 386 | * the following properties: 387 | * 388 | * - source: The filename of the original source. 389 | * - line: The line number in the original source. 390 | * - column: The column number in the original source. 391 | * 392 | * and an object is returned with the following properties: 393 | * 394 | * - line: The line number in the generated source, or null. 395 | * - column: The column number in the generated source, or null. 396 | */ 397 | SourceMapConsumer.prototype.generatedPositionFor = 398 | function SourceMapConsumer_generatedPositionFor(aArgs) { 399 | var needle = { 400 | source: util.getArg(aArgs, 'source'), 401 | originalLine: util.getArg(aArgs, 'line'), 402 | originalColumn: util.getArg(aArgs, 'column') 403 | }; 404 | 405 | if (this.sourceRoot != null) { 406 | needle.source = util.relative(this.sourceRoot, needle.source); 407 | } 408 | 409 | var mapping = this._findMapping(needle, 410 | this._originalMappings, 411 | "originalLine", 412 | "originalColumn", 413 | util.compareByOriginalPositions); 414 | 415 | if (mapping) { 416 | return { 417 | line: util.getArg(mapping, 'generatedLine', null), 418 | column: util.getArg(mapping, 'generatedColumn', null) 419 | }; 420 | } 421 | 422 | return { 423 | line: null, 424 | column: null 425 | }; 426 | }; 427 | 428 | SourceMapConsumer.GENERATED_ORDER = 1; 429 | SourceMapConsumer.ORIGINAL_ORDER = 2; 430 | 431 | /** 432 | * Iterate over each mapping between an original source/line/column and a 433 | * generated line/column in this source map. 434 | * 435 | * @param Function aCallback 436 | * The function that is called with each mapping. 437 | * @param Object aContext 438 | * Optional. If specified, this object will be the value of `this` every 439 | * time that `aCallback` is called. 440 | * @param aOrder 441 | * Either `SourceMapConsumer.GENERATED_ORDER` or 442 | * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to 443 | * iterate over the mappings sorted by the generated file's line/column 444 | * order or the original's source/line/column order, respectively. Defaults to 445 | * `SourceMapConsumer.GENERATED_ORDER`. 446 | */ 447 | SourceMapConsumer.prototype.eachMapping = 448 | function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { 449 | var context = aContext || null; 450 | var order = aOrder || SourceMapConsumer.GENERATED_ORDER; 451 | 452 | var mappings; 453 | switch (order) { 454 | case SourceMapConsumer.GENERATED_ORDER: 455 | mappings = this._generatedMappings; 456 | break; 457 | case SourceMapConsumer.ORIGINAL_ORDER: 458 | mappings = this._originalMappings; 459 | break; 460 | default: 461 | throw new Error("Unknown order of iteration."); 462 | } 463 | 464 | var sourceRoot = this.sourceRoot; 465 | mappings.map(function (mapping) { 466 | var source = mapping.source; 467 | if (source != null && sourceRoot != null) { 468 | source = util.join(sourceRoot, source); 469 | } 470 | return { 471 | source: source, 472 | generatedLine: mapping.generatedLine, 473 | generatedColumn: mapping.generatedColumn, 474 | originalLine: mapping.originalLine, 475 | originalColumn: mapping.originalColumn, 476 | name: mapping.name 477 | }; 478 | }).forEach(aCallback, context); 479 | }; 480 | 481 | exports.SourceMapConsumer = SourceMapConsumer; 482 | 483 | }); 484 | -------------------------------------------------------------------------------- /SourceMap/source-map/source-map-generator.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | var base64VLQ = require('./base64-vlq'); 13 | var util = require('./util'); 14 | var ArraySet = require('./array-set').ArraySet; 15 | 16 | /** 17 | * An instance of the SourceMapGenerator represents a source map which is 18 | * being built incrementally. You may pass an object with the following 19 | * properties: 20 | * 21 | * - file: The filename of the generated source. 22 | * - sourceRoot: A root for all relative URLs in this source map. 23 | */ 24 | function SourceMapGenerator(aArgs) { 25 | if (!aArgs) { 26 | aArgs = {}; 27 | } 28 | this._file = util.getArg(aArgs, 'file', null); 29 | this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); 30 | this._sources = new ArraySet(); 31 | this._names = new ArraySet(); 32 | this._mappings = []; 33 | this._sourcesContents = null; 34 | } 35 | 36 | SourceMapGenerator.prototype._version = 3; 37 | 38 | /** 39 | * Creates a new SourceMapGenerator based on a SourceMapConsumer 40 | * 41 | * @param aSourceMapConsumer The SourceMap. 42 | */ 43 | SourceMapGenerator.fromSourceMap = 44 | function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { 45 | var sourceRoot = aSourceMapConsumer.sourceRoot; 46 | var generator = new SourceMapGenerator({ 47 | file: aSourceMapConsumer.file, 48 | sourceRoot: sourceRoot 49 | }); 50 | aSourceMapConsumer.eachMapping(function (mapping) { 51 | var newMapping = { 52 | generated: { 53 | line: mapping.generatedLine, 54 | column: mapping.generatedColumn 55 | } 56 | }; 57 | 58 | if (mapping.source != null) { 59 | newMapping.source = mapping.source; 60 | if (sourceRoot != null) { 61 | newMapping.source = util.relative(sourceRoot, newMapping.source); 62 | } 63 | 64 | newMapping.original = { 65 | line: mapping.originalLine, 66 | column: mapping.originalColumn 67 | }; 68 | 69 | if (mapping.name != null) { 70 | newMapping.name = mapping.name; 71 | } 72 | } 73 | 74 | generator.addMapping(newMapping); 75 | }); 76 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 77 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 78 | if (content != null) { 79 | generator.setSourceContent(sourceFile, content); 80 | } 81 | }); 82 | return generator; 83 | }; 84 | 85 | /** 86 | * Add a single mapping from original source line and column to the generated 87 | * source's line and column for this source map being created. The mapping 88 | * object should have the following properties: 89 | * 90 | * - generated: An object with the generated line and column positions. 91 | * - original: An object with the original line and column positions. 92 | * - source: The original source file (relative to the sourceRoot). 93 | * - name: An optional original token name for this mapping. 94 | */ 95 | SourceMapGenerator.prototype.addMapping = 96 | function SourceMapGenerator_addMapping(aArgs) { 97 | var generated = util.getArg(aArgs, 'generated'); 98 | var original = util.getArg(aArgs, 'original', null); 99 | var source = util.getArg(aArgs, 'source', null); 100 | var name = util.getArg(aArgs, 'name', null); 101 | 102 | this._validateMapping(generated, original, source, name); 103 | 104 | if (source != null && !this._sources.has(source)) { 105 | this._sources.add(source); 106 | } 107 | 108 | if (name != null && !this._names.has(name)) { 109 | this._names.add(name); 110 | } 111 | 112 | this._mappings.push({ 113 | generatedLine: generated.line, 114 | generatedColumn: generated.column, 115 | originalLine: original != null && original.line, 116 | originalColumn: original != null && original.column, 117 | source: source, 118 | name: name 119 | }); 120 | }; 121 | 122 | /** 123 | * Set the source content for a source file. 124 | */ 125 | SourceMapGenerator.prototype.setSourceContent = 126 | function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { 127 | var source = aSourceFile; 128 | if (this._sourceRoot != null) { 129 | source = util.relative(this._sourceRoot, source); 130 | } 131 | 132 | if (aSourceContent != null) { 133 | // Add the source content to the _sourcesContents map. 134 | // Create a new _sourcesContents map if the property is null. 135 | if (!this._sourcesContents) { 136 | this._sourcesContents = {}; 137 | } 138 | this._sourcesContents[util.toSetString(source)] = aSourceContent; 139 | } else if (this._sourcesContents) { 140 | // Remove the source file from the _sourcesContents map. 141 | // If the _sourcesContents map is empty, set the property to null. 142 | delete this._sourcesContents[util.toSetString(source)]; 143 | if (Object.keys(this._sourcesContents).length === 0) { 144 | this._sourcesContents = null; 145 | } 146 | } 147 | }; 148 | 149 | /** 150 | * Applies the mappings of a sub-source-map for a specific source file to the 151 | * source map being generated. Each mapping to the supplied source file is 152 | * rewritten using the supplied source map. Note: The resolution for the 153 | * resulting mappings is the minimium of this map and the supplied map. 154 | * 155 | * @param aSourceMapConsumer The source map to be applied. 156 | * @param aSourceFile Optional. The filename of the source file. 157 | * If omitted, SourceMapConsumer's file property will be used. 158 | * @param aSourceMapPath Optional. The dirname of the path to the source map 159 | * to be applied. If relative, it is relative to the SourceMapConsumer. 160 | * This parameter is needed when the two source maps aren't in the same 161 | * directory, and the source map to be applied contains relative source 162 | * paths. If so, those relative source paths need to be rewritten 163 | * relative to the SourceMapGenerator. 164 | */ 165 | SourceMapGenerator.prototype.applySourceMap = 166 | function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) { 167 | var sourceFile = aSourceFile; 168 | // If aSourceFile is omitted, we will use the file property of the SourceMap 169 | if (aSourceFile == null) { 170 | if (aSourceMapConsumer.file == null) { 171 | throw new Error( 172 | 'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' + 173 | 'or the source map\'s "file" property. Both were omitted.' 174 | ); 175 | } 176 | sourceFile = aSourceMapConsumer.file; 177 | } 178 | var sourceRoot = this._sourceRoot; 179 | // Make "sourceFile" relative if an absolute Url is passed. 180 | if (sourceRoot != null) { 181 | sourceFile = util.relative(sourceRoot, sourceFile); 182 | } 183 | // Applying the SourceMap can add and remove items from the sources and 184 | // the names array. 185 | var newSources = new ArraySet(); 186 | var newNames = new ArraySet(); 187 | 188 | // Find mappings for the "sourceFile" 189 | this._mappings.forEach(function (mapping) { 190 | if (mapping.source === sourceFile && mapping.originalLine != null) { 191 | // Check if it can be mapped by the source map, then update the mapping. 192 | var original = aSourceMapConsumer.originalPositionFor({ 193 | line: mapping.originalLine, 194 | column: mapping.originalColumn 195 | }); 196 | if (original.source != null) { 197 | // Copy mapping 198 | mapping.source = original.source; 199 | if (aSourceMapPath != null) { 200 | mapping.source = util.join(aSourceMapPath, mapping.source) 201 | } 202 | if (sourceRoot != null) { 203 | mapping.source = util.relative(sourceRoot, mapping.source); 204 | } 205 | mapping.originalLine = original.line; 206 | mapping.originalColumn = original.column; 207 | if (original.name != null) { 208 | mapping.name = original.name; 209 | } 210 | } 211 | } 212 | 213 | var source = mapping.source; 214 | if (source != null && !newSources.has(source)) { 215 | newSources.add(source); 216 | } 217 | 218 | var name = mapping.name; 219 | if (name != null && !newNames.has(name)) { 220 | newNames.add(name); 221 | } 222 | 223 | }, this); 224 | this._sources = newSources; 225 | this._names = newNames; 226 | 227 | // Copy sourcesContents of applied map. 228 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 229 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 230 | if (content != null) { 231 | if (aSourceMapPath != null) { 232 | sourceFile = util.join(aSourceMapPath, sourceFile); 233 | } 234 | if (sourceRoot != null) { 235 | sourceFile = util.relative(sourceRoot, sourceFile); 236 | } 237 | this.setSourceContent(sourceFile, content); 238 | } 239 | }, this); 240 | }; 241 | 242 | /** 243 | * A mapping can have one of the three levels of data: 244 | * 245 | * 1. Just the generated position. 246 | * 2. The Generated position, original position, and original source. 247 | * 3. Generated and original position, original source, as well as a name 248 | * token. 249 | * 250 | * To maintain consistency, we validate that any new mapping being added falls 251 | * in to one of these categories. 252 | */ 253 | SourceMapGenerator.prototype._validateMapping = 254 | function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, 255 | aName) { 256 | if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 257 | && aGenerated.line > 0 && aGenerated.column >= 0 258 | && !aOriginal && !aSource && !aName) { 259 | // Case 1. 260 | return; 261 | } 262 | else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated 263 | && aOriginal && 'line' in aOriginal && 'column' in aOriginal 264 | && aGenerated.line > 0 && aGenerated.column >= 0 265 | && aOriginal.line > 0 && aOriginal.column >= 0 266 | && aSource) { 267 | // Cases 2 and 3. 268 | return; 269 | } 270 | else { 271 | throw new Error('Invalid mapping: ' + JSON.stringify({ 272 | generated: aGenerated, 273 | source: aSource, 274 | original: aOriginal, 275 | name: aName 276 | })); 277 | } 278 | }; 279 | 280 | /** 281 | * Serialize the accumulated mappings in to the stream of base 64 VLQs 282 | * specified by the source map format. 283 | */ 284 | SourceMapGenerator.prototype._serializeMappings = 285 | function SourceMapGenerator_serializeMappings() { 286 | var previousGeneratedColumn = 0; 287 | var previousGeneratedLine = 1; 288 | var previousOriginalColumn = 0; 289 | var previousOriginalLine = 0; 290 | var previousName = 0; 291 | var previousSource = 0; 292 | var result = ''; 293 | var mapping; 294 | 295 | // The mappings must be guaranteed to be in sorted order before we start 296 | // serializing them or else the generated line numbers (which are defined 297 | // via the ';' separators) will be all messed up. Note: it might be more 298 | // performant to maintain the sorting as we insert them, rather than as we 299 | // serialize them, but the big O is the same either way. 300 | this._mappings.sort(util.compareByGeneratedPositions); 301 | 302 | for (var i = 0, len = this._mappings.length; i < len; i++) { 303 | mapping = this._mappings[i]; 304 | 305 | if (mapping.generatedLine !== previousGeneratedLine) { 306 | previousGeneratedColumn = 0; 307 | while (mapping.generatedLine !== previousGeneratedLine) { 308 | result += ';'; 309 | previousGeneratedLine++; 310 | } 311 | } 312 | else { 313 | if (i > 0) { 314 | if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) { 315 | continue; 316 | } 317 | result += ','; 318 | } 319 | } 320 | 321 | result += base64VLQ.encode(mapping.generatedColumn 322 | - previousGeneratedColumn); 323 | previousGeneratedColumn = mapping.generatedColumn; 324 | 325 | if (mapping.source != null) { 326 | result += base64VLQ.encode(this._sources.indexOf(mapping.source) 327 | - previousSource); 328 | previousSource = this._sources.indexOf(mapping.source); 329 | 330 | // lines are stored 0-based in SourceMap spec version 3 331 | result += base64VLQ.encode(mapping.originalLine - 1 332 | - previousOriginalLine); 333 | previousOriginalLine = mapping.originalLine - 1; 334 | 335 | result += base64VLQ.encode(mapping.originalColumn 336 | - previousOriginalColumn); 337 | previousOriginalColumn = mapping.originalColumn; 338 | 339 | if (mapping.name != null) { 340 | result += base64VLQ.encode(this._names.indexOf(mapping.name) 341 | - previousName); 342 | previousName = this._names.indexOf(mapping.name); 343 | } 344 | } 345 | } 346 | 347 | return result; 348 | }; 349 | 350 | SourceMapGenerator.prototype._generateSourcesContent = 351 | function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { 352 | return aSources.map(function (source) { 353 | if (!this._sourcesContents) { 354 | return null; 355 | } 356 | if (aSourceRoot != null) { 357 | source = util.relative(aSourceRoot, source); 358 | } 359 | var key = util.toSetString(source); 360 | return Object.prototype.hasOwnProperty.call(this._sourcesContents, 361 | key) 362 | ? this._sourcesContents[key] 363 | : null; 364 | }, this); 365 | }; 366 | 367 | /** 368 | * Externalize the source map. 369 | */ 370 | SourceMapGenerator.prototype.toJSON = 371 | function SourceMapGenerator_toJSON() { 372 | var map = { 373 | version: this._version, 374 | sources: this._sources.toArray(), 375 | names: this._names.toArray(), 376 | mappings: this._serializeMappings() 377 | }; 378 | if (this._file != null) { 379 | map.file = this._file; 380 | } 381 | if (this._sourceRoot != null) { 382 | map.sourceRoot = this._sourceRoot; 383 | } 384 | if (this._sourcesContents) { 385 | map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); 386 | } 387 | 388 | return map; 389 | }; 390 | 391 | /** 392 | * Render the source map being generated to a string. 393 | */ 394 | SourceMapGenerator.prototype.toString = 395 | function SourceMapGenerator_toString() { 396 | return JSON.stringify(this); 397 | }; 398 | 399 | exports.SourceMapGenerator = SourceMapGenerator; 400 | 401 | }); 402 | -------------------------------------------------------------------------------- /SourceMap/source-map/source-node.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; 13 | var util = require('./util'); 14 | 15 | // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other 16 | // operating systems these days (capturing the result). 17 | var REGEX_NEWLINE = /(\r?\n)/; 18 | 19 | // Matches a Windows-style newline, or any character. 20 | var REGEX_CHARACTER = /\r\n|[\s\S]/g; 21 | 22 | /** 23 | * SourceNodes provide a way to abstract over interpolating/concatenating 24 | * snippets of generated JavaScript source code while maintaining the line and 25 | * column information associated with the original source code. 26 | * 27 | * @param aLine The original line number. 28 | * @param aColumn The original column number. 29 | * @param aSource The original source's filename. 30 | * @param aChunks Optional. An array of strings which are snippets of 31 | * generated JS, or other SourceNodes. 32 | * @param aName The original identifier. 33 | */ 34 | function SourceNode(aLine, aColumn, aSource, aChunks, aName) { 35 | this.children = []; 36 | this.sourceContents = {}; 37 | this.line = aLine == null ? null : aLine; 38 | this.column = aColumn == null ? null : aColumn; 39 | this.source = aSource == null ? null : aSource; 40 | this.name = aName == null ? null : aName; 41 | if (aChunks != null) this.add(aChunks); 42 | } 43 | 44 | /** 45 | * Creates a SourceNode from generated code and a SourceMapConsumer. 46 | * 47 | * @param aGeneratedCode The generated code 48 | * @param aSourceMapConsumer The SourceMap for the generated code 49 | * @param aRelativePath Optional. The path that relative sources in the 50 | * SourceMapConsumer should be relative to. 51 | */ 52 | SourceNode.fromStringWithSourceMap = 53 | function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) { 54 | // The SourceNode we want to fill with the generated code 55 | // and the SourceMap 56 | var node = new SourceNode(); 57 | 58 | // All even indices of this array are one line of the generated code, 59 | // while all odd indices are the newlines between two adjacent lines 60 | // (since `REGEX_NEWLINE` captures its match). 61 | // Processed fragments are removed from this array, by calling `shiftNextLine`. 62 | var remainingLines = aGeneratedCode.split(REGEX_NEWLINE); 63 | var shiftNextLine = function() { 64 | var lineContents = remainingLines.shift(); 65 | // The last line of a file might not have a newline. 66 | var newLine = remainingLines.shift() || ""; 67 | return lineContents + newLine; 68 | }; 69 | 70 | // We need to remember the position of "remainingLines" 71 | var lastGeneratedLine = 1, lastGeneratedColumn = 0; 72 | 73 | // The generate SourceNodes we need a code range. 74 | // To extract it current and last mapping is used. 75 | // Here we store the last mapping. 76 | var lastMapping = null; 77 | 78 | aSourceMapConsumer.eachMapping(function (mapping) { 79 | if (lastMapping !== null) { 80 | // We add the code from "lastMapping" to "mapping": 81 | // First check if there is a new line in between. 82 | if (lastGeneratedLine < mapping.generatedLine) { 83 | var code = ""; 84 | // Associate first line with "lastMapping" 85 | addMappingWithCode(lastMapping, shiftNextLine()); 86 | lastGeneratedLine++; 87 | lastGeneratedColumn = 0; 88 | // The remaining code is added without mapping 89 | } else { 90 | // There is no new line in between. 91 | // Associate the code between "lastGeneratedColumn" and 92 | // "mapping.generatedColumn" with "lastMapping" 93 | var nextLine = remainingLines[0]; 94 | var code = nextLine.substr(0, mapping.generatedColumn - 95 | lastGeneratedColumn); 96 | remainingLines[0] = nextLine.substr(mapping.generatedColumn - 97 | lastGeneratedColumn); 98 | lastGeneratedColumn = mapping.generatedColumn; 99 | addMappingWithCode(lastMapping, code); 100 | // No more remaining code, continue 101 | lastMapping = mapping; 102 | return; 103 | } 104 | } 105 | // We add the generated code until the first mapping 106 | // to the SourceNode without any mapping. 107 | // Each line is added as separate string. 108 | while (lastGeneratedLine < mapping.generatedLine) { 109 | node.add(shiftNextLine()); 110 | lastGeneratedLine++; 111 | } 112 | if (lastGeneratedColumn < mapping.generatedColumn) { 113 | var nextLine = remainingLines[0]; 114 | node.add(nextLine.substr(0, mapping.generatedColumn)); 115 | remainingLines[0] = nextLine.substr(mapping.generatedColumn); 116 | lastGeneratedColumn = mapping.generatedColumn; 117 | } 118 | lastMapping = mapping; 119 | }, this); 120 | // We have processed all mappings. 121 | if (remainingLines.length > 0) { 122 | if (lastMapping) { 123 | // Associate the remaining code in the current line with "lastMapping" 124 | addMappingWithCode(lastMapping, shiftNextLine()); 125 | } 126 | // and add the remaining lines without any mapping 127 | node.add(remainingLines.join("")); 128 | } 129 | 130 | // Copy sourcesContent into SourceNode 131 | aSourceMapConsumer.sources.forEach(function (sourceFile) { 132 | var content = aSourceMapConsumer.sourceContentFor(sourceFile); 133 | if (content != null) { 134 | if (aRelativePath != null) { 135 | sourceFile = util.join(aRelativePath, sourceFile); 136 | } 137 | node.setSourceContent(sourceFile, content); 138 | } 139 | }); 140 | 141 | return node; 142 | 143 | function addMappingWithCode(mapping, code) { 144 | if (mapping === null || mapping.source === undefined) { 145 | node.add(code); 146 | } else { 147 | var source = aRelativePath 148 | ? util.join(aRelativePath, mapping.source) 149 | : mapping.source; 150 | node.add(new SourceNode(mapping.originalLine, 151 | mapping.originalColumn, 152 | source, 153 | code, 154 | mapping.name)); 155 | } 156 | } 157 | }; 158 | 159 | /** 160 | * Add a chunk of generated JS to this source node. 161 | * 162 | * @param aChunk A string snippet of generated JS code, another instance of 163 | * SourceNode, or an array where each member is one of those things. 164 | */ 165 | SourceNode.prototype.add = function SourceNode_add(aChunk) { 166 | if (Array.isArray(aChunk)) { 167 | aChunk.forEach(function (chunk) { 168 | this.add(chunk); 169 | }, this); 170 | } 171 | else if (aChunk instanceof SourceNode || typeof aChunk === "string") { 172 | if (aChunk) { 173 | this.children.push(aChunk); 174 | } 175 | } 176 | else { 177 | throw new TypeError( 178 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 179 | ); 180 | } 181 | return this; 182 | }; 183 | 184 | /** 185 | * Add a chunk of generated JS to the beginning of this source node. 186 | * 187 | * @param aChunk A string snippet of generated JS code, another instance of 188 | * SourceNode, or an array where each member is one of those things. 189 | */ 190 | SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { 191 | if (Array.isArray(aChunk)) { 192 | for (var i = aChunk.length-1; i >= 0; i--) { 193 | this.prepend(aChunk[i]); 194 | } 195 | } 196 | else if (aChunk instanceof SourceNode || typeof aChunk === "string") { 197 | this.children.unshift(aChunk); 198 | } 199 | else { 200 | throw new TypeError( 201 | "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk 202 | ); 203 | } 204 | return this; 205 | }; 206 | 207 | /** 208 | * Walk over the tree of JS snippets in this node and its children. The 209 | * walking function is called once for each snippet of JS and is passed that 210 | * snippet and the its original associated source's line/column location. 211 | * 212 | * @param aFn The traversal function. 213 | */ 214 | SourceNode.prototype.walk = function SourceNode_walk(aFn) { 215 | var chunk; 216 | for (var i = 0, len = this.children.length; i < len; i++) { 217 | chunk = this.children[i]; 218 | if (chunk instanceof SourceNode) { 219 | chunk.walk(aFn); 220 | } 221 | else { 222 | if (chunk !== '') { 223 | aFn(chunk, { source: this.source, 224 | line: this.line, 225 | column: this.column, 226 | name: this.name }); 227 | } 228 | } 229 | } 230 | }; 231 | 232 | /** 233 | * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between 234 | * each of `this.children`. 235 | * 236 | * @param aSep The separator. 237 | */ 238 | SourceNode.prototype.join = function SourceNode_join(aSep) { 239 | var newChildren; 240 | var i; 241 | var len = this.children.length; 242 | if (len > 0) { 243 | newChildren = []; 244 | for (i = 0; i < len-1; i++) { 245 | newChildren.push(this.children[i]); 246 | newChildren.push(aSep); 247 | } 248 | newChildren.push(this.children[i]); 249 | this.children = newChildren; 250 | } 251 | return this; 252 | }; 253 | 254 | /** 255 | * Call String.prototype.replace on the very right-most source snippet. Useful 256 | * for trimming whitespace from the end of a source node, etc. 257 | * 258 | * @param aPattern The pattern to replace. 259 | * @param aReplacement The thing to replace the pattern with. 260 | */ 261 | SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { 262 | var lastChild = this.children[this.children.length - 1]; 263 | if (lastChild instanceof SourceNode) { 264 | lastChild.replaceRight(aPattern, aReplacement); 265 | } 266 | else if (typeof lastChild === 'string') { 267 | this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); 268 | } 269 | else { 270 | this.children.push(''.replace(aPattern, aReplacement)); 271 | } 272 | return this; 273 | }; 274 | 275 | /** 276 | * Set the source content for a source file. This will be added to the SourceMapGenerator 277 | * in the sourcesContent field. 278 | * 279 | * @param aSourceFile The filename of the source file 280 | * @param aSourceContent The content of the source file 281 | */ 282 | SourceNode.prototype.setSourceContent = 283 | function SourceNode_setSourceContent(aSourceFile, aSourceContent) { 284 | this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; 285 | }; 286 | 287 | /** 288 | * Walk over the tree of SourceNodes. The walking function is called for each 289 | * source file content and is passed the filename and source content. 290 | * 291 | * @param aFn The traversal function. 292 | */ 293 | SourceNode.prototype.walkSourceContents = 294 | function SourceNode_walkSourceContents(aFn) { 295 | for (var i = 0, len = this.children.length; i < len; i++) { 296 | if (this.children[i] instanceof SourceNode) { 297 | this.children[i].walkSourceContents(aFn); 298 | } 299 | } 300 | 301 | var sources = Object.keys(this.sourceContents); 302 | for (var i = 0, len = sources.length; i < len; i++) { 303 | aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); 304 | } 305 | }; 306 | 307 | /** 308 | * Return the string representation of this source node. Walks over the tree 309 | * and concatenates all the various snippets together to one string. 310 | */ 311 | SourceNode.prototype.toString = function SourceNode_toString() { 312 | var str = ""; 313 | this.walk(function (chunk) { 314 | str += chunk; 315 | }); 316 | return str; 317 | }; 318 | 319 | /** 320 | * Returns the string representation of this source node along with a source 321 | * map. 322 | */ 323 | SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { 324 | var generated = { 325 | code: "", 326 | line: 1, 327 | column: 0 328 | }; 329 | var map = new SourceMapGenerator(aArgs); 330 | var sourceMappingActive = false; 331 | var lastOriginalSource = null; 332 | var lastOriginalLine = null; 333 | var lastOriginalColumn = null; 334 | var lastOriginalName = null; 335 | this.walk(function (chunk, original) { 336 | generated.code += chunk; 337 | if (original.source !== null 338 | && original.line !== null 339 | && original.column !== null) { 340 | if(lastOriginalSource !== original.source 341 | || lastOriginalLine !== original.line 342 | || lastOriginalColumn !== original.column 343 | || lastOriginalName !== original.name) { 344 | map.addMapping({ 345 | source: original.source, 346 | original: { 347 | line: original.line, 348 | column: original.column 349 | }, 350 | generated: { 351 | line: generated.line, 352 | column: generated.column 353 | }, 354 | name: original.name 355 | }); 356 | } 357 | lastOriginalSource = original.source; 358 | lastOriginalLine = original.line; 359 | lastOriginalColumn = original.column; 360 | lastOriginalName = original.name; 361 | sourceMappingActive = true; 362 | } else if (sourceMappingActive) { 363 | map.addMapping({ 364 | generated: { 365 | line: generated.line, 366 | column: generated.column 367 | } 368 | }); 369 | lastOriginalSource = null; 370 | sourceMappingActive = false; 371 | } 372 | chunk.match(REGEX_CHARACTER).forEach(function (ch, idx, array) { 373 | if (REGEX_NEWLINE.test(ch)) { 374 | generated.line++; 375 | generated.column = 0; 376 | // Mappings end at eol 377 | if (idx + 1 === array.length) { 378 | lastOriginalSource = null; 379 | sourceMappingActive = false; 380 | } else if (sourceMappingActive) { 381 | map.addMapping({ 382 | source: original.source, 383 | original: { 384 | line: original.line, 385 | column: original.column 386 | }, 387 | generated: { 388 | line: generated.line, 389 | column: generated.column 390 | }, 391 | name: original.name 392 | }); 393 | } 394 | } else { 395 | generated.column += ch.length; 396 | } 397 | }); 398 | }); 399 | this.walkSourceContents(function (sourceFile, sourceContent) { 400 | map.setSourceContent(sourceFile, sourceContent); 401 | }); 402 | 403 | return { code: generated.code, map: map }; 404 | }; 405 | 406 | exports.SourceNode = SourceNode; 407 | 408 | }); 409 | -------------------------------------------------------------------------------- /SourceMap/source-map/util.js: -------------------------------------------------------------------------------- 1 | /* -*- Mode: js; js-indent-level: 2; -*- */ 2 | /* 3 | * Copyright 2011 Mozilla Foundation and contributors 4 | * Licensed under the New BSD license. See LICENSE or: 5 | * http://opensource.org/licenses/BSD-3-Clause 6 | */ 7 | if (typeof define !== 'function') { 8 | var define = require('amdefine')(module, require); 9 | } 10 | define(function (require, exports, module) { 11 | 12 | /** 13 | * This is a helper function for getting values from parameter/options 14 | * objects. 15 | * 16 | * @param args The object we are extracting values from 17 | * @param name The name of the property we are getting. 18 | * @param defaultValue An optional value to return if the property is missing 19 | * from the object. If this is not specified and the property is missing, an 20 | * error will be thrown. 21 | */ 22 | function getArg(aArgs, aName, aDefaultValue) { 23 | if (aName in aArgs) { 24 | return aArgs[aName]; 25 | } else if (arguments.length === 3) { 26 | return aDefaultValue; 27 | } else { 28 | throw new Error('"' + aName + '" is a required argument.'); 29 | } 30 | } 31 | exports.getArg = getArg; 32 | 33 | var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/; 34 | var dataUrlRegexp = /^data:.+\,.+$/; 35 | 36 | function urlParse(aUrl) { 37 | var match = aUrl.match(urlRegexp); 38 | if (!match) { 39 | return null; 40 | } 41 | return { 42 | scheme: match[1], 43 | auth: match[2], 44 | host: match[3], 45 | port: match[4], 46 | path: match[5] 47 | }; 48 | } 49 | exports.urlParse = urlParse; 50 | 51 | function urlGenerate(aParsedUrl) { 52 | var url = ''; 53 | if (aParsedUrl.scheme) { 54 | url += aParsedUrl.scheme + ':'; 55 | } 56 | url += '//'; 57 | if (aParsedUrl.auth) { 58 | url += aParsedUrl.auth + '@'; 59 | } 60 | if (aParsedUrl.host) { 61 | url += aParsedUrl.host; 62 | } 63 | if (aParsedUrl.port) { 64 | url += ":" + aParsedUrl.port 65 | } 66 | if (aParsedUrl.path) { 67 | url += aParsedUrl.path; 68 | } 69 | return url; 70 | } 71 | exports.urlGenerate = urlGenerate; 72 | 73 | /** 74 | * Normalizes a path, or the path portion of a URL: 75 | * 76 | * - Replaces consequtive slashes with one slash. 77 | * - Removes unnecessary '.' parts. 78 | * - Removes unnecessary '/..' parts. 79 | * 80 | * Based on code in the Node.js 'path' core module. 81 | * 82 | * @param aPath The path or url to normalize. 83 | */ 84 | function normalize(aPath) { 85 | var path = aPath; 86 | var url = urlParse(aPath); 87 | if (url) { 88 | if (!url.path) { 89 | return aPath; 90 | } 91 | path = url.path; 92 | } 93 | var isAbsolute = (path.charAt(0) === '/'); 94 | 95 | var parts = path.split(/\/+/); 96 | for (var part, up = 0, i = parts.length - 1; i >= 0; i--) { 97 | part = parts[i]; 98 | if (part === '.') { 99 | parts.splice(i, 1); 100 | } else if (part === '..') { 101 | up++; 102 | } else if (up > 0) { 103 | if (part === '') { 104 | // The first part is blank if the path is absolute. Trying to go 105 | // above the root is a no-op. Therefore we can remove all '..' parts 106 | // directly after the root. 107 | parts.splice(i + 1, up); 108 | up = 0; 109 | } else { 110 | parts.splice(i, 2); 111 | up--; 112 | } 113 | } 114 | } 115 | path = parts.join('/'); 116 | 117 | if (path === '') { 118 | path = isAbsolute ? '/' : '.'; 119 | } 120 | 121 | if (url) { 122 | url.path = path; 123 | return urlGenerate(url); 124 | } 125 | return path; 126 | } 127 | exports.normalize = normalize; 128 | 129 | /** 130 | * Joins two paths/URLs. 131 | * 132 | * @param aRoot The root path or URL. 133 | * @param aPath The path or URL to be joined with the root. 134 | * 135 | * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a 136 | * scheme-relative URL: Then the scheme of aRoot, if any, is prepended 137 | * first. 138 | * - Otherwise aPath is a path. If aRoot is a URL, then its path portion 139 | * is updated with the result and aRoot is returned. Otherwise the result 140 | * is returned. 141 | * - If aPath is absolute, the result is aPath. 142 | * - Otherwise the two paths are joined with a slash. 143 | * - Joining for example 'http://' and 'www.example.com' is also supported. 144 | */ 145 | function join(aRoot, aPath) { 146 | if (aRoot === "") { 147 | aRoot = "."; 148 | } 149 | if (aPath === "") { 150 | aPath = "."; 151 | } 152 | var aPathUrl = urlParse(aPath); 153 | var aRootUrl = urlParse(aRoot); 154 | if (aRootUrl) { 155 | aRoot = aRootUrl.path || '/'; 156 | } 157 | 158 | // `join(foo, '//www.example.org')` 159 | if (aPathUrl && !aPathUrl.scheme) { 160 | if (aRootUrl) { 161 | aPathUrl.scheme = aRootUrl.scheme; 162 | } 163 | return urlGenerate(aPathUrl); 164 | } 165 | 166 | if (aPathUrl || aPath.match(dataUrlRegexp)) { 167 | return aPath; 168 | } 169 | 170 | // `join('http://', 'www.example.com')` 171 | if (aRootUrl && !aRootUrl.host && !aRootUrl.path) { 172 | aRootUrl.host = aPath; 173 | return urlGenerate(aRootUrl); 174 | } 175 | 176 | var joined = aPath.charAt(0) === '/' 177 | ? aPath 178 | : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath); 179 | 180 | if (aRootUrl) { 181 | aRootUrl.path = joined; 182 | return urlGenerate(aRootUrl); 183 | } 184 | return joined; 185 | } 186 | exports.join = join; 187 | 188 | /** 189 | * Make a path relative to a URL or another path. 190 | * 191 | * @param aRoot The root path or URL. 192 | * @param aPath The path or URL to be made relative to aRoot. 193 | */ 194 | function relative(aRoot, aPath) { 195 | if (aRoot === "") { 196 | aRoot = "."; 197 | } 198 | 199 | aRoot = aRoot.replace(/\/$/, ''); 200 | 201 | // XXX: It is possible to remove this block, and the tests still pass! 202 | var url = urlParse(aRoot); 203 | if (aPath.charAt(0) == "/" && url && url.path == "/") { 204 | return aPath.slice(1); 205 | } 206 | 207 | return aPath.indexOf(aRoot + '/') === 0 208 | ? aPath.substr(aRoot.length + 1) 209 | : aPath; 210 | } 211 | exports.relative = relative; 212 | 213 | /** 214 | * Because behavior goes wacky when you set `__proto__` on objects, we 215 | * have to prefix all the strings in our set with an arbitrary character. 216 | * 217 | * See https://github.com/mozilla/source-map/pull/31 and 218 | * https://github.com/mozilla/source-map/issues/30 219 | * 220 | * @param String aStr 221 | */ 222 | function toSetString(aStr) { 223 | return '$' + aStr; 224 | } 225 | exports.toSetString = toSetString; 226 | 227 | function fromSetString(aStr) { 228 | return aStr.substr(1); 229 | } 230 | exports.fromSetString = fromSetString; 231 | 232 | function strcmp(aStr1, aStr2) { 233 | var s1 = aStr1 || ""; 234 | var s2 = aStr2 || ""; 235 | return (s1 > s2) - (s1 < s2); 236 | } 237 | 238 | /** 239 | * Comparator between two mappings where the original positions are compared. 240 | * 241 | * Optionally pass in `true` as `onlyCompareGenerated` to consider two 242 | * mappings with the same original source/line/column, but different generated 243 | * line and column the same. Useful when searching for a mapping with a 244 | * stubbed out mapping. 245 | */ 246 | function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { 247 | var cmp; 248 | 249 | cmp = strcmp(mappingA.source, mappingB.source); 250 | if (cmp) { 251 | return cmp; 252 | } 253 | 254 | cmp = mappingA.originalLine - mappingB.originalLine; 255 | if (cmp) { 256 | return cmp; 257 | } 258 | 259 | cmp = mappingA.originalColumn - mappingB.originalColumn; 260 | if (cmp || onlyCompareOriginal) { 261 | return cmp; 262 | } 263 | 264 | cmp = strcmp(mappingA.name, mappingB.name); 265 | if (cmp) { 266 | return cmp; 267 | } 268 | 269 | cmp = mappingA.generatedLine - mappingB.generatedLine; 270 | if (cmp) { 271 | return cmp; 272 | } 273 | 274 | return mappingA.generatedColumn - mappingB.generatedColumn; 275 | }; 276 | exports.compareByOriginalPositions = compareByOriginalPositions; 277 | 278 | /** 279 | * Comparator between two mappings where the generated positions are 280 | * compared. 281 | * 282 | * Optionally pass in `true` as `onlyCompareGenerated` to consider two 283 | * mappings with the same generated line and column, but different 284 | * source/name/original line and column the same. Useful when searching for a 285 | * mapping with a stubbed out mapping. 286 | */ 287 | function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { 288 | var cmp; 289 | 290 | cmp = mappingA.generatedLine - mappingB.generatedLine; 291 | if (cmp) { 292 | return cmp; 293 | } 294 | 295 | cmp = mappingA.generatedColumn - mappingB.generatedColumn; 296 | if (cmp || onlyCompareGenerated) { 297 | return cmp; 298 | } 299 | 300 | cmp = strcmp(mappingA.source, mappingB.source); 301 | if (cmp) { 302 | return cmp; 303 | } 304 | 305 | cmp = mappingA.originalLine - mappingB.originalLine; 306 | if (cmp) { 307 | return cmp; 308 | } 309 | 310 | cmp = mappingA.originalColumn - mappingB.originalColumn; 311 | if (cmp) { 312 | return cmp; 313 | } 314 | 315 | return strcmp(mappingA.name, mappingB.name); 316 | }; 317 | exports.compareByGeneratedPositions = compareByGeneratedPositions; 318 | 319 | }); 320 | -------------------------------------------------------------------------------- /UglifyJS/LICENSE: -------------------------------------------------------------------------------- 1 | UglifyJS is released under the BSD license: 2 | 3 | Copyright 2012-2013 (c) Mihai Bazon 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | * Redistributions of source code must retain the above 10 | copyright notice, this list of conditions and the following 11 | disclaimer. 12 | 13 | * Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following 15 | disclaimer in the documentation and/or other materials 16 | provided with the distribution. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER “AS IS” AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE 22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, 23 | OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 25 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 28 | THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 | SUCH DAMAGE. -------------------------------------------------------------------------------- /UglifyJS/uglifyjs.js: -------------------------------------------------------------------------------- 1 | !function(n,e){"use strict";function t(n){for(var e=Object.create(null),t=0;t=0;)if(e[t]==n)return!0;return!1}function a(n,e){for(var t=0,r=e.length;r>t;++t)if(n(e[t]))return e[t]}function u(n,e){if(0>=e)return"";if(1==e)return n;var t=u(n,e>>1);return t+=t,1&e&&(t+=n),t}function s(n,e){Error.call(this,n),this.msg=n,this.defs=e}function c(n,e,t){n===!0&&(n={});var r=n||{};if(t)for(var i in r)r.hasOwnProperty(i)&&!e.hasOwnProperty(i)&&s.croak("`"+i+"` is not a supported option",e);for(var i in e)e.hasOwnProperty(i)&&(r[i]=n&&n.hasOwnProperty(i)?n[i]:e[i]);return r}function f(n,e){for(var t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function l(){}function p(n,e){n.indexOf(e)<0&&n.push(e)}function d(n,e){return n.replace(/\{(.+?)\}/g,function(n,t){return e[t]})}function h(n,e){for(var t=n.length;--t>=0;)n[t]===e&&n.splice(t,1)}function _(n,e){function t(n,t){for(var r=[],i=0,o=0,a=0;i=0})}function g(n){function e(n){if(1==n.length)return t+="return str === "+JSON.stringify(n[0])+";";t+="switch(str){";for(var e=0;e3){r.sort(function(n,e){return e.length-n.length}),t+="switch(str.length){";for(var i=0;i=0;)if(!e(n[t]))return!1;return!0}function y(){this._values=Object.create(null),this._size=0}function A(n,e,t,r){arguments.length<4&&(r=W),e=e?e.split(/\s+/):[];var i=e;r&&r.PROPS&&(e=e.concat(r.PROPS));for(var o="return function AST_"+n+"(props){ if (props) { ",a=e.length;--a>=0;)o+="this."+e[a]+" = props."+e[a]+";";var u=r&&new r;(u&&u.initialize||t&&t.initialize)&&(o+="this.initialize();"),o+="}}";var s=new Function(o)();if(u&&(s.prototype=u,s.BASE=r),r&&r.SUBCLASSES.push(s),s.prototype.CTOR=s,s.PROPS=e||null,s.SELF_PROPS=i,s.SUBCLASSES=[],n&&(s.prototype.TYPE=s.TYPE=n),t)for(a in t)t.hasOwnProperty(a)&&(/^\$/.test(a)?s[a.substr(1)]=t[a]:s.prototype[a]=t[a]);return s.DEFMETHOD=function(n,e){this.prototype[n]=e},s}function w(n,e){n.body instanceof Y?n.body._walk(e):n.body.forEach(function(n){n._walk(e)})}function E(n){this.visit=n,this.stack=[]}function D(n){return n>=97&&122>=n||n>=65&&90>=n||n>=170&&qt.letter.test(String.fromCharCode(n))}function F(n){return n>=48&&57>=n}function S(n){return F(n)||D(n)}function C(n){return qt.non_spacing_mark.test(n)||qt.space_combining_mark.test(n)}function k(n){return qt.connector_punctuation.test(n)}function x(n){return!St(n)&&/^[a-z_$][a-z0-9_$]*$/i.test(n)}function B(n){return 36==n||95==n||D(n)}function T(n){var e=n.charCodeAt(0);return B(e)||F(e)||8204==e||8205==e||C(n)||k(n)}function $(n){var e=n.length;if(0==e)return!1;if(!B(n.charCodeAt(0)))return!1;for(;--e>=0;)if(!T(n.charAt(e)))return!1;return!0}function O(n){return xt.test(n)?parseInt(n.substr(2),16):Bt.test(n)?parseInt(n.substr(1),8):Tt.test(n)?parseFloat(n):void 0}function M(n,e,t,r){this.message=n,this.line=e,this.col=t,this.pos=r,this.stack=(new Error).stack}function N(n,e,t,r,i){throw new M(n,t,r,i)}function R(n,e,t){return n.type==e&&(null==t||n.value==t)}function q(n,e,t){function r(){return D.text.charAt(D.pos)}function i(n,e){var t=D.text.charAt(D.pos++);if(n&&!t)throw Ht;return"\n"==t?(D.newline_before=D.newline_before||!e,++D.line,D.col=0):++D.col,t}function o(n){for(;n-->0;)i()}function a(n){return D.text.substr(D.pos,n.length)==n}function u(n,e){var t=D.text.indexOf(n,D.pos);if(e&&-1==t)throw Ht;return t}function s(){D.tokline=D.line,D.tokcol=D.col,D.tokpos=D.pos}function c(n,t,r){D.regex_allowed="operator"==n&&!Pt(t)||"keyword"==n&&Ct(t)||"punc"==n&&Mt(t),C="punc"==n&&"."==t;var i={type:n,value:t,line:D.tokline,col:D.tokcol,pos:D.tokpos,endpos:D.pos,nlb:D.newline_before,file:e};if(!r){i.comments_before=D.comments_before,D.comments_before=[];for(var o=0,a=i.comments_before.length;a>o;o++)i.nlb=i.nlb||i.comments_before[o].nlb}return D.newline_before=!1,new L(i)}function f(){for(;Ot(r());)i()}function l(n){for(var e,t="",o=0;(e=r())&&n(e,o++);)t+=i();return t}function p(n){N(n,e,D.tokline,D.tokcol,D.tokpos)}function d(n){var e=!1,t=!1,r=!1,i="."==n,o=l(function(o,a){var u=o.charCodeAt(0);switch(u){case 120:case 88:return r?!1:r=!0;case 101:case 69:return r?!0:e?!1:e=t=!0;case 45:return t||0==a&&!n;case 43:return t;case t=!1,46:return i||r||e?!1:i=!0}return S(u)});n&&(o=n+o);var a=O(o);return isNaN(a)?void p("Invalid syntax: "+o):c("num",a)}function h(n){var e=i(!0,n);switch(e.charCodeAt(0)){case 110:return"\n";case 114:return"\r";case 116:return" ";case 98:return"\b";case 118:return" ";case 102:return"\f";case 48:return"\x00";case 120:return String.fromCharCode(_(2));case 117:return String.fromCharCode(_(4));case 10:return"";default:return e}}function _(n){for(var e=0;n>0;--n){var t=parseInt(i(!0),16);isNaN(t)&&p("Invalid hex-character pattern in string"),e=e<<4|t}return e}function m(n){var e,t=D.regex_allowed,r=u("\n");return-1==r?(e=D.text.substr(D.pos),D.pos=D.text.length):(e=D.text.substring(D.pos,r),D.pos=r),D.comments_before.push(c(n,e,!0)),D.regex_allowed=t,E()}function v(){for(var n,e,t=!1,o="",a=!1;null!=(n=r());)if(t)"u"!=n&&p("Expecting UnicodeEscapeSequence -- uXXXX"),n=h(),T(n)||p("Unicode char: "+n.charCodeAt(0)+" is not valid in identifier"),o+=n,t=!1;else if("\\"==n)a=t=!0,i();else{if(!T(n))break;o+=i()}return Dt(o)&&a&&(e=o.charCodeAt(0).toString(16).toUpperCase(),o="\\u"+"0000".substr(e.length)+e+o.slice(1)),o}function g(n){function e(n){if(!r())return n;var t=n+r();return $t(t)?(i(),e(t)):n}return c("operator",e(n||i()))}function b(){switch(i(),r()){case"/":return i(),m("comment1");case"*":return i(),x()}return D.regex_allowed?$(""):g("/")}function y(){return i(),F(r().charCodeAt(0))?d("."):c("punc",".")}function A(){var n=v();return C?c("name",n):Ft(n)?c("atom",n):Dt(n)?$t(n)?c("operator",n):c("keyword",n):c("name",n)}function w(n,e){return function(t){try{return e(t)}catch(r){if(r!==Ht)throw r;p(n)}}}function E(n){if(null!=n)return $(n);if(f(),s(),t){if(a("")&&D.newline_before)return o(3),m("comment4")}var e=r();if(!e)return c("eof");var u=e.charCodeAt(0);switch(u){case 34:case 39:return k();case 46:return y();case 47:return b()}return F(u)?d():Nt(e)?c("punc",i()):kt(e)?g():92==u||B(u)?A():void p("Unexpected character '"+e+"'")}var D={text:n.replace(/\r\n?|[\n\u2028\u2029]/g,"\n").replace(/\uFEFF/g,""),filename:e,pos:0,tokpos:0,line:1,tokline:0,col:0,tokcol:0,newline_before:!1,regex_allowed:!1,comments_before:[]},C=!1,k=w("Unterminated string constant",function(){for(var n=i(),e="";;){var t=i(!0);if("\\"==t){var r=0,o=null;t=l(function(n){if(n>="0"&&"7">=n){if(!o)return o=n,++r;if("3">=o&&2>=r)return++r;if(o>="4"&&1>=r)return++r}return!1}),t=r>0?String.fromCharCode(parseInt(t,8)):h(!0)}else if(t==n)break;e+=t}return c("string",e)}),x=w("Unterminated multiline comment",function(){var n=D.regex_allowed,e=u("*/",!0),t=D.text.substring(D.pos,e),r=t.split("\n"),i=r.length;D.pos=e+2,D.line+=i-1,i>1?D.col=r[i-1].length:D.col+=r[i-1].length,D.col+=2;var o=D.newline_before=D.newline_before||t.indexOf("\n")>=0;return D.comments_before.push(c("comment2",t,!0)),D.regex_allowed=n,D.newline_before=o,E()}),$=w("Unterminated regular expression",function(n){for(var e,t=!1,r=!1;e=i(!0);)if(t)n+="\\"+e,t=!1;else if("["==e)r=!0,n+=e;else if("]"==e&&r)r=!1,n+=e;else{if("/"==e&&!r)break;"\\"==e?t=!0:n+=e}var o=v();return c("regexp",new RegExp(n,o))});return E.context=function(n){return n&&(D=n),D},E}function H(n,e){function t(n,e){return R(I.token,n,e)}function r(){return I.peeked||(I.peeked=I.input())}function i(){return I.prev=I.token,I.peeked?(I.token=I.peeked,I.peeked=null):I.token=I.input(),I.in_directives=I.in_directives&&("string"==I.token.type||t("punc",";")),I.token}function o(){return I.prev}function u(n,e,t,r){var i=I.input.context();N(n,i.filename,null!=e?e:i.tokline,null!=t?t:i.tokcol,null!=r?r:i.tokpos)}function s(n,e){u(e,n.line,n.col)}function f(n){null==n&&(n=I.token),s(n,"Unexpected token: "+n.type+" ("+n.value+")")}function l(n,e){return t(n,e)?i():void s(I.token,"Unexpected token "+I.token.type+" «"+I.token.value+"», expected "+n+" «"+e+"»")}function p(n){return l("punc",n)}function d(){return!e.strict&&(I.token.nlb||t("eof")||t("punc","}"))}function h(){t("punc",";")?i():d()||f()}function _(){p("(");var n=De(!0);return p(")"),n}function m(n){return function(){var e=I.token,t=n(),r=o();return t.start=e,t.end=r,t}}function v(){(t("operator","/")||t("operator","/="))&&(I.peeked=null,I.token=I.input(I.token.value.substr(1)))}function g(){var n=M(ut);a(function(e){return e.name==n.name},I.labels)&&u("Label "+n.name+" defined twice"),p(":"),I.labels.push(n);var e=U();return I.labels.pop(),e instanceof te||n.references.forEach(function(e){e instanceof Ae&&(e=e.label.start,u("Continue label `"+n.name+"` refers to non-IterationStatement.",e.line,e.col,e.pos))}),new ee({body:e,label:n})}function b(n){return new K({body:(n=De(!0),h(),n)})}function y(n){var e,t=null;d()||(t=M(ct,!0)),null!=t?(e=a(function(n){return n.name==t.name},I.labels),e||u("Undefined label "+t.name),t.thedef=e):0==I.in_loop&&u(n.TYPE+" not inside a loop or switch"),h();var r=new n({label:t});return e&&e.references.push(r),r}function A(){p("(");var n=null;return!t("punc",";")&&(n=t("keyword","var")?(i(),L(!0)):De(!0,!0),t("operator","in"))?(n instanceof Te&&n.definitions.length>1&&u("Only one variable declaration allowed in for..in loop"),i(),E(n)):w(n)}function w(n){p(";");var e=t("punc",";")?null:De(!0);p(";");var r=t("punc",")")?null:De(!0);return p(")"),new ae({init:n,condition:e,step:r,body:j(U)})}function E(n){var e=n instanceof Te?n.definitions[0].name:null,t=De(!0);return p(")"),new ue({init:n,name:e,object:t,body:j(U)})}function D(){var n=_(),e=U(),r=null;return t("keyword","else")&&(i(),r=U()),new we({condition:n,body:e,alternative:r})}function F(){p("{");for(var n=[];!t("punc","}");)t("eof")&&f(),n.push(U());return i(),n}function S(){p("{");for(var n,e=[],r=null,a=null;!t("punc","}");)t("eof")&&f(),t("keyword","case")?(a&&(a.end=o()),r=[],a=new Se({start:(n=I.token,i(),n),expression:De(!0),body:r}),e.push(a),p(":")):t("keyword","default")?(a&&(a.end=o()),r=[],a=new Fe({start:(n=I.token,i(),p(":"),n),body:r}),e.push(a)):(r||f(),r.push(U()));return a&&(a.end=o()),i(),e}function C(){var n=F(),e=null,r=null;if(t("keyword","catch")){var a=I.token;i(),p("(");var s=M(at);p(")"),e=new ke({start:a,argname:s,body:F(),end:o()})}if(t("keyword","finally")){var a=I.token;i(),r=new xe({start:a,body:F(),end:o()})}return e||r||u("Missing catch/finally blocks"),new Ce({body:n,bcatch:e,bfinally:r})}function k(n,e){for(var r=[];r.push(new Oe({start:I.token,name:M(e?tt:et),value:t("operator","=")?(i(),De(!1,n)):null,end:o()})),t("punc",",");)i();return r}function x(){var n,e=I.token;switch(e.type){case"name":case"keyword":n=O(st);break;case"num":n=new dt({start:e,end:e,value:e.value});break;case"string":n=new pt({start:e,end:e,value:e.value});break;case"regexp":n=new ht({start:e,end:e,value:e.value});break;case"atom":switch(e.value){case"false":n=new wt({start:e,end:e});break;case"true":n=new Et({start:e,end:e});break;case"null":n=new mt({start:e,end:e})}}return i(),n}function B(n,e,r){for(var o=!0,a=[];!t("punc",n)&&(o?o=!1:p(","),!e||!t("punc",n));)a.push(t("punc",",")&&r?new bt({start:I.token,end:I.token}):De(!1));return i(),a}function T(){var n=I.token;switch(i(),n.type){case"num":case"string":case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function $(){var n=I.token;switch(i(),n.type){case"name":case"operator":case"keyword":case"atom":return n.value;default:f()}}function O(n){var e=I.token.value;return new("this"==e?ft:n)({name:String(e),start:I.token,end:I.token})}function M(n,e){if(!t("name"))return e||u("Name expected"),null;var r=O(n);return i(),r}function H(n,e,t){return"++"!=e&&"--"!=e||P(t)||u("Invalid use of "+e+" operator"),new n({operator:e,expression:t})}function z(n){return _e(le(!0),0,n)}function P(n){return e.strict?n instanceof ft?!1:n instanceof qe||n instanceof Ze:!0}function j(n){++I.in_loop;var e=n();return--I.in_loop,e}e=c(e,{strict:!1,filename:null,toplevel:null,expression:!1,html5_comments:!0});var I={input:"string"==typeof n?q(n,e.filename,e.html5_comments):n,token:null,prev:null,peeked:null,in_function:0,in_directives:!0,in_loop:0,labels:[]};I.token=i();var U=m(function(){var n;switch(v(),I.token.type){case"string":var e=I.in_directives,a=b();return e&&a.body instanceof pt&&!t("punc",",")?new G({value:a.body.value}):a;case"num":case"regexp":case"operator":case"atom":return b();case"name":return R(r(),"punc",":")?g():b();case"punc":switch(I.token.value){case"{":return new Z({start:I.token,body:F(),end:o()});case"[":case"(":return b();case";":return i(),new Q;default:f()}case"keyword":switch(n=I.token.value,i(),n){case"break":return y(ye);case"continue":return y(Ae);case"debugger":return h(),new X;case"do":return new ie({body:j(U),condition:(l("keyword","while"),n=_(),h(),n)});case"while":return new oe({condition:_(),body:j(U)});case"for":return A();case"function":return V(he);case"if":return D();case"return":return 0==I.in_function&&u("'return' outside of function"),new ve({value:t("punc",";")?(i(),null):d()?null:(n=De(!0),h(),n)});case"switch":return new Ee({expression:_(),body:j(S)});case"throw":return I.token.nlb&&u("Illegal newline after 'throw'"),new ge({value:(n=De(!0),h(),n)});case"try":return C();case"var":return n=L(),h(),n;case"const":return n=W(),h(),n;case"with":return new se({expression:_(),body:U()});default:f()}}}),V=function(n){var e=n===he,r=t("name")?M(e?it:ot):null;return e&&!r&&f(),p("("),new n({name:r,argnames:function(n,e){for(;!t("punc",")");)n?n=!1:p(","),e.push(M(rt));return i(),e}(!0,[]),body:function(n,e){++I.in_function,I.in_directives=!0,I.in_loop=0,I.labels=[];var t=F();return--I.in_function,I.in_loop=n,I.labels=e,t}(I.in_loop,I.labels)})},L=function(n){return new Te({start:o(),definitions:k(n,!1),end:o()})},W=function(){return new $e({start:o(),definitions:k(!1,!0),end:o()})},Y=function(){var n=I.token;l("operator","new");var e,r=J(!1);return t("punc","(")?(i(),e=B(")")):e=[],ce(new Ne({start:n,expression:r,args:e,end:o()}),!0)},J=function(n){if(t("operator","new"))return Y();var e=I.token;if(t("punc")){switch(e.value){case"(":i();var r=De(!0);return r.start=e,r.end=I.token,p(")"),ce(r,n);case"[":return ce(ne(),n);case"{":return ce(re(),n)}f()}if(t("keyword","function")){i();var a=V(de);return a.start=e,a.end=o(),ce(a,n)}return Vt[I.token.type]?ce(x(),n):void f()},ne=m(function(){return p("["),new We({elements:B("]",!e.strict,!0)})}),re=m(function(){p("{");for(var n=!0,r=[];!t("punc","}")&&(n?n=!1:p(","),e.strict||!t("punc","}"));){var a=I.token,u=a.type,s=T();if("name"==u&&!t("punc",":")){if("get"==s){r.push(new Je({start:a,key:x(),value:V(pe),end:o()}));continue}if("set"==s){r.push(new Ke({start:a,key:x(),value:V(pe),end:o()}));continue}}p(":"),r.push(new Ge({start:a,key:s,value:De(!1),end:o()}))}return i(),new Ye({properties:r})}),ce=function(n,e){var r=n.start;if(t("punc","."))return i(),ce(new He({start:r,expression:n,property:$(),end:o()}),e);if(t("punc","[")){i();var a=De(!0);return p("]"),ce(new ze({start:r,expression:n,property:a,end:o()}),e)}return e&&t("punc","(")?(i(),ce(new Me({start:r,expression:n,args:B(")"),end:o()}),!0)):n},le=function(n){var e=I.token;if(t("operator")&&zt(e.value)){i(),v();var r=H(je,e.value,le(n));return r.start=e,r.end=o(),r}for(var a=J(n);t("operator")&&Pt(I.token.value)&&!I.token.nlb;)a=H(Ie,I.token.value,a),a.start=e,a.end=I.token,i();return a},_e=function(n,e,r){var o=t("operator")?I.token.value:null;"in"==o&&r&&(o=null);var a=null!=o?It[o]:null;if(null!=a&&a>e){i();var u=_e(le(!0),a,r);return _e(new Ue({start:n.start,left:n,operator:o,right:u,end:u.end}),e,r)}return n},me=function(n){var e=I.token,r=z(n);if(t("operator","?")){i();var a=De(!1);return p(":"),new Ve({start:e,condition:r,consequent:a,alternative:De(!1,n),end:o()})}return r},be=function(n){var e=I.token,r=me(n),a=I.token.value;if(t("operator")&&jt(a)){if(P(r))return i(),new Le({start:e,left:r,operator:a,right:be(n),end:o()});u("Invalid assignment")}return r},De=function(n,e){var o=I.token,a=be(e);return n&&t("punc",",")?(i(),new Re({start:o,car:a,cdr:De(!0,e),end:r()})):a};return e.expression?De(!0):function(){for(var n=I.token,r=[];!t("eof");)r.push(U());var i=o(),a=e.toplevel;return a?(a.body=a.body.concat(r),a.end=i):a=new fe({start:n,body:r,end:i}),a}()}function z(n,e){E.call(this),this.before=n,this.after=e}function P(n,e,t){this.name=t.name,this.orig=[t],this.scope=n,this.references=[],this.global=!1,this.mangled_name=null,this.undeclared=!1,this.constant=!1,this.index=e}function j(n){function e(n,e){return n.replace(/[\u0080-\uffff]/g,function(n){var t=n.charCodeAt(0).toString(16);if(t.length<=2&&!e){for(;t.length<2;)t="0"+t;return"\\x"+t}for(;t.length<4;)t="0"+t;return"\\u"+t})}function t(t){var r=0,i=0;return t=t.replace(/[\\\b\f\n\r\t\x22\x27\u2028\u2029\0]/g,function(n){switch(n){case"\\":return"\\\\";case"\b":return"\\b";case"\f":return"\\f";case"\n":return"\\n";case"\r":return"\\r";case"\u2028":return"\\u2028";case"\u2029":return"\\u2029";case'"':return++r,'"';case"'":return++i,"'";case"\x00":return"\\x00"}return n}),n.ascii_only&&(t=e(t)),r>i?"'"+t.replace(/\x27/g,"\\'")+"'":'"'+t.replace(/\x22/g,'\\"')+'"'}function r(e){var r=t(e);return n.inline_script&&(r=r.replace(/<\x2fscript([>\/\t\n\f\r ])/gi,"<\\/script$1")),r}function i(t){return t=t.toString(),n.ascii_only&&(t=e(t,!0)),t}function o(e){return u(" ",n.indent_start+A-e*n.indent_level)}function a(){return k.charAt(k.length-1)}function s(){n.max_line_len&&w>n.max_line_len&&f("\n")}function f(e){e=String(e);var t=e.charAt(0);if(C&&(t&&!(";}".indexOf(t)<0)||/[;]$/.test(k)||(n.semicolons||x(t)?(F+=";",w++,D++):(F+="\n",D++,E++,w=0),n.beautify||(S=!1)),C=!1,s()),!n.beautify&&n.preserve_line&&q[q.length-1])for(var r=q[q.length-1].start.line;r>E;)F+="\n",D++,E++,w=0,S=!1;if(S){var i=a();(T(i)&&(T(t)||"\\"==t)||/^[\+\-\/]$/.test(t)&&t==i)&&(F+=" ",w++,D++),S=!1}var o=e.split(/\r?\n/),u=o.length-1;E+=u,0==u?w+=o[u].length:w=o[u].length,D+=e.length,k=e,F+=e}function p(){C=!1,f(";")}function d(){return A+n.indent_level}function h(n){var e;return f("{"),M(),O(d(),function(){e=n()}),$(),f("}"),e}function _(n){f("(");var e=n();return f(")"),e}function m(n){f("[");var e=n();return f("]"),e}function v(){f(","),B()}function b(){f(":"),n.space_colon&&B()}function y(){return F}n=c(n,{indent_start:0,indent_level:4,quote_keys:!1,space_colon:!0,ascii_only:!1,unescape_regexps:!1,inline_script:!1,width:80,max_line_len:32e3,beautify:!1,source_map:null,bracketize:!1,semicolons:!0,comments:!1,preserve_line:!1,screw_ie8:!1,preamble:null},!0);var A=0,w=0,E=1,D=0,F="",S=!1,C=!1,k=null,x=g("( [ + * / - , ."),B=n.beautify?function(){f(" ")}:function(){S=!0},$=n.beautify?function(e){n.beautify&&f(o(e?.5:0))}:l,O=n.beautify?function(n,e){n===!0&&(n=d());var t=A;A=n;var r=e();return A=t,r}:function(n,e){return e()},M=n.beautify?function(){f("\n")}:l,N=n.beautify?function(){f(";")}:function(){C=!0},R=n.source_map?function(e,t){try{e&&n.source_map.add(e.file||"?",E,w,e.line,e.col,t||"name"!=e.type?t:e.value)}catch(r){W.warn("Couldn't figure out mapping for {file}:{line},{col} → {cline},{ccol} [{name}]",{file:e.file,line:e.line,col:e.col,cline:E,ccol:w,name:t||""})}}:l;n.preamble&&f(n.preamble.replace(/\r\n?|[\n\u2028\u2029]|\s*$/g,"\n"));var q=[];return{get:y,toString:y,indent:$,indentation:function(){return A},current_width:function(){return w-A},should_break:function(){return n.width&&this.current_width()>=n.width},newline:M,print:f,space:B,comma:v,colon:b,last:function(){return k},semicolon:N,force_semicolon:p,to_ascii:e,print_name:function(n){f(i(n))},print_string:function(n){f(r(n))},next_indent:d,with_indent:O,with_block:h,with_parens:_,with_square:m,add_mapping:R,option:function(e){return n[e]},line:function(){return E},col:function(){return w},pos:function(){return D},push_node:function(n){q.push(n)},pop_node:function(){return q.pop()},stack:function(){return q},parent:function(n){return q[q.length-2-(n||0)]}}}function I(n,e){return this instanceof I?(z.call(this,this.before,this.after),void(this.options=c(n,{sequences:!e,properties:!e,dead_code:!e,drop_debugger:!e,unsafe:!1,unsafe_comps:!1,conditionals:!e,comparisons:!e,evaluate:!e,booleans:!e,loops:!e,unused:!e,hoist_funs:!e,keep_fargs:!1,hoist_vars:!1,if_return:!e,join_vars:!e,cascade:!e,side_effects:!e,pure_getters:!1,pure_funcs:null,negate_iife:!e,screw_ie8:!1,drop_console:!1,angular:!1,warnings:!0,global_defs:{}},!0))):new I(n,e)}function U(n){function e(e,i,o,a,u,s){if(r){var c=r.originalPositionFor({line:a,column:u});if(null===c.source)return;e=c.source,a=c.line,u=c.column,s=c.name}t.addMapping({generated:{line:i+n.dest_line_diff,column:o},original:{line:a+n.orig_line_diff,column:u},source:e,name:s})}n=c(n,{file:null,root:null,orig:null,orig_line_diff:0,dest_line_diff:0});var t=new MOZ_SourceMap.SourceMapGenerator({file:n.file,sourceRoot:n.root}),r=n.orig&&new MOZ_SourceMap.SourceMapConsumer(n.orig);return{add:e,get:function(){return t},toString:function(){return t.toString()}}}e.UglifyJS=n,s.prototype=Object.create(Error.prototype),s.prototype.constructor=s,s.croak=function(n,e){throw new s(n,e)};var V=function(){function n(n,o,a){function u(){var u=o(n[s],s),l=u instanceof r;return l&&(u=u.v),u instanceof e?(u=u.v,u instanceof t?f.push.apply(f,a?u.v.slice().reverse():u.v):f.push(u)):u!==i&&(u instanceof t?c.push.apply(c,a?u.v.slice().reverse():u.v):c.push(u)),l}var s,c=[],f=[];if(n instanceof Array)if(a){for(s=n.length;--s>=0&&!u(););c.reverse(),f.reverse()}else for(s=0;s SymbolDef for all variables/functions defined in this scope",functions:"[Object/S] like `variables`, but only lists function declarations",uses_with:"[boolean/S] tells whether this scope uses the `with` statement",uses_eval:"[boolean/S] tells whether this scope contains a direct call to the global `eval`",parent_scope:"[AST_Scope?/S] link to the parent scope",enclosed:"[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes",cname:"[integer/S] current index for mangling variables (used internally by the mangler)"}},J),fe=A("Toplevel","globals",{$documentation:"The toplevel scope",$propdoc:{globals:"[Object/S] a map of name -> SymbolDef for all undeclared names"},wrap_enclose:function(n){var e=this,t=[],r=[];n.forEach(function(n){var e=n.split(":");t.push(e[0]),r.push(e[1])});var i="(function("+r.join(",")+"){ '$ORIG'; })("+t.join(",")+")";return i=H(i),i=i.transform(new z(function(n){return n instanceof G&&"$ORIG"==n.value?V.splice(e.body):void 0}))},wrap_commonjs:function(n,e){var t=this,r=[];e&&(t.figure_out_scope(),t.walk(new E(function(n){n instanceof nt&&n.definition().global&&(a(function(e){return e.name==n.name},r)||r.push(n))})));var i="(function(exports, global){ global['"+n+"'] = exports; '$ORIG'; '$EXPORTS'; }({}, (function(){return this}())))";return i=H(i),i=i.transform(new z(function(n){if(n instanceof K&&(n=n.body,n instanceof pt))switch(n.getValue()){case"$ORIG":return V.splice(t.body);case"$EXPORTS":var e=[];return r.forEach(function(n){e.push(new K({body:new Le({left:new ze({expression:new st({name:"exports"}),property:new pt({value:n.name})}),operator:"=",right:new st(n)})}))}),V.splice(e)}}))}},ce),le=A("Lambda","name argnames uses_arguments",{$documentation:"Base class for functions",$propdoc:{name:"[AST_SymbolDeclaration?] the name of this function",argnames:"[AST_SymbolFunarg*] array of function arguments",uses_arguments:"[boolean/S] tells whether this function accesses the arguments array"},_walk:function(n){return n._visit(this,function(){this.name&&this.name._walk(n),this.argnames.forEach(function(e){e._walk(n)}),w(this,n)})}},ce),pe=A("Accessor",null,{$documentation:"A setter/getter function. The `name` property is always null."},le),de=A("Function",null,{$documentation:"A function expression"},le),he=A("Defun",null,{$documentation:"A function definition"},le),_e=A("Jump",null,{$documentation:"Base class for “jumps” (for now that's `return`, `throw`, `break` and `continue`)"},Y),me=A("Exit","value",{$documentation:"Base class for “exits” (`return` and `throw`)",$propdoc:{value:"[AST_Node?] the value returned or thrown by this statement; could be null for AST_Return"},_walk:function(n){return n._visit(this,this.value&&function(){this.value._walk(n)})}},_e),ve=A("Return",null,{$documentation:"A `return` statement"},me),ge=A("Throw",null,{$documentation:"A `throw` statement"},me),be=A("LoopControl","label",{$documentation:"Base class for loop control statements (`break` and `continue`)",$propdoc:{label:"[AST_LabelRef?] the label, or null if none"},_walk:function(n){return n._visit(this,this.label&&function(){this.label._walk(n)})}},_e),ye=A("Break",null,{$documentation:"A `break` statement"},be),Ae=A("Continue",null,{$documentation:"A `continue` statement"},be),we=A("If","condition alternative",{$documentation:"A `if` statement",$propdoc:{condition:"[AST_Node] the `if` condition",alternative:"[AST_Statement?] the `else` part, or null if not present"},_walk:function(n){return n._visit(this,function(){this.condition._walk(n),this.body._walk(n),this.alternative&&this.alternative._walk(n)})}},ne),Ee=A("Switch","expression",{$documentation:"A `switch` statement",$propdoc:{expression:"[AST_Node] the `switch` “discriminant”"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),w(this,n)})}},J),De=A("SwitchBranch",null,{$documentation:"Base class for `switch` branches"},J),Fe=A("Default",null,{$documentation:"A `default` switch branch"},De),Se=A("Case","expression",{$documentation:"A `case` switch branch",$propdoc:{expression:"[AST_Node] the `case` expression"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),w(this,n)})}},De),Ce=A("Try","bcatch bfinally",{$documentation:"A `try` statement",$propdoc:{bcatch:"[AST_Catch?] the catch block, or null if not present",bfinally:"[AST_Finally?] the finally block, or null if not present"},_walk:function(n){return n._visit(this,function(){w(this,n),this.bcatch&&this.bcatch._walk(n),this.bfinally&&this.bfinally._walk(n)})}},J),ke=A("Catch","argname",{$documentation:"A `catch` node; only makes sense as part of a `try` statement",$propdoc:{argname:"[AST_SymbolCatch] symbol for the exception"},_walk:function(n){return n._visit(this,function(){this.argname._walk(n),w(this,n) 2 | })}},J),xe=A("Finally",null,{$documentation:"A `finally` node; only makes sense as part of a `try` statement"},J),Be=A("Definitions","definitions",{$documentation:"Base class for `var` or `const` nodes (variable declarations/initializations)",$propdoc:{definitions:"[AST_VarDef*] array of variable definitions"},_walk:function(n){return n._visit(this,function(){this.definitions.forEach(function(e){e._walk(n)})})}},Y),Te=A("Var",null,{$documentation:"A `var` statement"},Be),$e=A("Const",null,{$documentation:"A `const` statement"},Be),Oe=A("VarDef","name value",{$documentation:"A variable declaration; only appears in a AST_Definitions node",$propdoc:{name:"[AST_SymbolVar|AST_SymbolConst] name of the variable",value:"[AST_Node?] initializer, or null of there's no initializer"},_walk:function(n){return n._visit(this,function(){this.name._walk(n),this.value&&this.value._walk(n)})}}),Me=A("Call","expression args",{$documentation:"A function call expression",$propdoc:{expression:"[AST_Node] expression to invoke as function",args:"[AST_Node*] array of arguments"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n),this.args.forEach(function(e){e._walk(n)})})}}),Ne=A("New",null,{$documentation:"An object instantiation. Derives from a function call since it has exactly the same properties"},Me),Re=A("Seq","car cdr",{$documentation:"A sequence expression (two comma-separated expressions)",$propdoc:{car:"[AST_Node] first element in sequence",cdr:"[AST_Node] second element in sequence"},$cons:function(n,e){var t=new Re(n);return t.car=n,t.cdr=e,t},$from_array:function(n){if(0==n.length)return null;if(1==n.length)return n[0].clone();for(var e=null,t=n.length;--t>=0;)e=Re.cons(n[t],e);for(var r=e;r;){if(r.cdr&&!r.cdr.cdr){r.cdr=r.cdr.car;break}r=r.cdr}return e},to_array:function(){for(var n=this,e=[];n;){if(e.push(n.car),n.cdr&&!(n.cdr instanceof Re)){e.push(n.cdr);break}n=n.cdr}return e},add:function(n){for(var e=this;e;){if(!(e.cdr instanceof Re)){var t=Re.cons(e.cdr,n);return e.cdr=t}e=e.cdr}},_walk:function(n){return n._visit(this,function(){this.car._walk(n),this.cdr&&this.cdr._walk(n)})}}),qe=A("PropAccess","expression property",{$documentation:'Base class for property access expressions, i.e. `a.foo` or `a["foo"]`',$propdoc:{expression:"[AST_Node] the “container” expression",property:"[AST_Node|string] the property to access. For AST_Dot this is always a plain string, while for AST_Sub it's an arbitrary AST_Node"}}),He=A("Dot",null,{$documentation:"A dotted property access expression",_walk:function(n){return n._visit(this,function(){this.expression._walk(n)})}},qe),ze=A("Sub",null,{$documentation:'Index-style property access, i.e. `a["foo"]`',_walk:function(n){return n._visit(this,function(){this.expression._walk(n),this.property._walk(n)})}},qe),Pe=A("Unary","operator expression",{$documentation:"Base class for unary expressions",$propdoc:{operator:"[string] the operator",expression:"[AST_Node] expression that this unary operator applies to"},_walk:function(n){return n._visit(this,function(){this.expression._walk(n)})}}),je=A("UnaryPrefix",null,{$documentation:"Unary prefix expression, i.e. `typeof i` or `++i`"},Pe),Ie=A("UnaryPostfix",null,{$documentation:"Unary postfix expression, i.e. `i++`"},Pe),Ue=A("Binary","left operator right",{$documentation:"Binary expression, i.e. `a + b`",$propdoc:{left:"[AST_Node] left-hand side expression",operator:"[string] the operator",right:"[AST_Node] right-hand side expression"},_walk:function(n){return n._visit(this,function(){this.left._walk(n),this.right._walk(n)})}}),Ve=A("Conditional","condition consequent alternative",{$documentation:"Conditional expression using the ternary operator, i.e. `a ? b : c`",$propdoc:{condition:"[AST_Node]",consequent:"[AST_Node]",alternative:"[AST_Node]"},_walk:function(n){return n._visit(this,function(){this.condition._walk(n),this.consequent._walk(n),this.alternative._walk(n)})}}),Le=A("Assign",null,{$documentation:"An assignment expression — `a = b + 5`"},Ue),We=A("Array","elements",{$documentation:"An array literal",$propdoc:{elements:"[AST_Node*] array of elements"},_walk:function(n){return n._visit(this,function(){this.elements.forEach(function(e){e._walk(n)})})}}),Ye=A("Object","properties",{$documentation:"An object literal",$propdoc:{properties:"[AST_ObjectProperty*] array of properties"},_walk:function(n){return n._visit(this,function(){this.properties.forEach(function(e){e._walk(n)})})}}),Xe=A("ObjectProperty","key value",{$documentation:"Base class for literal object properties",$propdoc:{key:"[string] the property name converted to a string for ObjectKeyVal. For setters and getters this is an arbitrary AST_Node.",value:"[AST_Node] property value. For setters and getters this is an AST_Function."},_walk:function(n){return n._visit(this,function(){this.value._walk(n)})}}),Ge=A("ObjectKeyVal",null,{$documentation:"A key: value object property"},Xe),Ke=A("ObjectSetter",null,{$documentation:"An object setter property"},Xe),Je=A("ObjectGetter",null,{$documentation:"An object getter property"},Xe),Ze=A("Symbol","scope name thedef",{$propdoc:{name:"[string] name of this symbol",scope:"[AST_Scope/S] the current scope (not necessarily the definition scope)",thedef:"[SymbolDef/S] the definition of this symbol"},$documentation:"Base class for all symbols"}),Qe=A("SymbolAccessor",null,{$documentation:"The name of a property accessor (setter/getter function)"},Ze),nt=A("SymbolDeclaration","init",{$documentation:"A declaration symbol (symbol in var/const, function name or argument, symbol in catch)",$propdoc:{init:"[AST_Node*/S] array of initializers for this declaration."}},Ze),et=A("SymbolVar",null,{$documentation:"Symbol defining a variable"},nt),tt=A("SymbolConst",null,{$documentation:"A constant declaration"},nt),rt=A("SymbolFunarg",null,{$documentation:"Symbol naming a function argument"},et),it=A("SymbolDefun",null,{$documentation:"Symbol defining a function"},nt),ot=A("SymbolLambda",null,{$documentation:"Symbol naming a function expression"},nt),at=A("SymbolCatch",null,{$documentation:"Symbol naming the exception in catch"},nt),ut=A("Label","references",{$documentation:"Symbol naming a label (declaration)",$propdoc:{references:"[AST_LoopControl*] a list of nodes referring to this label"},initialize:function(){this.references=[],this.thedef=this}},Ze),st=A("SymbolRef",null,{$documentation:"Reference to some symbol (not definition/declaration)"},Ze),ct=A("LabelRef",null,{$documentation:"Reference to a label symbol"},Ze),ft=A("This",null,{$documentation:"The `this` symbol"},Ze),lt=A("Constant",null,{$documentation:"Base class for all constants",getValue:function(){return this.value}}),pt=A("String","value",{$documentation:"A string literal",$propdoc:{value:"[string] the contents of this string"}},lt),dt=A("Number","value",{$documentation:"A number literal",$propdoc:{value:"[number] the numeric value"}},lt),ht=A("RegExp","value",{$documentation:"A regexp literal",$propdoc:{value:"[RegExp] the actual regexp"}},lt),_t=A("Atom",null,{$documentation:"Base class for atoms"},lt),mt=A("Null",null,{$documentation:"The `null` atom",value:null},_t),vt=A("NaN",null,{$documentation:"The impossible value",value:0/0},_t),gt=A("Undefined",null,{$documentation:"The `undefined` value",value:void 0},_t),bt=A("Hole",null,{$documentation:"A hole in an array",value:void 0},_t),yt=A("Infinity",null,{$documentation:"The `Infinity` value",value:1/0},_t),At=A("Boolean",null,{$documentation:"Base class for booleans"},_t),wt=A("False",null,{$documentation:"The `false` atom",value:!1},At),Et=A("True",null,{$documentation:"The `true` atom",value:!0},At);E.prototype={_visit:function(n,e){this.stack.push(n);var t=this.visit(n,e?function(){e.call(n)}:l);return!t&&e&&e.call(n),this.stack.pop(),t},parent:function(n){return this.stack[this.stack.length-2-(n||0)]},push:function(n){this.stack.push(n)},pop:function(){return this.stack.pop()},self:function(){return this.stack[this.stack.length-1]},find_parent:function(n){for(var e=this.stack,t=e.length;--t>=0;){var r=e[t];if(r instanceof n)return r}},has_directive:function(n){return this.find_parent(ce).has_directive(n)},in_boolean_context:function(){for(var n=this.stack,e=n.length,t=n[--e];e>0;){var r=n[--e];if(r instanceof we&&r.condition===t||r instanceof Ve&&r.condition===t||r instanceof re&&r.condition===t||r instanceof ae&&r.condition===t||r instanceof je&&"!"==r.operator&&r.expression===t)return!0;if(!(r instanceof Ue)||"&&"!=r.operator&&"||"!=r.operator)return!1;t=r}},loopcontrol_target:function(n){var e=this.stack;if(n)for(var t=e.length;--t>=0;){var r=e[t];if(r instanceof ee&&r.label.name==n.name)return r.body}else for(var t=e.length;--t>=0;){var r=e[t];if(r instanceof Ee||r instanceof te)return r}}};var Dt="break case catch const continue debugger default delete do else finally for function if in instanceof new return switch throw try typeof var void while with",Ft="false null true",St="abstract boolean byte char class double enum export extends final float goto implements import int interface long native package private protected public short static super synchronized this throws transient volatile yield "+Ft+" "+Dt,Ct="return new delete throw else case";Dt=g(Dt),St=g(St),Ct=g(Ct),Ft=g(Ft);var kt=g(i("+-*&%=<>!?|~^")),xt=/^0x[0-9a-f]+$/i,Bt=/^0[0-7]+$/,Tt=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i,$t=g(["in","instanceof","typeof","new","void","delete","++","--","+","-","!","~","&","|","^","*","/","%",">>","<<",">>>","<",">","<=",">=","==","===","!=","!==","?","=","+=","-=","/=","*=","%=",">>=","<<=",">>>=","|=","^=","&=","&&","||"]),Ot=g(i("  \n\r \f ​᠎              ")),Mt=g(i("[{(,.;:")),Nt=g(i("[]{}(),;:")),Rt=g(i("gmsiy")),qt={letter:new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\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\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\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\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\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-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\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-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\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]"),non_spacing_mark:new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),space_combining_mark:new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),connector_punctuation:new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")};M.prototype.toString=function(){return this.message+" (line: "+this.line+", col: "+this.col+", pos: "+this.pos+")\n\n"+this.stack};var Ht={},zt=g(["typeof","void","delete","--","++","!","~","-","+"]),Pt=g(["--","++"]),jt=g(["=","+=","-=","/=","*=","%=",">>=","<<=",">>>=","|=","^=","&="]),It=function(n,e){for(var t=0;t","<=",">=","in","instanceof"],[">>","<<",">>>"],["+","-"],["*","/","%"]],{}),Ut=t(["for","do","while","switch"]),Vt=t(["atom","num","string","regexp","name"]);z.prototype=new E,function(n){function e(e,t){e.DEFMETHOD("transform",function(e,r){var i,o;return e.push(this),e.before&&(i=e.before(this,t,r)),i===n&&(e.after?(e.stack[e.stack.length-1]=i=this.clone(),t(i,e),o=e.after(i,r),o!==n&&(i=o)):(i=this,t(i,e))),e.pop(),i})}function t(n,e){return V(n,function(n){return n.transform(e,!0)})}e(W,l),e(ee,function(n,e){n.label=n.label.transform(e),n.body=n.body.transform(e)}),e(K,function(n,e){n.body=n.body.transform(e)}),e(J,function(n,e){n.body=t(n.body,e)}),e(re,function(n,e){n.condition=n.condition.transform(e),n.body=n.body.transform(e)}),e(ae,function(n,e){n.init&&(n.init=n.init.transform(e)),n.condition&&(n.condition=n.condition.transform(e)),n.step&&(n.step=n.step.transform(e)),n.body=n.body.transform(e)}),e(ue,function(n,e){n.init=n.init.transform(e),n.object=n.object.transform(e),n.body=n.body.transform(e)}),e(se,function(n,e){n.expression=n.expression.transform(e),n.body=n.body.transform(e)}),e(me,function(n,e){n.value&&(n.value=n.value.transform(e))}),e(be,function(n,e){n.label&&(n.label=n.label.transform(e))}),e(we,function(n,e){n.condition=n.condition.transform(e),n.body=n.body.transform(e),n.alternative&&(n.alternative=n.alternative.transform(e))}),e(Ee,function(n,e){n.expression=n.expression.transform(e),n.body=t(n.body,e)}),e(Se,function(n,e){n.expression=n.expression.transform(e),n.body=t(n.body,e)}),e(Ce,function(n,e){n.body=t(n.body,e),n.bcatch&&(n.bcatch=n.bcatch.transform(e)),n.bfinally&&(n.bfinally=n.bfinally.transform(e))}),e(ke,function(n,e){n.argname=n.argname.transform(e),n.body=t(n.body,e)}),e(Be,function(n,e){n.definitions=t(n.definitions,e)}),e(Oe,function(n,e){n.name=n.name.transform(e),n.value&&(n.value=n.value.transform(e))}),e(le,function(n,e){n.name&&(n.name=n.name.transform(e)),n.argnames=t(n.argnames,e),n.body=t(n.body,e)}),e(Me,function(n,e){n.expression=n.expression.transform(e),n.args=t(n.args,e)}),e(Re,function(n,e){n.car=n.car.transform(e),n.cdr=n.cdr.transform(e)}),e(He,function(n,e){n.expression=n.expression.transform(e)}),e(ze,function(n,e){n.expression=n.expression.transform(e),n.property=n.property.transform(e)}),e(Pe,function(n,e){n.expression=n.expression.transform(e)}),e(Ue,function(n,e){n.left=n.left.transform(e),n.right=n.right.transform(e)}),e(Ve,function(n,e){n.condition=n.condition.transform(e),n.consequent=n.consequent.transform(e),n.alternative=n.alternative.transform(e)}),e(We,function(n,e){n.elements=t(n.elements,e)}),e(Ye,function(n,e){n.properties=t(n.properties,e)}),e(Xe,function(n,e){n.value=n.value.transform(e)})}(),P.prototype={unmangleable:function(n){return this.global&&!(n&&n.toplevel)||this.undeclared||!(n&&n.eval)&&(this.scope.uses_eval||this.scope.uses_with)},mangle:function(n){if(!this.mangled_name&&!this.unmangleable(n)){var e=this.scope;!n.screw_ie8&&this.orig[0]instanceof ot&&(e=e.parent_scope),this.mangled_name=e.next_mangled(n,this)}}},fe.DEFMETHOD("figure_out_scope",function(n){n=c(n,{screw_ie8:!1});var e=this,t=e.parent_scope=null,r=null,i=0,o=new E(function(e,a){if(n.screw_ie8&&e instanceof ke){var u=t;return t=new ce(e),t.init_scope_vars(i),t.parent_scope=u,a(),t=u,!0}if(e instanceof ce){e.init_scope_vars(i);var u=e.parent_scope=t,s=r;return r=t=e,++i,a(),--i,t=u,r=s,!0}if(e instanceof G)return e.scope=t,p(t.directives,e.value),!0;if(e instanceof se)for(var c=t;c;c=c.parent_scope)c.uses_with=!0;else if(e instanceof Ze&&(e.scope=t),e instanceof ot)r.def_function(e);else if(e instanceof it)(e.scope=r.parent_scope).def_function(e);else if(e instanceof et||e instanceof tt){var f=r.def_variable(e);f.constant=e instanceof tt,f.init=o.parent().value}else e instanceof at&&(n.screw_ie8?t:r).def_variable(e)});e.walk(o);var a=null,u=e.globals=new y,o=new E(function(n,t){if(n instanceof le){var r=a;return a=n,t(),a=r,!0}if(n instanceof st){var i=n.name,s=n.scope.find_variable(i);if(s)n.thedef=s;else{var c;if(u.has(i)?c=u.get(i):(c=new P(e,u.size(),n),c.undeclared=!0,c.global=!0,u.set(i,c)),n.thedef=c,"eval"==i&&o.parent()instanceof Me)for(var f=n.scope;f&&!f.uses_eval;f=f.parent_scope)f.uses_eval=!0;a&&"arguments"==i&&(a.uses_arguments=!0)}return n.reference(),!0}});e.walk(o)}),ce.DEFMETHOD("init_scope_vars",function(n){this.directives=[],this.variables=new y,this.functions=new y,this.uses_with=!1,this.uses_eval=!1,this.parent_scope=null,this.enclosed=[],this.cname=-1,this.nesting=n}),ce.DEFMETHOD("strict",function(){return this.has_directive("use strict")}),le.DEFMETHOD("init_scope_vars",function(){ce.prototype.init_scope_vars.apply(this,arguments),this.uses_arguments=!1}),st.DEFMETHOD("reference",function(){var n=this.definition();n.references.push(this);for(var e=this.scope;e&&(p(e.enclosed,n),e!==n.scope);)e=e.parent_scope;this.frame=this.scope.nesting-n.scope.nesting}),ce.DEFMETHOD("find_variable",function(n){return n instanceof Ze&&(n=n.name),this.variables.get(n)||this.parent_scope&&this.parent_scope.find_variable(n)}),ce.DEFMETHOD("has_directive",function(n){return this.parent_scope&&this.parent_scope.has_directive(n)||(this.directives.indexOf(n)>=0?this:null)}),ce.DEFMETHOD("def_function",function(n){this.functions.set(n.name,this.def_variable(n))}),ce.DEFMETHOD("def_variable",function(n){var e;return this.variables.has(n.name)?(e=this.variables.get(n.name),e.orig.push(n)):(e=new P(this,this.variables.size(),n),this.variables.set(n.name,e),e.global=!this.parent_scope),n.thedef=e}),ce.DEFMETHOD("next_mangled",function(n){var e=this.enclosed;n:for(;;){var t=Lt(++this.cname);if(x(t)&&!(n.except.indexOf(t)>=0)){for(var r=e.length;--r>=0;){var i=e[r],o=i.mangled_name||i.unmangleable(n)&&i.name;if(t==o)continue n}return t}}}),de.DEFMETHOD("next_mangled",function(n,e){for(var t=e.orig[0]instanceof rt&&this.name&&this.name.definition();;){var r=le.prototype.next_mangled.call(this,n,e);if(!t||t.mangled_name!=r)return r}}),ce.DEFMETHOD("references",function(n){return n instanceof Ze&&(n=n.definition()),this.enclosed.indexOf(n)<0?null:n}),Ze.DEFMETHOD("unmangleable",function(n){return this.definition().unmangleable(n)}),Qe.DEFMETHOD("unmangleable",function(){return!0}),ut.DEFMETHOD("unmangleable",function(){return!1}),Ze.DEFMETHOD("unreferenced",function(){return 0==this.definition().references.length&&!(this.scope.uses_eval||this.scope.uses_with)}),Ze.DEFMETHOD("undeclared",function(){return this.definition().undeclared}),ct.DEFMETHOD("undeclared",function(){return!1}),ut.DEFMETHOD("undeclared",function(){return!1}),Ze.DEFMETHOD("definition",function(){return this.thedef}),Ze.DEFMETHOD("global",function(){return this.definition().global}),fe.DEFMETHOD("_default_mangler_options",function(n){return c(n,{except:[],eval:!1,sort:!1,toplevel:!1,screw_ie8:!1})}),fe.DEFMETHOD("mangle_names",function(n){n=this._default_mangler_options(n);var e=-1,t=[],r=new E(function(i,o){if(i instanceof ee){var a=e;return o(),e=a,!0}if(i instanceof ce){var u=(r.parent(),[]);return i.variables.each(function(e){n.except.indexOf(e.name)<0&&u.push(e)}),n.sort&&u.sort(function(n,e){return e.references.length-n.references.length}),void t.push.apply(t,u)}if(i instanceof ut){var s;do s=Lt(++e);while(!x(s));return i.mangled_name=s,!0}return n.screw_ie8&&i instanceof at?void t.push(i.definition()):void 0});this.walk(r),t.forEach(function(e){e.mangle(n)})}),fe.DEFMETHOD("compute_char_frequency",function(n){n=this._default_mangler_options(n);var e=new E(function(e){e instanceof lt?Lt.consider(e.print_to_string()):e instanceof ve?Lt.consider("return"):e instanceof ge?Lt.consider("throw"):e instanceof Ae?Lt.consider("continue"):e instanceof ye?Lt.consider("break"):e instanceof X?Lt.consider("debugger"):e instanceof G?Lt.consider(e.value):e instanceof oe?Lt.consider("while"):e instanceof ie?Lt.consider("do while"):e instanceof we?(Lt.consider("if"),e.alternative&&Lt.consider("else")):e instanceof Te?Lt.consider("var"):e instanceof $e?Lt.consider("const"):e instanceof le?Lt.consider("function"):e instanceof ae?Lt.consider("for"):e instanceof ue?Lt.consider("for in"):e instanceof Ee?Lt.consider("switch"):e instanceof Se?Lt.consider("case"):e instanceof Fe?Lt.consider("default"):e instanceof se?Lt.consider("with"):e instanceof Ke?Lt.consider("set"+e.key):e instanceof Je?Lt.consider("get"+e.key):e instanceof Ge?Lt.consider(e.key):e instanceof Ne?Lt.consider("new"):e instanceof ft?Lt.consider("this"):e instanceof Ce?Lt.consider("try"):e instanceof ke?Lt.consider("catch"):e instanceof xe?Lt.consider("finally"):e instanceof Ze&&e.unmangleable(n)?Lt.consider(e.name):e instanceof Pe||e instanceof Ue?Lt.consider(e.operator):e instanceof He&&Lt.consider(e.property)});this.walk(e),Lt.sort()});var Lt=function(){function n(){r=Object.create(null),t=i.split("").map(function(n){return n.charCodeAt(0)}),t.forEach(function(n){r[n]=0})}function e(n){var e="",r=54;do e+=String.fromCharCode(t[n%r]),n=Math.floor(n/r),r=64;while(n>0);return e}var t,r,i="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";return e.consider=function(n){for(var e=n.length;--e>=0;){var t=n.charCodeAt(e);t in r&&++r[t]}},e.sort=function(){t=_(t,function(n,e){return F(n)&&!F(e)?1:F(e)&&!F(n)?-1:r[e]-r[n]})},e.reset=n,n(),e.get=function(){return t},e.freq=function(){return r},e}();fe.DEFMETHOD("scope_warnings",function(n){n=c(n,{undeclared:!1,unreferenced:!0,assign_to_global:!0,func_arguments:!0,nested_defuns:!0,eval:!0});var e=new E(function(t){if(n.undeclared&&t instanceof st&&t.undeclared()&&W.warn("Undeclared symbol: {name} [{file}:{line},{col}]",{name:t.name,file:t.start.file,line:t.start.line,col:t.start.col}),n.assign_to_global){var r=null;t instanceof Le&&t.left instanceof st?r=t.left:t instanceof ue&&t.init instanceof st&&(r=t.init),r&&(r.undeclared()||r.global()&&r.scope!==r.definition().scope)&&W.warn("{msg}: {name} [{file}:{line},{col}]",{msg:r.undeclared()?"Accidental global?":"Assignment to global",name:r.name,file:r.start.file,line:r.start.line,col:r.start.col})}n.eval&&t instanceof st&&t.undeclared()&&"eval"==t.name&&W.warn("Eval is used [{file}:{line},{col}]",t.start),n.unreferenced&&(t instanceof nt||t instanceof ut)&&t.unreferenced()&&W.warn("{type} {name} is declared but not referenced [{file}:{line},{col}]",{type:t instanceof ut?"Label":"Symbol",name:t.name,file:t.start.file,line:t.start.line,col:t.start.col}),n.func_arguments&&t instanceof le&&t.uses_arguments&&W.warn("arguments used in function {name} [{file}:{line},{col}]",{name:t.name?t.name.name:"anonymous",file:t.start.file,line:t.start.line,col:t.start.col}),n.nested_defuns&&t instanceof he&&!(e.parent()instanceof ce)&&W.warn('Function {name} declared in nested statement "{type}" [{file}:{line},{col}]',{name:t.name.name,type:e.parent().TYPE,file:t.start.file,line:t.start.line,col:t.start.col})});this.walk(e)}),function(){function n(n,e){n.DEFMETHOD("_codegen",e)}function e(n,e){n.DEFMETHOD("needs_parens",e)}function t(n){var e=n.parent();return e instanceof Pe?!0:e instanceof Ue&&!(e instanceof Le)?!0:e instanceof Me&&e.expression===this?!0:e instanceof Ve&&e.condition===this?!0:e instanceof qe&&e.expression===this?!0:void 0}function r(n,e,t){var r=n.length-1;n.forEach(function(n,i){n instanceof Q||(t.indent(),n.print(t),i==r&&e||(t.newline(),e&&t.newline()))})}function i(n,e){n.length>0?e.with_block(function(){r(n,!1,e)}):e.print("{}")}function o(n,e){if(e.option("bracketize"))return void h(n.body,e);if(!n.body)return e.force_semicolon();if(n.body instanceof ie&&!e.option("screw_ie8"))return void h(n.body,e);for(var t=n.body;;)if(t instanceof we){if(!t.alternative)return void h(n.body,e);t=t.alternative}else{if(!(t instanceof ne))break;t=t.body}s(n.body,e)}function a(n,e,t){if(t)try{n.walk(new E(function(n){if(n instanceof Ue&&"in"==n.operator)throw e})),n.print(e)}catch(r){if(r!==e)throw r;n.print(e,!0)}else n.print(e)}function u(n){return[92,47,46,43,42,63,40,41,91,93,123,125,36,94,58,124,33,10,13,0,65279,8232,8233].indexOf(n)<0}function s(n,e){e.option("bracketize")?!n||n instanceof Q?e.print("{}"):n instanceof Z?n.print(e):e.with_block(function(){e.indent(),n.print(e),e.newline()}):!n||n instanceof Q?e.force_semicolon():n.print(e)}function c(n){for(var e=n.stack(),t=e.length,r=e[--t],i=e[--t];t>0;){if(i instanceof Y&&i.body===r)return!0;if(!(i instanceof Re&&i.car===r||i instanceof Me&&i.expression===r&&!(i instanceof Ne)||i instanceof He&&i.expression===r||i instanceof ze&&i.expression===r||i instanceof Ve&&i.condition===r||i instanceof Ue&&i.left===r||i instanceof Ie&&i.expression===r))return!1;r=i,i=e[--t]}}function f(n,e){return 0==n.args.length&&!e.option("beautify")}function p(n){for(var e=n[0],t=e.length,r=1;r=0?r.push("0x"+n.toString(16).toLowerCase(),"0"+n.toString(8)):r.push("-0x"+(-n).toString(16).toLowerCase(),"-0"+(-n).toString(8)),(e=/^(.*?)(0+)$/.exec(n))&&r.push(e[1]+"e"+e[2].length)):(e=/^0?\.(0+)(.*)$/.exec(n))&&r.push(e[2]+"e-"+(e[1].length+e[2].length),t.substr(t.indexOf("."))),p(r)}function h(n,e){return n instanceof Z?void n.print(e):void e.with_block(function(){e.indent(),n.print(e),e.newline()})}function _(n,e){n.DEFMETHOD("add_source_map",function(n){e(this,n)})}function m(n,e){e.add_mapping(n.start)}W.DEFMETHOD("print",function(n,e){function t(){r.add_comments(n),r.add_source_map(n),i(r,n)}var r=this,i=r._codegen;n.push_node(r),e||r.needs_parens(n)?n.with_parens(t):t(),n.pop_node()}),W.DEFMETHOD("print_to_string",function(n){var e=j(n);return this.print(e),e.get()}),W.DEFMETHOD("add_comments",function(n){var e=n.option("comments"),t=this;if(e){var r=t.start;if(r&&!r._comments_dumped){r._comments_dumped=!0;var i=r.comments_before||[];t instanceof me&&t.value&&t.value.walk(new E(function(n){return n.start&&n.start.comments_before&&(i=i.concat(n.start.comments_before),n.start.comments_before=[]),n instanceof de||n instanceof We||n instanceof Ye?!0:void 0 3 | })),e.test?i=i.filter(function(n){return e.test(n.value)}):"function"==typeof e&&(i=i.filter(function(n){return e(t,n)})),i.forEach(function(e){/comment[134]/.test(e.type)?(n.print("//"+e.value+"\n"),n.indent()):"comment2"==e.type&&(n.print("/*"+e.value+"*/"),r.nlb?(n.print("\n"),n.indent()):n.space())})}}}),e(W,function(){return!1}),e(de,function(n){return c(n)}),e(Ye,function(n){return c(n)}),e(Pe,function(n){var e=n.parent();return e instanceof qe&&e.expression===this}),e(Re,function(n){var e=n.parent();return e instanceof Me||e instanceof Pe||e instanceof Ue||e instanceof Oe||e instanceof qe||e instanceof We||e instanceof Xe||e instanceof Ve}),e(Ue,function(n){var e=n.parent();if(e instanceof Me&&e.expression===this)return!0;if(e instanceof Pe)return!0;if(e instanceof qe&&e.expression===this)return!0;if(e instanceof Ue){var t=e.operator,r=It[t],i=this.operator,o=It[i];if(r>o||r==o&&this===e.right)return!0}}),e(qe,function(n){var e=n.parent();if(e instanceof Ne&&e.expression===this)try{this.walk(new E(function(n){if(n instanceof Me)throw e}))}catch(t){if(t!==e)throw t;return!0}}),e(Me,function(n){var e,t=n.parent();return t instanceof Ne&&t.expression===this?!0:this.expression instanceof de&&t instanceof qe&&t.expression===this&&(e=n.parent(1))instanceof Le&&e.left===t}),e(Ne,function(n){var e=n.parent();return f(this,n)&&(e instanceof qe||e instanceof Me&&e.expression===this)?!0:void 0}),e(dt,function(n){var e=n.parent();return this.getValue()<0&&e instanceof qe&&e.expression===this?!0:void 0}),e(vt,function(n){var e=n.parent();return e instanceof qe&&e.expression===this?!0:void 0}),e(Le,t),e(Ve,t),n(G,function(n,e){e.print_string(n.value),e.semicolon()}),n(X,function(n,e){e.print("debugger"),e.semicolon()}),ne.DEFMETHOD("_do_print_body",function(n){s(this.body,n)}),n(Y,function(n,e){n.body.print(e),e.semicolon()}),n(fe,function(n,e){r(n.body,!0,e),e.print("")}),n(ee,function(n,e){n.label.print(e),e.colon(),n.body.print(e)}),n(K,function(n,e){n.body.print(e),e.semicolon()}),n(Z,function(n,e){i(n.body,e)}),n(Q,function(n,e){e.semicolon()}),n(ie,function(n,e){e.print("do"),e.space(),n._do_print_body(e),e.space(),e.print("while"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.semicolon()}),n(oe,function(n,e){e.print("while"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.space(),n._do_print_body(e)}),n(ae,function(n,e){e.print("for"),e.space(),e.with_parens(function(){n.init?(n.init instanceof Be?n.init.print(e):a(n.init,e,!0),e.print(";"),e.space()):e.print(";"),n.condition?(n.condition.print(e),e.print(";"),e.space()):e.print(";"),n.step&&n.step.print(e)}),e.space(),n._do_print_body(e)}),n(ue,function(n,e){e.print("for"),e.space(),e.with_parens(function(){n.init.print(e),e.space(),e.print("in"),e.space(),n.object.print(e)}),e.space(),n._do_print_body(e)}),n(se,function(n,e){e.print("with"),e.space(),e.with_parens(function(){n.expression.print(e)}),e.space(),n._do_print_body(e)}),le.DEFMETHOD("_do_print",function(n,e){var t=this;e||n.print("function"),t.name&&(n.space(),t.name.print(n)),n.with_parens(function(){t.argnames.forEach(function(e,t){t&&n.comma(),e.print(n)})}),n.space(),i(t.body,n)}),n(le,function(n,e){n._do_print(e)}),me.DEFMETHOD("_do_print",function(n,e){n.print(e),this.value&&(n.space(),this.value.print(n)),n.semicolon()}),n(ve,function(n,e){n._do_print(e,"return")}),n(ge,function(n,e){n._do_print(e,"throw")}),be.DEFMETHOD("_do_print",function(n,e){n.print(e),this.label&&(n.space(),this.label.print(n)),n.semicolon()}),n(ye,function(n,e){n._do_print(e,"break")}),n(Ae,function(n,e){n._do_print(e,"continue")}),n(we,function(n,e){e.print("if"),e.space(),e.with_parens(function(){n.condition.print(e)}),e.space(),n.alternative?(o(n,e),e.space(),e.print("else"),e.space(),s(n.alternative,e)):n._do_print_body(e)}),n(Ee,function(n,e){e.print("switch"),e.space(),e.with_parens(function(){n.expression.print(e)}),e.space(),n.body.length>0?e.with_block(function(){n.body.forEach(function(n,t){t&&e.newline(),e.indent(!0),n.print(e)})}):e.print("{}")}),De.DEFMETHOD("_do_print_body",function(n){this.body.length>0&&(n.newline(),this.body.forEach(function(e){n.indent(),e.print(n),n.newline()}))}),n(Fe,function(n,e){e.print("default:"),n._do_print_body(e)}),n(Se,function(n,e){e.print("case"),e.space(),n.expression.print(e),e.print(":"),n._do_print_body(e)}),n(Ce,function(n,e){e.print("try"),e.space(),i(n.body,e),n.bcatch&&(e.space(),n.bcatch.print(e)),n.bfinally&&(e.space(),n.bfinally.print(e))}),n(ke,function(n,e){e.print("catch"),e.space(),e.with_parens(function(){n.argname.print(e)}),e.space(),i(n.body,e)}),n(xe,function(n,e){e.print("finally"),e.space(),i(n.body,e)}),Be.DEFMETHOD("_do_print",function(n,e){n.print(e),n.space(),this.definitions.forEach(function(e,t){t&&n.comma(),e.print(n)});var t=n.parent(),r=t instanceof ae||t instanceof ue,i=r&&t.init===this;i||n.semicolon()}),n(Te,function(n,e){n._do_print(e,"var")}),n($e,function(n,e){n._do_print(e,"const")}),n(Oe,function(n,e){if(n.name.print(e),n.value){e.space(),e.print("="),e.space();var t=e.parent(1),r=t instanceof ae||t instanceof ue;a(n.value,e,r)}}),n(Me,function(n,e){n.expression.print(e),n instanceof Ne&&f(n,e)||e.with_parens(function(){n.args.forEach(function(n,t){t&&e.comma(),n.print(e)})})}),n(Ne,function(n,e){e.print("new"),e.space(),Me.prototype._codegen(n,e)}),Re.DEFMETHOD("_do_print",function(n){this.car.print(n),this.cdr&&(n.comma(),n.should_break()&&(n.newline(),n.indent()),this.cdr.print(n))}),n(Re,function(n,e){n._do_print(e)}),n(He,function(n,e){var t=n.expression;t.print(e),t instanceof dt&&t.getValue()>=0&&(/[xa-f.]/i.test(e.last())||e.print(".")),e.print("."),e.add_mapping(n.end),e.print_name(n.property)}),n(ze,function(n,e){n.expression.print(e),e.print("["),n.property.print(e),e.print("]")}),n(je,function(n,e){var t=n.operator;e.print(t),/^[a-z]/i.test(t)&&e.space(),n.expression.print(e)}),n(Ie,function(n,e){n.expression.print(e),e.print(n.operator)}),n(Ue,function(n,e){n.left.print(e),e.space(),e.print(n.operator),"<"==n.operator&&n.right instanceof je&&"!"==n.right.operator&&n.right.expression instanceof je&&"--"==n.right.expression.operator?e.print(" "):e.space(),n.right.print(e)}),n(Ve,function(n,e){n.condition.print(e),e.space(),e.print("?"),e.space(),n.consequent.print(e),e.space(),e.colon(),n.alternative.print(e)}),n(We,function(n,e){e.with_square(function(){var t=n.elements,r=t.length;r>0&&e.space(),t.forEach(function(n,t){t&&e.comma(),n.print(e),t===r-1&&n instanceof bt&&e.comma()}),r>0&&e.space()})}),n(Ye,function(n,e){n.properties.length>0?e.with_block(function(){n.properties.forEach(function(n,t){t&&(e.print(","),e.newline()),e.indent(),n.print(e)}),e.newline()}):e.print("{}")}),n(Ge,function(n,e){var t=n.key;e.option("quote_keys")?e.print_string(t+""):("number"==typeof t||!e.option("beautify")&&+t+""==t)&&parseFloat(t)>=0?e.print(d(t)):(St(t)?e.option("screw_ie8"):$(t))?e.print_name(t):e.print_string(t),e.colon(),n.value.print(e)}),n(Ke,function(n,e){e.print("set"),e.space(),n.key.print(e),n.value._do_print(e,!0)}),n(Je,function(n,e){e.print("get"),e.space(),n.key.print(e),n.value._do_print(e,!0)}),n(Ze,function(n,e){var t=n.definition();e.print_name(t?t.mangled_name||t.name:n.name)}),n(gt,function(n,e){e.print("void 0")}),n(bt,l),n(yt,function(n,e){e.print("1/0")}),n(vt,function(n,e){e.print("0/0")}),n(ft,function(n,e){e.print("this")}),n(lt,function(n,e){e.print(n.getValue())}),n(pt,function(n,e){e.print_string(n.getValue())}),n(dt,function(n,e){e.print(d(n.getValue()))}),n(ht,function(n,e){var t=n.getValue().toString();e.option("ascii_only")?t=e.to_ascii(t):e.option("unescape_regexps")&&(t=t.split("\\\\").map(function(n){return n.replace(/\\u[0-9a-fA-F]{4}|\\x[0-9a-fA-F]{2}/g,function(n){var e=parseInt(n.substr(2),16);return u(e)?String.fromCharCode(e):n})}).join("\\\\")),e.print(t);var r=e.parent();r instanceof Ue&&/^in/.test(r.operator)&&r.left===n&&e.print(" ")}),_(W,l),_(G,m),_(X,m),_(Ze,m),_(_e,m),_(ne,m),_(ee,l),_(le,m),_(Ee,m),_(De,m),_(Z,m),_(fe,l),_(Ne,m),_(Ce,m),_(ke,m),_(xe,m),_(Be,m),_(lt,m),_(Xe,function(n,e){e.add_mapping(n.start,n.key)})}(),I.prototype=new z,f(I.prototype,{option:function(n){return this.options[n]},warn:function(){this.options.warnings&&W.warn.apply(W,arguments)},before:function(n,e){if(n._squeezed)return n;var t=!1;return n instanceof ce&&(n=n.hoist_declarations(this),t=!0),e(n,this),n=n.optimize(this),t&&n instanceof ce&&(n.drop_unused(this),e(n,this)),n._squeezed=!0,n}}),function(){function n(n,e){n.DEFMETHOD("optimize",function(n){var t=this;if(t._optimized)return t;var r=e(t,n);return r._optimized=!0,r===t?r:r.transform(n)})}function e(n,e,t){return t||(t={}),e&&(t.start||(t.start=e.start),t.end||(t.end=e.end)),new n(t)}function t(n,t,r){if(t instanceof W)return t.transform(n);switch(typeof t){case"string":return e(pt,r,{value:t}).optimize(n);case"number":return e(isNaN(t)?vt:dt,r,{value:t}).optimize(n);case"boolean":return e(t?Et:wt,r).optimize(n);case"undefined":return e(gt,r).optimize(n);default:if(null===t)return e(mt,r).optimize(n);if(t instanceof RegExp)return e(ht,r).optimize(n);throw new Error(d("Can't handle constant of type: {type}",{type:typeof t}))}}function r(n){if(null===n)return[];if(n instanceof Z)return n.body;if(n instanceof Q)return[];if(n instanceof Y)return[n];throw new Error("Can't convert thing to statement array")}function i(n){return null===n?!0:n instanceof Q?!0:n instanceof Z?0==n.body.length:!1}function u(n){return n instanceof Ee?n:(n instanceof ae||n instanceof ue||n instanceof re)&&n.body instanceof Z?n.body:n}function s(n,t){function i(n){function r(n,t){return e(K,n,{body:e(Le,n,{operator:"=",left:e(He,t,{expression:e(st,t,t),property:"$inject"}),right:e(We,n,{elements:n.argnames.map(function(n){return e(pt,n,{value:n.name})})})})})}return n.reduce(function(n,e){n.push(e);var i=e.start,o=i.comments_before;if(o&&o.length>0){var a=o.pop();/@ngInject/.test(a.value)&&(e instanceof he?n.push(r(e,e.name)):e instanceof Be?e.definitions.forEach(function(e){e.value&&e.value instanceof le&&n.push(r(e.value,e.name))}):t.warn("Unknown statement marked with @ngInject [{file}:{line},{col}]",i))}return n},[])}function o(n){var e=[];return n.reduce(function(n,t){return t instanceof Z?(_=!0,n.push.apply(n,o(t.body))):t instanceof Q?_=!0:t instanceof G?e.indexOf(t.value)<0?(n.push(t),e.push(t.value)):_=!0:n.push(t),n},[])}function a(n,t){var i=t.self(),o=i instanceof le,a=[];n:for(var s=n.length;--s>=0;){var c=n[s];switch(!0){case o&&c instanceof ve&&!c.value&&0==a.length:_=!0;continue n;case c instanceof we:if(c.body instanceof ve){if((o&&0==a.length||a[0]instanceof ve&&!a[0].value)&&!c.body.value&&!c.alternative){_=!0;var f=e(K,c.condition,{body:c.condition});a.unshift(f);continue n}if(a[0]instanceof ve&&c.body.value&&a[0].value&&!c.alternative){_=!0,c=c.clone(),c.alternative=a[0],a[0]=c.transform(t);continue n}if((0==a.length||a[0]instanceof ve)&&c.body.value&&!c.alternative&&o){_=!0,c=c.clone(),c.alternative=a[0]||e(ve,c,{value:e(gt,c)}),a[0]=c.transform(t);continue n}if(!c.body.value&&o){_=!0,c=c.clone(),c.condition=c.condition.negate(t),c.body=e(Z,c,{body:r(c.alternative).concat(a)}),c.alternative=null,a=[c.transform(t)];continue n}if(1==a.length&&o&&a[0]instanceof K&&(!c.alternative||c.alternative instanceof K)){_=!0,a.push(e(ve,a[0],{value:e(gt,a[0])}).transform(t)),a=r(c.alternative).concat(a),a.unshift(c);continue n}}var l=m(c.body),p=l instanceof be?t.loopcontrol_target(l.label):null;if(l&&(l instanceof ve&&!l.value&&o||l instanceof Ae&&i===u(p)||l instanceof ye&&p instanceof Z&&i===p)){l.label&&h(l.label.thedef.references,l),_=!0;var d=r(c.body).slice(0,-1);c=c.clone(),c.condition=c.condition.negate(t),c.body=e(Z,c,{body:r(c.alternative).concat(a)}),c.alternative=e(Z,c,{body:d}),a=[c.transform(t)];continue n}var l=m(c.alternative),p=l instanceof be?t.loopcontrol_target(l.label):null;if(l&&(l instanceof ve&&!l.value&&o||l instanceof Ae&&i===u(p)||l instanceof ye&&p instanceof Z&&i===p)){l.label&&h(l.label.thedef.references,l),_=!0,c=c.clone(),c.body=e(Z,c.body,{body:r(c.body).concat(a)}),c.alternative=e(Z,c.alternative,{body:r(c.alternative).slice(0,-1)}),a=[c.transform(t)];continue n}a.unshift(c);break;default:a.unshift(c)}}return a}function s(n,e){var t=!1,r=n.length,i=e.self();return n=n.reduce(function(n,r){if(t)c(e,r,n);else{if(r instanceof be){var o=e.loopcontrol_target(r.label);r instanceof ye&&o instanceof Z&&u(o)===i||r instanceof Ae&&u(o)===i?r.label&&h(r.label.thedef.references,r):n.push(r)}else n.push(r);m(r)&&(t=!0)}return n},[]),_=n.length!=r,n}function f(n,t){function r(){i=Re.from_array(i),i&&o.push(e(K,i,{body:i})),i=[]}if(n.length<2)return n;var i=[],o=[];return n.forEach(function(n){n instanceof K?i.push(n.body):(r(),o.push(n))}),r(),o=l(o,t),_=o.length!=n.length,o}function l(n,t){function r(n){i.pop();var e=o.body;return e instanceof Re?e.add(n):e=Re.cons(e,n),e.transform(t)}var i=[],o=null;return n.forEach(function(n){if(o)if(n instanceof ae){var t={};try{o.body.walk(new E(function(n){if(n instanceof Ue&&"in"==n.operator)throw t})),!n.init||n.init instanceof Be?n.init||(n.init=o.body,i.pop()):n.init=r(n.init)}catch(a){if(a!==t)throw a}}else n instanceof we?n.condition=r(n.condition):n instanceof se?n.expression=r(n.expression):n instanceof me&&n.value?n.value=r(n.value):n instanceof me?n.value=r(e(gt,n)):n instanceof Ee&&(n.expression=r(n.expression));i.push(n),o=n instanceof K?n:null}),i}function p(n){var e=null;return n.reduce(function(n,t){return t instanceof Be&&e&&e.TYPE==t.TYPE?(e.definitions=e.definitions.concat(t.definitions),_=!0):t instanceof ae&&e instanceof Be&&(!t.init||t.init.TYPE==e.TYPE)?(_=!0,n.pop(),t.init?t.init.definitions=e.definitions.concat(t.init.definitions):t.init=e,n.push(t),e=t):(e=t,n.push(t)),n},[])}function d(n){n.forEach(function(n){n instanceof K&&(n.body=function t(n){return n.transform(new z(function(n){if(n instanceof Me&&n.expression instanceof de)return e(je,n,{operator:"!",expression:n});if(n instanceof Me)n.expression=t(n.expression);else if(n instanceof Re)n.car=t(n.car);else if(n instanceof Ve){var r=t(n.condition);if(r!==n.condition){n.condition=r;var i=n.consequent;n.consequent=n.alternative,n.alternative=i}}return n}))}(n.body))})}var _;do _=!1,t.option("angular")&&(n=i(n)),n=o(n),t.option("dead_code")&&(n=s(n,t)),t.option("if_return")&&(n=a(n,t)),t.option("sequences")&&(n=f(n,t)),t.option("join_vars")&&(n=p(n,t));while(_);return t.option("negate_iife")&&d(n,t),n}function c(n,e,t){n.warn("Dropping unreachable code [{file}:{line},{col}]",e.start),e.walk(new E(function(e){return e instanceof Be?(n.warn("Declarations in unreachable code! [{file}:{line},{col}]",e.start),e.remove_initializers(),t.push(e),!0):e instanceof he?(t.push(e),!0):e instanceof ce?!0:void 0}))}function f(n,e){return n.print_to_string().length>e.print_to_string().length?e:n}function m(n){return n&&n.aborts()}function v(n,t){function i(i){i=r(i),n.body instanceof Z?(n.body=n.body.clone(),n.body.body=i.concat(n.body.body.slice(1)),n.body=n.body.transform(t)):n.body=e(Z,n.body,{body:i}).transform(t),v(n,t)}var o=n.body instanceof Z?n.body.body[0]:n.body;o instanceof we&&(o.body instanceof ye&&t.loopcontrol_target(o.body.label)===n?(n.condition=n.condition?e(Ue,n.condition,{left:n.condition,operator:"&&",right:o.condition.negate(t)}):o.condition.negate(t),i(o.alternative)):o.alternative instanceof ye&&t.loopcontrol_target(o.alternative.label)===n&&(n.condition=n.condition?e(Ue,n.condition,{left:n.condition,operator:"&&",right:o.condition}):o.condition,i(o.body)))}function A(n,e){var t=e.option("pure_getters");e.options.pure_getters=!1;var r=n.has_side_effects(e);return e.options.pure_getters=t,r}function w(n,t){return t.option("booleans")&&t.in_boolean_context()?e(Et,n):n}n(W,function(n){return n}),W.DEFMETHOD("equivalent_to",function(n){return this.print_to_string()==n.print_to_string()}),function(n){var e=["!","delete"],t=["in","instanceof","==","!=","===","!==","<","<=",">=",">"];n(W,function(){return!1}),n(je,function(){return o(this.operator,e)}),n(Ue,function(){return o(this.operator,t)||("&&"==this.operator||"||"==this.operator)&&this.left.is_boolean()&&this.right.is_boolean()}),n(Ve,function(){return this.consequent.is_boolean()&&this.alternative.is_boolean()}),n(Le,function(){return"="==this.operator&&this.right.is_boolean()}),n(Re,function(){return this.cdr.is_boolean()}),n(Et,function(){return!0}),n(wt,function(){return!0})}(function(n,e){n.DEFMETHOD("is_boolean",e)}),function(n){n(W,function(){return!1}),n(pt,function(){return!0}),n(je,function(){return"typeof"==this.operator}),n(Ue,function(n){return"+"==this.operator&&(this.left.is_string(n)||this.right.is_string(n))}),n(Le,function(n){return("="==this.operator||"+="==this.operator)&&this.right.is_string(n)}),n(Re,function(n){return this.cdr.is_string(n)}),n(Ve,function(n){return this.consequent.is_string(n)&&this.alternative.is_string(n)}),n(Me,function(n){return n.option("unsafe")&&this.expression instanceof st&&"String"==this.expression.name&&this.expression.undeclared()})}(function(n,e){n.DEFMETHOD("is_string",e)}),function(n){function e(n,e){if(!e)throw new Error("Compressor must be passed");return n._eval(e)}W.DEFMETHOD("evaluate",function(e){if(!e.option("evaluate"))return[this];try{var r=this._eval(e);return[f(t(e,r,this),this),r]}catch(i){if(i!==n)throw i;return[this]}}),n(Y,function(){throw new Error(d("Cannot evaluate a statement [{file}:{line},{col}]",this.start))}),n(de,function(){throw n}),n(W,function(){throw n}),n(lt,function(){return this.getValue()}),n(je,function(t){var r=this.expression;switch(this.operator){case"!":return!e(r,t);case"typeof":if(r instanceof de)return"function";if(r=e(r,t),r instanceof RegExp)throw n;return typeof r;case"void":return void e(r,t);case"~":return~e(r,t);case"-":if(r=e(r,t),0===r)throw n;return-r;case"+":return+e(r,t)}throw n}),n(Ue,function(t){var r=this.left,i=this.right;switch(this.operator){case"&&":return e(r,t)&&e(i,t);case"||":return e(r,t)||e(i,t);case"|":return e(r,t)|e(i,t);case"&":return e(r,t)&e(i,t);case"^":return e(r,t)^e(i,t);case"+":return e(r,t)+e(i,t);case"*":return e(r,t)*e(i,t);case"/":return e(r,t)/e(i,t);case"%":return e(r,t)%e(i,t);case"-":return e(r,t)-e(i,t);case"<<":return e(r,t)<>":return e(r,t)>>e(i,t);case">>>":return e(r,t)>>>e(i,t);case"==":return e(r,t)==e(i,t);case"===":return e(r,t)===e(i,t);case"!=":return e(r,t)!=e(i,t);case"!==":return e(r,t)!==e(i,t);case"<":return e(r,t)":return e(r,t)>e(i,t);case">=":return e(r,t)>=e(i,t);case"in":return e(r,t)in e(i,t);case"instanceof":return e(r,t)instanceof e(i,t)}throw n}),n(Ve,function(n){return e(this.condition,n)?e(this.consequent,n):e(this.alternative,n)}),n(st,function(t){var r=this.definition();if(r&&r.constant&&r.init)return e(r.init,t);throw n})}(function(n,e){n.DEFMETHOD("_eval",e)}),function(n){function t(n){return e(je,n,{operator:"!",expression:n})}n(W,function(){return t(this)}),n(Y,function(){throw new Error("Cannot negate a statement")}),n(de,function(){return t(this)}),n(je,function(){return"!"==this.operator?this.expression:t(this)}),n(Re,function(n){var e=this.clone();return e.cdr=e.cdr.negate(n),e}),n(Ve,function(n){var e=this.clone();return e.consequent=e.consequent.negate(n),e.alternative=e.alternative.negate(n),f(t(this),e)}),n(Ue,function(n){var e=this.clone(),r=this.operator;if(n.option("unsafe_comps"))switch(r){case"<=":return e.operator=">",e;case"<":return e.operator=">=",e;case">=":return e.operator="<",e;case">":return e.operator="<=",e}switch(r){case"==":return e.operator="!=",e;case"!=":return e.operator="==",e;case"===":return e.operator="!==",e;case"!==":return e.operator="===",e;case"&&":return e.operator="||",e.left=e.left.negate(n),e.right=e.right.negate(n),f(t(this),e);case"||":return e.operator="&&",e.left=e.left.negate(n),e.right=e.right.negate(n),f(t(this),e)}return t(this)})}(function(n,e){n.DEFMETHOD("negate",function(n){return e.call(this,n)})}),function(n){n(W,function(){return!0}),n(Q,function(){return!1}),n(lt,function(){return!1}),n(ft,function(){return!1}),n(Me,function(n){var e=n.option("pure_funcs");return e?e.indexOf(this.expression.print_to_string())<0:!0}),n(J,function(n){for(var e=this.body.length;--e>=0;)if(this.body[e].has_side_effects(n))return!0;return!1}),n(K,function(n){return this.body.has_side_effects(n)}),n(he,function(){return!0}),n(de,function(){return!1}),n(Ue,function(n){return this.left.has_side_effects(n)||this.right.has_side_effects(n)}),n(Le,function(){return!0}),n(Ve,function(n){return this.condition.has_side_effects(n)||this.consequent.has_side_effects(n)||this.alternative.has_side_effects(n)}),n(Pe,function(n){return"delete"==this.operator||"++"==this.operator||"--"==this.operator||this.expression.has_side_effects(n)}),n(st,function(){return!1}),n(Ye,function(n){for(var e=this.properties.length;--e>=0;)if(this.properties[e].has_side_effects(n))return!0;return!1}),n(Xe,function(n){return this.value.has_side_effects(n)}),n(We,function(n){for(var e=this.elements.length;--e>=0;)if(this.elements[e].has_side_effects(n))return!0;return!1}),n(He,function(n){return n.option("pure_getters")?this.expression.has_side_effects(n):!0}),n(ze,function(n){return n.option("pure_getters")?this.expression.has_side_effects(n)||this.property.has_side_effects(n):!0}),n(qe,function(n){return!n.option("pure_getters")}),n(Re,function(n){return this.car.has_side_effects(n)||this.cdr.has_side_effects(n)})}(function(n,e){n.DEFMETHOD("has_side_effects",e)}),function(n){function e(){var n=this.body.length;return n>0&&m(this.body[n-1])}n(Y,function(){return null}),n(_e,function(){return this}),n(Z,e),n(De,e),n(we,function(){return this.alternative&&m(this.body)&&m(this.alternative)})}(function(n,e){n.DEFMETHOD("aborts",e)}),n(G,function(n){return n.scope.has_directive(n.value)!==n.scope?e(Q,n):n}),n(X,function(n,t){return t.option("drop_debugger")?e(Q,n):n}),n(ee,function(n,t){return n.body instanceof ye&&t.loopcontrol_target(n.body.label)===n.body?e(Q,n):0==n.label.references.length?n.body:n}),n(J,function(n,e){return n.body=s(n.body,e),n}),n(Z,function(n,t){switch(n.body=s(n.body,t),n.body.length){case 1:return n.body[0];case 0:return e(Q,n)}return n}),ce.DEFMETHOD("drop_unused",function(n){var t=this;if(n.option("unused")&&!(t instanceof fe)&&!t.uses_eval){var r=[],i=new y,a=this,u=new E(function(e,o){if(e!==t){if(e instanceof he)return i.add(e.name.name,e),!0;if(e instanceof Be&&a===t)return e.definitions.forEach(function(e){e.value&&(i.add(e.name.name,e.value),e.value.has_side_effects(n)&&e.value.walk(u))}),!0;if(e instanceof st)return p(r,e.definition()),!0;if(e instanceof ce){var s=a;return a=e,o(),a=s,!0}}});t.walk(u);for(var s=0;s=0;){var l=s[f];if(!l.unreferenced())break;s.pop(),n.warn("Dropping unused function argument {name} [{file}:{line},{col}]",{name:l.name,file:l.start.file,line:l.start.line,col:l.start.col})}if(i instanceof he&&i!==t)return o(i.name.definition(),r)?i:(n.warn("Dropping unused function {name} [{file}:{line},{col}]",{name:i.name.name,file:i.name.start.file,line:i.name.start.line,col:i.name.start.col}),e(Q,i));if(i instanceof Be&&!(c.parent()instanceof ue)){var p=i.definitions.filter(function(e){if(o(e.name.definition(),r))return!0;var t={name:e.name.name,file:e.name.start.file,line:e.name.start.line,col:e.name.start.col};return e.value&&e.value.has_side_effects(n)?(e._unused_side_effects=!0,n.warn("Side effects in initialization of unused variable {name} [{file}:{line},{col}]",t),!0):(n.warn("Dropping unused variable {name} [{file}:{line},{col}]",t),!1)});p=_(p,function(n,e){return!n.value&&e.value?-1:!e.value&&n.value?1:0});for(var d=[],f=0;f0&&(d.push(h.value),h.value=Re.from_array(d),d=[]),++f)}return d=d.length>0?e(Z,i,{body:[e(K,i,{body:Re.from_array(d)})]}):null,0!=p.length||d?0==p.length?d:(i.definitions=p,d&&(d.body.unshift(i),i=d),i):e(Q,i)}if(i instanceof ae&&(a(i,this),i.init instanceof Z)){var m=i.init.body.slice(0,-1);return i.init=i.init.body.slice(-1)[0].body,m.push(i),u?V.splice(m):e(Z,i,{body:m})}return i instanceof ce&&i!==t?i:void 0});t.transform(c)}}),ce.DEFMETHOD("hoist_declarations",function(n){var t=n.option("hoist_funs"),r=n.option("hoist_vars"),i=this;if(t||r){var o=[],u=[],s=new y,c=0,f=0;i.walk(new E(function(n){return n instanceof ce&&n!==i?!0:n instanceof Te?(++f,!0):void 0})),r=r&&f>1;var l=new z(function(n){if(n!==i){if(n instanceof G)return o.push(n),e(Q,n);if(n instanceof he&&t)return u.push(n),e(Q,n);if(n instanceof Te&&r){n.definitions.forEach(function(n){s.set(n.name.name,n),++c});var a=n.to_assignments(),f=l.parent();return f instanceof ue&&f.init===n?null==a?n.definitions[0].name:a:f instanceof ae&&f.init===n?a:a?e(K,n,{body:a}):e(Q,n)}if(n instanceof ce)return n}});if(i=i.transform(l),c>0){var p=[];if(s.each(function(n,e){i instanceof le&&a(function(e){return e.name==n.name.name},i.argnames)?s.del(e):(n=n.clone(),n.value=null,p.push(n),s.set(e,n))}),p.length>0){for(var d=0;d1){if(r[1])return e(ae,n,{body:n.body});if(n instanceof oe&&t.option("dead_code")){var i=[];return c(t,n.body,i),e(Z,n,{body:i})}}return n}),n(oe,function(n,t){return t.option("loops")?(n=re.prototype.optimize.call(n,t),n instanceof oe&&(v(n,t),n=e(ae,n,n).transform(t)),n):n}),n(ae,function(n,t){var r=n.condition;if(r&&(r=r.evaluate(t),n.condition=r[0]),!t.option("loops"))return n;if(r&&r.length>1&&!r[1]&&t.option("dead_code")){var i=[];return n.init instanceof Y?i.push(n.init):n.init&&i.push(e(K,n.init,{body:n.init})),c(t,n.body,i),e(Z,n,{body:i})}return v(n,t),n}),n(we,function(n,t){if(!t.option("conditionals"))return n;var r=n.condition.evaluate(t);if(n.condition=r[0],r.length>1)if(r[1]){if(t.warn("Condition always true [{file}:{line},{col}]",n.condition.start),t.option("dead_code")){var o=[];return n.alternative&&c(t,n.alternative,o),o.push(n.body),e(Z,n,{body:o}).transform(t)}}else if(t.warn("Condition always false [{file}:{line},{col}]",n.condition.start),t.option("dead_code")){var o=[];return c(t,n.body,o),n.alternative&&o.push(n.alternative),e(Z,n,{body:o}).transform(t)}i(n.alternative)&&(n.alternative=null);var a=n.condition.negate(t),u=f(n.condition,a)===a;if(n.alternative&&u){u=!1,n.condition=a;var s=n.body;n.body=n.alternative||e(Q),n.alternative=s}if(i(n.body)&&i(n.alternative))return e(K,n.condition,{body:n.condition}).transform(t);if(n.body instanceof K&&n.alternative instanceof K)return e(K,n,{body:e(Ve,n,{condition:n.condition,consequent:n.body.body,alternative:n.alternative.body})}).transform(t);if(i(n.alternative)&&n.body instanceof K)return u?e(K,n,{body:e(Ue,n,{operator:"||",left:a,right:n.body.body})}).transform(t):e(K,n,{body:e(Ue,n,{operator:"&&",left:n.condition,right:n.body.body})}).transform(t);if(n.body instanceof Q&&n.alternative&&n.alternative instanceof K)return e(K,n,{body:e(Ue,n,{operator:"||",left:n.condition,right:n.alternative.body})}).transform(t);if(n.body instanceof me&&n.alternative instanceof me&&n.body.TYPE==n.alternative.TYPE)return e(n.body.CTOR,n,{value:e(Ve,n,{condition:n.condition,consequent:n.body.value||e(gt,n.body).optimize(t),alternative:n.alternative.value||e(gt,n.alternative).optimize(t)})}).transform(t);if(n.body instanceof we&&!n.body.alternative&&!n.alternative&&(n.condition=e(Ue,n.condition,{operator:"&&",left:n.condition,right:n.body.condition}).transform(t),n.body=n.body.body),m(n.body)&&n.alternative){var l=n.alternative;return n.alternative=null,e(Z,n,{body:[n,l]}).transform(t)}if(m(n.alternative)){var p=n.body;return n.body=n.alternative,n.condition=u?a:n.condition.negate(t),n.alternative=null,e(Z,n,{body:[n,p]}).transform(t)}return n}),n(Ee,function(n,t){if(0==n.body.length&&t.option("conditionals"))return e(K,n,{body:n.expression}).transform(t);for(;;){var r=n.body[n.body.length-1];if(r){var i=r.body[r.body.length-1];if(i instanceof ye&&u(t.loopcontrol_target(i.label))===n&&r.body.pop(),r instanceof Fe&&0==r.body.length){n.body.pop();continue}}break}var o=n.expression.evaluate(t);n:if(2==o.length)try{if(n.expression=o[0],!t.option("dead_code"))break n;var a=o[1],s=!1,c=!1,f=!1,l=!1,p=!1,d=new z(function(r,i,o){if(r instanceof le||r instanceof K)return r;if(r instanceof Ee&&r===n)return r=r.clone(),i(r,this),p?r:e(Z,r,{body:r.body.reduce(function(n,e){return n.concat(e.body)},[])}).transform(t);if(r instanceof we||r instanceof Ce){var u=s;return s=!c,i(r,this),s=u,r}if(r instanceof ne||r instanceof Ee){var u=c;return c=!0,i(r,this),c=u,r}if(r instanceof ye&&this.loopcontrol_target(r.label)===n)return s?(p=!0,r):c?r:(l=!0,o?V.skip:e(Q,r));if(r instanceof De&&this.parent()===n){if(l)return V.skip;if(r instanceof Se){var d=r.expression.evaluate(t);if(d.length<2)throw n;return d[1]===a||f?(f=!0,m(r)&&(l=!0),i(r,this),r):V.skip}return i(r,this),r}});d.stack=t.stack.slice(),n=n.transform(d)}catch(h){if(h!==n)throw h}return n}),n(Se,function(n,e){return n.body=s(n.body,e),n}),n(Ce,function(n,e){return n.body=s(n.body,e),n}),Be.DEFMETHOD("remove_initializers",function(){this.definitions.forEach(function(n){n.value=null})}),Be.DEFMETHOD("to_assignments",function(){var n=this.definitions.reduce(function(n,t){if(t.value){var r=e(st,t.name,t.name);n.push(e(Le,t,{operator:"=",left:r,right:t.value}))}return n},[]);return 0==n.length?null:Re.from_array(n)}),n(Be,function(n){return 0==n.definitions.length?e(Q,n):n}),n(de,function(n,e){return n=le.prototype.optimize.call(n,e),e.option("unused")&&n.name&&n.name.unreferenced()&&(n.name=null),n}),n(Me,function(n,r){if(r.option("unsafe")){var i=n.expression;if(i instanceof st&&i.undeclared())switch(i.name){case"Array":if(1!=n.args.length)return e(We,n,{elements:n.args}).transform(r);break;case"Object":if(0==n.args.length)return e(Ye,n,{properties:[]});break;case"String":if(0==n.args.length)return e(pt,n,{value:""});if(n.args.length<=1)return e(Ue,n,{left:n.args[0],operator:"+",right:e(pt,n,{value:""})}).transform(r);break;case"Number":if(0==n.args.length)return e(dt,n,{value:0});if(1==n.args.length)return e(je,n,{expression:n.args[0],operator:"+"}).transform(r);case"Boolean":if(0==n.args.length)return e(wt,n);if(1==n.args.length)return e(je,n,{expression:e(je,null,{expression:n.args[0],operator:"!"}),operator:"!"}).transform(r);break;case"Function":if(b(n.args,function(n){return n instanceof pt}))try{var o="(function("+n.args.slice(0,-1).map(function(n){return n.value}).join(",")+"){"+n.args[n.args.length-1].value+"})()",a=H(o);a.figure_out_scope({screw_ie8:r.option("screw_ie8")});var u=new I(r.options);a=a.transform(u),a.figure_out_scope({screw_ie8:r.option("screw_ie8")}),a.mangle_names();var s;try{a.walk(new E(function(n){if(n instanceof le)throw s=n,a 4 | }))}catch(c){if(c!==a)throw c}var l=s.argnames.map(function(t,r){return e(pt,n.args[r],{value:t.print_to_string()})}),o=j();return Z.prototype._codegen.call(s,s,o),o=o.toString().replace(/^\{|\}$/g,""),l.push(e(pt,n.args[n.args.length-1],{value:o})),n.args=l,n}catch(c){if(!(c instanceof M))throw console.log(c),c;r.warn("Error parsing code passed to new Function [{file}:{line},{col}]",n.args[n.args.length-1].start),r.warn(c.toString())}}else{if(i instanceof He&&"toString"==i.property&&0==n.args.length)return e(Ue,n,{left:e(pt,n,{value:""}),operator:"+",right:i.expression}).transform(r);if(i instanceof He&&i.expression instanceof We&&"join"==i.property){var p=0==n.args.length?",":n.args[0].evaluate(r)[1];if(null!=p){var d=i.expression.elements.reduce(function(n,e){if(e=e.evaluate(r),0==n.length||1==e.length)n.push(e);else{var i=n[n.length-1];if(2==i.length){var o=""+i[1]+p+e[1];n[n.length-1]=[t(r,o,i[0]),o]}else n.push(e)}return n},[]);if(0==d.length)return e(pt,n,{value:""});if(1==d.length)return d[0][0];if(""==p){var h;return h=d[0][0]instanceof pt||d[1][0]instanceof pt?d.shift()[0]:e(pt,n,{value:""}),d.reduce(function(n,t){return e(Ue,t[0],{operator:"+",left:n,right:t[0]})},h).transform(r)}var _=n.clone();return _.expression=_.expression.clone(),_.expression.expression=_.expression.expression.clone(),_.expression.expression.elements=d.map(function(n){return n[0]}),f(n,_)}}}}return r.option("side_effects")&&n.expression instanceof de&&0==n.args.length&&!J.prototype.has_side_effects.call(n.expression,r)?e(gt,n).transform(r):r.option("drop_console")&&n.expression instanceof qe&&n.expression.expression instanceof st&&"console"==n.expression.expression.name&&n.expression.expression.undeclared()?e(gt,n).transform(r):n.evaluate(r)[0]}),n(Ne,function(n,t){if(t.option("unsafe")){var r=n.expression;if(r instanceof st&&r.undeclared())switch(r.name){case"Object":case"RegExp":case"Function":case"Error":case"Array":return e(Me,n,n).transform(t)}}return n}),n(Re,function(n,t){if(!t.option("side_effects"))return n;if(!n.car.has_side_effects(t)){var r;if(!(n.cdr instanceof st&&"eval"==n.cdr.name&&n.cdr.undeclared()&&(r=t.parent())instanceof Me&&r.expression===n))return n.cdr}if(t.option("cascade")){if(n.car instanceof Le&&!n.car.left.has_side_effects(t)){if(n.car.left.equivalent_to(n.cdr))return n.car;if(n.cdr instanceof Me&&n.cdr.expression.equivalent_to(n.car.left))return n.cdr.expression=n.car,n.cdr}if(!n.car.has_side_effects(t)&&!n.cdr.has_side_effects(t)&&n.car.equivalent_to(n.cdr))return n.car}return n.cdr instanceof je&&"void"==n.cdr.operator&&!n.cdr.expression.has_side_effects(t)?(n.cdr.operator=n.car,n.cdr):n.cdr instanceof gt?e(je,n,{operator:"void",expression:n.car}):n}),Pe.DEFMETHOD("lift_sequences",function(n){if(n.option("sequences")&&this.expression instanceof Re){var e=this.expression,t=e.to_array();return this.expression=t.pop(),t.push(this),e=Re.from_array(t).transform(n)}return this}),n(Ie,function(n,e){return n.lift_sequences(e)}),n(je,function(n,t){n=n.lift_sequences(t);var r=n.expression;if(t.option("booleans")&&t.in_boolean_context()){switch(n.operator){case"!":if(r instanceof je&&"!"==r.operator)return r.expression;break;case"typeof":return t.warn("Boolean expression always true [{file}:{line},{col}]",n.start),e(Et,n)}r instanceof Ue&&"!"==n.operator&&(n=f(n,r.negate(t)))}return n.evaluate(t)[0]}),Ue.DEFMETHOD("lift_sequences",function(n){if(n.option("sequences")){if(this.left instanceof Re){var e=this.left,t=e.to_array();return this.left=t.pop(),t.push(this),e=Re.from_array(t).transform(n)}if(this.right instanceof Re&&this instanceof Le&&!A(this.left,n)){var e=this.right,t=e.to_array();return this.right=t.pop(),t.push(this),e=Re.from_array(t).transform(n)}}return this});var D=g("== === != !== * & | ^");n(Ue,function(n,t){var r=t.has_directive("use asm")?l:function(e,r){if(r||!n.left.has_side_effects(t)&&!n.right.has_side_effects(t)){e&&(n.operator=e);var i=n.left;n.left=n.right,n.right=i}};if(D(n.operator)&&(n.right instanceof lt&&!(n.left instanceof lt)&&(n.left instanceof Ue&&It[n.left.operator]>=It[n.operator]||r(null,!0)),/^[!=]==?$/.test(n.operator))){if(n.left instanceof st&&n.right instanceof Ve){if(n.right.consequent instanceof st&&n.right.consequent.definition()===n.left.definition()){if(/^==/.test(n.operator))return n.right.condition;if(/^!=/.test(n.operator))return n.right.condition.negate(t)}if(n.right.alternative instanceof st&&n.right.alternative.definition()===n.left.definition()){if(/^==/.test(n.operator))return n.right.condition.negate(t);if(/^!=/.test(n.operator))return n.right.condition}}if(n.right instanceof st&&n.left instanceof Ve){if(n.left.consequent instanceof st&&n.left.consequent.definition()===n.right.definition()){if(/^==/.test(n.operator))return n.left.condition;if(/^!=/.test(n.operator))return n.left.condition.negate(t)}if(n.left.alternative instanceof st&&n.left.alternative.definition()===n.right.definition()){if(/^==/.test(n.operator))return n.left.condition.negate(t);if(/^!=/.test(n.operator))return n.left.condition}}}if(n=n.lift_sequences(t),t.option("comparisons"))switch(n.operator){case"===":case"!==":(n.left.is_string(t)&&n.right.is_string(t)||n.left.is_boolean()&&n.right.is_boolean())&&(n.operator=n.operator.substr(0,2));case"==":case"!=":n.left instanceof pt&&"undefined"==n.left.value&&n.right instanceof je&&"typeof"==n.right.operator&&t.option("unsafe")&&(n.right.expression instanceof st&&n.right.expression.undeclared()||(n.right=n.right.expression,n.left=e(gt,n.left).optimize(t),2==n.operator.length&&(n.operator+="=")))}if(t.option("booleans")&&t.in_boolean_context())switch(n.operator){case"&&":var i=n.left.evaluate(t),o=n.right.evaluate(t);if(i.length>1&&!i[1]||o.length>1&&!o[1])return t.warn("Boolean && always false [{file}:{line},{col}]",n.start),e(wt,n);if(i.length>1&&i[1])return o[0];if(o.length>1&&o[1])return i[0];break;case"||":var i=n.left.evaluate(t),o=n.right.evaluate(t);if(i.length>1&&i[1]||o.length>1&&o[1])return t.warn("Boolean || always true [{file}:{line},{col}]",n.start),e(Et,n);if(i.length>1&&!i[1])return o[0];if(o.length>1&&!o[1])return i[0];break;case"+":var i=n.left.evaluate(t),o=n.right.evaluate(t);if(i.length>1&&i[0]instanceof pt&&i[1]||o.length>1&&o[0]instanceof pt&&o[1])return t.warn("+ in boolean context always true [{file}:{line},{col}]",n.start),e(Et,n)}if(t.option("comparisons")){if(!(t.parent()instanceof Ue)||t.parent()instanceof Le){var a=e(je,n,{operator:"!",expression:n.negate(t)});n=f(n,a)}switch(n.operator){case"<":r(">");break;case"<=":r(">=")}}return"+"==n.operator&&n.right instanceof pt&&""===n.right.getValue()&&n.left instanceof Ue&&"+"==n.left.operator&&n.left.is_string(t)?n.left:(t.option("evaluate")&&"+"==n.operator&&(n.left instanceof lt&&n.right instanceof Ue&&"+"==n.right.operator&&n.right.left instanceof lt&&n.right.is_string(t)&&(n=e(Ue,n,{operator:"+",left:e(pt,null,{value:""+n.left.getValue()+n.right.left.getValue(),start:n.left.start,end:n.right.left.end}),right:n.right.right})),n.right instanceof lt&&n.left instanceof Ue&&"+"==n.left.operator&&n.left.right instanceof lt&&n.left.is_string(t)&&(n=e(Ue,n,{operator:"+",left:n.left.left,right:e(pt,null,{value:""+n.left.right.getValue()+n.right.getValue(),start:n.left.right.start,end:n.right.end})})),n.left instanceof Ue&&"+"==n.left.operator&&n.left.is_string(t)&&n.left.right instanceof lt&&n.right instanceof Ue&&"+"==n.right.operator&&n.right.left instanceof lt&&n.right.is_string(t)&&(n=e(Ue,n,{operator:"+",left:e(Ue,n.left,{operator:"+",left:n.left.left,right:e(pt,null,{value:""+n.left.right.getValue()+n.right.left.getValue(),start:n.left.right.start,end:n.right.left.end})}),right:n.right.right}))),n.right instanceof Ue&&n.right.operator==n.operator&&("*"==n.operator||"&&"==n.operator||"||"==n.operator)?(n.left=e(Ue,n.left,{operator:n.operator,left:n.left,right:n.right.left}),n.right=n.right.right,n.transform(t)):n.evaluate(t)[0])}),n(st,function(n,r){if(n.undeclared()){var i=r.option("global_defs");if(i&&i.hasOwnProperty(n.name))return t(r,i[n.name],n);switch(n.name){case"undefined":return e(gt,n);case"NaN":return e(vt,n);case"Infinity":return e(yt,n)}}return n}),n(gt,function(n,t){if(t.option("unsafe")){var r=t.find_parent(ce),i=r.find_variable("undefined");if(i){var o=e(st,n,{name:"undefined",scope:r,thedef:i});return o.reference(),o}}return n});var F=["+","-","/","*","%",">>","<<",">>>","|","^","&"];n(Le,function(n,e){return n=n.lift_sequences(e),"="==n.operator&&n.left instanceof st&&n.right instanceof Ue&&n.right.left instanceof st&&n.right.left.name==n.left.name&&o(n.right.operator,F)&&(n.operator=n.right.operator+"=",n.right=n.right.right),n}),n(Ve,function(n,t){if(!t.option("conditionals"))return n;if(n.condition instanceof Re){var r=n.condition.car;return n.condition=n.condition.cdr,Re.cons(r,n)}var i=n.condition.evaluate(t);if(i.length>1)return i[1]?(t.warn("Condition always true [{file}:{line},{col}]",n.start),n.consequent):(t.warn("Condition always false [{file}:{line},{col}]",n.start),n.alternative);var o=i[0].negate(t);f(i[0],o)===o&&(n=e(Ve,n,{condition:o,consequent:n.alternative,alternative:n.consequent}));var a=n.consequent,u=n.alternative;if(a instanceof Le&&u instanceof Le&&a.operator==u.operator&&a.left.equivalent_to(u.left))return e(Le,n,{operator:a.operator,left:a.left,right:e(Ve,n,{condition:n.condition,consequent:a.right,alternative:u.right})});if(a instanceof Me&&u.TYPE===a.TYPE&&a.args.length==u.args.length&&a.expression.equivalent_to(u.expression)){if(0==a.args.length)return e(Re,n,{car:n.condition,cdr:a});if(1==a.args.length)return a.args[0]=e(Ve,n,{condition:n.condition,consequent:a.args[0],alternative:u.args[0]}),a}return a instanceof Ve&&a.alternative.equivalent_to(u)?e(Ve,n,{condition:e(Ue,n,{left:n.condition,operator:"&&",right:a.condition}),consequent:a.consequent,alternative:u}):n}),n(At,function(n,t){if(t.option("booleans")){var r=t.parent();return r instanceof Ue&&("=="==r.operator||"!="==r.operator)?(t.warn("Non-strict equality against boolean: {operator} {value} [{file}:{line},{col}]",{operator:r.operator,value:n.value,file:r.start.file,line:r.start.line,col:r.start.col}),e(dt,n,{value:+n.value})):e(je,n,{operator:"!",expression:e(dt,n,{value:1-n.value})})}return n}),n(ze,function(n,t){var r=n.property;if(r instanceof pt&&t.option("properties")){if(r=r.getValue(),St(r)?t.option("screw_ie8"):$(r))return e(He,n,{expression:n.expression,property:r});var i=parseFloat(r);isNaN(i)||i.toString()!=r||(n.property=e(dt,n.property,{value:i}))}return n}),n(We,w),n(Ye,w),n(ht,w)}(),function(){function n(n){var r="prefix"in n?n.prefix:"UnaryExpression"==n.type?!0:!1;return new(r?je:Ie)({start:e(n),end:t(n),operator:n.operator,expression:i(n.argument)})}function e(n){return new L({file:n.loc&&n.loc.source,line:n.loc&&n.loc.start.line,col:n.loc&&n.loc.start.column,pos:n.start,endpos:n.start})}function t(n){return new L({file:n.loc&&n.loc.source,line:n.loc&&n.loc.end.line,col:n.loc&&n.loc.end.column,pos:n.end,endpos:n.end})}function r(n,r,a){var u="function From_Moz_"+n+"(M){\n";return u+="return new mytype({\nstart: my_start_token(M),\nend: my_end_token(M)",a&&a.split(/\s*,\s*/).forEach(function(n){var e=/([a-z0-9$_]+)(=|@|>|%)([a-z0-9$_]+)/i.exec(n);if(!e)throw new Error("Can't understand property map: "+n);var t="M."+e[1],r=e[2],i=e[3];if(u+=",\n"+i+": ","@"==r)u+=t+".map(from_moz)";else if(">"==r)u+="from_moz("+t+")";else if("="==r)u+=t;else{if("%"!=r)throw new Error("Can't understand operator in propmap: "+n);u+="from_moz("+t+").body"}}),u+="\n})}",u=new Function("mytype","my_start_token","my_end_token","from_moz","return("+u+")")(r,e,t,i),o[n]=u}function i(n){a.push(n);var e=null!=n?o[n.type](n):null;return a.pop(),e}var o={TryStatement:function(n){return new Ce({start:e(n),end:t(n),body:i(n.block).body,bcatch:i(n.handlers[0]),bfinally:n.finalizer?new xe(i(n.finalizer)):null})},CatchClause:function(n){return new ke({start:e(n),end:t(n),argname:i(n.param),body:i(n.body).body})},ObjectExpression:function(n){return new Ye({start:e(n),end:t(n),properties:n.properties.map(function(n){var r=n.key,o="Identifier"==r.type?r.name:r.value,a={start:e(r),end:t(n.value),key:o,value:i(n.value)};switch(n.kind){case"init":return new Ge(a);case"set":return a.value.name=i(r),new Ke(a);case"get":return a.value.name=i(r),new Je(a)}})})},SequenceExpression:function(n){return Re.from_array(n.expressions.map(i))},MemberExpression:function(n){return new(n.computed?ze:He)({start:e(n),end:t(n),property:n.computed?i(n.property):n.property.name,expression:i(n.object)})},SwitchCase:function(n){return new(n.test?Se:Fe)({start:e(n),end:t(n),expression:i(n.test),body:n.consequent.map(i)})},Literal:function(n){var r=n.value,i={start:e(n),end:t(n)};if(null===r)return new mt(i);switch(typeof r){case"string":return i.value=r,new pt(i);case"number":return i.value=r,new dt(i);case"boolean":return new(r?Et:wt)(i);default:return i.value=r,new ht(i)}},UnaryExpression:n,UpdateExpression:n,Identifier:function(n){var r=a[a.length-2];return new("this"==n.name?ft:"LabeledStatement"==r.type?ut:"VariableDeclarator"==r.type&&r.id===n?"const"==r.kind?tt:et:"FunctionExpression"==r.type?r.id===n?ot:rt:"FunctionDeclaration"==r.type?r.id===n?it:rt:"CatchClause"==r.type?at:"BreakStatement"==r.type||"ContinueStatement"==r.type?ct:st)({start:e(n),end:t(n),name:n.name})}};r("Node",W),r("Program",fe,"body@body"),r("Function",de,"id>name, params@argnames, body%body"),r("EmptyStatement",Q),r("BlockStatement",Z,"body@body"),r("ExpressionStatement",K,"expression>body"),r("IfStatement",we,"test>condition, consequent>body, alternate>alternative"),r("LabeledStatement",ee,"label>label, body>body"),r("BreakStatement",ye,"label>label"),r("ContinueStatement",Ae,"label>label"),r("WithStatement",se,"object>expression, body>body"),r("SwitchStatement",Ee,"discriminant>expression, cases@body"),r("ReturnStatement",ve,"argument>value"),r("ThrowStatement",ge,"argument>value"),r("WhileStatement",oe,"test>condition, body>body"),r("DoWhileStatement",ie,"test>condition, body>body"),r("ForStatement",ae,"init>init, test>condition, update>step, body>body"),r("ForInStatement",ue,"left>init, right>object, body>body"),r("DebuggerStatement",X),r("FunctionDeclaration",he,"id>name, params@argnames, body%body"),r("VariableDeclaration",Te,"declarations@definitions"),r("VariableDeclarator",Oe,"id>name, init>value"),r("ThisExpression",ft),r("ArrayExpression",We,"elements@elements"),r("FunctionExpression",de,"id>name, params@argnames, body%body"),r("BinaryExpression",Ue,"operator=operator, left>left, right>right"),r("AssignmentExpression",Le,"operator=operator, left>left, right>right"),r("LogicalExpression",Ue,"operator=operator, left>left, right>right"),r("ConditionalExpression",Ve,"test>condition, consequent>consequent, alternate>alternative"),r("NewExpression",Ne,"callee>expression, arguments@args"),r("CallExpression",Me,"callee>expression, arguments@args");var a=null;W.from_mozilla_ast=function(n){var e=a;a=[];var t=i(n);return a=e,t}}(),n.array_to_hash=t,n.slice=r,n.characters=i,n.member=o,n.find_if=a,n.repeat_string=u,n.DefaultsError=s,n.defaults=c,n.merge=f,n.noop=l,n.MAP=V,n.push_uniq=p,n.string_template=d,n.remove=h,n.mergeSort=_,n.set_difference=m,n.set_intersection=v,n.makePredicate=g,n.all=b,n.Dictionary=y,n.DEFNODE=A,n.AST_Token=L,n.AST_Node=W,n.AST_Statement=Y,n.AST_Debugger=X,n.AST_Directive=G,n.AST_SimpleStatement=K,n.walk_body=w,n.AST_Block=J,n.AST_BlockStatement=Z,n.AST_EmptyStatement=Q,n.AST_StatementWithBody=ne,n.AST_LabeledStatement=ee,n.AST_IterationStatement=te,n.AST_DWLoop=re,n.AST_Do=ie,n.AST_While=oe,n.AST_For=ae,n.AST_ForIn=ue,n.AST_With=se,n.AST_Scope=ce,n.AST_Toplevel=fe,n.AST_Lambda=le,n.AST_Accessor=pe,n.AST_Function=de,n.AST_Defun=he,n.AST_Jump=_e,n.AST_Exit=me,n.AST_Return=ve,n.AST_Throw=ge,n.AST_LoopControl=be,n.AST_Break=ye,n.AST_Continue=Ae,n.AST_If=we,n.AST_Switch=Ee,n.AST_SwitchBranch=De,n.AST_Default=Fe,n.AST_Case=Se,n.AST_Try=Ce,n.AST_Catch=ke,n.AST_Finally=xe,n.AST_Definitions=Be,n.AST_Var=Te,n.AST_Const=$e,n.AST_VarDef=Oe,n.AST_Call=Me,n.AST_New=Ne,n.AST_Seq=Re,n.AST_PropAccess=qe,n.AST_Dot=He,n.AST_Sub=ze,n.AST_Unary=Pe,n.AST_UnaryPrefix=je,n.AST_UnaryPostfix=Ie,n.AST_Binary=Ue,n.AST_Conditional=Ve,n.AST_Assign=Le,n.AST_Array=We,n.AST_Object=Ye,n.AST_ObjectProperty=Xe,n.AST_ObjectKeyVal=Ge,n.AST_ObjectSetter=Ke,n.AST_ObjectGetter=Je,n.AST_Symbol=Ze,n.AST_SymbolAccessor=Qe,n.AST_SymbolDeclaration=nt,n.AST_SymbolVar=et,n.AST_SymbolConst=tt,n.AST_SymbolFunarg=rt,n.AST_SymbolDefun=it,n.AST_SymbolLambda=ot,n.AST_SymbolCatch=at,n.AST_Label=ut,n.AST_SymbolRef=st,n.AST_LabelRef=ct,n.AST_This=ft,n.AST_Constant=lt,n.AST_String=pt,n.AST_Number=dt,n.AST_RegExp=ht,n.AST_Atom=_t,n.AST_Null=mt,n.AST_NaN=vt,n.AST_Undefined=gt,n.AST_Hole=bt,n.AST_Infinity=yt,n.AST_Boolean=At,n.AST_False=wt,n.AST_True=Et,n.TreeWalker=E,n.KEYWORDS=Dt,n.KEYWORDS_ATOM=Ft,n.RESERVED_WORDS=St,n.KEYWORDS_BEFORE_EXPRESSION=Ct,n.OPERATOR_CHARS=kt,n.RE_HEX_NUMBER=xt,n.RE_OCT_NUMBER=Bt,n.RE_DEC_NUMBER=Tt,n.OPERATORS=$t,n.WHITESPACE_CHARS=Ot,n.PUNC_BEFORE_EXPRESSION=Mt,n.PUNC_CHARS=Nt,n.REGEXP_MODIFIERS=Rt,n.UNICODE=qt,n.is_letter=D,n.is_digit=F,n.is_alphanumeric_char=S,n.is_unicode_combining_mark=C,n.is_unicode_connector_punctuation=k,n.is_identifier=x,n.is_identifier_start=B,n.is_identifier_char=T,n.is_identifier_string=$,n.parse_js_number=O,n.JS_Parse_Error=M,n.js_error=N,n.is_token=R,n.EX_EOF=Ht,n.tokenizer=q,n.UNARY_PREFIX=zt,n.UNARY_POSTFIX=Pt,n.ASSIGNMENT=jt,n.PRECEDENCE=It,n.STATEMENTS_WITH_LABELS=Ut,n.ATOMIC_START_TOKEN=Vt,n.parse=H,n.TreeTransformer=z,n.SymbolDef=P,n.base54=Lt,n.OutputStream=j,n.Compressor=I,n.SourceMap=U}({},function(){return this}());define(UglifyJS); -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | /*global brackets, define, $ */ 2 | define(function (require, exports, module) { 3 | 'use strict'; 4 | 5 | var Commands = brackets.getModule('command/Commands'), 6 | CommandManager = brackets.getModule('command/CommandManager'), 7 | Menus = brackets.getModule('command/Menus'), 8 | DocumentManager = brackets.getModule('document/DocumentManager'), 9 | FileSystem = brackets.getModule('filesystem/FileSystem'), 10 | PreferencesManager = brackets.getModule('preferences/PreferencesManager'), 11 | ProjectManager = brackets.getModule('project/ProjectManager'), 12 | ExtensionUtils = brackets.getModule('utils/ExtensionUtils'), 13 | WorkspaceManager = brackets.getModule('view/WorkspaceManager'), 14 | DefaultDialogs = brackets.getModule('widgets/DefaultDialogs'), 15 | Dialogs = brackets.getModule('widgets/Dialogs'), 16 | UglifyJS = require('UglifyJS/uglifyjs'), 17 | 18 | menu = Menus.getMenu(Menus.AppMenuBar.FILE_MENU), 19 | bottomPanel = null, 20 | panelLog = null, 21 | toolbarIcon = null, 22 | statusIcon = null, 23 | pendingTasks = 0, 24 | prefs = PreferencesManager.getExtensionPrefs("jscompiler"), 25 | compileAutoId = 'jscompiler.auto', 26 | automaton; 27 | 28 | prefs.definePreference("on-save", "boolean", false); 29 | 30 | window.MOZ_SourceMap = require('./SourceMap/source-map'); 31 | 32 | // Log 33 | function log(s) { 34 | window.console.log('[JSCompiler] ' + s); 35 | } 36 | 37 | function appendLog(s) { 38 | panelLog.append('
' + s); 39 | panelLog.scrollTop(panelLog[0].scrollHeight); 40 | } 41 | 42 | function taskDone() { 43 | pendingTasks -= 1; 44 | if (pendingTasks < 1) { 45 | appendLog('Done!
'); 46 | if (toolbarIcon.getAttribute('class') === 'active') { 47 | toolbarIcon.setAttribute('class', 'success'); 48 | } 49 | if (statusIcon.getAttribute('class') === 'active') { 50 | statusIcon.setAttribute('class', 'success'); 51 | } 52 | window.setTimeout(function () { 53 | if (prefs.get("on-save")) { 54 | toolbarIcon.setAttribute('class', 'active'); 55 | statusIcon.setAttribute('class', 'active'); 56 | } else { 57 | toolbarIcon.removeAttribute('class'); 58 | statusIcon.removeAttribute('class'); 59 | } 60 | }, 3000); 61 | } 62 | } 63 | 64 | // UglifyJS call 65 | function doUglify(inputs, output, options, directory) { 66 | 67 | // Get current directory 68 | if (directory === undefined) { 69 | directory = DocumentManager.getCurrentDocument().file.parentPath; 70 | } 71 | var path = directory + output, 72 | 73 | // Start UglifyJS magic! 74 | ast = null, 75 | code = null, 76 | compressor = UglifyJS.Compressor(), 77 | source_map = UglifyJS.SourceMap(), 78 | stream = UglifyJS.OutputStream({source_map: source_map}), 79 | i = 0, 80 | l = 0; 81 | for (i = 0, l = inputs.length; i < l; i += 1) { 82 | appendLog('Parsing file: ' + inputs[i].name); 83 | ast = UglifyJS.parse(inputs[i].content, {filename: inputs[i].name, toplevel: ast}); 84 | } 85 | appendLog('Compressing...'); 86 | ast.figure_out_scope(); 87 | ast.transform(compressor); 88 | if (!options || options.mangle !== false) { 89 | appendLog('Mangling...'); 90 | ast.figure_out_scope(); 91 | ast.compute_char_frequency(); 92 | ast.mangle_names(); 93 | } 94 | appendLog('Extracting...'); 95 | ast.print(stream); 96 | code = stream.toString(); 97 | 98 | // Append isolation code 99 | if (options && options.isolate) { 100 | appendLog('Isolating...'); 101 | code = '(function(window,undefined){' + code + '})(window);'; 102 | } 103 | 104 | appendLog('Exporting...'); 105 | // Save the map 106 | if (!options || options.generateMap !== false) { 107 | code += '\n//# sourceMappingURL=' + output.split('/').pop() + '.map'; 108 | pendingTasks += 1; 109 | FileSystem.getFileForPath(path + '.map').write(source_map.toString(), {blind: true}, function (err) { 110 | if (err) { 111 | appendLog('Error generating map at:
' + path + '.map'); 112 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on map genetarion:\n' + err); 113 | toolbarIcon.setAttribute('class', 'error'); 114 | statusIcon.setAttribute('class', 'error'); 115 | } else { 116 | appendLog('Map successfully generated at:
' + path + '.map'); 117 | } 118 | taskDone(); 119 | }); 120 | } 121 | 122 | // Save the code 123 | pendingTasks += 1; 124 | FileSystem.getFileForPath(path).write(code, {blind: true}, function (err) { 125 | if (err) { 126 | appendLog('Error compiling code at:
' + path); 127 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on compilation:\n' + err); 128 | toolbarIcon.setAttribute('class', 'error'); 129 | statusIcon.setAttribute('class', 'error'); 130 | } else { 131 | appendLog('File successfully compiled at:
' + path); 132 | } 133 | taskDone(); 134 | }); 135 | } 136 | 137 | function getContentsFrom(options, directory, contents, counter) { 138 | var output = options.output || options.inputs[0].replace(/\.js$/, '.min.js'), 139 | content = '', 140 | i = 0, 141 | l = 0; 142 | if (counter < options.inputs.length) { 143 | // There is content pending to get. Read it! 144 | appendLog('Reading ' + options.inputs[counter] + '...'); 145 | 146 | FileSystem.getFileForPath(directory + options.inputs[counter]).read({}, function (err, content) { 147 | if (err) { 148 | appendLog('Error on reading ' + options.inputs[counter] + ': ' + err + '
' + output + ' compilation cancelled.
'); 149 | toolbarIcon.setAttribute('class', 'warning'); 150 | statusIcon.setAttribute('class', 'warning'); 151 | } else { 152 | // Read content 153 | contents.push({name: options.inputs[counter], content: content}); 154 | getContentsFrom(options, directory, contents, counter + 1); 155 | } 156 | }); 157 | } else { 158 | // Contents where collected 159 | if (contents.length > 0) { 160 | // Finally compile the code 161 | if (options.precompile) { 162 | appendLog('Precompiling code into: precompiled.js'); 163 | for (i = 0, l = contents.length; i < l; i += 1) { 164 | content += contents[i].content + '\n'; 165 | } 166 | doUglify([{name: 'precompiled.js', content: content}], output, options, directory); 167 | } else { 168 | doUglify(contents, output, options, directory); 169 | } 170 | } else { 171 | appendLog('Something went wrong.
Done!'); 172 | } 173 | } 174 | } 175 | 176 | function compileWithOptions(options, directory) { 177 | var i = 0, 178 | l = 0; 179 | if (options.outputs) { 180 | // Compile each output in options 181 | l = options.outputs.length; 182 | appendLog('Found ' + l + ' outputs'); 183 | for (i = 0; i < l; i += 1) { 184 | appendLog('Generating ' + (options.outputs[i].output || options.outputs[i].inputs[0])); 185 | getContentsFrom(options.outputs[i], directory, [], 0); 186 | } 187 | } else { 188 | // Compile with old single output option format 189 | appendLog('Generating ' + options.output); 190 | getContentsFrom(options, directory, [], 0); 191 | } 192 | } 193 | 194 | function compileCurrentJS() { 195 | var currentFile = DocumentManager.getCurrentDocument().file, 196 | ext = currentFile.name.split('.').pop(); 197 | if (ext === 'js') { 198 | doUglify([{name: currentFile.name, content: DocumentManager.getCurrentDocument().getText()}], currentFile.name.replace(/\.js$/, '.min.js'), undefined, currentFile.parentPath); 199 | } else { 200 | // Current file is not JavaScript. Warn! 201 | appendLog('Current document is not JavaScript'); 202 | } 203 | } 204 | 205 | function compileJS() { 206 | log('Executing Command Compile'); 207 | pendingTasks = 0; 208 | toolbarIcon.setAttribute('class', 'active'); 209 | statusIcon.setAttribute('class', 'active'); 210 | 211 | // Search for options file 212 | var currentFile = DocumentManager.getCurrentDocument().file, 213 | directory = currentFile.parentPath, 214 | options, 215 | preferences = null; 216 | FileSystem.getFileForPath(directory + '.jscompiler.json').read({}, function (err, content) { 217 | if (err) { 218 | if (err === 'NotFound') { 219 | // Options file not found. Using project options? 220 | preferences = PreferencesManager.get('jscompiler'); 221 | if (preferences !== undefined) { 222 | // Read project options file 223 | appendLog('Loading project options'); 224 | compileWithOptions(preferences, ProjectManager.getProjectRoot().fullPath); 225 | } else { 226 | // Options not found. Try to compile current file 227 | appendLog('No options file. Compiling current script'); 228 | compileCurrentJS(); 229 | } 230 | } else { 231 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on reading options:\n' + err); 232 | toolbarIcon.setAttribute('class', 'error'); 233 | statusIcon.setAttribute('class', 'error'); 234 | } 235 | } else { 236 | // Read portable options file 237 | appendLog('Loading portable options'); 238 | options = JSON.parse(content); 239 | compileWithOptions(options, directory); 240 | } 241 | }); 242 | } 243 | 244 | function generateOptions() { 245 | // Read the template 246 | ExtensionUtils.loadFile(module, 'templates/.jscompiler.json').then(function (result) { 247 | // Get directory and file name for project options 248 | var code = null, 249 | jsonCode = null, 250 | file = DocumentManager.getCurrentDocument().file, 251 | directory = file.parentPath, 252 | directories = directory.split('/'), 253 | dirname = directories.pop(), 254 | filename = file.name.replace(/\.js$/, ''), 255 | i = 0, 256 | j = 0, 257 | l = 0, 258 | jl = 0; 259 | window.console.log(directory); 260 | if (filename === file.name) { 261 | filename = 'script'; 262 | } 263 | dirname = directories.pop(); 264 | code = result.replace(/%DIRECTORY%/g, dirname).replace(/%FILENAME%/g, filename); 265 | 266 | // Ask the user which class of options file wants to use 267 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_INFO, 'Options file not found', 'Select the type of options file you want to use for this project:', [{className: Dialogs.DIALOG_BTN_CLASS_LEFT, id: Dialogs.DIALOG_BTN_CANCEL, text: 'Cancel'}, {className: Dialogs.DIALOG_BTN_CLASS_PRIMARY, id: 'project', text: 'Project'}, {className: Dialogs.DIALOG_BTN_CLASS_NORMAL, id: 'portable', text: 'Portable'}]).done(function (id) { 268 | window.console.log('ID: ' + id); 269 | if (id === 'project') { 270 | // Create options in project file 271 | jsonCode = JSON.parse(code); 272 | directory = ProjectManager.makeProjectRelativeIfPossible(directory); 273 | for (i = 0, l = jsonCode.outputs.length; i < l; i += 1) { 274 | // Assign relative path to each input and output 275 | for (j = 0, jl = jsonCode.outputs[i].inputs.length; j < jl; j += 1) { 276 | jsonCode.outputs[i].inputs[j] = directory + jsonCode.outputs[i].inputs[j]; 277 | } 278 | jsonCode.outputs[i].output = directory + jsonCode.outputs[i].output; 279 | } 280 | PreferencesManager.set('jscompiler', jsonCode, {location: {scope: 'project'}}); 281 | // Open project options file 282 | window.setTimeout(function () {CommandManager.execute(Commands.CMD_OPEN, {fullPath: ProjectManager.getProjectRoot().fullPath + '.brackets.json'}); }, 200); 283 | } else if (id === 'portable') { 284 | // Create portable options file 285 | FileSystem.getFileForPath(directory + '.jscompiler.json').write(code, {blind: true}, function (err) { 286 | if (err) { 287 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on creating options:\n' + err); 288 | } else { 289 | // Open options file 290 | CommandManager.execute(Commands.CMD_OPEN, {fullPath: directory + '.jscompiler.json'}); 291 | } 292 | }); 293 | } 294 | }); 295 | }); 296 | } 297 | 298 | function openOptions() { 299 | var directory = DocumentManager.getCurrentDocument().file.parentPath, 300 | path = directory + '.jscompiler.json', 301 | preferences = null; 302 | 303 | // Reading the options file content 304 | FileSystem.getFileForPath(path).read({}, function (err, content) { 305 | if (err) { 306 | if (err === 'NotFound') { 307 | // Options file not found. Using project options? 308 | preferences = PreferencesManager.get('jscompiler'); 309 | if (preferences !== undefined) { 310 | // Open project options file 311 | CommandManager.execute(Commands.CMD_OPEN, {fullPath: ProjectManager.getProjectRoot().fullPath + '.brackets.json'}); 312 | } else { 313 | // Options not found. Generate 314 | log('Options file not found. Creating!'); 315 | generateOptions(); 316 | } 317 | } else { 318 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on reading options:\n' + err); 319 | } 320 | } else { 321 | // Open portable options file 322 | CommandManager.execute(Commands.CMD_OPEN, {fullPath: path}); 323 | } 324 | }); 325 | } 326 | 327 | function openTemplate() { 328 | var path = ExtensionUtils.getModulePath(module, 'templates/.jscompiler.json'); 329 | 330 | // Reading the options template... Just to be sure no one has deleted it accidentally... 331 | FileSystem.getFileForPath(path).read({}, function (err, content) { 332 | if (err) { 333 | Dialogs.showModalDialog(DefaultDialogs.DIALOG_ID_ERROR, 'JS Compiler', 'Error on reading template:\n' + err); 334 | } else { 335 | // Open options template 336 | CommandManager.execute(Commands.CMD_OPEN, {fullPath: path}); 337 | } 338 | }); 339 | } 340 | 341 | function closePanel() { 342 | bottomPanel.hide(); 343 | } 344 | 345 | function showHideAutoCompile() { 346 | if (prefs.get("on-save")) { 347 | toolbarIcon.setAttribute('class', 'active'); 348 | statusIcon.setAttribute('class', 'active'); 349 | bottomPanel.$panel.find('.compile.auto').css('background-color', '#78b2f2'); 350 | } else { 351 | statusIcon.removeAttribute('class'); 352 | toolbarIcon.removeAttribute('class'); 353 | bottomPanel.$panel.find('.compile.auto').css('background-color', ''); 354 | } 355 | } 356 | 357 | function toggleAutoCompile() { 358 | automaton.setChecked(!automaton.getChecked()); 359 | prefs.set("on-save", automaton.getChecked()); 360 | showHideAutoCompile(); 361 | } 362 | 363 | // Add file menu option 364 | menu.addMenuDivider(); 365 | 366 | // Register commands 367 | CommandManager.register('Compress JavaScript', 'jscompiler.compile', compileJS); 368 | menu.addMenuItem('jscompiler.compile'); 369 | 370 | CommandManager.register('Compress JavaScript on Save', compileAutoId, toggleAutoCompile); 371 | automaton = CommandManager.get(compileAutoId); 372 | menu.addMenuItem(automaton); 373 | 374 | CommandManager.register('Compress JavaScript: Options', 'jscompiler.options', openOptions); 375 | menu.addMenuItem('jscompiler.options'); 376 | 377 | CommandManager.register('Compress JavaScript: Options template', 'jscompiler.template', openTemplate); 378 | menu.addMenuItem('jscompiler.template'); 379 | 380 | automaton.setChecked(prefs.get("on-save")); 381 | 382 | // Start bottom panel 383 | bottomPanel = WorkspaceManager.createBottomPanel('jscompiler.panel', $('
JSCompiler
×
')); 384 | panelLog = bottomPanel.$panel.find('#log'); 385 | bottomPanel.$panel.find('.close').on('click', closePanel); 386 | bottomPanel.$panel.find('.compile.auto').click(toggleAutoCompile); 387 | bottomPanel.$panel.find('.compile.now').click(compileJS); 388 | 389 | // Load css 390 | ExtensionUtils.loadStyleSheet(module, 'styles/main.css'); 391 | 392 | // Add toolbar icon 393 | toolbarIcon = $('') 394 | .attr({ 395 | id: 'toolbar-jscompiler', 396 | title: 'Compress JavaScript', 397 | href: '#' 398 | }) 399 | .click(function () { 400 | bottomPanel.show(); 401 | compileJS(); 402 | }) 403 | .appendTo($('#main-toolbar .buttons'))[0]; 404 | 405 | // Add status icon 406 | statusIcon = $('
 
') 407 | .attr({ 408 | id: 'status-jscompiler', 409 | title: 'JavaScript Compiler Log', 410 | href: '#' 411 | }) 412 | .click(function () { 413 | if ($('#jscompiler-panel').css('display') === 'none') { 414 | bottomPanel.show(); 415 | } else { 416 | bottomPanel.hide(); 417 | } 418 | }) 419 | .insertAfter($('#status-indicators #status-indent'))[0]; 420 | 421 | // Compile on save 422 | $(DocumentManager).on("documentSaved", function (event, doc) { 423 | if (prefs.get("on-save")) { 424 | var ext = DocumentManager.getCurrentDocument().file.name.split('.').pop(); 425 | if (ext === 'js') { 426 | compileCurrentJS(); 427 | } 428 | } 429 | }); 430 | 431 | showHideAutoCompile(); 432 | }); 433 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ktayfer.jscompiler", 3 | "title": "JSCompiler2", 4 | "description": "Compress your JavaScript code from multiple files into one minified file (Powered by UglifyJS2).", 5 | "homepage": "https://github.com/daPhyre/brackets-jscompiler", 6 | "version": "2.1.1", 7 | "author": "Karl Tayfer", 8 | "contributors": [ 9 | "Karl Tayfer (https://github.com/daPhyre)", 10 | "mrmckeb (https://github.com/mrmckeb)", 11 | "Henry LaVoo (https://github.com/henrylavoo)" 12 | ], 13 | "license": "MIT", 14 | "engines": { 15 | "brackets": ">=1.0.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /styles/images/jscompiler.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /styles/main.css: -------------------------------------------------------------------------------- 1 | #toolbar-jscompiler { 2 | background-image: url(images/jscompiler.svg); 3 | height: 24px; 4 | width: 24px; 5 | } 6 | #toolbar-jscompiler.success { 7 | background-position: 0 -24px; 8 | } 9 | #toolbar-jscompiler.active { 10 | background-position: 0 -48px; 11 | } 12 | #toolbar-jscompiler.warning { 13 | background-position: 0 -72px; 14 | } 15 | #toolbar-jscompiler.error { 16 | background-position: 0 -96px; 17 | } 18 | #toolbar-jscompiler.disabled { 19 | opacity: 0.4; 20 | } 21 | 22 | #status-jscompiler { 23 | background-color: transparent; 24 | background-image: url(images/jscompiler.svg); 25 | background-repeat: no-repeat; 26 | cursor: pointer; 27 | width: 5px; 28 | } 29 | #status-jscompiler.success { 30 | background-position: 0 -24px; 31 | } 32 | #status-jscompiler.active { 33 | background-position: 0 -48px; 34 | } 35 | #status-jscompiler.warning { 36 | background-position: 0 -72px; 37 | } 38 | #status-jscompiler.error { 39 | background-position: 0 -96px; 40 | } 41 | #status-jscompiler.disabled { 42 | opacity: 0.4; 43 | } 44 | 45 | #jscompiler-panel .compile { 46 | margin-left: 10px; 47 | padding: 0 5px; 48 | border: none; 49 | border-radius: 3px; 50 | background-color: #3C3F41; 51 | text-transform: uppercase; 52 | font-size: 12px; 53 | color: #ddd; 54 | cursor: pointer; 55 | } 56 | #jscompiler-panel .compile:hover { 57 | background-color: #47484B; 58 | color: #fff; 59 | } 60 | -------------------------------------------------------------------------------- /templates/.jscompiler.json: -------------------------------------------------------------------------------- 1 | { 2 | "outputs": [ 3 | { 4 | "inputs": ["%FILENAME%.js"], 5 | "output": "%FILENAME%.min.js", 6 | "generateMap": true, 7 | "mangle": true, 8 | "isolate": false 9 | } 10 | ] 11 | } --------------------------------------------------------------------------------