Initial commit
[yaffs-website] / node_modules / source-map / dist / source-map.js
1 (function webpackUniversalModuleDefinition(root, factory) {
2         if(typeof exports === 'object' && typeof module === 'object')
3                 module.exports = factory();
4         else if(typeof define === 'function' && define.amd)
5                 define([], factory);
6         else if(typeof exports === 'object')
7                 exports["sourceMap"] = factory();
8         else
9                 root["sourceMap"] = factory();
10 })(this, function() {
11 return /******/ (function(modules) { // webpackBootstrap
12 /******/        // The module cache
13 /******/        var installedModules = {};
14
15 /******/        // The require function
16 /******/        function __webpack_require__(moduleId) {
17
18 /******/                // Check if module is in cache
19 /******/                if(installedModules[moduleId])
20 /******/                        return installedModules[moduleId].exports;
21
22 /******/                // Create a new module (and put it into the cache)
23 /******/                var module = installedModules[moduleId] = {
24 /******/                        exports: {},
25 /******/                        id: moduleId,
26 /******/                        loaded: false
27 /******/                };
28
29 /******/                // Execute the module function
30 /******/                modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31
32 /******/                // Flag the module as loaded
33 /******/                module.loaded = true;
34
35 /******/                // Return the exports of the module
36 /******/                return module.exports;
37 /******/        }
38
39
40 /******/        // expose the modules object (__webpack_modules__)
41 /******/        __webpack_require__.m = modules;
42
43 /******/        // expose the module cache
44 /******/        __webpack_require__.c = installedModules;
45
46 /******/        // __webpack_public_path__
47 /******/        __webpack_require__.p = "";
48
49 /******/        // Load entry module and return exports
50 /******/        return __webpack_require__(0);
51 /******/ })
52 /************************************************************************/
53 /******/ ([
54 /* 0 */
55 /***/ function(module, exports, __webpack_require__) {
56
57         /*
58          * Copyright 2009-2011 Mozilla Foundation and contributors
59          * Licensed under the New BSD license. See LICENSE.txt or:
60          * http://opensource.org/licenses/BSD-3-Clause
61          */
62         exports.SourceMapGenerator = __webpack_require__(1).SourceMapGenerator;
63         exports.SourceMapConsumer = __webpack_require__(7).SourceMapConsumer;
64         exports.SourceNode = __webpack_require__(10).SourceNode;
65
66
67 /***/ },
68 /* 1 */
69 /***/ function(module, exports, __webpack_require__) {
70
71         /* -*- Mode: js; js-indent-level: 2; -*- */
72         /*
73          * Copyright 2011 Mozilla Foundation and contributors
74          * Licensed under the New BSD license. See LICENSE or:
75          * http://opensource.org/licenses/BSD-3-Clause
76          */
77
78         var base64VLQ = __webpack_require__(2);
79         var util = __webpack_require__(4);
80         var ArraySet = __webpack_require__(5).ArraySet;
81         var MappingList = __webpack_require__(6).MappingList;
82
83         /**
84          * An instance of the SourceMapGenerator represents a source map which is
85          * being built incrementally. You may pass an object with the following
86          * properties:
87          *
88          *   - file: The filename of the generated source.
89          *   - sourceRoot: A root for all relative URLs in this source map.
90          */
91         function SourceMapGenerator(aArgs) {
92           if (!aArgs) {
93             aArgs = {};
94           }
95           this._file = util.getArg(aArgs, 'file', null);
96           this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null);
97           this._skipValidation = util.getArg(aArgs, 'skipValidation', false);
98           this._sources = new ArraySet();
99           this._names = new ArraySet();
100           this._mappings = new MappingList();
101           this._sourcesContents = null;
102         }
103
104         SourceMapGenerator.prototype._version = 3;
105
106         /**
107          * Creates a new SourceMapGenerator based on a SourceMapConsumer
108          *
109          * @param aSourceMapConsumer The SourceMap.
110          */
111         SourceMapGenerator.fromSourceMap =
112           function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) {
113             var sourceRoot = aSourceMapConsumer.sourceRoot;
114             var generator = new SourceMapGenerator({
115               file: aSourceMapConsumer.file,
116               sourceRoot: sourceRoot
117             });
118             aSourceMapConsumer.eachMapping(function (mapping) {
119               var newMapping = {
120                 generated: {
121                   line: mapping.generatedLine,
122                   column: mapping.generatedColumn
123                 }
124               };
125
126               if (mapping.source != null) {
127                 newMapping.source = mapping.source;
128                 if (sourceRoot != null) {
129                   newMapping.source = util.relative(sourceRoot, newMapping.source);
130                 }
131
132                 newMapping.original = {
133                   line: mapping.originalLine,
134                   column: mapping.originalColumn
135                 };
136
137                 if (mapping.name != null) {
138                   newMapping.name = mapping.name;
139                 }
140               }
141
142               generator.addMapping(newMapping);
143             });
144             aSourceMapConsumer.sources.forEach(function (sourceFile) {
145               var content = aSourceMapConsumer.sourceContentFor(sourceFile);
146               if (content != null) {
147                 generator.setSourceContent(sourceFile, content);
148               }
149             });
150             return generator;
151           };
152
153         /**
154          * Add a single mapping from original source line and column to the generated
155          * source's line and column for this source map being created. The mapping
156          * object should have the following properties:
157          *
158          *   - generated: An object with the generated line and column positions.
159          *   - original: An object with the original line and column positions.
160          *   - source: The original source file (relative to the sourceRoot).
161          *   - name: An optional original token name for this mapping.
162          */
163         SourceMapGenerator.prototype.addMapping =
164           function SourceMapGenerator_addMapping(aArgs) {
165             var generated = util.getArg(aArgs, 'generated');
166             var original = util.getArg(aArgs, 'original', null);
167             var source = util.getArg(aArgs, 'source', null);
168             var name = util.getArg(aArgs, 'name', null);
169
170             if (!this._skipValidation) {
171               this._validateMapping(generated, original, source, name);
172             }
173
174             if (source != null) {
175               source = String(source);
176               if (!this._sources.has(source)) {
177                 this._sources.add(source);
178               }
179             }
180
181             if (name != null) {
182               name = String(name);
183               if (!this._names.has(name)) {
184                 this._names.add(name);
185               }
186             }
187
188             this._mappings.add({
189               generatedLine: generated.line,
190               generatedColumn: generated.column,
191               originalLine: original != null && original.line,
192               originalColumn: original != null && original.column,
193               source: source,
194               name: name
195             });
196           };
197
198         /**
199          * Set the source content for a source file.
200          */
201         SourceMapGenerator.prototype.setSourceContent =
202           function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) {
203             var source = aSourceFile;
204             if (this._sourceRoot != null) {
205               source = util.relative(this._sourceRoot, source);
206             }
207
208             if (aSourceContent != null) {
209               // Add the source content to the _sourcesContents map.
210               // Create a new _sourcesContents map if the property is null.
211               if (!this._sourcesContents) {
212                 this._sourcesContents = Object.create(null);
213               }
214               this._sourcesContents[util.toSetString(source)] = aSourceContent;
215             } else if (this._sourcesContents) {
216               // Remove the source file from the _sourcesContents map.
217               // If the _sourcesContents map is empty, set the property to null.
218               delete this._sourcesContents[util.toSetString(source)];
219               if (Object.keys(this._sourcesContents).length === 0) {
220                 this._sourcesContents = null;
221               }
222             }
223           };
224
225         /**
226          * Applies the mappings of a sub-source-map for a specific source file to the
227          * source map being generated. Each mapping to the supplied source file is
228          * rewritten using the supplied source map. Note: The resolution for the
229          * resulting mappings is the minimium of this map and the supplied map.
230          *
231          * @param aSourceMapConsumer The source map to be applied.
232          * @param aSourceFile Optional. The filename of the source file.
233          *        If omitted, SourceMapConsumer's file property will be used.
234          * @param aSourceMapPath Optional. The dirname of the path to the source map
235          *        to be applied. If relative, it is relative to the SourceMapConsumer.
236          *        This parameter is needed when the two source maps aren't in the same
237          *        directory, and the source map to be applied contains relative source
238          *        paths. If so, those relative source paths need to be rewritten
239          *        relative to the SourceMapGenerator.
240          */
241         SourceMapGenerator.prototype.applySourceMap =
242           function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile, aSourceMapPath) {
243             var sourceFile = aSourceFile;
244             // If aSourceFile is omitted, we will use the file property of the SourceMap
245             if (aSourceFile == null) {
246               if (aSourceMapConsumer.file == null) {
247                 throw new Error(
248                   'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
249                   'or the source map\'s "file" property. Both were omitted.'
250                 );
251               }
252               sourceFile = aSourceMapConsumer.file;
253             }
254             var sourceRoot = this._sourceRoot;
255             // Make "sourceFile" relative if an absolute Url is passed.
256             if (sourceRoot != null) {
257               sourceFile = util.relative(sourceRoot, sourceFile);
258             }
259             // Applying the SourceMap can add and remove items from the sources and
260             // the names array.
261             var newSources = new ArraySet();
262             var newNames = new ArraySet();
263
264             // Find mappings for the "sourceFile"
265             this._mappings.unsortedForEach(function (mapping) {
266               if (mapping.source === sourceFile && mapping.originalLine != null) {
267                 // Check if it can be mapped by the source map, then update the mapping.
268                 var original = aSourceMapConsumer.originalPositionFor({
269                   line: mapping.originalLine,
270                   column: mapping.originalColumn
271                 });
272                 if (original.source != null) {
273                   // Copy mapping
274                   mapping.source = original.source;
275                   if (aSourceMapPath != null) {
276                     mapping.source = util.join(aSourceMapPath, mapping.source)
277                   }
278                   if (sourceRoot != null) {
279                     mapping.source = util.relative(sourceRoot, mapping.source);
280                   }
281                   mapping.originalLine = original.line;
282                   mapping.originalColumn = original.column;
283                   if (original.name != null) {
284                     mapping.name = original.name;
285                   }
286                 }
287               }
288
289               var source = mapping.source;
290               if (source != null && !newSources.has(source)) {
291                 newSources.add(source);
292               }
293
294               var name = mapping.name;
295               if (name != null && !newNames.has(name)) {
296                 newNames.add(name);
297               }
298
299             }, this);
300             this._sources = newSources;
301             this._names = newNames;
302
303             // Copy sourcesContents of applied map.
304             aSourceMapConsumer.sources.forEach(function (sourceFile) {
305               var content = aSourceMapConsumer.sourceContentFor(sourceFile);
306               if (content != null) {
307                 if (aSourceMapPath != null) {
308                   sourceFile = util.join(aSourceMapPath, sourceFile);
309                 }
310                 if (sourceRoot != null) {
311                   sourceFile = util.relative(sourceRoot, sourceFile);
312                 }
313                 this.setSourceContent(sourceFile, content);
314               }
315             }, this);
316           };
317
318         /**
319          * A mapping can have one of the three levels of data:
320          *
321          *   1. Just the generated position.
322          *   2. The Generated position, original position, and original source.
323          *   3. Generated and original position, original source, as well as a name
324          *      token.
325          *
326          * To maintain consistency, we validate that any new mapping being added falls
327          * in to one of these categories.
328          */
329         SourceMapGenerator.prototype._validateMapping =
330           function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource,
331                                                       aName) {
332             if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
333                 && aGenerated.line > 0 && aGenerated.column >= 0
334                 && !aOriginal && !aSource && !aName) {
335               // Case 1.
336               return;
337             }
338             else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated
339                      && aOriginal && 'line' in aOriginal && 'column' in aOriginal
340                      && aGenerated.line > 0 && aGenerated.column >= 0
341                      && aOriginal.line > 0 && aOriginal.column >= 0
342                      && aSource) {
343               // Cases 2 and 3.
344               return;
345             }
346             else {
347               throw new Error('Invalid mapping: ' + JSON.stringify({
348                 generated: aGenerated,
349                 source: aSource,
350                 original: aOriginal,
351                 name: aName
352               }));
353             }
354           };
355
356         /**
357          * Serialize the accumulated mappings in to the stream of base 64 VLQs
358          * specified by the source map format.
359          */
360         SourceMapGenerator.prototype._serializeMappings =
361           function SourceMapGenerator_serializeMappings() {
362             var previousGeneratedColumn = 0;
363             var previousGeneratedLine = 1;
364             var previousOriginalColumn = 0;
365             var previousOriginalLine = 0;
366             var previousName = 0;
367             var previousSource = 0;
368             var result = '';
369             var next;
370             var mapping;
371             var nameIdx;
372             var sourceIdx;
373
374             var mappings = this._mappings.toArray();
375             for (var i = 0, len = mappings.length; i < len; i++) {
376               mapping = mappings[i];
377               next = ''
378
379               if (mapping.generatedLine !== previousGeneratedLine) {
380                 previousGeneratedColumn = 0;
381                 while (mapping.generatedLine !== previousGeneratedLine) {
382                   next += ';';
383                   previousGeneratedLine++;
384                 }
385               }
386               else {
387                 if (i > 0) {
388                   if (!util.compareByGeneratedPositionsInflated(mapping, mappings[i - 1])) {
389                     continue;
390                   }
391                   next += ',';
392                 }
393               }
394
395               next += base64VLQ.encode(mapping.generatedColumn
396                                          - previousGeneratedColumn);
397               previousGeneratedColumn = mapping.generatedColumn;
398
399               if (mapping.source != null) {
400                 sourceIdx = this._sources.indexOf(mapping.source);
401                 next += base64VLQ.encode(sourceIdx - previousSource);
402                 previousSource = sourceIdx;
403
404                 // lines are stored 0-based in SourceMap spec version 3
405                 next += base64VLQ.encode(mapping.originalLine - 1
406                                            - previousOriginalLine);
407                 previousOriginalLine = mapping.originalLine - 1;
408
409                 next += base64VLQ.encode(mapping.originalColumn
410                                            - previousOriginalColumn);
411                 previousOriginalColumn = mapping.originalColumn;
412
413                 if (mapping.name != null) {
414                   nameIdx = this._names.indexOf(mapping.name);
415                   next += base64VLQ.encode(nameIdx - previousName);
416                   previousName = nameIdx;
417                 }
418               }
419
420               result += next;
421             }
422
423             return result;
424           };
425
426         SourceMapGenerator.prototype._generateSourcesContent =
427           function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) {
428             return aSources.map(function (source) {
429               if (!this._sourcesContents) {
430                 return null;
431               }
432               if (aSourceRoot != null) {
433                 source = util.relative(aSourceRoot, source);
434               }
435               var key = util.toSetString(source);
436               return Object.prototype.hasOwnProperty.call(this._sourcesContents, key)
437                 ? this._sourcesContents[key]
438                 : null;
439             }, this);
440           };
441
442         /**
443          * Externalize the source map.
444          */
445         SourceMapGenerator.prototype.toJSON =
446           function SourceMapGenerator_toJSON() {
447             var map = {
448               version: this._version,
449               sources: this._sources.toArray(),
450               names: this._names.toArray(),
451               mappings: this._serializeMappings()
452             };
453             if (this._file != null) {
454               map.file = this._file;
455             }
456             if (this._sourceRoot != null) {
457               map.sourceRoot = this._sourceRoot;
458             }
459             if (this._sourcesContents) {
460               map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot);
461             }
462
463             return map;
464           };
465
466         /**
467          * Render the source map being generated to a string.
468          */
469         SourceMapGenerator.prototype.toString =
470           function SourceMapGenerator_toString() {
471             return JSON.stringify(this.toJSON());
472           };
473
474         exports.SourceMapGenerator = SourceMapGenerator;
475
476
477 /***/ },
478 /* 2 */
479 /***/ function(module, exports, __webpack_require__) {
480
481         /* -*- Mode: js; js-indent-level: 2; -*- */
482         /*
483          * Copyright 2011 Mozilla Foundation and contributors
484          * Licensed under the New BSD license. See LICENSE or:
485          * http://opensource.org/licenses/BSD-3-Clause
486          *
487          * Based on the Base 64 VLQ implementation in Closure Compiler:
488          * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java
489          *
490          * Copyright 2011 The Closure Compiler Authors. All rights reserved.
491          * Redistribution and use in source and binary forms, with or without
492          * modification, are permitted provided that the following conditions are
493          * met:
494          *
495          *  * Redistributions of source code must retain the above copyright
496          *    notice, this list of conditions and the following disclaimer.
497          *  * Redistributions in binary form must reproduce the above
498          *    copyright notice, this list of conditions and the following
499          *    disclaimer in the documentation and/or other materials provided
500          *    with the distribution.
501          *  * Neither the name of Google Inc. nor the names of its
502          *    contributors may be used to endorse or promote products derived
503          *    from this software without specific prior written permission.
504          *
505          * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
506          * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
507          * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
508          * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
509          * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
510          * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
511          * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
512          * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
513          * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
514          * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
515          * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
516          */
517
518         var base64 = __webpack_require__(3);
519
520         // A single base 64 digit can contain 6 bits of data. For the base 64 variable
521         // length quantities we use in the source map spec, the first bit is the sign,
522         // the next four bits are the actual value, and the 6th bit is the
523         // continuation bit. The continuation bit tells us whether there are more
524         // digits in this value following this digit.
525         //
526         //   Continuation
527         //   |    Sign
528         //   |    |
529         //   V    V
530         //   101011
531
532         var VLQ_BASE_SHIFT = 5;
533
534         // binary: 100000
535         var VLQ_BASE = 1 << VLQ_BASE_SHIFT;
536
537         // binary: 011111
538         var VLQ_BASE_MASK = VLQ_BASE - 1;
539
540         // binary: 100000
541         var VLQ_CONTINUATION_BIT = VLQ_BASE;
542
543         /**
544          * Converts from a two-complement value to a value where the sign bit is
545          * placed in the least significant bit.  For example, as decimals:
546          *   1 becomes 2 (10 binary), -1 becomes 3 (11 binary)
547          *   2 becomes 4 (100 binary), -2 becomes 5 (101 binary)
548          */
549         function toVLQSigned(aValue) {
550           return aValue < 0
551             ? ((-aValue) << 1) + 1
552             : (aValue << 1) + 0;
553         }
554
555         /**
556          * Converts to a two-complement value from a value where the sign bit is
557          * placed in the least significant bit.  For example, as decimals:
558          *   2 (10 binary) becomes 1, 3 (11 binary) becomes -1
559          *   4 (100 binary) becomes 2, 5 (101 binary) becomes -2
560          */
561         function fromVLQSigned(aValue) {
562           var isNegative = (aValue & 1) === 1;
563           var shifted = aValue >> 1;
564           return isNegative
565             ? -shifted
566             : shifted;
567         }
568
569         /**
570          * Returns the base 64 VLQ encoded value.
571          */
572         exports.encode = function base64VLQ_encode(aValue) {
573           var encoded = "";
574           var digit;
575
576           var vlq = toVLQSigned(aValue);
577
578           do {
579             digit = vlq & VLQ_BASE_MASK;
580             vlq >>>= VLQ_BASE_SHIFT;
581             if (vlq > 0) {
582               // There are still more digits in this value, so we must make sure the
583               // continuation bit is marked.
584               digit |= VLQ_CONTINUATION_BIT;
585             }
586             encoded += base64.encode(digit);
587           } while (vlq > 0);
588
589           return encoded;
590         };
591
592         /**
593          * Decodes the next base 64 VLQ value from the given string and returns the
594          * value and the rest of the string via the out parameter.
595          */
596         exports.decode = function base64VLQ_decode(aStr, aIndex, aOutParam) {
597           var strLen = aStr.length;
598           var result = 0;
599           var shift = 0;
600           var continuation, digit;
601
602           do {
603             if (aIndex >= strLen) {
604               throw new Error("Expected more digits in base 64 VLQ value.");
605             }
606
607             digit = base64.decode(aStr.charCodeAt(aIndex++));
608             if (digit === -1) {
609               throw new Error("Invalid base64 digit: " + aStr.charAt(aIndex - 1));
610             }
611
612             continuation = !!(digit & VLQ_CONTINUATION_BIT);
613             digit &= VLQ_BASE_MASK;
614             result = result + (digit << shift);
615             shift += VLQ_BASE_SHIFT;
616           } while (continuation);
617
618           aOutParam.value = fromVLQSigned(result);
619           aOutParam.rest = aIndex;
620         };
621
622
623 /***/ },
624 /* 3 */
625 /***/ function(module, exports) {
626
627         /* -*- Mode: js; js-indent-level: 2; -*- */
628         /*
629          * Copyright 2011 Mozilla Foundation and contributors
630          * Licensed under the New BSD license. See LICENSE or:
631          * http://opensource.org/licenses/BSD-3-Clause
632          */
633
634         var intToCharMap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'.split('');
635
636         /**
637          * Encode an integer in the range of 0 to 63 to a single base 64 digit.
638          */
639         exports.encode = function (number) {
640           if (0 <= number && number < intToCharMap.length) {
641             return intToCharMap[number];
642           }
643           throw new TypeError("Must be between 0 and 63: " + number);
644         };
645
646         /**
647          * Decode a single base 64 character code digit to an integer. Returns -1 on
648          * failure.
649          */
650         exports.decode = function (charCode) {
651           var bigA = 65;     // 'A'
652           var bigZ = 90;     // 'Z'
653
654           var littleA = 97;  // 'a'
655           var littleZ = 122; // 'z'
656
657           var zero = 48;     // '0'
658           var nine = 57;     // '9'
659
660           var plus = 43;     // '+'
661           var slash = 47;    // '/'
662
663           var littleOffset = 26;
664           var numberOffset = 52;
665
666           // 0 - 25: ABCDEFGHIJKLMNOPQRSTUVWXYZ
667           if (bigA <= charCode && charCode <= bigZ) {
668             return (charCode - bigA);
669           }
670
671           // 26 - 51: abcdefghijklmnopqrstuvwxyz
672           if (littleA <= charCode && charCode <= littleZ) {
673             return (charCode - littleA + littleOffset);
674           }
675
676           // 52 - 61: 0123456789
677           if (zero <= charCode && charCode <= nine) {
678             return (charCode - zero + numberOffset);
679           }
680
681           // 62: +
682           if (charCode == plus) {
683             return 62;
684           }
685
686           // 63: /
687           if (charCode == slash) {
688             return 63;
689           }
690
691           // Invalid base64 digit.
692           return -1;
693         };
694
695
696 /***/ },
697 /* 4 */
698 /***/ function(module, exports) {
699
700         /* -*- Mode: js; js-indent-level: 2; -*- */
701         /*
702          * Copyright 2011 Mozilla Foundation and contributors
703          * Licensed under the New BSD license. See LICENSE or:
704          * http://opensource.org/licenses/BSD-3-Clause
705          */
706
707         /**
708          * This is a helper function for getting values from parameter/options
709          * objects.
710          *
711          * @param args The object we are extracting values from
712          * @param name The name of the property we are getting.
713          * @param defaultValue An optional value to return if the property is missing
714          * from the object. If this is not specified and the property is missing, an
715          * error will be thrown.
716          */
717         function getArg(aArgs, aName, aDefaultValue) {
718           if (aName in aArgs) {
719             return aArgs[aName];
720           } else if (arguments.length === 3) {
721             return aDefaultValue;
722           } else {
723             throw new Error('"' + aName + '" is a required argument.');
724           }
725         }
726         exports.getArg = getArg;
727
728         var urlRegexp = /^(?:([\w+\-.]+):)?\/\/(?:(\w+:\w+)@)?([\w.]*)(?::(\d+))?(\S*)$/;
729         var dataUrlRegexp = /^data:.+\,.+$/;
730
731         function urlParse(aUrl) {
732           var match = aUrl.match(urlRegexp);
733           if (!match) {
734             return null;
735           }
736           return {
737             scheme: match[1],
738             auth: match[2],
739             host: match[3],
740             port: match[4],
741             path: match[5]
742           };
743         }
744         exports.urlParse = urlParse;
745
746         function urlGenerate(aParsedUrl) {
747           var url = '';
748           if (aParsedUrl.scheme) {
749             url += aParsedUrl.scheme + ':';
750           }
751           url += '//';
752           if (aParsedUrl.auth) {
753             url += aParsedUrl.auth + '@';
754           }
755           if (aParsedUrl.host) {
756             url += aParsedUrl.host;
757           }
758           if (aParsedUrl.port) {
759             url += ":" + aParsedUrl.port
760           }
761           if (aParsedUrl.path) {
762             url += aParsedUrl.path;
763           }
764           return url;
765         }
766         exports.urlGenerate = urlGenerate;
767
768         /**
769          * Normalizes a path, or the path portion of a URL:
770          *
771          * - Replaces consequtive slashes with one slash.
772          * - Removes unnecessary '.' parts.
773          * - Removes unnecessary '<dir>/..' parts.
774          *
775          * Based on code in the Node.js 'path' core module.
776          *
777          * @param aPath The path or url to normalize.
778          */
779         function normalize(aPath) {
780           var path = aPath;
781           var url = urlParse(aPath);
782           if (url) {
783             if (!url.path) {
784               return aPath;
785             }
786             path = url.path;
787           }
788           var isAbsolute = exports.isAbsolute(path);
789
790           var parts = path.split(/\/+/);
791           for (var part, up = 0, i = parts.length - 1; i >= 0; i--) {
792             part = parts[i];
793             if (part === '.') {
794               parts.splice(i, 1);
795             } else if (part === '..') {
796               up++;
797             } else if (up > 0) {
798               if (part === '') {
799                 // The first part is blank if the path is absolute. Trying to go
800                 // above the root is a no-op. Therefore we can remove all '..' parts
801                 // directly after the root.
802                 parts.splice(i + 1, up);
803                 up = 0;
804               } else {
805                 parts.splice(i, 2);
806                 up--;
807               }
808             }
809           }
810           path = parts.join('/');
811
812           if (path === '') {
813             path = isAbsolute ? '/' : '.';
814           }
815
816           if (url) {
817             url.path = path;
818             return urlGenerate(url);
819           }
820           return path;
821         }
822         exports.normalize = normalize;
823
824         /**
825          * Joins two paths/URLs.
826          *
827          * @param aRoot The root path or URL.
828          * @param aPath The path or URL to be joined with the root.
829          *
830          * - If aPath is a URL or a data URI, aPath is returned, unless aPath is a
831          *   scheme-relative URL: Then the scheme of aRoot, if any, is prepended
832          *   first.
833          * - Otherwise aPath is a path. If aRoot is a URL, then its path portion
834          *   is updated with the result and aRoot is returned. Otherwise the result
835          *   is returned.
836          *   - If aPath is absolute, the result is aPath.
837          *   - Otherwise the two paths are joined with a slash.
838          * - Joining for example 'http://' and 'www.example.com' is also supported.
839          */
840         function join(aRoot, aPath) {
841           if (aRoot === "") {
842             aRoot = ".";
843           }
844           if (aPath === "") {
845             aPath = ".";
846           }
847           var aPathUrl = urlParse(aPath);
848           var aRootUrl = urlParse(aRoot);
849           if (aRootUrl) {
850             aRoot = aRootUrl.path || '/';
851           }
852
853           // `join(foo, '//www.example.org')`
854           if (aPathUrl && !aPathUrl.scheme) {
855             if (aRootUrl) {
856               aPathUrl.scheme = aRootUrl.scheme;
857             }
858             return urlGenerate(aPathUrl);
859           }
860
861           if (aPathUrl || aPath.match(dataUrlRegexp)) {
862             return aPath;
863           }
864
865           // `join('http://', 'www.example.com')`
866           if (aRootUrl && !aRootUrl.host && !aRootUrl.path) {
867             aRootUrl.host = aPath;
868             return urlGenerate(aRootUrl);
869           }
870
871           var joined = aPath.charAt(0) === '/'
872             ? aPath
873             : normalize(aRoot.replace(/\/+$/, '') + '/' + aPath);
874
875           if (aRootUrl) {
876             aRootUrl.path = joined;
877             return urlGenerate(aRootUrl);
878           }
879           return joined;
880         }
881         exports.join = join;
882
883         exports.isAbsolute = function (aPath) {
884           return aPath.charAt(0) === '/' || !!aPath.match(urlRegexp);
885         };
886
887         /**
888          * Make a path relative to a URL or another path.
889          *
890          * @param aRoot The root path or URL.
891          * @param aPath The path or URL to be made relative to aRoot.
892          */
893         function relative(aRoot, aPath) {
894           if (aRoot === "") {
895             aRoot = ".";
896           }
897
898           aRoot = aRoot.replace(/\/$/, '');
899
900           // It is possible for the path to be above the root. In this case, simply
901           // checking whether the root is a prefix of the path won't work. Instead, we
902           // need to remove components from the root one by one, until either we find
903           // a prefix that fits, or we run out of components to remove.
904           var level = 0;
905           while (aPath.indexOf(aRoot + '/') !== 0) {
906             var index = aRoot.lastIndexOf("/");
907             if (index < 0) {
908               return aPath;
909             }
910
911             // If the only part of the root that is left is the scheme (i.e. http://,
912             // file:///, etc.), one or more slashes (/), or simply nothing at all, we
913             // have exhausted all components, so the path is not relative to the root.
914             aRoot = aRoot.slice(0, index);
915             if (aRoot.match(/^([^\/]+:\/)?\/*$/)) {
916               return aPath;
917             }
918
919             ++level;
920           }
921
922           // Make sure we add a "../" for each component we removed from the root.
923           return Array(level + 1).join("../") + aPath.substr(aRoot.length + 1);
924         }
925         exports.relative = relative;
926
927         var supportsNullProto = (function () {
928           var obj = Object.create(null);
929           return !('__proto__' in obj);
930         }());
931
932         function identity (s) {
933           return s;
934         }
935
936         /**
937          * Because behavior goes wacky when you set `__proto__` on objects, we
938          * have to prefix all the strings in our set with an arbitrary character.
939          *
940          * See https://github.com/mozilla/source-map/pull/31 and
941          * https://github.com/mozilla/source-map/issues/30
942          *
943          * @param String aStr
944          */
945         function toSetString(aStr) {
946           if (isProtoString(aStr)) {
947             return '$' + aStr;
948           }
949
950           return aStr;
951         }
952         exports.toSetString = supportsNullProto ? identity : toSetString;
953
954         function fromSetString(aStr) {
955           if (isProtoString(aStr)) {
956             return aStr.slice(1);
957           }
958
959           return aStr;
960         }
961         exports.fromSetString = supportsNullProto ? identity : fromSetString;
962
963         function isProtoString(s) {
964           if (!s) {
965             return false;
966           }
967
968           var length = s.length;
969
970           if (length < 9 /* "__proto__".length */) {
971             return false;
972           }
973
974           if (s.charCodeAt(length - 1) !== 95  /* '_' */ ||
975               s.charCodeAt(length - 2) !== 95  /* '_' */ ||
976               s.charCodeAt(length - 3) !== 111 /* 'o' */ ||
977               s.charCodeAt(length - 4) !== 116 /* 't' */ ||
978               s.charCodeAt(length - 5) !== 111 /* 'o' */ ||
979               s.charCodeAt(length - 6) !== 114 /* 'r' */ ||
980               s.charCodeAt(length - 7) !== 112 /* 'p' */ ||
981               s.charCodeAt(length - 8) !== 95  /* '_' */ ||
982               s.charCodeAt(length - 9) !== 95  /* '_' */) {
983             return false;
984           }
985
986           for (var i = length - 10; i >= 0; i--) {
987             if (s.charCodeAt(i) !== 36 /* '$' */) {
988               return false;
989             }
990           }
991
992           return true;
993         }
994
995         /**
996          * Comparator between two mappings where the original positions are compared.
997          *
998          * Optionally pass in `true` as `onlyCompareGenerated` to consider two
999          * mappings with the same original source/line/column, but different generated
1000          * line and column the same. Useful when searching for a mapping with a
1001          * stubbed out mapping.
1002          */
1003         function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) {
1004           var cmp = mappingA.source - mappingB.source;
1005           if (cmp !== 0) {
1006             return cmp;
1007           }
1008
1009           cmp = mappingA.originalLine - mappingB.originalLine;
1010           if (cmp !== 0) {
1011             return cmp;
1012           }
1013
1014           cmp = mappingA.originalColumn - mappingB.originalColumn;
1015           if (cmp !== 0 || onlyCompareOriginal) {
1016             return cmp;
1017           }
1018
1019           cmp = mappingA.generatedColumn - mappingB.generatedColumn;
1020           if (cmp !== 0) {
1021             return cmp;
1022           }
1023
1024           cmp = mappingA.generatedLine - mappingB.generatedLine;
1025           if (cmp !== 0) {
1026             return cmp;
1027           }
1028
1029           return mappingA.name - mappingB.name;
1030         }
1031         exports.compareByOriginalPositions = compareByOriginalPositions;
1032
1033         /**
1034          * Comparator between two mappings with deflated source and name indices where
1035          * the generated positions are compared.
1036          *
1037          * Optionally pass in `true` as `onlyCompareGenerated` to consider two
1038          * mappings with the same generated line and column, but different
1039          * source/name/original line and column the same. Useful when searching for a
1040          * mapping with a stubbed out mapping.
1041          */
1042         function compareByGeneratedPositionsDeflated(mappingA, mappingB, onlyCompareGenerated) {
1043           var cmp = mappingA.generatedLine - mappingB.generatedLine;
1044           if (cmp !== 0) {
1045             return cmp;
1046           }
1047
1048           cmp = mappingA.generatedColumn - mappingB.generatedColumn;
1049           if (cmp !== 0 || onlyCompareGenerated) {
1050             return cmp;
1051           }
1052
1053           cmp = mappingA.source - mappingB.source;
1054           if (cmp !== 0) {
1055             return cmp;
1056           }
1057
1058           cmp = mappingA.originalLine - mappingB.originalLine;
1059           if (cmp !== 0) {
1060             return cmp;
1061           }
1062
1063           cmp = mappingA.originalColumn - mappingB.originalColumn;
1064           if (cmp !== 0) {
1065             return cmp;
1066           }
1067
1068           return mappingA.name - mappingB.name;
1069         }
1070         exports.compareByGeneratedPositionsDeflated = compareByGeneratedPositionsDeflated;
1071
1072         function strcmp(aStr1, aStr2) {
1073           if (aStr1 === aStr2) {
1074             return 0;
1075           }
1076
1077           if (aStr1 > aStr2) {
1078             return 1;
1079           }
1080
1081           return -1;
1082         }
1083
1084         /**
1085          * Comparator between two mappings with inflated source and name strings where
1086          * the generated positions are compared.
1087          */
1088         function compareByGeneratedPositionsInflated(mappingA, mappingB) {
1089           var cmp = mappingA.generatedLine - mappingB.generatedLine;
1090           if (cmp !== 0) {
1091             return cmp;
1092           }
1093
1094           cmp = mappingA.generatedColumn - mappingB.generatedColumn;
1095           if (cmp !== 0) {
1096             return cmp;
1097           }
1098
1099           cmp = strcmp(mappingA.source, mappingB.source);
1100           if (cmp !== 0) {
1101             return cmp;
1102           }
1103
1104           cmp = mappingA.originalLine - mappingB.originalLine;
1105           if (cmp !== 0) {
1106             return cmp;
1107           }
1108
1109           cmp = mappingA.originalColumn - mappingB.originalColumn;
1110           if (cmp !== 0) {
1111             return cmp;
1112           }
1113
1114           return strcmp(mappingA.name, mappingB.name);
1115         }
1116         exports.compareByGeneratedPositionsInflated = compareByGeneratedPositionsInflated;
1117
1118
1119 /***/ },
1120 /* 5 */
1121 /***/ function(module, exports, __webpack_require__) {
1122
1123         /* -*- Mode: js; js-indent-level: 2; -*- */
1124         /*
1125          * Copyright 2011 Mozilla Foundation and contributors
1126          * Licensed under the New BSD license. See LICENSE or:
1127          * http://opensource.org/licenses/BSD-3-Clause
1128          */
1129
1130         var util = __webpack_require__(4);
1131         var has = Object.prototype.hasOwnProperty;
1132
1133         /**
1134          * A data structure which is a combination of an array and a set. Adding a new
1135          * member is O(1), testing for membership is O(1), and finding the index of an
1136          * element is O(1). Removing elements from the set is not supported. Only
1137          * strings are supported for membership.
1138          */
1139         function ArraySet() {
1140           this._array = [];
1141           this._set = Object.create(null);
1142         }
1143
1144         /**
1145          * Static method for creating ArraySet instances from an existing array.
1146          */
1147         ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) {
1148           var set = new ArraySet();
1149           for (var i = 0, len = aArray.length; i < len; i++) {
1150             set.add(aArray[i], aAllowDuplicates);
1151           }
1152           return set;
1153         };
1154
1155         /**
1156          * Return how many unique items are in this ArraySet. If duplicates have been
1157          * added, than those do not count towards the size.
1158          *
1159          * @returns Number
1160          */
1161         ArraySet.prototype.size = function ArraySet_size() {
1162           return Object.getOwnPropertyNames(this._set).length;
1163         };
1164
1165         /**
1166          * Add the given string to this set.
1167          *
1168          * @param String aStr
1169          */
1170         ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) {
1171           var sStr = util.toSetString(aStr);
1172           var isDuplicate = has.call(this._set, sStr);
1173           var idx = this._array.length;
1174           if (!isDuplicate || aAllowDuplicates) {
1175             this._array.push(aStr);
1176           }
1177           if (!isDuplicate) {
1178             this._set[sStr] = idx;
1179           }
1180         };
1181
1182         /**
1183          * Is the given string a member of this set?
1184          *
1185          * @param String aStr
1186          */
1187         ArraySet.prototype.has = function ArraySet_has(aStr) {
1188           var sStr = util.toSetString(aStr);
1189           return has.call(this._set, sStr);
1190         };
1191
1192         /**
1193          * What is the index of the given string in the array?
1194          *
1195          * @param String aStr
1196          */
1197         ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) {
1198           var sStr = util.toSetString(aStr);
1199           if (has.call(this._set, sStr)) {
1200             return this._set[sStr];
1201           }
1202           throw new Error('"' + aStr + '" is not in the set.');
1203         };
1204
1205         /**
1206          * What is the element at the given index?
1207          *
1208          * @param Number aIdx
1209          */
1210         ArraySet.prototype.at = function ArraySet_at(aIdx) {
1211           if (aIdx >= 0 && aIdx < this._array.length) {
1212             return this._array[aIdx];
1213           }
1214           throw new Error('No element indexed by ' + aIdx);
1215         };
1216
1217         /**
1218          * Returns the array representation of this set (which has the proper indices
1219          * indicated by indexOf). Note that this is a copy of the internal array used
1220          * for storing the members so that no one can mess with internal state.
1221          */
1222         ArraySet.prototype.toArray = function ArraySet_toArray() {
1223           return this._array.slice();
1224         };
1225
1226         exports.ArraySet = ArraySet;
1227
1228
1229 /***/ },
1230 /* 6 */
1231 /***/ function(module, exports, __webpack_require__) {
1232
1233         /* -*- Mode: js; js-indent-level: 2; -*- */
1234         /*
1235          * Copyright 2014 Mozilla Foundation and contributors
1236          * Licensed under the New BSD license. See LICENSE or:
1237          * http://opensource.org/licenses/BSD-3-Clause
1238          */
1239
1240         var util = __webpack_require__(4);
1241
1242         /**
1243          * Determine whether mappingB is after mappingA with respect to generated
1244          * position.
1245          */
1246         function generatedPositionAfter(mappingA, mappingB) {
1247           // Optimized for most common case
1248           var lineA = mappingA.generatedLine;
1249           var lineB = mappingB.generatedLine;
1250           var columnA = mappingA.generatedColumn;
1251           var columnB = mappingB.generatedColumn;
1252           return lineB > lineA || lineB == lineA && columnB >= columnA ||
1253                  util.compareByGeneratedPositionsInflated(mappingA, mappingB) <= 0;
1254         }
1255
1256         /**
1257          * A data structure to provide a sorted view of accumulated mappings in a
1258          * performance conscious manner. It trades a neglibable overhead in general
1259          * case for a large speedup in case of mappings being added in order.
1260          */
1261         function MappingList() {
1262           this._array = [];
1263           this._sorted = true;
1264           // Serves as infimum
1265           this._last = {generatedLine: -1, generatedColumn: 0};
1266         }
1267
1268         /**
1269          * Iterate through internal items. This method takes the same arguments that
1270          * `Array.prototype.forEach` takes.
1271          *
1272          * NOTE: The order of the mappings is NOT guaranteed.
1273          */
1274         MappingList.prototype.unsortedForEach =
1275           function MappingList_forEach(aCallback, aThisArg) {
1276             this._array.forEach(aCallback, aThisArg);
1277           };
1278
1279         /**
1280          * Add the given source mapping.
1281          *
1282          * @param Object aMapping
1283          */
1284         MappingList.prototype.add = function MappingList_add(aMapping) {
1285           if (generatedPositionAfter(this._last, aMapping)) {
1286             this._last = aMapping;
1287             this._array.push(aMapping);
1288           } else {
1289             this._sorted = false;
1290             this._array.push(aMapping);
1291           }
1292         };
1293
1294         /**
1295          * Returns the flat, sorted array of mappings. The mappings are sorted by
1296          * generated position.
1297          *
1298          * WARNING: This method returns internal data without copying, for
1299          * performance. The return value must NOT be mutated, and should be treated as
1300          * an immutable borrow. If you want to take ownership, you must make your own
1301          * copy.
1302          */
1303         MappingList.prototype.toArray = function MappingList_toArray() {
1304           if (!this._sorted) {
1305             this._array.sort(util.compareByGeneratedPositionsInflated);
1306             this._sorted = true;
1307           }
1308           return this._array;
1309         };
1310
1311         exports.MappingList = MappingList;
1312
1313
1314 /***/ },
1315 /* 7 */
1316 /***/ function(module, exports, __webpack_require__) {
1317
1318         /* -*- Mode: js; js-indent-level: 2; -*- */
1319         /*
1320          * Copyright 2011 Mozilla Foundation and contributors
1321          * Licensed under the New BSD license. See LICENSE or:
1322          * http://opensource.org/licenses/BSD-3-Clause
1323          */
1324
1325         var util = __webpack_require__(4);
1326         var binarySearch = __webpack_require__(8);
1327         var ArraySet = __webpack_require__(5).ArraySet;
1328         var base64VLQ = __webpack_require__(2);
1329         var quickSort = __webpack_require__(9).quickSort;
1330
1331         function SourceMapConsumer(aSourceMap) {
1332           var sourceMap = aSourceMap;
1333           if (typeof aSourceMap === 'string') {
1334             sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
1335           }
1336
1337           return sourceMap.sections != null
1338             ? new IndexedSourceMapConsumer(sourceMap)
1339             : new BasicSourceMapConsumer(sourceMap);
1340         }
1341
1342         SourceMapConsumer.fromSourceMap = function(aSourceMap) {
1343           return BasicSourceMapConsumer.fromSourceMap(aSourceMap);
1344         }
1345
1346         /**
1347          * The version of the source mapping spec that we are consuming.
1348          */
1349         SourceMapConsumer.prototype._version = 3;
1350
1351         // `__generatedMappings` and `__originalMappings` are arrays that hold the
1352         // parsed mapping coordinates from the source map's "mappings" attribute. They
1353         // are lazily instantiated, accessed via the `_generatedMappings` and
1354         // `_originalMappings` getters respectively, and we only parse the mappings
1355         // and create these arrays once queried for a source location. We jump through
1356         // these hoops because there can be many thousands of mappings, and parsing
1357         // them is expensive, so we only want to do it if we must.
1358         //
1359         // Each object in the arrays is of the form:
1360         //
1361         //     {
1362         //       generatedLine: The line number in the generated code,
1363         //       generatedColumn: The column number in the generated code,
1364         //       source: The path to the original source file that generated this
1365         //               chunk of code,
1366         //       originalLine: The line number in the original source that
1367         //                     corresponds to this chunk of generated code,
1368         //       originalColumn: The column number in the original source that
1369         //                       corresponds to this chunk of generated code,
1370         //       name: The name of the original symbol which generated this chunk of
1371         //             code.
1372         //     }
1373         //
1374         // All properties except for `generatedLine` and `generatedColumn` can be
1375         // `null`.
1376         //
1377         // `_generatedMappings` is ordered by the generated positions.
1378         //
1379         // `_originalMappings` is ordered by the original positions.
1380
1381         SourceMapConsumer.prototype.__generatedMappings = null;
1382         Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', {
1383           get: function () {
1384             if (!this.__generatedMappings) {
1385               this._parseMappings(this._mappings, this.sourceRoot);
1386             }
1387
1388             return this.__generatedMappings;
1389           }
1390         });
1391
1392         SourceMapConsumer.prototype.__originalMappings = null;
1393         Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', {
1394           get: function () {
1395             if (!this.__originalMappings) {
1396               this._parseMappings(this._mappings, this.sourceRoot);
1397             }
1398
1399             return this.__originalMappings;
1400           }
1401         });
1402
1403         SourceMapConsumer.prototype._charIsMappingSeparator =
1404           function SourceMapConsumer_charIsMappingSeparator(aStr, index) {
1405             var c = aStr.charAt(index);
1406             return c === ";" || c === ",";
1407           };
1408
1409         /**
1410          * Parse the mappings in a string in to a data structure which we can easily
1411          * query (the ordered arrays in the `this.__generatedMappings` and
1412          * `this.__originalMappings` properties).
1413          */
1414         SourceMapConsumer.prototype._parseMappings =
1415           function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1416             throw new Error("Subclasses must implement _parseMappings");
1417           };
1418
1419         SourceMapConsumer.GENERATED_ORDER = 1;
1420         SourceMapConsumer.ORIGINAL_ORDER = 2;
1421
1422         SourceMapConsumer.GREATEST_LOWER_BOUND = 1;
1423         SourceMapConsumer.LEAST_UPPER_BOUND = 2;
1424
1425         /**
1426          * Iterate over each mapping between an original source/line/column and a
1427          * generated line/column in this source map.
1428          *
1429          * @param Function aCallback
1430          *        The function that is called with each mapping.
1431          * @param Object aContext
1432          *        Optional. If specified, this object will be the value of `this` every
1433          *        time that `aCallback` is called.
1434          * @param aOrder
1435          *        Either `SourceMapConsumer.GENERATED_ORDER` or
1436          *        `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to
1437          *        iterate over the mappings sorted by the generated file's line/column
1438          *        order or the original's source/line/column order, respectively. Defaults to
1439          *        `SourceMapConsumer.GENERATED_ORDER`.
1440          */
1441         SourceMapConsumer.prototype.eachMapping =
1442           function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) {
1443             var context = aContext || null;
1444             var order = aOrder || SourceMapConsumer.GENERATED_ORDER;
1445
1446             var mappings;
1447             switch (order) {
1448             case SourceMapConsumer.GENERATED_ORDER:
1449               mappings = this._generatedMappings;
1450               break;
1451             case SourceMapConsumer.ORIGINAL_ORDER:
1452               mappings = this._originalMappings;
1453               break;
1454             default:
1455               throw new Error("Unknown order of iteration.");
1456             }
1457
1458             var sourceRoot = this.sourceRoot;
1459             mappings.map(function (mapping) {
1460               var source = mapping.source === null ? null : this._sources.at(mapping.source);
1461               if (source != null && sourceRoot != null) {
1462                 source = util.join(sourceRoot, source);
1463               }
1464               return {
1465                 source: source,
1466                 generatedLine: mapping.generatedLine,
1467                 generatedColumn: mapping.generatedColumn,
1468                 originalLine: mapping.originalLine,
1469                 originalColumn: mapping.originalColumn,
1470                 name: mapping.name === null ? null : this._names.at(mapping.name)
1471               };
1472             }, this).forEach(aCallback, context);
1473           };
1474
1475         /**
1476          * Returns all generated line and column information for the original source,
1477          * line, and column provided. If no column is provided, returns all mappings
1478          * corresponding to a either the line we are searching for or the next
1479          * closest line that has any mappings. Otherwise, returns all mappings
1480          * corresponding to the given line and either the column we are searching for
1481          * or the next closest column that has any offsets.
1482          *
1483          * The only argument is an object with the following properties:
1484          *
1485          *   - source: The filename of the original source.
1486          *   - line: The line number in the original source.
1487          *   - column: Optional. the column number in the original source.
1488          *
1489          * and an array of objects is returned, each with the following properties:
1490          *
1491          *   - line: The line number in the generated source, or null.
1492          *   - column: The column number in the generated source, or null.
1493          */
1494         SourceMapConsumer.prototype.allGeneratedPositionsFor =
1495           function SourceMapConsumer_allGeneratedPositionsFor(aArgs) {
1496             var line = util.getArg(aArgs, 'line');
1497
1498             // When there is no exact match, BasicSourceMapConsumer.prototype._findMapping
1499             // returns the index of the closest mapping less than the needle. By
1500             // setting needle.originalColumn to 0, we thus find the last mapping for
1501             // the given line, provided such a mapping exists.
1502             var needle = {
1503               source: util.getArg(aArgs, 'source'),
1504               originalLine: line,
1505               originalColumn: util.getArg(aArgs, 'column', 0)
1506             };
1507
1508             if (this.sourceRoot != null) {
1509               needle.source = util.relative(this.sourceRoot, needle.source);
1510             }
1511             if (!this._sources.has(needle.source)) {
1512               return [];
1513             }
1514             needle.source = this._sources.indexOf(needle.source);
1515
1516             var mappings = [];
1517
1518             var index = this._findMapping(needle,
1519                                           this._originalMappings,
1520                                           "originalLine",
1521                                           "originalColumn",
1522                                           util.compareByOriginalPositions,
1523                                           binarySearch.LEAST_UPPER_BOUND);
1524             if (index >= 0) {
1525               var mapping = this._originalMappings[index];
1526
1527               if (aArgs.column === undefined) {
1528                 var originalLine = mapping.originalLine;
1529
1530                 // Iterate until either we run out of mappings, or we run into
1531                 // a mapping for a different line than the one we found. Since
1532                 // mappings are sorted, this is guaranteed to find all mappings for
1533                 // the line we found.
1534                 while (mapping && mapping.originalLine === originalLine) {
1535                   mappings.push({
1536                     line: util.getArg(mapping, 'generatedLine', null),
1537                     column: util.getArg(mapping, 'generatedColumn', null),
1538                     lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
1539                   });
1540
1541                   mapping = this._originalMappings[++index];
1542                 }
1543               } else {
1544                 var originalColumn = mapping.originalColumn;
1545
1546                 // Iterate until either we run out of mappings, or we run into
1547                 // a mapping for a different line than the one we were searching for.
1548                 // Since mappings are sorted, this is guaranteed to find all mappings for
1549                 // the line we are searching for.
1550                 while (mapping &&
1551                        mapping.originalLine === line &&
1552                        mapping.originalColumn == originalColumn) {
1553                   mappings.push({
1554                     line: util.getArg(mapping, 'generatedLine', null),
1555                     column: util.getArg(mapping, 'generatedColumn', null),
1556                     lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
1557                   });
1558
1559                   mapping = this._originalMappings[++index];
1560                 }
1561               }
1562             }
1563
1564             return mappings;
1565           };
1566
1567         exports.SourceMapConsumer = SourceMapConsumer;
1568
1569         /**
1570          * A BasicSourceMapConsumer instance represents a parsed source map which we can
1571          * query for information about the original file positions by giving it a file
1572          * position in the generated source.
1573          *
1574          * The only parameter is the raw source map (either as a JSON string, or
1575          * already parsed to an object). According to the spec, source maps have the
1576          * following attributes:
1577          *
1578          *   - version: Which version of the source map spec this map is following.
1579          *   - sources: An array of URLs to the original source files.
1580          *   - names: An array of identifiers which can be referrenced by individual mappings.
1581          *   - sourceRoot: Optional. The URL root from which all sources are relative.
1582          *   - sourcesContent: Optional. An array of contents of the original source files.
1583          *   - mappings: A string of base64 VLQs which contain the actual mappings.
1584          *   - file: Optional. The generated file this source map is associated with.
1585          *
1586          * Here is an example source map, taken from the source map spec[0]:
1587          *
1588          *     {
1589          *       version : 3,
1590          *       file: "out.js",
1591          *       sourceRoot : "",
1592          *       sources: ["foo.js", "bar.js"],
1593          *       names: ["src", "maps", "are", "fun"],
1594          *       mappings: "AA,AB;;ABCDE;"
1595          *     }
1596          *
1597          * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1#
1598          */
1599         function BasicSourceMapConsumer(aSourceMap) {
1600           var sourceMap = aSourceMap;
1601           if (typeof aSourceMap === 'string') {
1602             sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
1603           }
1604
1605           var version = util.getArg(sourceMap, 'version');
1606           var sources = util.getArg(sourceMap, 'sources');
1607           // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which
1608           // requires the array) to play nice here.
1609           var names = util.getArg(sourceMap, 'names', []);
1610           var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null);
1611           var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null);
1612           var mappings = util.getArg(sourceMap, 'mappings');
1613           var file = util.getArg(sourceMap, 'file', null);
1614
1615           // Once again, Sass deviates from the spec and supplies the version as a
1616           // string rather than a number, so we use loose equality checking here.
1617           if (version != this._version) {
1618             throw new Error('Unsupported version: ' + version);
1619           }
1620
1621           sources = sources
1622             .map(String)
1623             // Some source maps produce relative source paths like "./foo.js" instead of
1624             // "foo.js".  Normalize these first so that future comparisons will succeed.
1625             // See bugzil.la/1090768.
1626             .map(util.normalize)
1627             // Always ensure that absolute sources are internally stored relative to
1628             // the source root, if the source root is absolute. Not doing this would
1629             // be particularly problematic when the source root is a prefix of the
1630             // source (valid, but why??). See github issue #199 and bugzil.la/1188982.
1631             .map(function (source) {
1632               return sourceRoot && util.isAbsolute(sourceRoot) && util.isAbsolute(source)
1633                 ? util.relative(sourceRoot, source)
1634                 : source;
1635             });
1636
1637           // Pass `true` below to allow duplicate names and sources. While source maps
1638           // are intended to be compressed and deduplicated, the TypeScript compiler
1639           // sometimes generates source maps with duplicates in them. See Github issue
1640           // #72 and bugzil.la/889492.
1641           this._names = ArraySet.fromArray(names.map(String), true);
1642           this._sources = ArraySet.fromArray(sources, true);
1643
1644           this.sourceRoot = sourceRoot;
1645           this.sourcesContent = sourcesContent;
1646           this._mappings = mappings;
1647           this.file = file;
1648         }
1649
1650         BasicSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
1651         BasicSourceMapConsumer.prototype.consumer = SourceMapConsumer;
1652
1653         /**
1654          * Create a BasicSourceMapConsumer from a SourceMapGenerator.
1655          *
1656          * @param SourceMapGenerator aSourceMap
1657          *        The source map that will be consumed.
1658          * @returns BasicSourceMapConsumer
1659          */
1660         BasicSourceMapConsumer.fromSourceMap =
1661           function SourceMapConsumer_fromSourceMap(aSourceMap) {
1662             var smc = Object.create(BasicSourceMapConsumer.prototype);
1663
1664             var names = smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true);
1665             var sources = smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true);
1666             smc.sourceRoot = aSourceMap._sourceRoot;
1667             smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(),
1668                                                                     smc.sourceRoot);
1669             smc.file = aSourceMap._file;
1670
1671             // Because we are modifying the entries (by converting string sources and
1672             // names to indices into the sources and names ArraySets), we have to make
1673             // a copy of the entry or else bad things happen. Shared mutable state
1674             // strikes again! See github issue #191.
1675
1676             var generatedMappings = aSourceMap._mappings.toArray().slice();
1677             var destGeneratedMappings = smc.__generatedMappings = [];
1678             var destOriginalMappings = smc.__originalMappings = [];
1679
1680             for (var i = 0, length = generatedMappings.length; i < length; i++) {
1681               var srcMapping = generatedMappings[i];
1682               var destMapping = new Mapping;
1683               destMapping.generatedLine = srcMapping.generatedLine;
1684               destMapping.generatedColumn = srcMapping.generatedColumn;
1685
1686               if (srcMapping.source) {
1687                 destMapping.source = sources.indexOf(srcMapping.source);
1688                 destMapping.originalLine = srcMapping.originalLine;
1689                 destMapping.originalColumn = srcMapping.originalColumn;
1690
1691                 if (srcMapping.name) {
1692                   destMapping.name = names.indexOf(srcMapping.name);
1693                 }
1694
1695                 destOriginalMappings.push(destMapping);
1696               }
1697
1698               destGeneratedMappings.push(destMapping);
1699             }
1700
1701             quickSort(smc.__originalMappings, util.compareByOriginalPositions);
1702
1703             return smc;
1704           };
1705
1706         /**
1707          * The version of the source mapping spec that we are consuming.
1708          */
1709         BasicSourceMapConsumer.prototype._version = 3;
1710
1711         /**
1712          * The list of original sources.
1713          */
1714         Object.defineProperty(BasicSourceMapConsumer.prototype, 'sources', {
1715           get: function () {
1716             return this._sources.toArray().map(function (s) {
1717               return this.sourceRoot != null ? util.join(this.sourceRoot, s) : s;
1718             }, this);
1719           }
1720         });
1721
1722         /**
1723          * Provide the JIT with a nice shape / hidden class.
1724          */
1725         function Mapping() {
1726           this.generatedLine = 0;
1727           this.generatedColumn = 0;
1728           this.source = null;
1729           this.originalLine = null;
1730           this.originalColumn = null;
1731           this.name = null;
1732         }
1733
1734         /**
1735          * Parse the mappings in a string in to a data structure which we can easily
1736          * query (the ordered arrays in the `this.__generatedMappings` and
1737          * `this.__originalMappings` properties).
1738          */
1739         BasicSourceMapConsumer.prototype._parseMappings =
1740           function SourceMapConsumer_parseMappings(aStr, aSourceRoot) {
1741             var generatedLine = 1;
1742             var previousGeneratedColumn = 0;
1743             var previousOriginalLine = 0;
1744             var previousOriginalColumn = 0;
1745             var previousSource = 0;
1746             var previousName = 0;
1747             var length = aStr.length;
1748             var index = 0;
1749             var cachedSegments = {};
1750             var temp = {};
1751             var originalMappings = [];
1752             var generatedMappings = [];
1753             var mapping, str, segment, end, value;
1754
1755             while (index < length) {
1756               if (aStr.charAt(index) === ';') {
1757                 generatedLine++;
1758                 index++;
1759                 previousGeneratedColumn = 0;
1760               }
1761               else if (aStr.charAt(index) === ',') {
1762                 index++;
1763               }
1764               else {
1765                 mapping = new Mapping();
1766                 mapping.generatedLine = generatedLine;
1767
1768                 // Because each offset is encoded relative to the previous one,
1769                 // many segments often have the same encoding. We can exploit this
1770                 // fact by caching the parsed variable length fields of each segment,
1771                 // allowing us to avoid a second parse if we encounter the same
1772                 // segment again.
1773                 for (end = index; end < length; end++) {
1774                   if (this._charIsMappingSeparator(aStr, end)) {
1775                     break;
1776                   }
1777                 }
1778                 str = aStr.slice(index, end);
1779
1780                 segment = cachedSegments[str];
1781                 if (segment) {
1782                   index += str.length;
1783                 } else {
1784                   segment = [];
1785                   while (index < end) {
1786                     base64VLQ.decode(aStr, index, temp);
1787                     value = temp.value;
1788                     index = temp.rest;
1789                     segment.push(value);
1790                   }
1791
1792                   if (segment.length === 2) {
1793                     throw new Error('Found a source, but no line and column');
1794                   }
1795
1796                   if (segment.length === 3) {
1797                     throw new Error('Found a source and line, but no column');
1798                   }
1799
1800                   cachedSegments[str] = segment;
1801                 }
1802
1803                 // Generated column.
1804                 mapping.generatedColumn = previousGeneratedColumn + segment[0];
1805                 previousGeneratedColumn = mapping.generatedColumn;
1806
1807                 if (segment.length > 1) {
1808                   // Original source.
1809                   mapping.source = previousSource + segment[1];
1810                   previousSource += segment[1];
1811
1812                   // Original line.
1813                   mapping.originalLine = previousOriginalLine + segment[2];
1814                   previousOriginalLine = mapping.originalLine;
1815                   // Lines are stored 0-based
1816                   mapping.originalLine += 1;
1817
1818                   // Original column.
1819                   mapping.originalColumn = previousOriginalColumn + segment[3];
1820                   previousOriginalColumn = mapping.originalColumn;
1821
1822                   if (segment.length > 4) {
1823                     // Original name.
1824                     mapping.name = previousName + segment[4];
1825                     previousName += segment[4];
1826                   }
1827                 }
1828
1829                 generatedMappings.push(mapping);
1830                 if (typeof mapping.originalLine === 'number') {
1831                   originalMappings.push(mapping);
1832                 }
1833               }
1834             }
1835
1836             quickSort(generatedMappings, util.compareByGeneratedPositionsDeflated);
1837             this.__generatedMappings = generatedMappings;
1838
1839             quickSort(originalMappings, util.compareByOriginalPositions);
1840             this.__originalMappings = originalMappings;
1841           };
1842
1843         /**
1844          * Find the mapping that best matches the hypothetical "needle" mapping that
1845          * we are searching for in the given "haystack" of mappings.
1846          */
1847         BasicSourceMapConsumer.prototype._findMapping =
1848           function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName,
1849                                                  aColumnName, aComparator, aBias) {
1850             // To return the position we are searching for, we must first find the
1851             // mapping for the given position and then return the opposite position it
1852             // points to. Because the mappings are sorted, we can use binary search to
1853             // find the best mapping.
1854
1855             if (aNeedle[aLineName] <= 0) {
1856               throw new TypeError('Line must be greater than or equal to 1, got '
1857                                   + aNeedle[aLineName]);
1858             }
1859             if (aNeedle[aColumnName] < 0) {
1860               throw new TypeError('Column must be greater than or equal to 0, got '
1861                                   + aNeedle[aColumnName]);
1862             }
1863
1864             return binarySearch.search(aNeedle, aMappings, aComparator, aBias);
1865           };
1866
1867         /**
1868          * Compute the last column for each generated mapping. The last column is
1869          * inclusive.
1870          */
1871         BasicSourceMapConsumer.prototype.computeColumnSpans =
1872           function SourceMapConsumer_computeColumnSpans() {
1873             for (var index = 0; index < this._generatedMappings.length; ++index) {
1874               var mapping = this._generatedMappings[index];
1875
1876               // Mappings do not contain a field for the last generated columnt. We
1877               // can come up with an optimistic estimate, however, by assuming that
1878               // mappings are contiguous (i.e. given two consecutive mappings, the
1879               // first mapping ends where the second one starts).
1880               if (index + 1 < this._generatedMappings.length) {
1881                 var nextMapping = this._generatedMappings[index + 1];
1882
1883                 if (mapping.generatedLine === nextMapping.generatedLine) {
1884                   mapping.lastGeneratedColumn = nextMapping.generatedColumn - 1;
1885                   continue;
1886                 }
1887               }
1888
1889               // The last mapping for each line spans the entire line.
1890               mapping.lastGeneratedColumn = Infinity;
1891             }
1892           };
1893
1894         /**
1895          * Returns the original source, line, and column information for the generated
1896          * source's line and column positions provided. The only argument is an object
1897          * with the following properties:
1898          *
1899          *   - line: The line number in the generated source.
1900          *   - column: The column number in the generated source.
1901          *   - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
1902          *     'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
1903          *     closest element that is smaller than or greater than the one we are
1904          *     searching for, respectively, if the exact element cannot be found.
1905          *     Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
1906          *
1907          * and an object is returned with the following properties:
1908          *
1909          *   - source: The original source file, or null.
1910          *   - line: The line number in the original source, or null.
1911          *   - column: The column number in the original source, or null.
1912          *   - name: The original identifier, or null.
1913          */
1914         BasicSourceMapConsumer.prototype.originalPositionFor =
1915           function SourceMapConsumer_originalPositionFor(aArgs) {
1916             var needle = {
1917               generatedLine: util.getArg(aArgs, 'line'),
1918               generatedColumn: util.getArg(aArgs, 'column')
1919             };
1920
1921             var index = this._findMapping(
1922               needle,
1923               this._generatedMappings,
1924               "generatedLine",
1925               "generatedColumn",
1926               util.compareByGeneratedPositionsDeflated,
1927               util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
1928             );
1929
1930             if (index >= 0) {
1931               var mapping = this._generatedMappings[index];
1932
1933               if (mapping.generatedLine === needle.generatedLine) {
1934                 var source = util.getArg(mapping, 'source', null);
1935                 if (source !== null) {
1936                   source = this._sources.at(source);
1937                   if (this.sourceRoot != null) {
1938                     source = util.join(this.sourceRoot, source);
1939                   }
1940                 }
1941                 var name = util.getArg(mapping, 'name', null);
1942                 if (name !== null) {
1943                   name = this._names.at(name);
1944                 }
1945                 return {
1946                   source: source,
1947                   line: util.getArg(mapping, 'originalLine', null),
1948                   column: util.getArg(mapping, 'originalColumn', null),
1949                   name: name
1950                 };
1951               }
1952             }
1953
1954             return {
1955               source: null,
1956               line: null,
1957               column: null,
1958               name: null
1959             };
1960           };
1961
1962         /**
1963          * Return true if we have the source content for every source in the source
1964          * map, false otherwise.
1965          */
1966         BasicSourceMapConsumer.prototype.hasContentsOfAllSources =
1967           function BasicSourceMapConsumer_hasContentsOfAllSources() {
1968             if (!this.sourcesContent) {
1969               return false;
1970             }
1971             return this.sourcesContent.length >= this._sources.size() &&
1972               !this.sourcesContent.some(function (sc) { return sc == null; });
1973           };
1974
1975         /**
1976          * Returns the original source content. The only argument is the url of the
1977          * original source file. Returns null if no original source content is
1978          * available.
1979          */
1980         BasicSourceMapConsumer.prototype.sourceContentFor =
1981           function SourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
1982             if (!this.sourcesContent) {
1983               return null;
1984             }
1985
1986             if (this.sourceRoot != null) {
1987               aSource = util.relative(this.sourceRoot, aSource);
1988             }
1989
1990             if (this._sources.has(aSource)) {
1991               return this.sourcesContent[this._sources.indexOf(aSource)];
1992             }
1993
1994             var url;
1995             if (this.sourceRoot != null
1996                 && (url = util.urlParse(this.sourceRoot))) {
1997               // XXX: file:// URIs and absolute paths lead to unexpected behavior for
1998               // many users. We can help them out when they expect file:// URIs to
1999               // behave like it would if they were running a local HTTP server. See
2000               // https://bugzilla.mozilla.org/show_bug.cgi?id=885597.
2001               var fileUriAbsPath = aSource.replace(/^file:\/\//, "");
2002               if (url.scheme == "file"
2003                   && this._sources.has(fileUriAbsPath)) {
2004                 return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)]
2005               }
2006
2007               if ((!url.path || url.path == "/")
2008                   && this._sources.has("/" + aSource)) {
2009                 return this.sourcesContent[this._sources.indexOf("/" + aSource)];
2010               }
2011             }
2012
2013             // This function is used recursively from
2014             // IndexedSourceMapConsumer.prototype.sourceContentFor. In that case, we
2015             // don't want to throw if we can't find the source - we just want to
2016             // return null, so we provide a flag to exit gracefully.
2017             if (nullOnMissing) {
2018               return null;
2019             }
2020             else {
2021               throw new Error('"' + aSource + '" is not in the SourceMap.');
2022             }
2023           };
2024
2025         /**
2026          * Returns the generated line and column information for the original source,
2027          * line, and column positions provided. The only argument is an object with
2028          * the following properties:
2029          *
2030          *   - source: The filename of the original source.
2031          *   - line: The line number in the original source.
2032          *   - column: The column number in the original source.
2033          *   - bias: Either 'SourceMapConsumer.GREATEST_LOWER_BOUND' or
2034          *     'SourceMapConsumer.LEAST_UPPER_BOUND'. Specifies whether to return the
2035          *     closest element that is smaller than or greater than the one we are
2036          *     searching for, respectively, if the exact element cannot be found.
2037          *     Defaults to 'SourceMapConsumer.GREATEST_LOWER_BOUND'.
2038          *
2039          * and an object is returned with the following properties:
2040          *
2041          *   - line: The line number in the generated source, or null.
2042          *   - column: The column number in the generated source, or null.
2043          */
2044         BasicSourceMapConsumer.prototype.generatedPositionFor =
2045           function SourceMapConsumer_generatedPositionFor(aArgs) {
2046             var source = util.getArg(aArgs, 'source');
2047             if (this.sourceRoot != null) {
2048               source = util.relative(this.sourceRoot, source);
2049             }
2050             if (!this._sources.has(source)) {
2051               return {
2052                 line: null,
2053                 column: null,
2054                 lastColumn: null
2055               };
2056             }
2057             source = this._sources.indexOf(source);
2058
2059             var needle = {
2060               source: source,
2061               originalLine: util.getArg(aArgs, 'line'),
2062               originalColumn: util.getArg(aArgs, 'column')
2063             };
2064
2065             var index = this._findMapping(
2066               needle,
2067               this._originalMappings,
2068               "originalLine",
2069               "originalColumn",
2070               util.compareByOriginalPositions,
2071               util.getArg(aArgs, 'bias', SourceMapConsumer.GREATEST_LOWER_BOUND)
2072             );
2073
2074             if (index >= 0) {
2075               var mapping = this._originalMappings[index];
2076
2077               if (mapping.source === needle.source) {
2078                 return {
2079                   line: util.getArg(mapping, 'generatedLine', null),
2080                   column: util.getArg(mapping, 'generatedColumn', null),
2081                   lastColumn: util.getArg(mapping, 'lastGeneratedColumn', null)
2082                 };
2083               }
2084             }
2085
2086             return {
2087               line: null,
2088               column: null,
2089               lastColumn: null
2090             };
2091           };
2092
2093         exports.BasicSourceMapConsumer = BasicSourceMapConsumer;
2094
2095         /**
2096          * An IndexedSourceMapConsumer instance represents a parsed source map which
2097          * we can query for information. It differs from BasicSourceMapConsumer in
2098          * that it takes "indexed" source maps (i.e. ones with a "sections" field) as
2099          * input.
2100          *
2101          * The only parameter is a raw source map (either as a JSON string, or already
2102          * parsed to an object). According to the spec for indexed source maps, they
2103          * have the following attributes:
2104          *
2105          *   - version: Which version of the source map spec this map is following.
2106          *   - file: Optional. The generated file this source map is associated with.
2107          *   - sections: A list of section definitions.
2108          *
2109          * Each value under the "sections" field has two fields:
2110          *   - offset: The offset into the original specified at which this section
2111          *       begins to apply, defined as an object with a "line" and "column"
2112          *       field.
2113          *   - map: A source map definition. This source map could also be indexed,
2114          *       but doesn't have to be.
2115          *
2116          * Instead of the "map" field, it's also possible to have a "url" field
2117          * specifying a URL to retrieve a source map from, but that's currently
2118          * unsupported.
2119          *
2120          * Here's an example source map, taken from the source map spec[0], but
2121          * modified to omit a section which uses the "url" field.
2122          *
2123          *  {
2124          *    version : 3,
2125          *    file: "app.js",
2126          *    sections: [{
2127          *      offset: {line:100, column:10},
2128          *      map: {
2129          *        version : 3,
2130          *        file: "section.js",
2131          *        sources: ["foo.js", "bar.js"],
2132          *        names: ["src", "maps", "are", "fun"],
2133          *        mappings: "AAAA,E;;ABCDE;"
2134          *      }
2135          *    }],
2136          *  }
2137          *
2138          * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit#heading=h.535es3xeprgt
2139          */
2140         function IndexedSourceMapConsumer(aSourceMap) {
2141           var sourceMap = aSourceMap;
2142           if (typeof aSourceMap === 'string') {
2143             sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, ''));
2144           }
2145
2146           var version = util.getArg(sourceMap, 'version');
2147           var sections = util.getArg(sourceMap, 'sections');
2148
2149           if (version != this._version) {
2150             throw new Error('Unsupported version: ' + version);
2151           }
2152
2153           this._sources = new ArraySet();
2154           this._names = new ArraySet();
2155
2156           var lastOffset = {
2157             line: -1,
2158             column: 0
2159           };
2160           this._sections = sections.map(function (s) {
2161             if (s.url) {
2162               // The url field will require support for asynchronicity.
2163               // See https://github.com/mozilla/source-map/issues/16
2164               throw new Error('Support for url field in sections not implemented.');
2165             }
2166             var offset = util.getArg(s, 'offset');
2167             var offsetLine = util.getArg(offset, 'line');
2168             var offsetColumn = util.getArg(offset, 'column');
2169
2170             if (offsetLine < lastOffset.line ||
2171                 (offsetLine === lastOffset.line && offsetColumn < lastOffset.column)) {
2172               throw new Error('Section offsets must be ordered and non-overlapping.');
2173             }
2174             lastOffset = offset;
2175
2176             return {
2177               generatedOffset: {
2178                 // The offset fields are 0-based, but we use 1-based indices when
2179                 // encoding/decoding from VLQ.
2180                 generatedLine: offsetLine + 1,
2181                 generatedColumn: offsetColumn + 1
2182               },
2183               consumer: new SourceMapConsumer(util.getArg(s, 'map'))
2184             }
2185           });
2186         }
2187
2188         IndexedSourceMapConsumer.prototype = Object.create(SourceMapConsumer.prototype);
2189         IndexedSourceMapConsumer.prototype.constructor = SourceMapConsumer;
2190
2191         /**
2192          * The version of the source mapping spec that we are consuming.
2193          */
2194         IndexedSourceMapConsumer.prototype._version = 3;
2195
2196         /**
2197          * The list of original sources.
2198          */
2199         Object.defineProperty(IndexedSourceMapConsumer.prototype, 'sources', {
2200           get: function () {
2201             var sources = [];
2202             for (var i = 0; i < this._sections.length; i++) {
2203               for (var j = 0; j < this._sections[i].consumer.sources.length; j++) {
2204                 sources.push(this._sections[i].consumer.sources[j]);
2205               }
2206             }
2207             return sources;
2208           }
2209         });
2210
2211         /**
2212          * Returns the original source, line, and column information for the generated
2213          * source's line and column positions provided. The only argument is an object
2214          * with the following properties:
2215          *
2216          *   - line: The line number in the generated source.
2217          *   - column: The column number in the generated source.
2218          *
2219          * and an object is returned with the following properties:
2220          *
2221          *   - source: The original source file, or null.
2222          *   - line: The line number in the original source, or null.
2223          *   - column: The column number in the original source, or null.
2224          *   - name: The original identifier, or null.
2225          */
2226         IndexedSourceMapConsumer.prototype.originalPositionFor =
2227           function IndexedSourceMapConsumer_originalPositionFor(aArgs) {
2228             var needle = {
2229               generatedLine: util.getArg(aArgs, 'line'),
2230               generatedColumn: util.getArg(aArgs, 'column')
2231             };
2232
2233             // Find the section containing the generated position we're trying to map
2234             // to an original position.
2235             var sectionIndex = binarySearch.search(needle, this._sections,
2236               function(needle, section) {
2237                 var cmp = needle.generatedLine - section.generatedOffset.generatedLine;
2238                 if (cmp) {
2239                   return cmp;
2240                 }
2241
2242                 return (needle.generatedColumn -
2243                         section.generatedOffset.generatedColumn);
2244               });
2245             var section = this._sections[sectionIndex];
2246
2247             if (!section) {
2248               return {
2249                 source: null,
2250                 line: null,
2251                 column: null,
2252                 name: null
2253               };
2254             }
2255
2256             return section.consumer.originalPositionFor({
2257               line: needle.generatedLine -
2258                 (section.generatedOffset.generatedLine - 1),
2259               column: needle.generatedColumn -
2260                 (section.generatedOffset.generatedLine === needle.generatedLine
2261                  ? section.generatedOffset.generatedColumn - 1
2262                  : 0),
2263               bias: aArgs.bias
2264             });
2265           };
2266
2267         /**
2268          * Return true if we have the source content for every source in the source
2269          * map, false otherwise.
2270          */
2271         IndexedSourceMapConsumer.prototype.hasContentsOfAllSources =
2272           function IndexedSourceMapConsumer_hasContentsOfAllSources() {
2273             return this._sections.every(function (s) {
2274               return s.consumer.hasContentsOfAllSources();
2275             });
2276           };
2277
2278         /**
2279          * Returns the original source content. The only argument is the url of the
2280          * original source file. Returns null if no original source content is
2281          * available.
2282          */
2283         IndexedSourceMapConsumer.prototype.sourceContentFor =
2284           function IndexedSourceMapConsumer_sourceContentFor(aSource, nullOnMissing) {
2285             for (var i = 0; i < this._sections.length; i++) {
2286               var section = this._sections[i];
2287
2288               var content = section.consumer.sourceContentFor(aSource, true);
2289               if (content) {
2290                 return content;
2291               }
2292             }
2293             if (nullOnMissing) {
2294               return null;
2295             }
2296             else {
2297               throw new Error('"' + aSource + '" is not in the SourceMap.');
2298             }
2299           };
2300
2301         /**
2302          * Returns the generated line and column information for the original source,
2303          * line, and column positions provided. The only argument is an object with
2304          * the following properties:
2305          *
2306          *   - source: The filename of the original source.
2307          *   - line: The line number in the original source.
2308          *   - column: The column number in the original source.
2309          *
2310          * and an object is returned with the following properties:
2311          *
2312          *   - line: The line number in the generated source, or null.
2313          *   - column: The column number in the generated source, or null.
2314          */
2315         IndexedSourceMapConsumer.prototype.generatedPositionFor =
2316           function IndexedSourceMapConsumer_generatedPositionFor(aArgs) {
2317             for (var i = 0; i < this._sections.length; i++) {
2318               var section = this._sections[i];
2319
2320               // Only consider this section if the requested source is in the list of
2321               // sources of the consumer.
2322               if (section.consumer.sources.indexOf(util.getArg(aArgs, 'source')) === -1) {
2323                 continue;
2324               }
2325               var generatedPosition = section.consumer.generatedPositionFor(aArgs);
2326               if (generatedPosition) {
2327                 var ret = {
2328                   line: generatedPosition.line +
2329                     (section.generatedOffset.generatedLine - 1),
2330                   column: generatedPosition.column +
2331                     (section.generatedOffset.generatedLine === generatedPosition.line
2332                      ? section.generatedOffset.generatedColumn - 1
2333                      : 0)
2334                 };
2335                 return ret;
2336               }
2337             }
2338
2339             return {
2340               line: null,
2341               column: null
2342             };
2343           };
2344
2345         /**
2346          * Parse the mappings in a string in to a data structure which we can easily
2347          * query (the ordered arrays in the `this.__generatedMappings` and
2348          * `this.__originalMappings` properties).
2349          */
2350         IndexedSourceMapConsumer.prototype._parseMappings =
2351           function IndexedSourceMapConsumer_parseMappings(aStr, aSourceRoot) {
2352             this.__generatedMappings = [];
2353             this.__originalMappings = [];
2354             for (var i = 0; i < this._sections.length; i++) {
2355               var section = this._sections[i];
2356               var sectionMappings = section.consumer._generatedMappings;
2357               for (var j = 0; j < sectionMappings.length; j++) {
2358                 var mapping = sectionMappings[j];
2359
2360                 var source = section.consumer._sources.at(mapping.source);
2361                 if (section.consumer.sourceRoot !== null) {
2362                   source = util.join(section.consumer.sourceRoot, source);
2363                 }
2364                 this._sources.add(source);
2365                 source = this._sources.indexOf(source);
2366
2367                 var name = section.consumer._names.at(mapping.name);
2368                 this._names.add(name);
2369                 name = this._names.indexOf(name);
2370
2371                 // The mappings coming from the consumer for the section have
2372                 // generated positions relative to the start of the section, so we
2373                 // need to offset them to be relative to the start of the concatenated
2374                 // generated file.
2375                 var adjustedMapping = {
2376                   source: source,
2377                   generatedLine: mapping.generatedLine +
2378                     (section.generatedOffset.generatedLine - 1),
2379                   generatedColumn: mapping.generatedColumn +
2380                     (section.generatedOffset.generatedLine === mapping.generatedLine
2381                     ? section.generatedOffset.generatedColumn - 1
2382                     : 0),
2383                   originalLine: mapping.originalLine,
2384                   originalColumn: mapping.originalColumn,
2385                   name: name
2386                 };
2387
2388                 this.__generatedMappings.push(adjustedMapping);
2389                 if (typeof adjustedMapping.originalLine === 'number') {
2390                   this.__originalMappings.push(adjustedMapping);
2391                 }
2392               }
2393             }
2394
2395             quickSort(this.__generatedMappings, util.compareByGeneratedPositionsDeflated);
2396             quickSort(this.__originalMappings, util.compareByOriginalPositions);
2397           };
2398
2399         exports.IndexedSourceMapConsumer = IndexedSourceMapConsumer;
2400
2401
2402 /***/ },
2403 /* 8 */
2404 /***/ function(module, exports) {
2405
2406         /* -*- Mode: js; js-indent-level: 2; -*- */
2407         /*
2408          * Copyright 2011 Mozilla Foundation and contributors
2409          * Licensed under the New BSD license. See LICENSE or:
2410          * http://opensource.org/licenses/BSD-3-Clause
2411          */
2412
2413         exports.GREATEST_LOWER_BOUND = 1;
2414         exports.LEAST_UPPER_BOUND = 2;
2415
2416         /**
2417          * Recursive implementation of binary search.
2418          *
2419          * @param aLow Indices here and lower do not contain the needle.
2420          * @param aHigh Indices here and higher do not contain the needle.
2421          * @param aNeedle The element being searched for.
2422          * @param aHaystack The non-empty array being searched.
2423          * @param aCompare Function which takes two elements and returns -1, 0, or 1.
2424          * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
2425          *     'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
2426          *     closest element that is smaller than or greater than the one we are
2427          *     searching for, respectively, if the exact element cannot be found.
2428          */
2429         function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare, aBias) {
2430           // This function terminates when one of the following is true:
2431           //
2432           //   1. We find the exact element we are looking for.
2433           //
2434           //   2. We did not find the exact element, but we can return the index of
2435           //      the next-closest element.
2436           //
2437           //   3. We did not find the exact element, and there is no next-closest
2438           //      element than the one we are searching for, so we return -1.
2439           var mid = Math.floor((aHigh - aLow) / 2) + aLow;
2440           var cmp = aCompare(aNeedle, aHaystack[mid], true);
2441           if (cmp === 0) {
2442             // Found the element we are looking for.
2443             return mid;
2444           }
2445           else if (cmp > 0) {
2446             // Our needle is greater than aHaystack[mid].
2447             if (aHigh - mid > 1) {
2448               // The element is in the upper half.
2449               return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare, aBias);
2450             }
2451
2452             // The exact needle element was not found in this haystack. Determine if
2453             // we are in termination case (3) or (2) and return the appropriate thing.
2454             if (aBias == exports.LEAST_UPPER_BOUND) {
2455               return aHigh < aHaystack.length ? aHigh : -1;
2456             } else {
2457               return mid;
2458             }
2459           }
2460           else {
2461             // Our needle is less than aHaystack[mid].
2462             if (mid - aLow > 1) {
2463               // The element is in the lower half.
2464               return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare, aBias);
2465             }
2466
2467             // we are in termination case (3) or (2) and return the appropriate thing.
2468             if (aBias == exports.LEAST_UPPER_BOUND) {
2469               return mid;
2470             } else {
2471               return aLow < 0 ? -1 : aLow;
2472             }
2473           }
2474         }
2475
2476         /**
2477          * This is an implementation of binary search which will always try and return
2478          * the index of the closest element if there is no exact hit. This is because
2479          * mappings between original and generated line/col pairs are single points,
2480          * and there is an implicit region between each of them, so a miss just means
2481          * that you aren't on the very start of a region.
2482          *
2483          * @param aNeedle The element you are looking for.
2484          * @param aHaystack The array that is being searched.
2485          * @param aCompare A function which takes the needle and an element in the
2486          *     array and returns -1, 0, or 1 depending on whether the needle is less
2487          *     than, equal to, or greater than the element, respectively.
2488          * @param aBias Either 'binarySearch.GREATEST_LOWER_BOUND' or
2489          *     'binarySearch.LEAST_UPPER_BOUND'. Specifies whether to return the
2490          *     closest element that is smaller than or greater than the one we are
2491          *     searching for, respectively, if the exact element cannot be found.
2492          *     Defaults to 'binarySearch.GREATEST_LOWER_BOUND'.
2493          */
2494         exports.search = function search(aNeedle, aHaystack, aCompare, aBias) {
2495           if (aHaystack.length === 0) {
2496             return -1;
2497           }
2498
2499           var index = recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack,
2500                                       aCompare, aBias || exports.GREATEST_LOWER_BOUND);
2501           if (index < 0) {
2502             return -1;
2503           }
2504
2505           // We have found either the exact element, or the next-closest element than
2506           // the one we are searching for. However, there may be more than one such
2507           // element. Make sure we always return the smallest of these.
2508           while (index - 1 >= 0) {
2509             if (aCompare(aHaystack[index], aHaystack[index - 1], true) !== 0) {
2510               break;
2511             }
2512             --index;
2513           }
2514
2515           return index;
2516         };
2517
2518
2519 /***/ },
2520 /* 9 */
2521 /***/ function(module, exports) {
2522
2523         /* -*- Mode: js; js-indent-level: 2; -*- */
2524         /*
2525          * Copyright 2011 Mozilla Foundation and contributors
2526          * Licensed under the New BSD license. See LICENSE or:
2527          * http://opensource.org/licenses/BSD-3-Clause
2528          */
2529
2530         // It turns out that some (most?) JavaScript engines don't self-host
2531         // `Array.prototype.sort`. This makes sense because C++ will likely remain
2532         // faster than JS when doing raw CPU-intensive sorting. However, when using a
2533         // custom comparator function, calling back and forth between the VM's C++ and
2534         // JIT'd JS is rather slow *and* loses JIT type information, resulting in
2535         // worse generated code for the comparator function than would be optimal. In
2536         // fact, when sorting with a comparator, these costs outweigh the benefits of
2537         // sorting in C++. By using our own JS-implemented Quick Sort (below), we get
2538         // a ~3500ms mean speed-up in `bench/bench.html`.
2539
2540         /**
2541          * Swap the elements indexed by `x` and `y` in the array `ary`.
2542          *
2543          * @param {Array} ary
2544          *        The array.
2545          * @param {Number} x
2546          *        The index of the first item.
2547          * @param {Number} y
2548          *        The index of the second item.
2549          */
2550         function swap(ary, x, y) {
2551           var temp = ary[x];
2552           ary[x] = ary[y];
2553           ary[y] = temp;
2554         }
2555
2556         /**
2557          * Returns a random integer within the range `low .. high` inclusive.
2558          *
2559          * @param {Number} low
2560          *        The lower bound on the range.
2561          * @param {Number} high
2562          *        The upper bound on the range.
2563          */
2564         function randomIntInRange(low, high) {
2565           return Math.round(low + (Math.random() * (high - low)));
2566         }
2567
2568         /**
2569          * The Quick Sort algorithm.
2570          *
2571          * @param {Array} ary
2572          *        An array to sort.
2573          * @param {function} comparator
2574          *        Function to use to compare two items.
2575          * @param {Number} p
2576          *        Start index of the array
2577          * @param {Number} r
2578          *        End index of the array
2579          */
2580         function doQuickSort(ary, comparator, p, r) {
2581           // If our lower bound is less than our upper bound, we (1) partition the
2582           // array into two pieces and (2) recurse on each half. If it is not, this is
2583           // the empty array and our base case.
2584
2585           if (p < r) {
2586             // (1) Partitioning.
2587             //
2588             // The partitioning chooses a pivot between `p` and `r` and moves all
2589             // elements that are less than or equal to the pivot to the before it, and
2590             // all the elements that are greater than it after it. The effect is that
2591             // once partition is done, the pivot is in the exact place it will be when
2592             // the array is put in sorted order, and it will not need to be moved
2593             // again. This runs in O(n) time.
2594
2595             // Always choose a random pivot so that an input array which is reverse
2596             // sorted does not cause O(n^2) running time.
2597             var pivotIndex = randomIntInRange(p, r);
2598             var i = p - 1;
2599
2600             swap(ary, pivotIndex, r);
2601             var pivot = ary[r];
2602
2603             // Immediately after `j` is incremented in this loop, the following hold
2604             // true:
2605             //
2606             //   * Every element in `ary[p .. i]` is less than or equal to the pivot.
2607             //
2608             //   * Every element in `ary[i+1 .. j-1]` is greater than the pivot.
2609             for (var j = p; j < r; j++) {
2610               if (comparator(ary[j], pivot) <= 0) {
2611                 i += 1;
2612                 swap(ary, i, j);
2613               }
2614             }
2615
2616             swap(ary, i + 1, j);
2617             var q = i + 1;
2618
2619             // (2) Recurse on each half.
2620
2621             doQuickSort(ary, comparator, p, q - 1);
2622             doQuickSort(ary, comparator, q + 1, r);
2623           }
2624         }
2625
2626         /**
2627          * Sort the given array in-place with the given comparator function.
2628          *
2629          * @param {Array} ary
2630          *        An array to sort.
2631          * @param {function} comparator
2632          *        Function to use to compare two items.
2633          */
2634         exports.quickSort = function (ary, comparator) {
2635           doQuickSort(ary, comparator, 0, ary.length - 1);
2636         };
2637
2638
2639 /***/ },
2640 /* 10 */
2641 /***/ function(module, exports, __webpack_require__) {
2642
2643         /* -*- Mode: js; js-indent-level: 2; -*- */
2644         /*
2645          * Copyright 2011 Mozilla Foundation and contributors
2646          * Licensed under the New BSD license. See LICENSE or:
2647          * http://opensource.org/licenses/BSD-3-Clause
2648          */
2649
2650         var SourceMapGenerator = __webpack_require__(1).SourceMapGenerator;
2651         var util = __webpack_require__(4);
2652
2653         // Matches a Windows-style `\r\n` newline or a `\n` newline used by all other
2654         // operating systems these days (capturing the result).
2655         var REGEX_NEWLINE = /(\r?\n)/;
2656
2657         // Newline character code for charCodeAt() comparisons
2658         var NEWLINE_CODE = 10;
2659
2660         // Private symbol for identifying `SourceNode`s when multiple versions of
2661         // the source-map library are loaded. This MUST NOT CHANGE across
2662         // versions!
2663         var isSourceNode = "$$$isSourceNode$$$";
2664
2665         /**
2666          * SourceNodes provide a way to abstract over interpolating/concatenating
2667          * snippets of generated JavaScript source code while maintaining the line and
2668          * column information associated with the original source code.
2669          *
2670          * @param aLine The original line number.
2671          * @param aColumn The original column number.
2672          * @param aSource The original source's filename.
2673          * @param aChunks Optional. An array of strings which are snippets of
2674          *        generated JS, or other SourceNodes.
2675          * @param aName The original identifier.
2676          */
2677         function SourceNode(aLine, aColumn, aSource, aChunks, aName) {
2678           this.children = [];
2679           this.sourceContents = {};
2680           this.line = aLine == null ? null : aLine;
2681           this.column = aColumn == null ? null : aColumn;
2682           this.source = aSource == null ? null : aSource;
2683           this.name = aName == null ? null : aName;
2684           this[isSourceNode] = true;
2685           if (aChunks != null) this.add(aChunks);
2686         }
2687
2688         /**
2689          * Creates a SourceNode from generated code and a SourceMapConsumer.
2690          *
2691          * @param aGeneratedCode The generated code
2692          * @param aSourceMapConsumer The SourceMap for the generated code
2693          * @param aRelativePath Optional. The path that relative sources in the
2694          *        SourceMapConsumer should be relative to.
2695          */
2696         SourceNode.fromStringWithSourceMap =
2697           function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer, aRelativePath) {
2698             // The SourceNode we want to fill with the generated code
2699             // and the SourceMap
2700             var node = new SourceNode();
2701
2702             // All even indices of this array are one line of the generated code,
2703             // while all odd indices are the newlines between two adjacent lines
2704             // (since `REGEX_NEWLINE` captures its match).
2705             // Processed fragments are removed from this array, by calling `shiftNextLine`.
2706             var remainingLines = aGeneratedCode.split(REGEX_NEWLINE);
2707             var shiftNextLine = function() {
2708               var lineContents = remainingLines.shift();
2709               // The last line of a file might not have a newline.
2710               var newLine = remainingLines.shift() || "";
2711               return lineContents + newLine;
2712             };
2713
2714             // We need to remember the position of "remainingLines"
2715             var lastGeneratedLine = 1, lastGeneratedColumn = 0;
2716
2717             // The generate SourceNodes we need a code range.
2718             // To extract it current and last mapping is used.
2719             // Here we store the last mapping.
2720             var lastMapping = null;
2721
2722             aSourceMapConsumer.eachMapping(function (mapping) {
2723               if (lastMapping !== null) {
2724                 // We add the code from "lastMapping" to "mapping":
2725                 // First check if there is a new line in between.
2726                 if (lastGeneratedLine < mapping.generatedLine) {
2727                   // Associate first line with "lastMapping"
2728                   addMappingWithCode(lastMapping, shiftNextLine());
2729                   lastGeneratedLine++;
2730                   lastGeneratedColumn = 0;
2731                   // The remaining code is added without mapping
2732                 } else {
2733                   // There is no new line in between.
2734                   // Associate the code between "lastGeneratedColumn" and
2735                   // "mapping.generatedColumn" with "lastMapping"
2736                   var nextLine = remainingLines[0];
2737                   var code = nextLine.substr(0, mapping.generatedColumn -
2738                                                 lastGeneratedColumn);
2739                   remainingLines[0] = nextLine.substr(mapping.generatedColumn -
2740                                                       lastGeneratedColumn);
2741                   lastGeneratedColumn = mapping.generatedColumn;
2742                   addMappingWithCode(lastMapping, code);
2743                   // No more remaining code, continue
2744                   lastMapping = mapping;
2745                   return;
2746                 }
2747               }
2748               // We add the generated code until the first mapping
2749               // to the SourceNode without any mapping.
2750               // Each line is added as separate string.
2751               while (lastGeneratedLine < mapping.generatedLine) {
2752                 node.add(shiftNextLine());
2753                 lastGeneratedLine++;
2754               }
2755               if (lastGeneratedColumn < mapping.generatedColumn) {
2756                 var nextLine = remainingLines[0];
2757                 node.add(nextLine.substr(0, mapping.generatedColumn));
2758                 remainingLines[0] = nextLine.substr(mapping.generatedColumn);
2759                 lastGeneratedColumn = mapping.generatedColumn;
2760               }
2761               lastMapping = mapping;
2762             }, this);
2763             // We have processed all mappings.
2764             if (remainingLines.length > 0) {
2765               if (lastMapping) {
2766                 // Associate the remaining code in the current line with "lastMapping"
2767                 addMappingWithCode(lastMapping, shiftNextLine());
2768               }
2769               // and add the remaining lines without any mapping
2770               node.add(remainingLines.join(""));
2771             }
2772
2773             // Copy sourcesContent into SourceNode
2774             aSourceMapConsumer.sources.forEach(function (sourceFile) {
2775               var content = aSourceMapConsumer.sourceContentFor(sourceFile);
2776               if (content != null) {
2777                 if (aRelativePath != null) {
2778                   sourceFile = util.join(aRelativePath, sourceFile);
2779                 }
2780                 node.setSourceContent(sourceFile, content);
2781               }
2782             });
2783
2784             return node;
2785
2786             function addMappingWithCode(mapping, code) {
2787               if (mapping === null || mapping.source === undefined) {
2788                 node.add(code);
2789               } else {
2790                 var source = aRelativePath
2791                   ? util.join(aRelativePath, mapping.source)
2792                   : mapping.source;
2793                 node.add(new SourceNode(mapping.originalLine,
2794                                         mapping.originalColumn,
2795                                         source,
2796                                         code,
2797                                         mapping.name));
2798               }
2799             }
2800           };
2801
2802         /**
2803          * Add a chunk of generated JS to this source node.
2804          *
2805          * @param aChunk A string snippet of generated JS code, another instance of
2806          *        SourceNode, or an array where each member is one of those things.
2807          */
2808         SourceNode.prototype.add = function SourceNode_add(aChunk) {
2809           if (Array.isArray(aChunk)) {
2810             aChunk.forEach(function (chunk) {
2811               this.add(chunk);
2812             }, this);
2813           }
2814           else if (aChunk[isSourceNode] || typeof aChunk === "string") {
2815             if (aChunk) {
2816               this.children.push(aChunk);
2817             }
2818           }
2819           else {
2820             throw new TypeError(
2821               "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
2822             );
2823           }
2824           return this;
2825         };
2826
2827         /**
2828          * Add a chunk of generated JS to the beginning of this source node.
2829          *
2830          * @param aChunk A string snippet of generated JS code, another instance of
2831          *        SourceNode, or an array where each member is one of those things.
2832          */
2833         SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) {
2834           if (Array.isArray(aChunk)) {
2835             for (var i = aChunk.length-1; i >= 0; i--) {
2836               this.prepend(aChunk[i]);
2837             }
2838           }
2839           else if (aChunk[isSourceNode] || typeof aChunk === "string") {
2840             this.children.unshift(aChunk);
2841           }
2842           else {
2843             throw new TypeError(
2844               "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk
2845             );
2846           }
2847           return this;
2848         };
2849
2850         /**
2851          * Walk over the tree of JS snippets in this node and its children. The
2852          * walking function is called once for each snippet of JS and is passed that
2853          * snippet and the its original associated source's line/column location.
2854          *
2855          * @param aFn The traversal function.
2856          */
2857         SourceNode.prototype.walk = function SourceNode_walk(aFn) {
2858           var chunk;
2859           for (var i = 0, len = this.children.length; i < len; i++) {
2860             chunk = this.children[i];
2861             if (chunk[isSourceNode]) {
2862               chunk.walk(aFn);
2863             }
2864             else {
2865               if (chunk !== '') {
2866                 aFn(chunk, { source: this.source,
2867                              line: this.line,
2868                              column: this.column,
2869                              name: this.name });
2870               }
2871             }
2872           }
2873         };
2874
2875         /**
2876          * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between
2877          * each of `this.children`.
2878          *
2879          * @param aSep The separator.
2880          */
2881         SourceNode.prototype.join = function SourceNode_join(aSep) {
2882           var newChildren;
2883           var i;
2884           var len = this.children.length;
2885           if (len > 0) {
2886             newChildren = [];
2887             for (i = 0; i < len-1; i++) {
2888               newChildren.push(this.children[i]);
2889               newChildren.push(aSep);
2890             }
2891             newChildren.push(this.children[i]);
2892             this.children = newChildren;
2893           }
2894           return this;
2895         };
2896
2897         /**
2898          * Call String.prototype.replace on the very right-most source snippet. Useful
2899          * for trimming whitespace from the end of a source node, etc.
2900          *
2901          * @param aPattern The pattern to replace.
2902          * @param aReplacement The thing to replace the pattern with.
2903          */
2904         SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) {
2905           var lastChild = this.children[this.children.length - 1];
2906           if (lastChild[isSourceNode]) {
2907             lastChild.replaceRight(aPattern, aReplacement);
2908           }
2909           else if (typeof lastChild === 'string') {
2910             this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement);
2911           }
2912           else {
2913             this.children.push(''.replace(aPattern, aReplacement));
2914           }
2915           return this;
2916         };
2917
2918         /**
2919          * Set the source content for a source file. This will be added to the SourceMapGenerator
2920          * in the sourcesContent field.
2921          *
2922          * @param aSourceFile The filename of the source file
2923          * @param aSourceContent The content of the source file
2924          */
2925         SourceNode.prototype.setSourceContent =
2926           function SourceNode_setSourceContent(aSourceFile, aSourceContent) {
2927             this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent;
2928           };
2929
2930         /**
2931          * Walk over the tree of SourceNodes. The walking function is called for each
2932          * source file content and is passed the filename and source content.
2933          *
2934          * @param aFn The traversal function.
2935          */
2936         SourceNode.prototype.walkSourceContents =
2937           function SourceNode_walkSourceContents(aFn) {
2938             for (var i = 0, len = this.children.length; i < len; i++) {
2939               if (this.children[i][isSourceNode]) {
2940                 this.children[i].walkSourceContents(aFn);
2941               }
2942             }
2943
2944             var sources = Object.keys(this.sourceContents);
2945             for (var i = 0, len = sources.length; i < len; i++) {
2946               aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]);
2947             }
2948           };
2949
2950         /**
2951          * Return the string representation of this source node. Walks over the tree
2952          * and concatenates all the various snippets together to one string.
2953          */
2954         SourceNode.prototype.toString = function SourceNode_toString() {
2955           var str = "";
2956           this.walk(function (chunk) {
2957             str += chunk;
2958           });
2959           return str;
2960         };
2961
2962         /**
2963          * Returns the string representation of this source node along with a source
2964          * map.
2965          */
2966         SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) {
2967           var generated = {
2968             code: "",
2969             line: 1,
2970             column: 0
2971           };
2972           var map = new SourceMapGenerator(aArgs);
2973           var sourceMappingActive = false;
2974           var lastOriginalSource = null;
2975           var lastOriginalLine = null;
2976           var lastOriginalColumn = null;
2977           var lastOriginalName = null;
2978           this.walk(function (chunk, original) {
2979             generated.code += chunk;
2980             if (original.source !== null
2981                 && original.line !== null
2982                 && original.column !== null) {
2983               if(lastOriginalSource !== original.source
2984                  || lastOriginalLine !== original.line
2985                  || lastOriginalColumn !== original.column
2986                  || lastOriginalName !== original.name) {
2987                 map.addMapping({
2988                   source: original.source,
2989                   original: {
2990                     line: original.line,
2991                     column: original.column
2992                   },
2993                   generated: {
2994                     line: generated.line,
2995                     column: generated.column
2996                   },
2997                   name: original.name
2998                 });
2999               }
3000               lastOriginalSource = original.source;
3001               lastOriginalLine = original.line;
3002               lastOriginalColumn = original.column;
3003               lastOriginalName = original.name;
3004               sourceMappingActive = true;
3005             } else if (sourceMappingActive) {
3006               map.addMapping({
3007                 generated: {
3008                   line: generated.line,
3009                   column: generated.column
3010                 }
3011               });
3012               lastOriginalSource = null;
3013               sourceMappingActive = false;
3014             }
3015             for (var idx = 0, length = chunk.length; idx < length; idx++) {
3016               if (chunk.charCodeAt(idx) === NEWLINE_CODE) {
3017                 generated.line++;
3018                 generated.column = 0;
3019                 // Mappings end at eol
3020                 if (idx + 1 === length) {
3021                   lastOriginalSource = null;
3022                   sourceMappingActive = false;
3023                 } else if (sourceMappingActive) {
3024                   map.addMapping({
3025                     source: original.source,
3026                     original: {
3027                       line: original.line,
3028                       column: original.column
3029                     },
3030                     generated: {
3031                       line: generated.line,
3032                       column: generated.column
3033                     },
3034                     name: original.name
3035                   });
3036                 }
3037               } else {
3038                 generated.column++;
3039               }
3040             }
3041           });
3042           this.walkSourceContents(function (sourceFile, sourceContent) {
3043             map.setSourceContent(sourceFile, sourceContent);
3044           });
3045
3046           return { code: generated.code, map: map };
3047         };
3048
3049         exports.SourceNode = SourceNode;
3050
3051
3052 /***/ }
3053 /******/ ])
3054 });
3055 ;