UNPKG

336 kBJavaScriptView Raw
1module.exports =
2/******/ (function(modules) { // webpackBootstrap
3/******/ // The module cache
4/******/ var installedModules = {};
5
6/******/ // The require function
7/******/ function __webpack_require__(moduleId) {
8
9/******/ // Check if module is in cache
10/******/ if(installedModules[moduleId])
11/******/ return installedModules[moduleId].exports;
12
13/******/ // Create a new module (and put it into the cache)
14/******/ var module = installedModules[moduleId] = {
15/******/ exports: {},
16/******/ id: moduleId,
17/******/ loaded: false
18/******/ };
19
20/******/ // Execute the module function
21/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
23/******/ // Flag the module as loaded
24/******/ module.loaded = true;
25
26/******/ // Return the exports of the module
27/******/ return module.exports;
28/******/ }
29
30
31/******/ // expose the modules object (__webpack_modules__)
32/******/ __webpack_require__.m = modules;
33
34/******/ // expose the module cache
35/******/ __webpack_require__.c = installedModules;
36
37/******/ // __webpack_public_path__
38/******/ __webpack_require__.p = "";
39
40/******/ // Load entry module and return exports
41/******/ return __webpack_require__(0);
42/******/ })
43/************************************************************************/
44/******/ ([
45/* 0 */
46/***/ (function(module, exports, __webpack_require__) {
47
48 module.exports = __webpack_require__(1);
49
50
51/***/ }),
52/* 1 */
53/***/ (function(module, exports, __webpack_require__) {
54
55 // Generated by CoffeeScript 1.12.7
56 (function() {
57 "use strict";
58 var builder, defaults, parser, processors,
59 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
60 hasProp = {}.hasOwnProperty;
61
62 defaults = __webpack_require__(2);
63
64 builder = __webpack_require__(3);
65
66 parser = __webpack_require__(26);
67
68 processors = __webpack_require__(60);
69
70 exports.defaults = defaults.defaults;
71
72 exports.processors = processors;
73
74 exports.ValidationError = (function(superClass) {
75 extend(ValidationError, superClass);
76
77 function ValidationError(message) {
78 this.message = message;
79 }
80
81 return ValidationError;
82
83 })(Error);
84
85 exports.Builder = builder.Builder;
86
87 exports.Parser = parser.Parser;
88
89 exports.parseString = parser.parseString;
90
91 }).call(this);
92
93
94/***/ }),
95/* 2 */
96/***/ (function(module, exports) {
97
98 // Generated by CoffeeScript 1.12.7
99 (function() {
100 exports.defaults = {
101 "0.1": {
102 explicitCharkey: false,
103 trim: true,
104 normalize: true,
105 normalizeTags: false,
106 attrkey: "@",
107 charkey: "#",
108 explicitArray: false,
109 ignoreAttrs: false,
110 mergeAttrs: false,
111 explicitRoot: false,
112 validator: null,
113 xmlns: false,
114 explicitChildren: false,
115 childkey: '@@',
116 charsAsChildren: false,
117 includeWhiteChars: false,
118 async: false,
119 strict: true,
120 attrNameProcessors: null,
121 attrValueProcessors: null,
122 tagNameProcessors: null,
123 valueProcessors: null,
124 emptyTag: ''
125 },
126 "0.2": {
127 explicitCharkey: false,
128 trim: false,
129 normalize: false,
130 normalizeTags: false,
131 attrkey: "$",
132 charkey: "_",
133 explicitArray: true,
134 ignoreAttrs: false,
135 mergeAttrs: false,
136 explicitRoot: true,
137 validator: null,
138 xmlns: false,
139 explicitChildren: false,
140 preserveChildrenOrder: false,
141 childkey: '$$',
142 charsAsChildren: false,
143 includeWhiteChars: false,
144 async: false,
145 strict: true,
146 attrNameProcessors: null,
147 attrValueProcessors: null,
148 tagNameProcessors: null,
149 valueProcessors: null,
150 rootName: 'root',
151 xmldec: {
152 'version': '1.0',
153 'encoding': 'UTF-8',
154 'standalone': true
155 },
156 doctype: null,
157 renderOpts: {
158 'pretty': true,
159 'indent': ' ',
160 'newline': '\n'
161 },
162 headless: false,
163 chunkSize: 10000,
164 emptyTag: '',
165 cdata: false
166 }
167 };
168
169 }).call(this);
170
171
172/***/ }),
173/* 3 */
174/***/ (function(module, exports, __webpack_require__) {
175
176 // Generated by CoffeeScript 1.12.7
177 (function() {
178 "use strict";
179 var builder, defaults, escapeCDATA, requiresCDATA, wrapCDATA,
180 hasProp = {}.hasOwnProperty;
181
182 builder = __webpack_require__(4);
183
184 defaults = __webpack_require__(2).defaults;
185
186 requiresCDATA = function(entry) {
187 return typeof entry === "string" && (entry.indexOf('&') >= 0 || entry.indexOf('>') >= 0 || entry.indexOf('<') >= 0);
188 };
189
190 wrapCDATA = function(entry) {
191 return "<![CDATA[" + (escapeCDATA(entry)) + "]]>";
192 };
193
194 escapeCDATA = function(entry) {
195 return entry.replace(']]>', ']]]]><![CDATA[>');
196 };
197
198 exports.Builder = (function() {
199 function Builder(opts) {
200 var key, ref, value;
201 this.options = {};
202 ref = defaults["0.2"];
203 for (key in ref) {
204 if (!hasProp.call(ref, key)) continue;
205 value = ref[key];
206 this.options[key] = value;
207 }
208 for (key in opts) {
209 if (!hasProp.call(opts, key)) continue;
210 value = opts[key];
211 this.options[key] = value;
212 }
213 }
214
215 Builder.prototype.buildObject = function(rootObj) {
216 var attrkey, charkey, render, rootElement, rootName;
217 attrkey = this.options.attrkey;
218 charkey = this.options.charkey;
219 if ((Object.keys(rootObj).length === 1) && (this.options.rootName === defaults['0.2'].rootName)) {
220 rootName = Object.keys(rootObj)[0];
221 rootObj = rootObj[rootName];
222 } else {
223 rootName = this.options.rootName;
224 }
225 render = (function(_this) {
226 return function(element, obj) {
227 var attr, child, entry, index, key, value;
228 if (typeof obj !== 'object') {
229 if (_this.options.cdata && requiresCDATA(obj)) {
230 element.raw(wrapCDATA(obj));
231 } else {
232 element.txt(obj);
233 }
234 } else if (Array.isArray(obj)) {
235 for (index in obj) {
236 if (!hasProp.call(obj, index)) continue;
237 child = obj[index];
238 for (key in child) {
239 entry = child[key];
240 element = render(element.ele(key), entry).up();
241 }
242 }
243 } else {
244 for (key in obj) {
245 if (!hasProp.call(obj, key)) continue;
246 child = obj[key];
247 if (key === attrkey) {
248 if (typeof child === "object") {
249 for (attr in child) {
250 value = child[attr];
251 element = element.att(attr, value);
252 }
253 }
254 } else if (key === charkey) {
255 if (_this.options.cdata && requiresCDATA(child)) {
256 element = element.raw(wrapCDATA(child));
257 } else {
258 element = element.txt(child);
259 }
260 } else if (Array.isArray(child)) {
261 for (index in child) {
262 if (!hasProp.call(child, index)) continue;
263 entry = child[index];
264 if (typeof entry === 'string') {
265 if (_this.options.cdata && requiresCDATA(entry)) {
266 element = element.ele(key).raw(wrapCDATA(entry)).up();
267 } else {
268 element = element.ele(key, entry).up();
269 }
270 } else {
271 element = render(element.ele(key), entry).up();
272 }
273 }
274 } else if (typeof child === "object") {
275 element = render(element.ele(key), child).up();
276 } else {
277 if (typeof child === 'string' && _this.options.cdata && requiresCDATA(child)) {
278 element = element.ele(key).raw(wrapCDATA(child)).up();
279 } else {
280 if (child == null) {
281 child = '';
282 }
283 element = element.ele(key, child.toString()).up();
284 }
285 }
286 }
287 }
288 return element;
289 };
290 })(this);
291 rootElement = builder.create(rootName, this.options.xmldec, this.options.doctype, {
292 headless: this.options.headless,
293 allowSurrogateChars: this.options.allowSurrogateChars
294 });
295 return render(rootElement, rootObj).end(this.options.renderOpts);
296 };
297
298 return Builder;
299
300 })();
301
302 }).call(this);
303
304
305/***/ }),
306/* 4 */
307/***/ (function(module, exports, __webpack_require__) {
308
309 // Generated by CoffeeScript 1.12.7
310 (function() {
311 var XMLDocument, XMLDocumentCB, XMLStreamWriter, XMLStringWriter, assign, isFunction, ref;
312
313 ref = __webpack_require__(5), assign = ref.assign, isFunction = ref.isFunction;
314
315 XMLDocument = __webpack_require__(6);
316
317 XMLDocumentCB = __webpack_require__(24);
318
319 XMLStringWriter = __webpack_require__(22);
320
321 XMLStreamWriter = __webpack_require__(25);
322
323 module.exports.create = function(name, xmldec, doctype, options) {
324 var doc, root;
325 if (name == null) {
326 throw new Error("Root element needs a name");
327 }
328 options = assign({}, xmldec, doctype, options);
329 doc = new XMLDocument(options);
330 root = doc.element(name);
331 if (!options.headless) {
332 doc.declaration(options);
333 if ((options.pubID != null) || (options.sysID != null)) {
334 doc.doctype(options);
335 }
336 }
337 return root;
338 };
339
340 module.exports.begin = function(options, onData, onEnd) {
341 var ref1;
342 if (isFunction(options)) {
343 ref1 = [options, onData], onData = ref1[0], onEnd = ref1[1];
344 options = {};
345 }
346 if (onData) {
347 return new XMLDocumentCB(options, onData, onEnd);
348 } else {
349 return new XMLDocument(options);
350 }
351 };
352
353 module.exports.stringWriter = function(options) {
354 return new XMLStringWriter(options);
355 };
356
357 module.exports.streamWriter = function(stream, options) {
358 return new XMLStreamWriter(stream, options);
359 };
360
361 }).call(this);
362
363
364/***/ }),
365/* 5 */
366/***/ (function(module, exports) {
367
368 // Generated by CoffeeScript 1.12.7
369 (function() {
370 var assign, isArray, isEmpty, isFunction, isObject, isPlainObject,
371 slice = [].slice,
372 hasProp = {}.hasOwnProperty;
373
374 assign = function() {
375 var i, key, len, source, sources, target;
376 target = arguments[0], sources = 2 <= arguments.length ? slice.call(arguments, 1) : [];
377 if (isFunction(Object.assign)) {
378 Object.assign.apply(null, arguments);
379 } else {
380 for (i = 0, len = sources.length; i < len; i++) {
381 source = sources[i];
382 if (source != null) {
383 for (key in source) {
384 if (!hasProp.call(source, key)) continue;
385 target[key] = source[key];
386 }
387 }
388 }
389 }
390 return target;
391 };
392
393 isFunction = function(val) {
394 return !!val && Object.prototype.toString.call(val) === '[object Function]';
395 };
396
397 isObject = function(val) {
398 var ref;
399 return !!val && ((ref = typeof val) === 'function' || ref === 'object');
400 };
401
402 isArray = function(val) {
403 if (isFunction(Array.isArray)) {
404 return Array.isArray(val);
405 } else {
406 return Object.prototype.toString.call(val) === '[object Array]';
407 }
408 };
409
410 isEmpty = function(val) {
411 var key;
412 if (isArray(val)) {
413 return !val.length;
414 } else {
415 for (key in val) {
416 if (!hasProp.call(val, key)) continue;
417 return false;
418 }
419 return true;
420 }
421 };
422
423 isPlainObject = function(val) {
424 var ctor, proto;
425 return isObject(val) && (proto = Object.getPrototypeOf(val)) && (ctor = proto.constructor) && (typeof ctor === 'function') && (ctor instanceof ctor) && (Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object));
426 };
427
428 module.exports.assign = assign;
429
430 module.exports.isFunction = isFunction;
431
432 module.exports.isObject = isObject;
433
434 module.exports.isArray = isArray;
435
436 module.exports.isEmpty = isEmpty;
437
438 module.exports.isPlainObject = isPlainObject;
439
440 }).call(this);
441
442
443/***/ }),
444/* 6 */
445/***/ (function(module, exports, __webpack_require__) {
446
447 // Generated by CoffeeScript 1.12.7
448 (function() {
449 var XMLDocument, XMLNode, XMLStringWriter, XMLStringifier, isPlainObject,
450 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
451 hasProp = {}.hasOwnProperty;
452
453 isPlainObject = __webpack_require__(5).isPlainObject;
454
455 XMLNode = __webpack_require__(7);
456
457 XMLStringifier = __webpack_require__(21);
458
459 XMLStringWriter = __webpack_require__(22);
460
461 module.exports = XMLDocument = (function(superClass) {
462 extend(XMLDocument, superClass);
463
464 function XMLDocument(options) {
465 XMLDocument.__super__.constructor.call(this, null);
466 options || (options = {});
467 if (!options.writer) {
468 options.writer = new XMLStringWriter();
469 }
470 this.options = options;
471 this.stringify = new XMLStringifier(options);
472 this.isDocument = true;
473 }
474
475 XMLDocument.prototype.end = function(writer) {
476 var writerOptions;
477 if (!writer) {
478 writer = this.options.writer;
479 } else if (isPlainObject(writer)) {
480 writerOptions = writer;
481 writer = this.options.writer.set(writerOptions);
482 }
483 return writer.document(this);
484 };
485
486 XMLDocument.prototype.toString = function(options) {
487 return this.options.writer.set(options).document(this);
488 };
489
490 return XMLDocument;
491
492 })(XMLNode);
493
494 }).call(this);
495
496
497/***/ }),
498/* 7 */
499/***/ (function(module, exports, __webpack_require__) {
500
501 // Generated by CoffeeScript 1.12.7
502 (function() {
503 var XMLCData, XMLComment, XMLDeclaration, XMLDocType, XMLElement, XMLNode, XMLProcessingInstruction, XMLRaw, XMLText, isEmpty, isFunction, isObject, ref,
504 hasProp = {}.hasOwnProperty;
505
506 ref = __webpack_require__(5), isObject = ref.isObject, isFunction = ref.isFunction, isEmpty = ref.isEmpty;
507
508 XMLElement = null;
509
510 XMLCData = null;
511
512 XMLComment = null;
513
514 XMLDeclaration = null;
515
516 XMLDocType = null;
517
518 XMLRaw = null;
519
520 XMLText = null;
521
522 XMLProcessingInstruction = null;
523
524 module.exports = XMLNode = (function() {
525 function XMLNode(parent) {
526 this.parent = parent;
527 if (this.parent) {
528 this.options = this.parent.options;
529 this.stringify = this.parent.stringify;
530 }
531 this.children = [];
532 if (!XMLElement) {
533 XMLElement = __webpack_require__(8);
534 XMLCData = __webpack_require__(10);
535 XMLComment = __webpack_require__(11);
536 XMLDeclaration = __webpack_require__(12);
537 XMLDocType = __webpack_require__(13);
538 XMLRaw = __webpack_require__(18);
539 XMLText = __webpack_require__(19);
540 XMLProcessingInstruction = __webpack_require__(20);
541 }
542 }
543
544 XMLNode.prototype.element = function(name, attributes, text) {
545 var childNode, item, j, k, key, lastChild, len, len1, ref1, val;
546 lastChild = null;
547 if (attributes == null) {
548 attributes = {};
549 }
550 attributes = attributes.valueOf();
551 if (!isObject(attributes)) {
552 ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
553 }
554 if (name != null) {
555 name = name.valueOf();
556 }
557 if (Array.isArray(name)) {
558 for (j = 0, len = name.length; j < len; j++) {
559 item = name[j];
560 lastChild = this.element(item);
561 }
562 } else if (isFunction(name)) {
563 lastChild = this.element(name.apply());
564 } else if (isObject(name)) {
565 for (key in name) {
566 if (!hasProp.call(name, key)) continue;
567 val = name[key];
568 if (isFunction(val)) {
569 val = val.apply();
570 }
571 if ((isObject(val)) && (isEmpty(val))) {
572 val = null;
573 }
574 if (!this.options.ignoreDecorators && this.stringify.convertAttKey && key.indexOf(this.stringify.convertAttKey) === 0) {
575 lastChild = this.attribute(key.substr(this.stringify.convertAttKey.length), val);
576 } else if (!this.options.separateArrayItems && Array.isArray(val)) {
577 for (k = 0, len1 = val.length; k < len1; k++) {
578 item = val[k];
579 childNode = {};
580 childNode[key] = item;
581 lastChild = this.element(childNode);
582 }
583 } else if (isObject(val)) {
584 lastChild = this.element(key);
585 lastChild.element(val);
586 } else {
587 lastChild = this.element(key, val);
588 }
589 }
590 } else {
591 if (!this.options.ignoreDecorators && this.stringify.convertTextKey && name.indexOf(this.stringify.convertTextKey) === 0) {
592 lastChild = this.text(text);
593 } else if (!this.options.ignoreDecorators && this.stringify.convertCDataKey && name.indexOf(this.stringify.convertCDataKey) === 0) {
594 lastChild = this.cdata(text);
595 } else if (!this.options.ignoreDecorators && this.stringify.convertCommentKey && name.indexOf(this.stringify.convertCommentKey) === 0) {
596 lastChild = this.comment(text);
597 } else if (!this.options.ignoreDecorators && this.stringify.convertRawKey && name.indexOf(this.stringify.convertRawKey) === 0) {
598 lastChild = this.raw(text);
599 } else if (!this.options.ignoreDecorators && this.stringify.convertPIKey && name.indexOf(this.stringify.convertPIKey) === 0) {
600 lastChild = this.instruction(name.substr(this.stringify.convertPIKey.length), text);
601 } else {
602 lastChild = this.node(name, attributes, text);
603 }
604 }
605 if (lastChild == null) {
606 throw new Error("Could not create any elements with: " + name);
607 }
608 return lastChild;
609 };
610
611 XMLNode.prototype.insertBefore = function(name, attributes, text) {
612 var child, i, removed;
613 if (this.isRoot) {
614 throw new Error("Cannot insert elements at root level");
615 }
616 i = this.parent.children.indexOf(this);
617 removed = this.parent.children.splice(i);
618 child = this.parent.element(name, attributes, text);
619 Array.prototype.push.apply(this.parent.children, removed);
620 return child;
621 };
622
623 XMLNode.prototype.insertAfter = function(name, attributes, text) {
624 var child, i, removed;
625 if (this.isRoot) {
626 throw new Error("Cannot insert elements at root level");
627 }
628 i = this.parent.children.indexOf(this);
629 removed = this.parent.children.splice(i + 1);
630 child = this.parent.element(name, attributes, text);
631 Array.prototype.push.apply(this.parent.children, removed);
632 return child;
633 };
634
635 XMLNode.prototype.remove = function() {
636 var i, ref1;
637 if (this.isRoot) {
638 throw new Error("Cannot remove the root element");
639 }
640 i = this.parent.children.indexOf(this);
641 [].splice.apply(this.parent.children, [i, i - i + 1].concat(ref1 = [])), ref1;
642 return this.parent;
643 };
644
645 XMLNode.prototype.node = function(name, attributes, text) {
646 var child, ref1;
647 if (name != null) {
648 name = name.valueOf();
649 }
650 attributes || (attributes = {});
651 attributes = attributes.valueOf();
652 if (!isObject(attributes)) {
653 ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
654 }
655 child = new XMLElement(this, name, attributes);
656 if (text != null) {
657 child.text(text);
658 }
659 this.children.push(child);
660 return child;
661 };
662
663 XMLNode.prototype.text = function(value) {
664 var child;
665 child = new XMLText(this, value);
666 this.children.push(child);
667 return this;
668 };
669
670 XMLNode.prototype.cdata = function(value) {
671 var child;
672 child = new XMLCData(this, value);
673 this.children.push(child);
674 return this;
675 };
676
677 XMLNode.prototype.comment = function(value) {
678 var child;
679 child = new XMLComment(this, value);
680 this.children.push(child);
681 return this;
682 };
683
684 XMLNode.prototype.commentBefore = function(value) {
685 var child, i, removed;
686 i = this.parent.children.indexOf(this);
687 removed = this.parent.children.splice(i);
688 child = this.parent.comment(value);
689 Array.prototype.push.apply(this.parent.children, removed);
690 return this;
691 };
692
693 XMLNode.prototype.commentAfter = function(value) {
694 var child, i, removed;
695 i = this.parent.children.indexOf(this);
696 removed = this.parent.children.splice(i + 1);
697 child = this.parent.comment(value);
698 Array.prototype.push.apply(this.parent.children, removed);
699 return this;
700 };
701
702 XMLNode.prototype.raw = function(value) {
703 var child;
704 child = new XMLRaw(this, value);
705 this.children.push(child);
706 return this;
707 };
708
709 XMLNode.prototype.instruction = function(target, value) {
710 var insTarget, insValue, instruction, j, len;
711 if (target != null) {
712 target = target.valueOf();
713 }
714 if (value != null) {
715 value = value.valueOf();
716 }
717 if (Array.isArray(target)) {
718 for (j = 0, len = target.length; j < len; j++) {
719 insTarget = target[j];
720 this.instruction(insTarget);
721 }
722 } else if (isObject(target)) {
723 for (insTarget in target) {
724 if (!hasProp.call(target, insTarget)) continue;
725 insValue = target[insTarget];
726 this.instruction(insTarget, insValue);
727 }
728 } else {
729 if (isFunction(value)) {
730 value = value.apply();
731 }
732 instruction = new XMLProcessingInstruction(this, target, value);
733 this.children.push(instruction);
734 }
735 return this;
736 };
737
738 XMLNode.prototype.instructionBefore = function(target, value) {
739 var child, i, removed;
740 i = this.parent.children.indexOf(this);
741 removed = this.parent.children.splice(i);
742 child = this.parent.instruction(target, value);
743 Array.prototype.push.apply(this.parent.children, removed);
744 return this;
745 };
746
747 XMLNode.prototype.instructionAfter = function(target, value) {
748 var child, i, removed;
749 i = this.parent.children.indexOf(this);
750 removed = this.parent.children.splice(i + 1);
751 child = this.parent.instruction(target, value);
752 Array.prototype.push.apply(this.parent.children, removed);
753 return this;
754 };
755
756 XMLNode.prototype.declaration = function(version, encoding, standalone) {
757 var doc, xmldec;
758 doc = this.document();
759 xmldec = new XMLDeclaration(doc, version, encoding, standalone);
760 if (doc.children[0] instanceof XMLDeclaration) {
761 doc.children[0] = xmldec;
762 } else {
763 doc.children.unshift(xmldec);
764 }
765 return doc.root() || doc;
766 };
767
768 XMLNode.prototype.doctype = function(pubID, sysID) {
769 var child, doc, doctype, i, j, k, len, len1, ref1, ref2;
770 doc = this.document();
771 doctype = new XMLDocType(doc, pubID, sysID);
772 ref1 = doc.children;
773 for (i = j = 0, len = ref1.length; j < len; i = ++j) {
774 child = ref1[i];
775 if (child instanceof XMLDocType) {
776 doc.children[i] = doctype;
777 return doctype;
778 }
779 }
780 ref2 = doc.children;
781 for (i = k = 0, len1 = ref2.length; k < len1; i = ++k) {
782 child = ref2[i];
783 if (child.isRoot) {
784 doc.children.splice(i, 0, doctype);
785 return doctype;
786 }
787 }
788 doc.children.push(doctype);
789 return doctype;
790 };
791
792 XMLNode.prototype.up = function() {
793 if (this.isRoot) {
794 throw new Error("The root node has no parent. Use doc() if you need to get the document object.");
795 }
796 return this.parent;
797 };
798
799 XMLNode.prototype.root = function() {
800 var node;
801 node = this;
802 while (node) {
803 if (node.isDocument) {
804 return node.rootObject;
805 } else if (node.isRoot) {
806 return node;
807 } else {
808 node = node.parent;
809 }
810 }
811 };
812
813 XMLNode.prototype.document = function() {
814 var node;
815 node = this;
816 while (node) {
817 if (node.isDocument) {
818 return node;
819 } else {
820 node = node.parent;
821 }
822 }
823 };
824
825 XMLNode.prototype.end = function(options) {
826 return this.document().end(options);
827 };
828
829 XMLNode.prototype.prev = function() {
830 var i;
831 i = this.parent.children.indexOf(this);
832 if (i < 1) {
833 throw new Error("Already at the first node");
834 }
835 return this.parent.children[i - 1];
836 };
837
838 XMLNode.prototype.next = function() {
839 var i;
840 i = this.parent.children.indexOf(this);
841 if (i === -1 || i === this.parent.children.length - 1) {
842 throw new Error("Already at the last node");
843 }
844 return this.parent.children[i + 1];
845 };
846
847 XMLNode.prototype.importDocument = function(doc) {
848 var clonedRoot;
849 clonedRoot = doc.root().clone();
850 clonedRoot.parent = this;
851 clonedRoot.isRoot = false;
852 this.children.push(clonedRoot);
853 return this;
854 };
855
856 XMLNode.prototype.ele = function(name, attributes, text) {
857 return this.element(name, attributes, text);
858 };
859
860 XMLNode.prototype.nod = function(name, attributes, text) {
861 return this.node(name, attributes, text);
862 };
863
864 XMLNode.prototype.txt = function(value) {
865 return this.text(value);
866 };
867
868 XMLNode.prototype.dat = function(value) {
869 return this.cdata(value);
870 };
871
872 XMLNode.prototype.com = function(value) {
873 return this.comment(value);
874 };
875
876 XMLNode.prototype.ins = function(target, value) {
877 return this.instruction(target, value);
878 };
879
880 XMLNode.prototype.doc = function() {
881 return this.document();
882 };
883
884 XMLNode.prototype.dec = function(version, encoding, standalone) {
885 return this.declaration(version, encoding, standalone);
886 };
887
888 XMLNode.prototype.dtd = function(pubID, sysID) {
889 return this.doctype(pubID, sysID);
890 };
891
892 XMLNode.prototype.e = function(name, attributes, text) {
893 return this.element(name, attributes, text);
894 };
895
896 XMLNode.prototype.n = function(name, attributes, text) {
897 return this.node(name, attributes, text);
898 };
899
900 XMLNode.prototype.t = function(value) {
901 return this.text(value);
902 };
903
904 XMLNode.prototype.d = function(value) {
905 return this.cdata(value);
906 };
907
908 XMLNode.prototype.c = function(value) {
909 return this.comment(value);
910 };
911
912 XMLNode.prototype.r = function(value) {
913 return this.raw(value);
914 };
915
916 XMLNode.prototype.i = function(target, value) {
917 return this.instruction(target, value);
918 };
919
920 XMLNode.prototype.u = function() {
921 return this.up();
922 };
923
924 XMLNode.prototype.importXMLBuilder = function(doc) {
925 return this.importDocument(doc);
926 };
927
928 return XMLNode;
929
930 })();
931
932 }).call(this);
933
934
935/***/ }),
936/* 8 */
937/***/ (function(module, exports, __webpack_require__) {
938
939 // Generated by CoffeeScript 1.12.7
940 (function() {
941 var XMLAttribute, XMLElement, XMLNode, isFunction, isObject, ref,
942 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
943 hasProp = {}.hasOwnProperty;
944
945 ref = __webpack_require__(5), isObject = ref.isObject, isFunction = ref.isFunction;
946
947 XMLNode = __webpack_require__(7);
948
949 XMLAttribute = __webpack_require__(9);
950
951 module.exports = XMLElement = (function(superClass) {
952 extend(XMLElement, superClass);
953
954 function XMLElement(parent, name, attributes) {
955 XMLElement.__super__.constructor.call(this, parent);
956 if (name == null) {
957 throw new Error("Missing element name");
958 }
959 this.name = this.stringify.eleName(name);
960 this.attributes = {};
961 if (attributes != null) {
962 this.attribute(attributes);
963 }
964 if (parent.isDocument) {
965 this.isRoot = true;
966 this.documentObject = parent;
967 parent.rootObject = this;
968 }
969 }
970
971 XMLElement.prototype.clone = function() {
972 var att, attName, clonedSelf, ref1;
973 clonedSelf = Object.create(this);
974 if (clonedSelf.isRoot) {
975 clonedSelf.documentObject = null;
976 }
977 clonedSelf.attributes = {};
978 ref1 = this.attributes;
979 for (attName in ref1) {
980 if (!hasProp.call(ref1, attName)) continue;
981 att = ref1[attName];
982 clonedSelf.attributes[attName] = att.clone();
983 }
984 clonedSelf.children = [];
985 this.children.forEach(function(child) {
986 var clonedChild;
987 clonedChild = child.clone();
988 clonedChild.parent = clonedSelf;
989 return clonedSelf.children.push(clonedChild);
990 });
991 return clonedSelf;
992 };
993
994 XMLElement.prototype.attribute = function(name, value) {
995 var attName, attValue;
996 if (name != null) {
997 name = name.valueOf();
998 }
999 if (isObject(name)) {
1000 for (attName in name) {
1001 if (!hasProp.call(name, attName)) continue;
1002 attValue = name[attName];
1003 this.attribute(attName, attValue);
1004 }
1005 } else {
1006 if (isFunction(value)) {
1007 value = value.apply();
1008 }
1009 if (!this.options.skipNullAttributes || (value != null)) {
1010 this.attributes[name] = new XMLAttribute(this, name, value);
1011 }
1012 }
1013 return this;
1014 };
1015
1016 XMLElement.prototype.removeAttribute = function(name) {
1017 var attName, i, len;
1018 if (name == null) {
1019 throw new Error("Missing attribute name");
1020 }
1021 name = name.valueOf();
1022 if (Array.isArray(name)) {
1023 for (i = 0, len = name.length; i < len; i++) {
1024 attName = name[i];
1025 delete this.attributes[attName];
1026 }
1027 } else {
1028 delete this.attributes[name];
1029 }
1030 return this;
1031 };
1032
1033 XMLElement.prototype.toString = function(options) {
1034 return this.options.writer.set(options).element(this);
1035 };
1036
1037 XMLElement.prototype.att = function(name, value) {
1038 return this.attribute(name, value);
1039 };
1040
1041 XMLElement.prototype.a = function(name, value) {
1042 return this.attribute(name, value);
1043 };
1044
1045 return XMLElement;
1046
1047 })(XMLNode);
1048
1049 }).call(this);
1050
1051
1052/***/ }),
1053/* 9 */
1054/***/ (function(module, exports) {
1055
1056 // Generated by CoffeeScript 1.12.7
1057 (function() {
1058 var XMLAttribute;
1059
1060 module.exports = XMLAttribute = (function() {
1061 function XMLAttribute(parent, name, value) {
1062 this.options = parent.options;
1063 this.stringify = parent.stringify;
1064 if (name == null) {
1065 throw new Error("Missing attribute name of element " + parent.name);
1066 }
1067 if (value == null) {
1068 throw new Error("Missing attribute value for attribute " + name + " of element " + parent.name);
1069 }
1070 this.name = this.stringify.attName(name);
1071 this.value = this.stringify.attValue(value);
1072 }
1073
1074 XMLAttribute.prototype.clone = function() {
1075 return Object.create(this);
1076 };
1077
1078 XMLAttribute.prototype.toString = function(options) {
1079 return this.options.writer.set(options).attribute(this);
1080 };
1081
1082 return XMLAttribute;
1083
1084 })();
1085
1086 }).call(this);
1087
1088
1089/***/ }),
1090/* 10 */
1091/***/ (function(module, exports, __webpack_require__) {
1092
1093 // Generated by CoffeeScript 1.12.7
1094 (function() {
1095 var XMLCData, XMLNode,
1096 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1097 hasProp = {}.hasOwnProperty;
1098
1099 XMLNode = __webpack_require__(7);
1100
1101 module.exports = XMLCData = (function(superClass) {
1102 extend(XMLCData, superClass);
1103
1104 function XMLCData(parent, text) {
1105 XMLCData.__super__.constructor.call(this, parent);
1106 if (text == null) {
1107 throw new Error("Missing CDATA text");
1108 }
1109 this.text = this.stringify.cdata(text);
1110 }
1111
1112 XMLCData.prototype.clone = function() {
1113 return Object.create(this);
1114 };
1115
1116 XMLCData.prototype.toString = function(options) {
1117 return this.options.writer.set(options).cdata(this);
1118 };
1119
1120 return XMLCData;
1121
1122 })(XMLNode);
1123
1124 }).call(this);
1125
1126
1127/***/ }),
1128/* 11 */
1129/***/ (function(module, exports, __webpack_require__) {
1130
1131 // Generated by CoffeeScript 1.12.7
1132 (function() {
1133 var XMLComment, XMLNode,
1134 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1135 hasProp = {}.hasOwnProperty;
1136
1137 XMLNode = __webpack_require__(7);
1138
1139 module.exports = XMLComment = (function(superClass) {
1140 extend(XMLComment, superClass);
1141
1142 function XMLComment(parent, text) {
1143 XMLComment.__super__.constructor.call(this, parent);
1144 if (text == null) {
1145 throw new Error("Missing comment text");
1146 }
1147 this.text = this.stringify.comment(text);
1148 }
1149
1150 XMLComment.prototype.clone = function() {
1151 return Object.create(this);
1152 };
1153
1154 XMLComment.prototype.toString = function(options) {
1155 return this.options.writer.set(options).comment(this);
1156 };
1157
1158 return XMLComment;
1159
1160 })(XMLNode);
1161
1162 }).call(this);
1163
1164
1165/***/ }),
1166/* 12 */
1167/***/ (function(module, exports, __webpack_require__) {
1168
1169 // Generated by CoffeeScript 1.12.7
1170 (function() {
1171 var XMLDeclaration, XMLNode, isObject,
1172 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1173 hasProp = {}.hasOwnProperty;
1174
1175 isObject = __webpack_require__(5).isObject;
1176
1177 XMLNode = __webpack_require__(7);
1178
1179 module.exports = XMLDeclaration = (function(superClass) {
1180 extend(XMLDeclaration, superClass);
1181
1182 function XMLDeclaration(parent, version, encoding, standalone) {
1183 var ref;
1184 XMLDeclaration.__super__.constructor.call(this, parent);
1185 if (isObject(version)) {
1186 ref = version, version = ref.version, encoding = ref.encoding, standalone = ref.standalone;
1187 }
1188 if (!version) {
1189 version = '1.0';
1190 }
1191 this.version = this.stringify.xmlVersion(version);
1192 if (encoding != null) {
1193 this.encoding = this.stringify.xmlEncoding(encoding);
1194 }
1195 if (standalone != null) {
1196 this.standalone = this.stringify.xmlStandalone(standalone);
1197 }
1198 }
1199
1200 XMLDeclaration.prototype.toString = function(options) {
1201 return this.options.writer.set(options).declaration(this);
1202 };
1203
1204 return XMLDeclaration;
1205
1206 })(XMLNode);
1207
1208 }).call(this);
1209
1210
1211/***/ }),
1212/* 13 */
1213/***/ (function(module, exports, __webpack_require__) {
1214
1215 // Generated by CoffeeScript 1.12.7
1216 (function() {
1217 var XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDocType, XMLNode, isObject,
1218 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1219 hasProp = {}.hasOwnProperty;
1220
1221 isObject = __webpack_require__(5).isObject;
1222
1223 XMLNode = __webpack_require__(7);
1224
1225 XMLDTDAttList = __webpack_require__(14);
1226
1227 XMLDTDEntity = __webpack_require__(15);
1228
1229 XMLDTDElement = __webpack_require__(16);
1230
1231 XMLDTDNotation = __webpack_require__(17);
1232
1233 module.exports = XMLDocType = (function(superClass) {
1234 extend(XMLDocType, superClass);
1235
1236 function XMLDocType(parent, pubID, sysID) {
1237 var ref, ref1;
1238 XMLDocType.__super__.constructor.call(this, parent);
1239 this.documentObject = parent;
1240 if (isObject(pubID)) {
1241 ref = pubID, pubID = ref.pubID, sysID = ref.sysID;
1242 }
1243 if (sysID == null) {
1244 ref1 = [pubID, sysID], sysID = ref1[0], pubID = ref1[1];
1245 }
1246 if (pubID != null) {
1247 this.pubID = this.stringify.dtdPubID(pubID);
1248 }
1249 if (sysID != null) {
1250 this.sysID = this.stringify.dtdSysID(sysID);
1251 }
1252 }
1253
1254 XMLDocType.prototype.element = function(name, value) {
1255 var child;
1256 child = new XMLDTDElement(this, name, value);
1257 this.children.push(child);
1258 return this;
1259 };
1260
1261 XMLDocType.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
1262 var child;
1263 child = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
1264 this.children.push(child);
1265 return this;
1266 };
1267
1268 XMLDocType.prototype.entity = function(name, value) {
1269 var child;
1270 child = new XMLDTDEntity(this, false, name, value);
1271 this.children.push(child);
1272 return this;
1273 };
1274
1275 XMLDocType.prototype.pEntity = function(name, value) {
1276 var child;
1277 child = new XMLDTDEntity(this, true, name, value);
1278 this.children.push(child);
1279 return this;
1280 };
1281
1282 XMLDocType.prototype.notation = function(name, value) {
1283 var child;
1284 child = new XMLDTDNotation(this, name, value);
1285 this.children.push(child);
1286 return this;
1287 };
1288
1289 XMLDocType.prototype.toString = function(options) {
1290 return this.options.writer.set(options).docType(this);
1291 };
1292
1293 XMLDocType.prototype.ele = function(name, value) {
1294 return this.element(name, value);
1295 };
1296
1297 XMLDocType.prototype.att = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
1298 return this.attList(elementName, attributeName, attributeType, defaultValueType, defaultValue);
1299 };
1300
1301 XMLDocType.prototype.ent = function(name, value) {
1302 return this.entity(name, value);
1303 };
1304
1305 XMLDocType.prototype.pent = function(name, value) {
1306 return this.pEntity(name, value);
1307 };
1308
1309 XMLDocType.prototype.not = function(name, value) {
1310 return this.notation(name, value);
1311 };
1312
1313 XMLDocType.prototype.up = function() {
1314 return this.root() || this.documentObject;
1315 };
1316
1317 return XMLDocType;
1318
1319 })(XMLNode);
1320
1321 }).call(this);
1322
1323
1324/***/ }),
1325/* 14 */
1326/***/ (function(module, exports, __webpack_require__) {
1327
1328 // Generated by CoffeeScript 1.12.7
1329 (function() {
1330 var XMLDTDAttList, XMLNode,
1331 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1332 hasProp = {}.hasOwnProperty;
1333
1334 XMLNode = __webpack_require__(7);
1335
1336 module.exports = XMLDTDAttList = (function(superClass) {
1337 extend(XMLDTDAttList, superClass);
1338
1339 function XMLDTDAttList(parent, elementName, attributeName, attributeType, defaultValueType, defaultValue) {
1340 XMLDTDAttList.__super__.constructor.call(this, parent);
1341 if (elementName == null) {
1342 throw new Error("Missing DTD element name");
1343 }
1344 if (attributeName == null) {
1345 throw new Error("Missing DTD attribute name");
1346 }
1347 if (!attributeType) {
1348 throw new Error("Missing DTD attribute type");
1349 }
1350 if (!defaultValueType) {
1351 throw new Error("Missing DTD attribute default");
1352 }
1353 if (defaultValueType.indexOf('#') !== 0) {
1354 defaultValueType = '#' + defaultValueType;
1355 }
1356 if (!defaultValueType.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/)) {
1357 throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT");
1358 }
1359 if (defaultValue && !defaultValueType.match(/^(#FIXED|#DEFAULT)$/)) {
1360 throw new Error("Default value only applies to #FIXED or #DEFAULT");
1361 }
1362 this.elementName = this.stringify.eleName(elementName);
1363 this.attributeName = this.stringify.attName(attributeName);
1364 this.attributeType = this.stringify.dtdAttType(attributeType);
1365 this.defaultValue = this.stringify.dtdAttDefault(defaultValue);
1366 this.defaultValueType = defaultValueType;
1367 }
1368
1369 XMLDTDAttList.prototype.toString = function(options) {
1370 return this.options.writer.set(options).dtdAttList(this);
1371 };
1372
1373 return XMLDTDAttList;
1374
1375 })(XMLNode);
1376
1377 }).call(this);
1378
1379
1380/***/ }),
1381/* 15 */
1382/***/ (function(module, exports, __webpack_require__) {
1383
1384 // Generated by CoffeeScript 1.12.7
1385 (function() {
1386 var XMLDTDEntity, XMLNode, isObject,
1387 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1388 hasProp = {}.hasOwnProperty;
1389
1390 isObject = __webpack_require__(5).isObject;
1391
1392 XMLNode = __webpack_require__(7);
1393
1394 module.exports = XMLDTDEntity = (function(superClass) {
1395 extend(XMLDTDEntity, superClass);
1396
1397 function XMLDTDEntity(parent, pe, name, value) {
1398 XMLDTDEntity.__super__.constructor.call(this, parent);
1399 if (name == null) {
1400 throw new Error("Missing entity name");
1401 }
1402 if (value == null) {
1403 throw new Error("Missing entity value");
1404 }
1405 this.pe = !!pe;
1406 this.name = this.stringify.eleName(name);
1407 if (!isObject(value)) {
1408 this.value = this.stringify.dtdEntityValue(value);
1409 } else {
1410 if (!value.pubID && !value.sysID) {
1411 throw new Error("Public and/or system identifiers are required for an external entity");
1412 }
1413 if (value.pubID && !value.sysID) {
1414 throw new Error("System identifier is required for a public external entity");
1415 }
1416 if (value.pubID != null) {
1417 this.pubID = this.stringify.dtdPubID(value.pubID);
1418 }
1419 if (value.sysID != null) {
1420 this.sysID = this.stringify.dtdSysID(value.sysID);
1421 }
1422 if (value.nData != null) {
1423 this.nData = this.stringify.dtdNData(value.nData);
1424 }
1425 if (this.pe && this.nData) {
1426 throw new Error("Notation declaration is not allowed in a parameter entity");
1427 }
1428 }
1429 }
1430
1431 XMLDTDEntity.prototype.toString = function(options) {
1432 return this.options.writer.set(options).dtdEntity(this);
1433 };
1434
1435 return XMLDTDEntity;
1436
1437 })(XMLNode);
1438
1439 }).call(this);
1440
1441
1442/***/ }),
1443/* 16 */
1444/***/ (function(module, exports, __webpack_require__) {
1445
1446 // Generated by CoffeeScript 1.12.7
1447 (function() {
1448 var XMLDTDElement, XMLNode,
1449 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1450 hasProp = {}.hasOwnProperty;
1451
1452 XMLNode = __webpack_require__(7);
1453
1454 module.exports = XMLDTDElement = (function(superClass) {
1455 extend(XMLDTDElement, superClass);
1456
1457 function XMLDTDElement(parent, name, value) {
1458 XMLDTDElement.__super__.constructor.call(this, parent);
1459 if (name == null) {
1460 throw new Error("Missing DTD element name");
1461 }
1462 if (!value) {
1463 value = '(#PCDATA)';
1464 }
1465 if (Array.isArray(value)) {
1466 value = '(' + value.join(',') + ')';
1467 }
1468 this.name = this.stringify.eleName(name);
1469 this.value = this.stringify.dtdElementValue(value);
1470 }
1471
1472 XMLDTDElement.prototype.toString = function(options) {
1473 return this.options.writer.set(options).dtdElement(this);
1474 };
1475
1476 return XMLDTDElement;
1477
1478 })(XMLNode);
1479
1480 }).call(this);
1481
1482
1483/***/ }),
1484/* 17 */
1485/***/ (function(module, exports, __webpack_require__) {
1486
1487 // Generated by CoffeeScript 1.12.7
1488 (function() {
1489 var XMLDTDNotation, XMLNode,
1490 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1491 hasProp = {}.hasOwnProperty;
1492
1493 XMLNode = __webpack_require__(7);
1494
1495 module.exports = XMLDTDNotation = (function(superClass) {
1496 extend(XMLDTDNotation, superClass);
1497
1498 function XMLDTDNotation(parent, name, value) {
1499 XMLDTDNotation.__super__.constructor.call(this, parent);
1500 if (name == null) {
1501 throw new Error("Missing notation name");
1502 }
1503 if (!value.pubID && !value.sysID) {
1504 throw new Error("Public or system identifiers are required for an external entity");
1505 }
1506 this.name = this.stringify.eleName(name);
1507 if (value.pubID != null) {
1508 this.pubID = this.stringify.dtdPubID(value.pubID);
1509 }
1510 if (value.sysID != null) {
1511 this.sysID = this.stringify.dtdSysID(value.sysID);
1512 }
1513 }
1514
1515 XMLDTDNotation.prototype.toString = function(options) {
1516 return this.options.writer.set(options).dtdNotation(this);
1517 };
1518
1519 return XMLDTDNotation;
1520
1521 })(XMLNode);
1522
1523 }).call(this);
1524
1525
1526/***/ }),
1527/* 18 */
1528/***/ (function(module, exports, __webpack_require__) {
1529
1530 // Generated by CoffeeScript 1.12.7
1531 (function() {
1532 var XMLNode, XMLRaw,
1533 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1534 hasProp = {}.hasOwnProperty;
1535
1536 XMLNode = __webpack_require__(7);
1537
1538 module.exports = XMLRaw = (function(superClass) {
1539 extend(XMLRaw, superClass);
1540
1541 function XMLRaw(parent, text) {
1542 XMLRaw.__super__.constructor.call(this, parent);
1543 if (text == null) {
1544 throw new Error("Missing raw text");
1545 }
1546 this.value = this.stringify.raw(text);
1547 }
1548
1549 XMLRaw.prototype.clone = function() {
1550 return Object.create(this);
1551 };
1552
1553 XMLRaw.prototype.toString = function(options) {
1554 return this.options.writer.set(options).raw(this);
1555 };
1556
1557 return XMLRaw;
1558
1559 })(XMLNode);
1560
1561 }).call(this);
1562
1563
1564/***/ }),
1565/* 19 */
1566/***/ (function(module, exports, __webpack_require__) {
1567
1568 // Generated by CoffeeScript 1.12.7
1569 (function() {
1570 var XMLNode, XMLText,
1571 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1572 hasProp = {}.hasOwnProperty;
1573
1574 XMLNode = __webpack_require__(7);
1575
1576 module.exports = XMLText = (function(superClass) {
1577 extend(XMLText, superClass);
1578
1579 function XMLText(parent, text) {
1580 XMLText.__super__.constructor.call(this, parent);
1581 if (text == null) {
1582 throw new Error("Missing element text");
1583 }
1584 this.value = this.stringify.eleText(text);
1585 }
1586
1587 XMLText.prototype.clone = function() {
1588 return Object.create(this);
1589 };
1590
1591 XMLText.prototype.toString = function(options) {
1592 return this.options.writer.set(options).text(this);
1593 };
1594
1595 return XMLText;
1596
1597 })(XMLNode);
1598
1599 }).call(this);
1600
1601
1602/***/ }),
1603/* 20 */
1604/***/ (function(module, exports, __webpack_require__) {
1605
1606 // Generated by CoffeeScript 1.12.7
1607 (function() {
1608 var XMLNode, XMLProcessingInstruction,
1609 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1610 hasProp = {}.hasOwnProperty;
1611
1612 XMLNode = __webpack_require__(7);
1613
1614 module.exports = XMLProcessingInstruction = (function(superClass) {
1615 extend(XMLProcessingInstruction, superClass);
1616
1617 function XMLProcessingInstruction(parent, target, value) {
1618 XMLProcessingInstruction.__super__.constructor.call(this, parent);
1619 if (target == null) {
1620 throw new Error("Missing instruction target");
1621 }
1622 this.target = this.stringify.insTarget(target);
1623 if (value) {
1624 this.value = this.stringify.insValue(value);
1625 }
1626 }
1627
1628 XMLProcessingInstruction.prototype.clone = function() {
1629 return Object.create(this);
1630 };
1631
1632 XMLProcessingInstruction.prototype.toString = function(options) {
1633 return this.options.writer.set(options).processingInstruction(this);
1634 };
1635
1636 return XMLProcessingInstruction;
1637
1638 })(XMLNode);
1639
1640 }).call(this);
1641
1642
1643/***/ }),
1644/* 21 */
1645/***/ (function(module, exports) {
1646
1647 // Generated by CoffeeScript 1.12.7
1648 (function() {
1649 var XMLStringifier,
1650 bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
1651 hasProp = {}.hasOwnProperty;
1652
1653 module.exports = XMLStringifier = (function() {
1654 function XMLStringifier(options) {
1655 this.assertLegalChar = bind(this.assertLegalChar, this);
1656 var key, ref, value;
1657 options || (options = {});
1658 this.noDoubleEncoding = options.noDoubleEncoding;
1659 ref = options.stringify || {};
1660 for (key in ref) {
1661 if (!hasProp.call(ref, key)) continue;
1662 value = ref[key];
1663 this[key] = value;
1664 }
1665 }
1666
1667 XMLStringifier.prototype.eleName = function(val) {
1668 val = '' + val || '';
1669 return this.assertLegalChar(val);
1670 };
1671
1672 XMLStringifier.prototype.eleText = function(val) {
1673 val = '' + val || '';
1674 return this.assertLegalChar(this.elEscape(val));
1675 };
1676
1677 XMLStringifier.prototype.cdata = function(val) {
1678 val = '' + val || '';
1679 val = val.replace(']]>', ']]]]><![CDATA[>');
1680 return this.assertLegalChar(val);
1681 };
1682
1683 XMLStringifier.prototype.comment = function(val) {
1684 val = '' + val || '';
1685 if (val.match(/--/)) {
1686 throw new Error("Comment text cannot contain double-hypen: " + val);
1687 }
1688 return this.assertLegalChar(val);
1689 };
1690
1691 XMLStringifier.prototype.raw = function(val) {
1692 return '' + val || '';
1693 };
1694
1695 XMLStringifier.prototype.attName = function(val) {
1696 return val = '' + val || '';
1697 };
1698
1699 XMLStringifier.prototype.attValue = function(val) {
1700 val = '' + val || '';
1701 return this.attEscape(val);
1702 };
1703
1704 XMLStringifier.prototype.insTarget = function(val) {
1705 return '' + val || '';
1706 };
1707
1708 XMLStringifier.prototype.insValue = function(val) {
1709 val = '' + val || '';
1710 if (val.match(/\?>/)) {
1711 throw new Error("Invalid processing instruction value: " + val);
1712 }
1713 return val;
1714 };
1715
1716 XMLStringifier.prototype.xmlVersion = function(val) {
1717 val = '' + val || '';
1718 if (!val.match(/1\.[0-9]+/)) {
1719 throw new Error("Invalid version number: " + val);
1720 }
1721 return val;
1722 };
1723
1724 XMLStringifier.prototype.xmlEncoding = function(val) {
1725 val = '' + val || '';
1726 if (!val.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/)) {
1727 throw new Error("Invalid encoding: " + val);
1728 }
1729 return val;
1730 };
1731
1732 XMLStringifier.prototype.xmlStandalone = function(val) {
1733 if (val) {
1734 return "yes";
1735 } else {
1736 return "no";
1737 }
1738 };
1739
1740 XMLStringifier.prototype.dtdPubID = function(val) {
1741 return '' + val || '';
1742 };
1743
1744 XMLStringifier.prototype.dtdSysID = function(val) {
1745 return '' + val || '';
1746 };
1747
1748 XMLStringifier.prototype.dtdElementValue = function(val) {
1749 return '' + val || '';
1750 };
1751
1752 XMLStringifier.prototype.dtdAttType = function(val) {
1753 return '' + val || '';
1754 };
1755
1756 XMLStringifier.prototype.dtdAttDefault = function(val) {
1757 if (val != null) {
1758 return '' + val || '';
1759 } else {
1760 return val;
1761 }
1762 };
1763
1764 XMLStringifier.prototype.dtdEntityValue = function(val) {
1765 return '' + val || '';
1766 };
1767
1768 XMLStringifier.prototype.dtdNData = function(val) {
1769 return '' + val || '';
1770 };
1771
1772 XMLStringifier.prototype.convertAttKey = '@';
1773
1774 XMLStringifier.prototype.convertPIKey = '?';
1775
1776 XMLStringifier.prototype.convertTextKey = '#text';
1777
1778 XMLStringifier.prototype.convertCDataKey = '#cdata';
1779
1780 XMLStringifier.prototype.convertCommentKey = '#comment';
1781
1782 XMLStringifier.prototype.convertRawKey = '#raw';
1783
1784 XMLStringifier.prototype.assertLegalChar = function(str) {
1785 var res;
1786 res = str.match(/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/);
1787 if (res) {
1788 throw new Error("Invalid character in string: " + str + " at index " + res.index);
1789 }
1790 return str;
1791 };
1792
1793 XMLStringifier.prototype.elEscape = function(str) {
1794 var ampregex;
1795 ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
1796 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\r/g, '&#xD;');
1797 };
1798
1799 XMLStringifier.prototype.attEscape = function(str) {
1800 var ampregex;
1801 ampregex = this.noDoubleEncoding ? /(?!&\S+;)&/g : /&/g;
1802 return str.replace(ampregex, '&amp;').replace(/</g, '&lt;').replace(/"/g, '&quot;').replace(/\t/g, '&#x9;').replace(/\n/g, '&#xA;').replace(/\r/g, '&#xD;');
1803 };
1804
1805 return XMLStringifier;
1806
1807 })();
1808
1809 }).call(this);
1810
1811
1812/***/ }),
1813/* 22 */
1814/***/ (function(module, exports, __webpack_require__) {
1815
1816 // Generated by CoffeeScript 1.12.7
1817 (function() {
1818 var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLText, XMLWriterBase,
1819 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1820 hasProp = {}.hasOwnProperty;
1821
1822 XMLDeclaration = __webpack_require__(12);
1823
1824 XMLDocType = __webpack_require__(13);
1825
1826 XMLCData = __webpack_require__(10);
1827
1828 XMLComment = __webpack_require__(11);
1829
1830 XMLElement = __webpack_require__(8);
1831
1832 XMLRaw = __webpack_require__(18);
1833
1834 XMLText = __webpack_require__(19);
1835
1836 XMLProcessingInstruction = __webpack_require__(20);
1837
1838 XMLDTDAttList = __webpack_require__(14);
1839
1840 XMLDTDElement = __webpack_require__(16);
1841
1842 XMLDTDEntity = __webpack_require__(15);
1843
1844 XMLDTDNotation = __webpack_require__(17);
1845
1846 XMLWriterBase = __webpack_require__(23);
1847
1848 module.exports = XMLStringWriter = (function(superClass) {
1849 extend(XMLStringWriter, superClass);
1850
1851 function XMLStringWriter(options) {
1852 XMLStringWriter.__super__.constructor.call(this, options);
1853 }
1854
1855 XMLStringWriter.prototype.document = function(doc) {
1856 var child, i, len, r, ref;
1857 this.textispresent = false;
1858 r = '';
1859 ref = doc.children;
1860 for (i = 0, len = ref.length; i < len; i++) {
1861 child = ref[i];
1862 r += (function() {
1863 switch (false) {
1864 case !(child instanceof XMLDeclaration):
1865 return this.declaration(child);
1866 case !(child instanceof XMLDocType):
1867 return this.docType(child);
1868 case !(child instanceof XMLComment):
1869 return this.comment(child);
1870 case !(child instanceof XMLProcessingInstruction):
1871 return this.processingInstruction(child);
1872 default:
1873 return this.element(child, 0);
1874 }
1875 }).call(this);
1876 }
1877 if (this.pretty && r.slice(-this.newline.length) === this.newline) {
1878 r = r.slice(0, -this.newline.length);
1879 }
1880 return r;
1881 };
1882
1883 XMLStringWriter.prototype.attribute = function(att) {
1884 return ' ' + att.name + '="' + att.value + '"';
1885 };
1886
1887 XMLStringWriter.prototype.cdata = function(node, level) {
1888 return this.space(level) + '<![CDATA[' + node.text + ']]>' + this.newline;
1889 };
1890
1891 XMLStringWriter.prototype.comment = function(node, level) {
1892 return this.space(level) + '<!-- ' + node.text + ' -->' + this.newline;
1893 };
1894
1895 XMLStringWriter.prototype.declaration = function(node, level) {
1896 var r;
1897 r = this.space(level);
1898 r += '<?xml version="' + node.version + '"';
1899 if (node.encoding != null) {
1900 r += ' encoding="' + node.encoding + '"';
1901 }
1902 if (node.standalone != null) {
1903 r += ' standalone="' + node.standalone + '"';
1904 }
1905 r += this.spacebeforeslash + '?>';
1906 r += this.newline;
1907 return r;
1908 };
1909
1910 XMLStringWriter.prototype.docType = function(node, level) {
1911 var child, i, len, r, ref;
1912 level || (level = 0);
1913 r = this.space(level);
1914 r += '<!DOCTYPE ' + node.root().name;
1915 if (node.pubID && node.sysID) {
1916 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
1917 } else if (node.sysID) {
1918 r += ' SYSTEM "' + node.sysID + '"';
1919 }
1920 if (node.children.length > 0) {
1921 r += ' [';
1922 r += this.newline;
1923 ref = node.children;
1924 for (i = 0, len = ref.length; i < len; i++) {
1925 child = ref[i];
1926 r += (function() {
1927 switch (false) {
1928 case !(child instanceof XMLDTDAttList):
1929 return this.dtdAttList(child, level + 1);
1930 case !(child instanceof XMLDTDElement):
1931 return this.dtdElement(child, level + 1);
1932 case !(child instanceof XMLDTDEntity):
1933 return this.dtdEntity(child, level + 1);
1934 case !(child instanceof XMLDTDNotation):
1935 return this.dtdNotation(child, level + 1);
1936 case !(child instanceof XMLCData):
1937 return this.cdata(child, level + 1);
1938 case !(child instanceof XMLComment):
1939 return this.comment(child, level + 1);
1940 case !(child instanceof XMLProcessingInstruction):
1941 return this.processingInstruction(child, level + 1);
1942 default:
1943 throw new Error("Unknown DTD node type: " + child.constructor.name);
1944 }
1945 }).call(this);
1946 }
1947 r += ']';
1948 }
1949 r += this.spacebeforeslash + '>';
1950 r += this.newline;
1951 return r;
1952 };
1953
1954 XMLStringWriter.prototype.element = function(node, level) {
1955 var att, child, i, j, len, len1, name, r, ref, ref1, ref2, space, textispresentwasset;
1956 level || (level = 0);
1957 textispresentwasset = false;
1958 if (this.textispresent) {
1959 this.newline = '';
1960 this.pretty = false;
1961 } else {
1962 this.newline = this.newlinedefault;
1963 this.pretty = this.prettydefault;
1964 }
1965 space = this.space(level);
1966 r = '';
1967 r += space + '<' + node.name;
1968 ref = node.attributes;
1969 for (name in ref) {
1970 if (!hasProp.call(ref, name)) continue;
1971 att = ref[name];
1972 r += this.attribute(att);
1973 }
1974 if (node.children.length === 0 || node.children.every(function(e) {
1975 return e.value === '';
1976 })) {
1977 if (this.allowEmpty) {
1978 r += '></' + node.name + '>' + this.newline;
1979 } else {
1980 r += this.spacebeforeslash + '/>' + this.newline;
1981 }
1982 } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
1983 r += '>';
1984 r += node.children[0].value;
1985 r += '</' + node.name + '>' + this.newline;
1986 } else {
1987 if (this.dontprettytextnodes) {
1988 ref1 = node.children;
1989 for (i = 0, len = ref1.length; i < len; i++) {
1990 child = ref1[i];
1991 if (child.value != null) {
1992 this.textispresent++;
1993 textispresentwasset = true;
1994 break;
1995 }
1996 }
1997 }
1998 if (this.textispresent) {
1999 this.newline = '';
2000 this.pretty = false;
2001 space = this.space(level);
2002 }
2003 r += '>' + this.newline;
2004 ref2 = node.children;
2005 for (j = 0, len1 = ref2.length; j < len1; j++) {
2006 child = ref2[j];
2007 r += (function() {
2008 switch (false) {
2009 case !(child instanceof XMLCData):
2010 return this.cdata(child, level + 1);
2011 case !(child instanceof XMLComment):
2012 return this.comment(child, level + 1);
2013 case !(child instanceof XMLElement):
2014 return this.element(child, level + 1);
2015 case !(child instanceof XMLRaw):
2016 return this.raw(child, level + 1);
2017 case !(child instanceof XMLText):
2018 return this.text(child, level + 1);
2019 case !(child instanceof XMLProcessingInstruction):
2020 return this.processingInstruction(child, level + 1);
2021 default:
2022 throw new Error("Unknown XML node type: " + child.constructor.name);
2023 }
2024 }).call(this);
2025 }
2026 if (textispresentwasset) {
2027 this.textispresent--;
2028 }
2029 if (!this.textispresent) {
2030 this.newline = this.newlinedefault;
2031 this.pretty = this.prettydefault;
2032 }
2033 r += space + '</' + node.name + '>' + this.newline;
2034 }
2035 return r;
2036 };
2037
2038 XMLStringWriter.prototype.processingInstruction = function(node, level) {
2039 var r;
2040 r = this.space(level) + '<?' + node.target;
2041 if (node.value) {
2042 r += ' ' + node.value;
2043 }
2044 r += this.spacebeforeslash + '?>' + this.newline;
2045 return r;
2046 };
2047
2048 XMLStringWriter.prototype.raw = function(node, level) {
2049 return this.space(level) + node.value + this.newline;
2050 };
2051
2052 XMLStringWriter.prototype.text = function(node, level) {
2053 return this.space(level) + node.value + this.newline;
2054 };
2055
2056 XMLStringWriter.prototype.dtdAttList = function(node, level) {
2057 var r;
2058 r = this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType;
2059 if (node.defaultValueType !== '#DEFAULT') {
2060 r += ' ' + node.defaultValueType;
2061 }
2062 if (node.defaultValue) {
2063 r += ' "' + node.defaultValue + '"';
2064 }
2065 r += this.spacebeforeslash + '>' + this.newline;
2066 return r;
2067 };
2068
2069 XMLStringWriter.prototype.dtdElement = function(node, level) {
2070 return this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value + this.spacebeforeslash + '>' + this.newline;
2071 };
2072
2073 XMLStringWriter.prototype.dtdEntity = function(node, level) {
2074 var r;
2075 r = this.space(level) + '<!ENTITY';
2076 if (node.pe) {
2077 r += ' %';
2078 }
2079 r += ' ' + node.name;
2080 if (node.value) {
2081 r += ' "' + node.value + '"';
2082 } else {
2083 if (node.pubID && node.sysID) {
2084 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
2085 } else if (node.sysID) {
2086 r += ' SYSTEM "' + node.sysID + '"';
2087 }
2088 if (node.nData) {
2089 r += ' NDATA ' + node.nData;
2090 }
2091 }
2092 r += this.spacebeforeslash + '>' + this.newline;
2093 return r;
2094 };
2095
2096 XMLStringWriter.prototype.dtdNotation = function(node, level) {
2097 var r;
2098 r = this.space(level) + '<!NOTATION ' + node.name;
2099 if (node.pubID && node.sysID) {
2100 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
2101 } else if (node.pubID) {
2102 r += ' PUBLIC "' + node.pubID + '"';
2103 } else if (node.sysID) {
2104 r += ' SYSTEM "' + node.sysID + '"';
2105 }
2106 r += this.spacebeforeslash + '>' + this.newline;
2107 return r;
2108 };
2109
2110 XMLStringWriter.prototype.openNode = function(node, level) {
2111 var att, name, r, ref;
2112 level || (level = 0);
2113 if (node instanceof XMLElement) {
2114 r = this.space(level) + '<' + node.name;
2115 ref = node.attributes;
2116 for (name in ref) {
2117 if (!hasProp.call(ref, name)) continue;
2118 att = ref[name];
2119 r += this.attribute(att);
2120 }
2121 r += (node.children ? '>' : '/>') + this.newline;
2122 return r;
2123 } else {
2124 r = this.space(level) + '<!DOCTYPE ' + node.rootNodeName;
2125 if (node.pubID && node.sysID) {
2126 r += ' PUBLIC "' + node.pubID + '" "' + node.sysID + '"';
2127 } else if (node.sysID) {
2128 r += ' SYSTEM "' + node.sysID + '"';
2129 }
2130 r += (node.children ? ' [' : '>') + this.newline;
2131 return r;
2132 }
2133 };
2134
2135 XMLStringWriter.prototype.closeNode = function(node, level) {
2136 level || (level = 0);
2137 switch (false) {
2138 case !(node instanceof XMLElement):
2139 return this.space(level) + '</' + node.name + '>' + this.newline;
2140 case !(node instanceof XMLDocType):
2141 return this.space(level) + ']>' + this.newline;
2142 }
2143 };
2144
2145 return XMLStringWriter;
2146
2147 })(XMLWriterBase);
2148
2149 }).call(this);
2150
2151
2152/***/ }),
2153/* 23 */
2154/***/ (function(module, exports) {
2155
2156 // Generated by CoffeeScript 1.12.7
2157 (function() {
2158 var XMLWriterBase,
2159 hasProp = {}.hasOwnProperty;
2160
2161 module.exports = XMLWriterBase = (function() {
2162 function XMLWriterBase(options) {
2163 var key, ref, ref1, ref2, ref3, ref4, ref5, ref6, value;
2164 options || (options = {});
2165 this.pretty = options.pretty || false;
2166 this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
2167 if (this.pretty) {
2168 this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
2169 this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
2170 this.offset = (ref3 = options.offset) != null ? ref3 : 0;
2171 this.dontprettytextnodes = (ref4 = options.dontprettytextnodes) != null ? ref4 : 0;
2172 } else {
2173 this.indent = '';
2174 this.newline = '';
2175 this.offset = 0;
2176 this.dontprettytextnodes = 0;
2177 }
2178 this.spacebeforeslash = (ref5 = options.spacebeforeslash) != null ? ref5 : '';
2179 if (this.spacebeforeslash === true) {
2180 this.spacebeforeslash = ' ';
2181 }
2182 this.newlinedefault = this.newline;
2183 this.prettydefault = this.pretty;
2184 ref6 = options.writer || {};
2185 for (key in ref6) {
2186 if (!hasProp.call(ref6, key)) continue;
2187 value = ref6[key];
2188 this[key] = value;
2189 }
2190 }
2191
2192 XMLWriterBase.prototype.set = function(options) {
2193 var key, ref, value;
2194 options || (options = {});
2195 if ("pretty" in options) {
2196 this.pretty = options.pretty;
2197 }
2198 if ("allowEmpty" in options) {
2199 this.allowEmpty = options.allowEmpty;
2200 }
2201 if (this.pretty) {
2202 this.indent = "indent" in options ? options.indent : ' ';
2203 this.newline = "newline" in options ? options.newline : '\n';
2204 this.offset = "offset" in options ? options.offset : 0;
2205 this.dontprettytextnodes = "dontprettytextnodes" in options ? options.dontprettytextnodes : 0;
2206 } else {
2207 this.indent = '';
2208 this.newline = '';
2209 this.offset = 0;
2210 this.dontprettytextnodes = 0;
2211 }
2212 this.spacebeforeslash = "spacebeforeslash" in options ? options.spacebeforeslash : '';
2213 if (this.spacebeforeslash === true) {
2214 this.spacebeforeslash = ' ';
2215 }
2216 this.newlinedefault = this.newline;
2217 this.prettydefault = this.pretty;
2218 ref = options.writer || {};
2219 for (key in ref) {
2220 if (!hasProp.call(ref, key)) continue;
2221 value = ref[key];
2222 this[key] = value;
2223 }
2224 return this;
2225 };
2226
2227 XMLWriterBase.prototype.space = function(level) {
2228 var indent;
2229 if (this.pretty) {
2230 indent = (level || 0) + this.offset + 1;
2231 if (indent > 0) {
2232 return new Array(indent).join(this.indent);
2233 } else {
2234 return '';
2235 }
2236 } else {
2237 return '';
2238 }
2239 };
2240
2241 return XMLWriterBase;
2242
2243 })();
2244
2245 }).call(this);
2246
2247
2248/***/ }),
2249/* 24 */
2250/***/ (function(module, exports, __webpack_require__) {
2251
2252 // Generated by CoffeeScript 1.12.7
2253 (function() {
2254 var XMLAttribute, XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLDocumentCB, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStringWriter, XMLStringifier, XMLText, isFunction, isObject, isPlainObject, ref,
2255 hasProp = {}.hasOwnProperty;
2256
2257 ref = __webpack_require__(5), isObject = ref.isObject, isFunction = ref.isFunction, isPlainObject = ref.isPlainObject;
2258
2259 XMLElement = __webpack_require__(8);
2260
2261 XMLCData = __webpack_require__(10);
2262
2263 XMLComment = __webpack_require__(11);
2264
2265 XMLRaw = __webpack_require__(18);
2266
2267 XMLText = __webpack_require__(19);
2268
2269 XMLProcessingInstruction = __webpack_require__(20);
2270
2271 XMLDeclaration = __webpack_require__(12);
2272
2273 XMLDocType = __webpack_require__(13);
2274
2275 XMLDTDAttList = __webpack_require__(14);
2276
2277 XMLDTDEntity = __webpack_require__(15);
2278
2279 XMLDTDElement = __webpack_require__(16);
2280
2281 XMLDTDNotation = __webpack_require__(17);
2282
2283 XMLAttribute = __webpack_require__(9);
2284
2285 XMLStringifier = __webpack_require__(21);
2286
2287 XMLStringWriter = __webpack_require__(22);
2288
2289 module.exports = XMLDocumentCB = (function() {
2290 function XMLDocumentCB(options, onData, onEnd) {
2291 var writerOptions;
2292 options || (options = {});
2293 if (!options.writer) {
2294 options.writer = new XMLStringWriter(options);
2295 } else if (isPlainObject(options.writer)) {
2296 writerOptions = options.writer;
2297 options.writer = new XMLStringWriter(writerOptions);
2298 }
2299 this.options = options;
2300 this.writer = options.writer;
2301 this.stringify = new XMLStringifier(options);
2302 this.onDataCallback = onData || function() {};
2303 this.onEndCallback = onEnd || function() {};
2304 this.currentNode = null;
2305 this.currentLevel = -1;
2306 this.openTags = {};
2307 this.documentStarted = false;
2308 this.documentCompleted = false;
2309 this.root = null;
2310 }
2311
2312 XMLDocumentCB.prototype.node = function(name, attributes, text) {
2313 var ref1;
2314 if (name == null) {
2315 throw new Error("Missing node name");
2316 }
2317 if (this.root && this.currentLevel === -1) {
2318 throw new Error("Document can only have one root node");
2319 }
2320 this.openCurrent();
2321 name = name.valueOf();
2322 if (attributes == null) {
2323 attributes = {};
2324 }
2325 attributes = attributes.valueOf();
2326 if (!isObject(attributes)) {
2327 ref1 = [attributes, text], text = ref1[0], attributes = ref1[1];
2328 }
2329 this.currentNode = new XMLElement(this, name, attributes);
2330 this.currentNode.children = false;
2331 this.currentLevel++;
2332 this.openTags[this.currentLevel] = this.currentNode;
2333 if (text != null) {
2334 this.text(text);
2335 }
2336 return this;
2337 };
2338
2339 XMLDocumentCB.prototype.element = function(name, attributes, text) {
2340 if (this.currentNode && this.currentNode instanceof XMLDocType) {
2341 return this.dtdElement.apply(this, arguments);
2342 } else {
2343 return this.node(name, attributes, text);
2344 }
2345 };
2346
2347 XMLDocumentCB.prototype.attribute = function(name, value) {
2348 var attName, attValue;
2349 if (!this.currentNode || this.currentNode.children) {
2350 throw new Error("att() can only be used immediately after an ele() call in callback mode");
2351 }
2352 if (name != null) {
2353 name = name.valueOf();
2354 }
2355 if (isObject(name)) {
2356 for (attName in name) {
2357 if (!hasProp.call(name, attName)) continue;
2358 attValue = name[attName];
2359 this.attribute(attName, attValue);
2360 }
2361 } else {
2362 if (isFunction(value)) {
2363 value = value.apply();
2364 }
2365 if (!this.options.skipNullAttributes || (value != null)) {
2366 this.currentNode.attributes[name] = new XMLAttribute(this, name, value);
2367 }
2368 }
2369 return this;
2370 };
2371
2372 XMLDocumentCB.prototype.text = function(value) {
2373 var node;
2374 this.openCurrent();
2375 node = new XMLText(this, value);
2376 this.onData(this.writer.text(node, this.currentLevel + 1));
2377 return this;
2378 };
2379
2380 XMLDocumentCB.prototype.cdata = function(value) {
2381 var node;
2382 this.openCurrent();
2383 node = new XMLCData(this, value);
2384 this.onData(this.writer.cdata(node, this.currentLevel + 1));
2385 return this;
2386 };
2387
2388 XMLDocumentCB.prototype.comment = function(value) {
2389 var node;
2390 this.openCurrent();
2391 node = new XMLComment(this, value);
2392 this.onData(this.writer.comment(node, this.currentLevel + 1));
2393 return this;
2394 };
2395
2396 XMLDocumentCB.prototype.raw = function(value) {
2397 var node;
2398 this.openCurrent();
2399 node = new XMLRaw(this, value);
2400 this.onData(this.writer.raw(node, this.currentLevel + 1));
2401 return this;
2402 };
2403
2404 XMLDocumentCB.prototype.instruction = function(target, value) {
2405 var i, insTarget, insValue, len, node;
2406 this.openCurrent();
2407 if (target != null) {
2408 target = target.valueOf();
2409 }
2410 if (value != null) {
2411 value = value.valueOf();
2412 }
2413 if (Array.isArray(target)) {
2414 for (i = 0, len = target.length; i < len; i++) {
2415 insTarget = target[i];
2416 this.instruction(insTarget);
2417 }
2418 } else if (isObject(target)) {
2419 for (insTarget in target) {
2420 if (!hasProp.call(target, insTarget)) continue;
2421 insValue = target[insTarget];
2422 this.instruction(insTarget, insValue);
2423 }
2424 } else {
2425 if (isFunction(value)) {
2426 value = value.apply();
2427 }
2428 node = new XMLProcessingInstruction(this, target, value);
2429 this.onData(this.writer.processingInstruction(node, this.currentLevel + 1));
2430 }
2431 return this;
2432 };
2433
2434 XMLDocumentCB.prototype.declaration = function(version, encoding, standalone) {
2435 var node;
2436 this.openCurrent();
2437 if (this.documentStarted) {
2438 throw new Error("declaration() must be the first node");
2439 }
2440 node = new XMLDeclaration(this, version, encoding, standalone);
2441 this.onData(this.writer.declaration(node, this.currentLevel + 1));
2442 return this;
2443 };
2444
2445 XMLDocumentCB.prototype.doctype = function(root, pubID, sysID) {
2446 this.openCurrent();
2447 if (root == null) {
2448 throw new Error("Missing root node name");
2449 }
2450 if (this.root) {
2451 throw new Error("dtd() must come before the root node");
2452 }
2453 this.currentNode = new XMLDocType(this, pubID, sysID);
2454 this.currentNode.rootNodeName = root;
2455 this.currentNode.children = false;
2456 this.currentLevel++;
2457 this.openTags[this.currentLevel] = this.currentNode;
2458 return this;
2459 };
2460
2461 XMLDocumentCB.prototype.dtdElement = function(name, value) {
2462 var node;
2463 this.openCurrent();
2464 node = new XMLDTDElement(this, name, value);
2465 this.onData(this.writer.dtdElement(node, this.currentLevel + 1));
2466 return this;
2467 };
2468
2469 XMLDocumentCB.prototype.attList = function(elementName, attributeName, attributeType, defaultValueType, defaultValue) {
2470 var node;
2471 this.openCurrent();
2472 node = new XMLDTDAttList(this, elementName, attributeName, attributeType, defaultValueType, defaultValue);
2473 this.onData(this.writer.dtdAttList(node, this.currentLevel + 1));
2474 return this;
2475 };
2476
2477 XMLDocumentCB.prototype.entity = function(name, value) {
2478 var node;
2479 this.openCurrent();
2480 node = new XMLDTDEntity(this, false, name, value);
2481 this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
2482 return this;
2483 };
2484
2485 XMLDocumentCB.prototype.pEntity = function(name, value) {
2486 var node;
2487 this.openCurrent();
2488 node = new XMLDTDEntity(this, true, name, value);
2489 this.onData(this.writer.dtdEntity(node, this.currentLevel + 1));
2490 return this;
2491 };
2492
2493 XMLDocumentCB.prototype.notation = function(name, value) {
2494 var node;
2495 this.openCurrent();
2496 node = new XMLDTDNotation(this, name, value);
2497 this.onData(this.writer.dtdNotation(node, this.currentLevel + 1));
2498 return this;
2499 };
2500
2501 XMLDocumentCB.prototype.up = function() {
2502 if (this.currentLevel < 0) {
2503 throw new Error("The document node has no parent");
2504 }
2505 if (this.currentNode) {
2506 if (this.currentNode.children) {
2507 this.closeNode(this.currentNode);
2508 } else {
2509 this.openNode(this.currentNode);
2510 }
2511 this.currentNode = null;
2512 } else {
2513 this.closeNode(this.openTags[this.currentLevel]);
2514 }
2515 delete this.openTags[this.currentLevel];
2516 this.currentLevel--;
2517 return this;
2518 };
2519
2520 XMLDocumentCB.prototype.end = function() {
2521 while (this.currentLevel >= 0) {
2522 this.up();
2523 }
2524 return this.onEnd();
2525 };
2526
2527 XMLDocumentCB.prototype.openCurrent = function() {
2528 if (this.currentNode) {
2529 this.currentNode.children = true;
2530 return this.openNode(this.currentNode);
2531 }
2532 };
2533
2534 XMLDocumentCB.prototype.openNode = function(node) {
2535 if (!node.isOpen) {
2536 if (!this.root && this.currentLevel === 0 && node instanceof XMLElement) {
2537 this.root = node;
2538 }
2539 this.onData(this.writer.openNode(node, this.currentLevel));
2540 return node.isOpen = true;
2541 }
2542 };
2543
2544 XMLDocumentCB.prototype.closeNode = function(node) {
2545 if (!node.isClosed) {
2546 this.onData(this.writer.closeNode(node, this.currentLevel));
2547 return node.isClosed = true;
2548 }
2549 };
2550
2551 XMLDocumentCB.prototype.onData = function(chunk) {
2552 this.documentStarted = true;
2553 return this.onDataCallback(chunk);
2554 };
2555
2556 XMLDocumentCB.prototype.onEnd = function() {
2557 this.documentCompleted = true;
2558 return this.onEndCallback();
2559 };
2560
2561 XMLDocumentCB.prototype.ele = function() {
2562 return this.element.apply(this, arguments);
2563 };
2564
2565 XMLDocumentCB.prototype.nod = function(name, attributes, text) {
2566 return this.node(name, attributes, text);
2567 };
2568
2569 XMLDocumentCB.prototype.txt = function(value) {
2570 return this.text(value);
2571 };
2572
2573 XMLDocumentCB.prototype.dat = function(value) {
2574 return this.cdata(value);
2575 };
2576
2577 XMLDocumentCB.prototype.com = function(value) {
2578 return this.comment(value);
2579 };
2580
2581 XMLDocumentCB.prototype.ins = function(target, value) {
2582 return this.instruction(target, value);
2583 };
2584
2585 XMLDocumentCB.prototype.dec = function(version, encoding, standalone) {
2586 return this.declaration(version, encoding, standalone);
2587 };
2588
2589 XMLDocumentCB.prototype.dtd = function(root, pubID, sysID) {
2590 return this.doctype(root, pubID, sysID);
2591 };
2592
2593 XMLDocumentCB.prototype.e = function(name, attributes, text) {
2594 return this.element(name, attributes, text);
2595 };
2596
2597 XMLDocumentCB.prototype.n = function(name, attributes, text) {
2598 return this.node(name, attributes, text);
2599 };
2600
2601 XMLDocumentCB.prototype.t = function(value) {
2602 return this.text(value);
2603 };
2604
2605 XMLDocumentCB.prototype.d = function(value) {
2606 return this.cdata(value);
2607 };
2608
2609 XMLDocumentCB.prototype.c = function(value) {
2610 return this.comment(value);
2611 };
2612
2613 XMLDocumentCB.prototype.r = function(value) {
2614 return this.raw(value);
2615 };
2616
2617 XMLDocumentCB.prototype.i = function(target, value) {
2618 return this.instruction(target, value);
2619 };
2620
2621 XMLDocumentCB.prototype.att = function() {
2622 if (this.currentNode && this.currentNode instanceof XMLDocType) {
2623 return this.attList.apply(this, arguments);
2624 } else {
2625 return this.attribute.apply(this, arguments);
2626 }
2627 };
2628
2629 XMLDocumentCB.prototype.a = function() {
2630 if (this.currentNode && this.currentNode instanceof XMLDocType) {
2631 return this.attList.apply(this, arguments);
2632 } else {
2633 return this.attribute.apply(this, arguments);
2634 }
2635 };
2636
2637 XMLDocumentCB.prototype.ent = function(name, value) {
2638 return this.entity(name, value);
2639 };
2640
2641 XMLDocumentCB.prototype.pent = function(name, value) {
2642 return this.pEntity(name, value);
2643 };
2644
2645 XMLDocumentCB.prototype.not = function(name, value) {
2646 return this.notation(name, value);
2647 };
2648
2649 return XMLDocumentCB;
2650
2651 })();
2652
2653 }).call(this);
2654
2655
2656/***/ }),
2657/* 25 */
2658/***/ (function(module, exports, __webpack_require__) {
2659
2660 // Generated by CoffeeScript 1.12.7
2661 (function() {
2662 var XMLCData, XMLComment, XMLDTDAttList, XMLDTDElement, XMLDTDEntity, XMLDTDNotation, XMLDeclaration, XMLDocType, XMLElement, XMLProcessingInstruction, XMLRaw, XMLStreamWriter, XMLText, XMLWriterBase,
2663 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
2664 hasProp = {}.hasOwnProperty;
2665
2666 XMLDeclaration = __webpack_require__(12);
2667
2668 XMLDocType = __webpack_require__(13);
2669
2670 XMLCData = __webpack_require__(10);
2671
2672 XMLComment = __webpack_require__(11);
2673
2674 XMLElement = __webpack_require__(8);
2675
2676 XMLRaw = __webpack_require__(18);
2677
2678 XMLText = __webpack_require__(19);
2679
2680 XMLProcessingInstruction = __webpack_require__(20);
2681
2682 XMLDTDAttList = __webpack_require__(14);
2683
2684 XMLDTDElement = __webpack_require__(16);
2685
2686 XMLDTDEntity = __webpack_require__(15);
2687
2688 XMLDTDNotation = __webpack_require__(17);
2689
2690 XMLWriterBase = __webpack_require__(23);
2691
2692 module.exports = XMLStreamWriter = (function(superClass) {
2693 extend(XMLStreamWriter, superClass);
2694
2695 function XMLStreamWriter(stream, options) {
2696 XMLStreamWriter.__super__.constructor.call(this, options);
2697 this.stream = stream;
2698 }
2699
2700 XMLStreamWriter.prototype.document = function(doc) {
2701 var child, i, j, len, len1, ref, ref1, results;
2702 ref = doc.children;
2703 for (i = 0, len = ref.length; i < len; i++) {
2704 child = ref[i];
2705 child.isLastRootNode = false;
2706 }
2707 doc.children[doc.children.length - 1].isLastRootNode = true;
2708 ref1 = doc.children;
2709 results = [];
2710 for (j = 0, len1 = ref1.length; j < len1; j++) {
2711 child = ref1[j];
2712 switch (false) {
2713 case !(child instanceof XMLDeclaration):
2714 results.push(this.declaration(child));
2715 break;
2716 case !(child instanceof XMLDocType):
2717 results.push(this.docType(child));
2718 break;
2719 case !(child instanceof XMLComment):
2720 results.push(this.comment(child));
2721 break;
2722 case !(child instanceof XMLProcessingInstruction):
2723 results.push(this.processingInstruction(child));
2724 break;
2725 default:
2726 results.push(this.element(child));
2727 }
2728 }
2729 return results;
2730 };
2731
2732 XMLStreamWriter.prototype.attribute = function(att) {
2733 return this.stream.write(' ' + att.name + '="' + att.value + '"');
2734 };
2735
2736 XMLStreamWriter.prototype.cdata = function(node, level) {
2737 return this.stream.write(this.space(level) + '<![CDATA[' + node.text + ']]>' + this.endline(node));
2738 };
2739
2740 XMLStreamWriter.prototype.comment = function(node, level) {
2741 return this.stream.write(this.space(level) + '<!-- ' + node.text + ' -->' + this.endline(node));
2742 };
2743
2744 XMLStreamWriter.prototype.declaration = function(node, level) {
2745 this.stream.write(this.space(level));
2746 this.stream.write('<?xml version="' + node.version + '"');
2747 if (node.encoding != null) {
2748 this.stream.write(' encoding="' + node.encoding + '"');
2749 }
2750 if (node.standalone != null) {
2751 this.stream.write(' standalone="' + node.standalone + '"');
2752 }
2753 this.stream.write(this.spacebeforeslash + '?>');
2754 return this.stream.write(this.endline(node));
2755 };
2756
2757 XMLStreamWriter.prototype.docType = function(node, level) {
2758 var child, i, len, ref;
2759 level || (level = 0);
2760 this.stream.write(this.space(level));
2761 this.stream.write('<!DOCTYPE ' + node.root().name);
2762 if (node.pubID && node.sysID) {
2763 this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
2764 } else if (node.sysID) {
2765 this.stream.write(' SYSTEM "' + node.sysID + '"');
2766 }
2767 if (node.children.length > 0) {
2768 this.stream.write(' [');
2769 this.stream.write(this.endline(node));
2770 ref = node.children;
2771 for (i = 0, len = ref.length; i < len; i++) {
2772 child = ref[i];
2773 switch (false) {
2774 case !(child instanceof XMLDTDAttList):
2775 this.dtdAttList(child, level + 1);
2776 break;
2777 case !(child instanceof XMLDTDElement):
2778 this.dtdElement(child, level + 1);
2779 break;
2780 case !(child instanceof XMLDTDEntity):
2781 this.dtdEntity(child, level + 1);
2782 break;
2783 case !(child instanceof XMLDTDNotation):
2784 this.dtdNotation(child, level + 1);
2785 break;
2786 case !(child instanceof XMLCData):
2787 this.cdata(child, level + 1);
2788 break;
2789 case !(child instanceof XMLComment):
2790 this.comment(child, level + 1);
2791 break;
2792 case !(child instanceof XMLProcessingInstruction):
2793 this.processingInstruction(child, level + 1);
2794 break;
2795 default:
2796 throw new Error("Unknown DTD node type: " + child.constructor.name);
2797 }
2798 }
2799 this.stream.write(']');
2800 }
2801 this.stream.write(this.spacebeforeslash + '>');
2802 return this.stream.write(this.endline(node));
2803 };
2804
2805 XMLStreamWriter.prototype.element = function(node, level) {
2806 var att, child, i, len, name, ref, ref1, space;
2807 level || (level = 0);
2808 space = this.space(level);
2809 this.stream.write(space + '<' + node.name);
2810 ref = node.attributes;
2811 for (name in ref) {
2812 if (!hasProp.call(ref, name)) continue;
2813 att = ref[name];
2814 this.attribute(att);
2815 }
2816 if (node.children.length === 0 || node.children.every(function(e) {
2817 return e.value === '';
2818 })) {
2819 if (this.allowEmpty) {
2820 this.stream.write('></' + node.name + '>');
2821 } else {
2822 this.stream.write(this.spacebeforeslash + '/>');
2823 }
2824 } else if (this.pretty && node.children.length === 1 && (node.children[0].value != null)) {
2825 this.stream.write('>');
2826 this.stream.write(node.children[0].value);
2827 this.stream.write('</' + node.name + '>');
2828 } else {
2829 this.stream.write('>' + this.newline);
2830 ref1 = node.children;
2831 for (i = 0, len = ref1.length; i < len; i++) {
2832 child = ref1[i];
2833 switch (false) {
2834 case !(child instanceof XMLCData):
2835 this.cdata(child, level + 1);
2836 break;
2837 case !(child instanceof XMLComment):
2838 this.comment(child, level + 1);
2839 break;
2840 case !(child instanceof XMLElement):
2841 this.element(child, level + 1);
2842 break;
2843 case !(child instanceof XMLRaw):
2844 this.raw(child, level + 1);
2845 break;
2846 case !(child instanceof XMLText):
2847 this.text(child, level + 1);
2848 break;
2849 case !(child instanceof XMLProcessingInstruction):
2850 this.processingInstruction(child, level + 1);
2851 break;
2852 default:
2853 throw new Error("Unknown XML node type: " + child.constructor.name);
2854 }
2855 }
2856 this.stream.write(space + '</' + node.name + '>');
2857 }
2858 return this.stream.write(this.endline(node));
2859 };
2860
2861 XMLStreamWriter.prototype.processingInstruction = function(node, level) {
2862 this.stream.write(this.space(level) + '<?' + node.target);
2863 if (node.value) {
2864 this.stream.write(' ' + node.value);
2865 }
2866 return this.stream.write(this.spacebeforeslash + '?>' + this.endline(node));
2867 };
2868
2869 XMLStreamWriter.prototype.raw = function(node, level) {
2870 return this.stream.write(this.space(level) + node.value + this.endline(node));
2871 };
2872
2873 XMLStreamWriter.prototype.text = function(node, level) {
2874 return this.stream.write(this.space(level) + node.value + this.endline(node));
2875 };
2876
2877 XMLStreamWriter.prototype.dtdAttList = function(node, level) {
2878 this.stream.write(this.space(level) + '<!ATTLIST ' + node.elementName + ' ' + node.attributeName + ' ' + node.attributeType);
2879 if (node.defaultValueType !== '#DEFAULT') {
2880 this.stream.write(' ' + node.defaultValueType);
2881 }
2882 if (node.defaultValue) {
2883 this.stream.write(' "' + node.defaultValue + '"');
2884 }
2885 return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
2886 };
2887
2888 XMLStreamWriter.prototype.dtdElement = function(node, level) {
2889 this.stream.write(this.space(level) + '<!ELEMENT ' + node.name + ' ' + node.value);
2890 return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
2891 };
2892
2893 XMLStreamWriter.prototype.dtdEntity = function(node, level) {
2894 this.stream.write(this.space(level) + '<!ENTITY');
2895 if (node.pe) {
2896 this.stream.write(' %');
2897 }
2898 this.stream.write(' ' + node.name);
2899 if (node.value) {
2900 this.stream.write(' "' + node.value + '"');
2901 } else {
2902 if (node.pubID && node.sysID) {
2903 this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
2904 } else if (node.sysID) {
2905 this.stream.write(' SYSTEM "' + node.sysID + '"');
2906 }
2907 if (node.nData) {
2908 this.stream.write(' NDATA ' + node.nData);
2909 }
2910 }
2911 return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
2912 };
2913
2914 XMLStreamWriter.prototype.dtdNotation = function(node, level) {
2915 this.stream.write(this.space(level) + '<!NOTATION ' + node.name);
2916 if (node.pubID && node.sysID) {
2917 this.stream.write(' PUBLIC "' + node.pubID + '" "' + node.sysID + '"');
2918 } else if (node.pubID) {
2919 this.stream.write(' PUBLIC "' + node.pubID + '"');
2920 } else if (node.sysID) {
2921 this.stream.write(' SYSTEM "' + node.sysID + '"');
2922 }
2923 return this.stream.write(this.spacebeforeslash + '>' + this.endline(node));
2924 };
2925
2926 XMLStreamWriter.prototype.endline = function(node) {
2927 if (!node.isLastRootNode) {
2928 return this.newline;
2929 } else {
2930 return '';
2931 }
2932 };
2933
2934 return XMLStreamWriter;
2935
2936 })(XMLWriterBase);
2937
2938 }).call(this);
2939
2940
2941/***/ }),
2942/* 26 */
2943/***/ (function(module, exports, __webpack_require__) {
2944
2945 // Generated by CoffeeScript 1.12.7
2946 (function() {
2947 "use strict";
2948 var bom, defaults, events, isEmpty, processItem, processors, sax, setImmediate,
2949 bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
2950 extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
2951 hasProp = {}.hasOwnProperty;
2952
2953 sax = __webpack_require__(27);
2954
2955 events = __webpack_require__(33);
2956
2957 bom = __webpack_require__(59);
2958
2959 processors = __webpack_require__(60);
2960
2961 setImmediate = __webpack_require__(48).setImmediate;
2962
2963 defaults = __webpack_require__(2).defaults;
2964
2965 isEmpty = function(thing) {
2966 return typeof thing === "object" && (thing != null) && Object.keys(thing).length === 0;
2967 };
2968
2969 processItem = function(processors, item, key) {
2970 var i, len, process;
2971 for (i = 0, len = processors.length; i < len; i++) {
2972 process = processors[i];
2973 item = process(item, key);
2974 }
2975 return item;
2976 };
2977
2978 exports.Parser = (function(superClass) {
2979 extend(Parser, superClass);
2980
2981 function Parser(opts) {
2982 this.parseString = bind(this.parseString, this);
2983 this.reset = bind(this.reset, this);
2984 this.assignOrPush = bind(this.assignOrPush, this);
2985 this.processAsync = bind(this.processAsync, this);
2986 var key, ref, value;
2987 if (!(this instanceof exports.Parser)) {
2988 return new exports.Parser(opts);
2989 }
2990 this.options = {};
2991 ref = defaults["0.2"];
2992 for (key in ref) {
2993 if (!hasProp.call(ref, key)) continue;
2994 value = ref[key];
2995 this.options[key] = value;
2996 }
2997 for (key in opts) {
2998 if (!hasProp.call(opts, key)) continue;
2999 value = opts[key];
3000 this.options[key] = value;
3001 }
3002 if (this.options.xmlns) {
3003 this.options.xmlnskey = this.options.attrkey + "ns";
3004 }
3005 if (this.options.normalizeTags) {
3006 if (!this.options.tagNameProcessors) {
3007 this.options.tagNameProcessors = [];
3008 }
3009 this.options.tagNameProcessors.unshift(processors.normalize);
3010 }
3011 this.reset();
3012 }
3013
3014 Parser.prototype.processAsync = function() {
3015 var chunk, err;
3016 try {
3017 if (this.remaining.length <= this.options.chunkSize) {
3018 chunk = this.remaining;
3019 this.remaining = '';
3020 this.saxParser = this.saxParser.write(chunk);
3021 return this.saxParser.close();
3022 } else {
3023 chunk = this.remaining.substr(0, this.options.chunkSize);
3024 this.remaining = this.remaining.substr(this.options.chunkSize, this.remaining.length);
3025 this.saxParser = this.saxParser.write(chunk);
3026 return setImmediate(this.processAsync);
3027 }
3028 } catch (error1) {
3029 err = error1;
3030 if (!this.saxParser.errThrown) {
3031 this.saxParser.errThrown = true;
3032 return this.emit(err);
3033 }
3034 }
3035 };
3036
3037 Parser.prototype.assignOrPush = function(obj, key, newValue) {
3038 if (!(key in obj)) {
3039 if (!this.options.explicitArray) {
3040 return obj[key] = newValue;
3041 } else {
3042 return obj[key] = [newValue];
3043 }
3044 } else {
3045 if (!(obj[key] instanceof Array)) {
3046 obj[key] = [obj[key]];
3047 }
3048 return obj[key].push(newValue);
3049 }
3050 };
3051
3052 Parser.prototype.reset = function() {
3053 var attrkey, charkey, ontext, stack;
3054 this.removeAllListeners();
3055 this.saxParser = sax.parser(this.options.strict, {
3056 trim: false,
3057 normalize: false,
3058 xmlns: this.options.xmlns
3059 });
3060 this.saxParser.errThrown = false;
3061 this.saxParser.onerror = (function(_this) {
3062 return function(error) {
3063 _this.saxParser.resume();
3064 if (!_this.saxParser.errThrown) {
3065 _this.saxParser.errThrown = true;
3066 return _this.emit("error", error);
3067 }
3068 };
3069 })(this);
3070 this.saxParser.onend = (function(_this) {
3071 return function() {
3072 if (!_this.saxParser.ended) {
3073 _this.saxParser.ended = true;
3074 return _this.emit("end", _this.resultObject);
3075 }
3076 };
3077 })(this);
3078 this.saxParser.ended = false;
3079 this.EXPLICIT_CHARKEY = this.options.explicitCharkey;
3080 this.resultObject = null;
3081 stack = [];
3082 attrkey = this.options.attrkey;
3083 charkey = this.options.charkey;
3084 this.saxParser.onopentag = (function(_this) {
3085 return function(node) {
3086 var key, newValue, obj, processedKey, ref;
3087 obj = {};
3088 obj[charkey] = "";
3089 if (!_this.options.ignoreAttrs) {
3090 ref = node.attributes;
3091 for (key in ref) {
3092 if (!hasProp.call(ref, key)) continue;
3093 if (!(attrkey in obj) && !_this.options.mergeAttrs) {
3094 obj[attrkey] = {};
3095 }
3096 newValue = _this.options.attrValueProcessors ? processItem(_this.options.attrValueProcessors, node.attributes[key], key) : node.attributes[key];
3097 processedKey = _this.options.attrNameProcessors ? processItem(_this.options.attrNameProcessors, key) : key;
3098 if (_this.options.mergeAttrs) {
3099 _this.assignOrPush(obj, processedKey, newValue);
3100 } else {
3101 obj[attrkey][processedKey] = newValue;
3102 }
3103 }
3104 }
3105 obj["#name"] = _this.options.tagNameProcessors ? processItem(_this.options.tagNameProcessors, node.name) : node.name;
3106 if (_this.options.xmlns) {
3107 obj[_this.options.xmlnskey] = {
3108 uri: node.uri,
3109 local: node.local
3110 };
3111 }
3112 return stack.push(obj);
3113 };
3114 })(this);
3115 this.saxParser.onclosetag = (function(_this) {
3116 return function() {
3117 var cdata, emptyStr, key, node, nodeName, obj, objClone, old, s, xpath;
3118 obj = stack.pop();
3119 nodeName = obj["#name"];
3120 if (!_this.options.explicitChildren || !_this.options.preserveChildrenOrder) {
3121 delete obj["#name"];
3122 }
3123 if (obj.cdata === true) {
3124 cdata = obj.cdata;
3125 delete obj.cdata;
3126 }
3127 s = stack[stack.length - 1];
3128 if (obj[charkey].match(/^\s*$/) && !cdata) {
3129 emptyStr = obj[charkey];
3130 delete obj[charkey];
3131 } else {
3132 if (_this.options.trim) {
3133 obj[charkey] = obj[charkey].trim();
3134 }
3135 if (_this.options.normalize) {
3136 obj[charkey] = obj[charkey].replace(/\s{2,}/g, " ").trim();
3137 }
3138 obj[charkey] = _this.options.valueProcessors ? processItem(_this.options.valueProcessors, obj[charkey], nodeName) : obj[charkey];
3139 if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
3140 obj = obj[charkey];
3141 }
3142 }
3143 if (isEmpty(obj)) {
3144 obj = _this.options.emptyTag !== '' ? _this.options.emptyTag : emptyStr;
3145 }
3146 if (_this.options.validator != null) {
3147 xpath = "/" + ((function() {
3148 var i, len, results;
3149 results = [];
3150 for (i = 0, len = stack.length; i < len; i++) {
3151 node = stack[i];
3152 results.push(node["#name"]);
3153 }
3154 return results;
3155 })()).concat(nodeName).join("/");
3156 (function() {
3157 var err;
3158 try {
3159 return obj = _this.options.validator(xpath, s && s[nodeName], obj);
3160 } catch (error1) {
3161 err = error1;
3162 return _this.emit("error", err);
3163 }
3164 })();
3165 }
3166 if (_this.options.explicitChildren && !_this.options.mergeAttrs && typeof obj === 'object') {
3167 if (!_this.options.preserveChildrenOrder) {
3168 node = {};
3169 if (_this.options.attrkey in obj) {
3170 node[_this.options.attrkey] = obj[_this.options.attrkey];
3171 delete obj[_this.options.attrkey];
3172 }
3173 if (!_this.options.charsAsChildren && _this.options.charkey in obj) {
3174 node[_this.options.charkey] = obj[_this.options.charkey];
3175 delete obj[_this.options.charkey];
3176 }
3177 if (Object.getOwnPropertyNames(obj).length > 0) {
3178 node[_this.options.childkey] = obj;
3179 }
3180 obj = node;
3181 } else if (s) {
3182 s[_this.options.childkey] = s[_this.options.childkey] || [];
3183 objClone = {};
3184 for (key in obj) {
3185 if (!hasProp.call(obj, key)) continue;
3186 objClone[key] = obj[key];
3187 }
3188 s[_this.options.childkey].push(objClone);
3189 delete obj["#name"];
3190 if (Object.keys(obj).length === 1 && charkey in obj && !_this.EXPLICIT_CHARKEY) {
3191 obj = obj[charkey];
3192 }
3193 }
3194 }
3195 if (stack.length > 0) {
3196 return _this.assignOrPush(s, nodeName, obj);
3197 } else {
3198 if (_this.options.explicitRoot) {
3199 old = obj;
3200 obj = {};
3201 obj[nodeName] = old;
3202 }
3203 _this.resultObject = obj;
3204 _this.saxParser.ended = true;
3205 return _this.emit("end", _this.resultObject);
3206 }
3207 };
3208 })(this);
3209 ontext = (function(_this) {
3210 return function(text) {
3211 var charChild, s;
3212 s = stack[stack.length - 1];
3213 if (s) {
3214 s[charkey] += text;
3215 if (_this.options.explicitChildren && _this.options.preserveChildrenOrder && _this.options.charsAsChildren && (_this.options.includeWhiteChars || text.replace(/\\n/g, '').trim() !== '')) {
3216 s[_this.options.childkey] = s[_this.options.childkey] || [];
3217 charChild = {
3218 '#name': '__text__'
3219 };
3220 charChild[charkey] = text;
3221 if (_this.options.normalize) {
3222 charChild[charkey] = charChild[charkey].replace(/\s{2,}/g, " ").trim();
3223 }
3224 s[_this.options.childkey].push(charChild);
3225 }
3226 return s;
3227 }
3228 };
3229 })(this);
3230 this.saxParser.ontext = ontext;
3231 return this.saxParser.oncdata = (function(_this) {
3232 return function(text) {
3233 var s;
3234 s = ontext(text);
3235 if (s) {
3236 return s.cdata = true;
3237 }
3238 };
3239 })(this);
3240 };
3241
3242 Parser.prototype.parseString = function(str, cb) {
3243 var err;
3244 if ((cb != null) && typeof cb === "function") {
3245 this.on("end", function(result) {
3246 this.reset();
3247 return cb(null, result);
3248 });
3249 this.on("error", function(err) {
3250 this.reset();
3251 return cb(err);
3252 });
3253 }
3254 try {
3255 str = str.toString();
3256 if (str.trim() === '') {
3257 this.emit("end", null);
3258 return true;
3259 }
3260 str = bom.stripBOM(str);
3261 if (this.options.async) {
3262 this.remaining = str;
3263 setImmediate(this.processAsync);
3264 return this.saxParser;
3265 }
3266 return this.saxParser.write(str).close();
3267 } catch (error1) {
3268 err = error1;
3269 if (!(this.saxParser.errThrown || this.saxParser.ended)) {
3270 this.emit('error', err);
3271 return this.saxParser.errThrown = true;
3272 } else if (this.saxParser.ended) {
3273 throw err;
3274 }
3275 }
3276 };
3277
3278 return Parser;
3279
3280 })(events.EventEmitter);
3281
3282 exports.parseString = function(str, a, b) {
3283 var cb, options, parser;
3284 if (b != null) {
3285 if (typeof b === 'function') {
3286 cb = b;
3287 }
3288 if (typeof a === 'object') {
3289 options = a;
3290 }
3291 } else {
3292 if (typeof a === 'function') {
3293 cb = a;
3294 }
3295 options = {};
3296 }
3297 parser = new exports.Parser(options);
3298 return parser.parseString(str, cb);
3299 };
3300
3301 }).call(this);
3302
3303
3304/***/ }),
3305/* 27 */
3306/***/ (function(module, exports, __webpack_require__) {
3307
3308 /* WEBPACK VAR INJECTION */(function(Buffer) {;(function (sax) { // wrapper for non-node envs
3309 sax.parser = function (strict, opt) { return new SAXParser(strict, opt) }
3310 sax.SAXParser = SAXParser
3311 sax.SAXStream = SAXStream
3312 sax.createStream = createStream
3313
3314 // When we pass the MAX_BUFFER_LENGTH position, start checking for buffer overruns.
3315 // When we check, schedule the next check for MAX_BUFFER_LENGTH - (max(buffer lengths)),
3316 // since that's the earliest that a buffer overrun could occur. This way, checks are
3317 // as rare as required, but as often as necessary to ensure never crossing this bound.
3318 // Furthermore, buffers are only tested at most once per write(), so passing a very
3319 // large string into write() might have undesirable effects, but this is manageable by
3320 // the caller, so it is assumed to be safe. Thus, a call to write() may, in the extreme
3321 // edge case, result in creating at most one complete copy of the string passed in.
3322 // Set to Infinity to have unlimited buffers.
3323 sax.MAX_BUFFER_LENGTH = 64 * 1024
3324
3325 var buffers = [
3326 'comment', 'sgmlDecl', 'textNode', 'tagName', 'doctype',
3327 'procInstName', 'procInstBody', 'entity', 'attribName',
3328 'attribValue', 'cdata', 'script'
3329 ]
3330
3331 sax.EVENTS = [
3332 'text',
3333 'processinginstruction',
3334 'sgmldeclaration',
3335 'doctype',
3336 'comment',
3337 'opentagstart',
3338 'attribute',
3339 'opentag',
3340 'closetag',
3341 'opencdata',
3342 'cdata',
3343 'closecdata',
3344 'error',
3345 'end',
3346 'ready',
3347 'script',
3348 'opennamespace',
3349 'closenamespace'
3350 ]
3351
3352 function SAXParser (strict, opt) {
3353 if (!(this instanceof SAXParser)) {
3354 return new SAXParser(strict, opt)
3355 }
3356
3357 var parser = this
3358 clearBuffers(parser)
3359 parser.q = parser.c = ''
3360 parser.bufferCheckPosition = sax.MAX_BUFFER_LENGTH
3361 parser.opt = opt || {}
3362 parser.opt.lowercase = parser.opt.lowercase || parser.opt.lowercasetags
3363 parser.looseCase = parser.opt.lowercase ? 'toLowerCase' : 'toUpperCase'
3364 parser.tags = []
3365 parser.closed = parser.closedRoot = parser.sawRoot = false
3366 parser.tag = parser.error = null
3367 parser.strict = !!strict
3368 parser.noscript = !!(strict || parser.opt.noscript)
3369 parser.state = S.BEGIN
3370 parser.strictEntities = parser.opt.strictEntities
3371 parser.ENTITIES = parser.strictEntities ? Object.create(sax.XML_ENTITIES) : Object.create(sax.ENTITIES)
3372 parser.attribList = []
3373
3374 // namespaces form a prototype chain.
3375 // it always points at the current tag,
3376 // which protos to its parent tag.
3377 if (parser.opt.xmlns) {
3378 parser.ns = Object.create(rootNS)
3379 }
3380
3381 // mostly just for error reporting
3382 parser.trackPosition = parser.opt.position !== false
3383 if (parser.trackPosition) {
3384 parser.position = parser.line = parser.column = 0
3385 }
3386 emit(parser, 'onready')
3387 }
3388
3389 if (!Object.create) {
3390 Object.create = function (o) {
3391 function F () {}
3392 F.prototype = o
3393 var newf = new F()
3394 return newf
3395 }
3396 }
3397
3398 if (!Object.keys) {
3399 Object.keys = function (o) {
3400 var a = []
3401 for (var i in o) if (o.hasOwnProperty(i)) a.push(i)
3402 return a
3403 }
3404 }
3405
3406 function checkBufferLength (parser) {
3407 var maxAllowed = Math.max(sax.MAX_BUFFER_LENGTH, 10)
3408 var maxActual = 0
3409 for (var i = 0, l = buffers.length; i < l; i++) {
3410 var len = parser[buffers[i]].length
3411 if (len > maxAllowed) {
3412 // Text/cdata nodes can get big, and since they're buffered,
3413 // we can get here under normal conditions.
3414 // Avoid issues by emitting the text node now,
3415 // so at least it won't get any bigger.
3416 switch (buffers[i]) {
3417 case 'textNode':
3418 closeText(parser)
3419 break
3420
3421 case 'cdata':
3422 emitNode(parser, 'oncdata', parser.cdata)
3423 parser.cdata = ''
3424 break
3425
3426 case 'script':
3427 emitNode(parser, 'onscript', parser.script)
3428 parser.script = ''
3429 break
3430
3431 default:
3432 error(parser, 'Max buffer length exceeded: ' + buffers[i])
3433 }
3434 }
3435 maxActual = Math.max(maxActual, len)
3436 }
3437 // schedule the next check for the earliest possible buffer overrun.
3438 var m = sax.MAX_BUFFER_LENGTH - maxActual
3439 parser.bufferCheckPosition = m + parser.position
3440 }
3441
3442 function clearBuffers (parser) {
3443 for (var i = 0, l = buffers.length; i < l; i++) {
3444 parser[buffers[i]] = ''
3445 }
3446 }
3447
3448 function flushBuffers (parser) {
3449 closeText(parser)
3450 if (parser.cdata !== '') {
3451 emitNode(parser, 'oncdata', parser.cdata)
3452 parser.cdata = ''
3453 }
3454 if (parser.script !== '') {
3455 emitNode(parser, 'onscript', parser.script)
3456 parser.script = ''
3457 }
3458 }
3459
3460 SAXParser.prototype = {
3461 end: function () { end(this) },
3462 write: write,
3463 resume: function () { this.error = null; return this },
3464 close: function () { return this.write(null) },
3465 flush: function () { flushBuffers(this) }
3466 }
3467
3468 var Stream
3469 try {
3470 Stream = __webpack_require__(32).Stream
3471 } catch (ex) {
3472 Stream = function () {}
3473 }
3474
3475 var streamWraps = sax.EVENTS.filter(function (ev) {
3476 return ev !== 'error' && ev !== 'end'
3477 })
3478
3479 function createStream (strict, opt) {
3480 return new SAXStream(strict, opt)
3481 }
3482
3483 function SAXStream (strict, opt) {
3484 if (!(this instanceof SAXStream)) {
3485 return new SAXStream(strict, opt)
3486 }
3487
3488 Stream.apply(this)
3489
3490 this._parser = new SAXParser(strict, opt)
3491 this.writable = true
3492 this.readable = true
3493
3494 var me = this
3495
3496 this._parser.onend = function () {
3497 me.emit('end')
3498 }
3499
3500 this._parser.onerror = function (er) {
3501 me.emit('error', er)
3502
3503 // if didn't throw, then means error was handled.
3504 // go ahead and clear error, so we can write again.
3505 me._parser.error = null
3506 }
3507
3508 this._decoder = null
3509
3510 streamWraps.forEach(function (ev) {
3511 Object.defineProperty(me, 'on' + ev, {
3512 get: function () {
3513 return me._parser['on' + ev]
3514 },
3515 set: function (h) {
3516 if (!h) {
3517 me.removeAllListeners(ev)
3518 me._parser['on' + ev] = h
3519 return h
3520 }
3521 me.on(ev, h)
3522 },
3523 enumerable: true,
3524 configurable: false
3525 })
3526 })
3527 }
3528
3529 SAXStream.prototype = Object.create(Stream.prototype, {
3530 constructor: {
3531 value: SAXStream
3532 }
3533 })
3534
3535 SAXStream.prototype.write = function (data) {
3536 if (typeof Buffer === 'function' &&
3537 typeof Buffer.isBuffer === 'function' &&
3538 Buffer.isBuffer(data)) {
3539 if (!this._decoder) {
3540 var SD = __webpack_require__(58).StringDecoder
3541 this._decoder = new SD('utf8')
3542 }
3543 data = this._decoder.write(data)
3544 }
3545
3546 this._parser.write(data.toString())
3547 this.emit('data', data)
3548 return true
3549 }
3550
3551 SAXStream.prototype.end = function (chunk) {
3552 if (chunk && chunk.length) {
3553 this.write(chunk)
3554 }
3555 this._parser.end()
3556 return true
3557 }
3558
3559 SAXStream.prototype.on = function (ev, handler) {
3560 var me = this
3561 if (!me._parser['on' + ev] && streamWraps.indexOf(ev) !== -1) {
3562 me._parser['on' + ev] = function () {
3563 var args = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments)
3564 args.splice(0, 0, ev)
3565 me.emit.apply(me, args)
3566 }
3567 }
3568
3569 return Stream.prototype.on.call(me, ev, handler)
3570 }
3571
3572 // character classes and tokens
3573 var whitespace = '\r\n\t '
3574
3575 // this really needs to be replaced with character classes.
3576 // XML allows all manner of ridiculous numbers and digits.
3577 var number = '0124356789'
3578 var letter = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
3579
3580 // (Letter | "_" | ":")
3581 var quote = '\'"'
3582 var attribEnd = whitespace + '>'
3583 var CDATA = '[CDATA['
3584 var DOCTYPE = 'DOCTYPE'
3585 var XML_NAMESPACE = 'http://www.w3.org/XML/1998/namespace'
3586 var XMLNS_NAMESPACE = 'http://www.w3.org/2000/xmlns/'
3587 var rootNS = { xml: XML_NAMESPACE, xmlns: XMLNS_NAMESPACE }
3588
3589 // turn all the string character sets into character class objects.
3590 whitespace = charClass(whitespace)
3591 number = charClass(number)
3592 letter = charClass(letter)
3593
3594 // http://www.w3.org/TR/REC-xml/#NT-NameStartChar
3595 // This implementation works on strings, a single character at a time
3596 // as such, it cannot ever support astral-plane characters (10000-EFFFF)
3597 // without a significant breaking change to either this parser, or the
3598 // JavaScript language. Implementation of an emoji-capable xml parser
3599 // is left as an exercise for the reader.
3600 var nameStart = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
3601
3602 var nameBody = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
3603
3604 var entityStart = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/
3605 var entityBody = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040\.\d-]/
3606
3607 quote = charClass(quote)
3608 attribEnd = charClass(attribEnd)
3609
3610 function charClass (str) {
3611 return str.split('').reduce(function (s, c) {
3612 s[c] = true
3613 return s
3614 }, {})
3615 }
3616
3617 function isRegExp (c) {
3618 return Object.prototype.toString.call(c) === '[object RegExp]'
3619 }
3620
3621 function is (charclass, c) {
3622 return isRegExp(charclass) ? !!c.match(charclass) : charclass[c]
3623 }
3624
3625 function not (charclass, c) {
3626 return !is(charclass, c)
3627 }
3628
3629 var S = 0
3630 sax.STATE = {
3631 BEGIN: S++, // leading byte order mark or whitespace
3632 BEGIN_WHITESPACE: S++, // leading whitespace
3633 TEXT: S++, // general stuff
3634 TEXT_ENTITY: S++, // &amp and such.
3635 OPEN_WAKA: S++, // <
3636 SGML_DECL: S++, // <!BLARG
3637 SGML_DECL_QUOTED: S++, // <!BLARG foo "bar
3638 DOCTYPE: S++, // <!DOCTYPE
3639 DOCTYPE_QUOTED: S++, // <!DOCTYPE "//blah
3640 DOCTYPE_DTD: S++, // <!DOCTYPE "//blah" [ ...
3641 DOCTYPE_DTD_QUOTED: S++, // <!DOCTYPE "//blah" [ "foo
3642 COMMENT_STARTING: S++, // <!-
3643 COMMENT: S++, // <!--
3644 COMMENT_ENDING: S++, // <!-- blah -
3645 COMMENT_ENDED: S++, // <!-- blah --
3646 CDATA: S++, // <![CDATA[ something
3647 CDATA_ENDING: S++, // ]
3648 CDATA_ENDING_2: S++, // ]]
3649 PROC_INST: S++, // <?hi
3650 PROC_INST_BODY: S++, // <?hi there
3651 PROC_INST_ENDING: S++, // <?hi "there" ?
3652 OPEN_TAG: S++, // <strong
3653 OPEN_TAG_SLASH: S++, // <strong /
3654 ATTRIB: S++, // <a
3655 ATTRIB_NAME: S++, // <a foo
3656 ATTRIB_NAME_SAW_WHITE: S++, // <a foo _
3657 ATTRIB_VALUE: S++, // <a foo=
3658 ATTRIB_VALUE_QUOTED: S++, // <a foo="bar
3659 ATTRIB_VALUE_CLOSED: S++, // <a foo="bar"
3660 ATTRIB_VALUE_UNQUOTED: S++, // <a foo=bar
3661 ATTRIB_VALUE_ENTITY_Q: S++, // <foo bar="&quot;"
3662 ATTRIB_VALUE_ENTITY_U: S++, // <foo bar=&quot
3663 CLOSE_TAG: S++, // </a
3664 CLOSE_TAG_SAW_WHITE: S++, // </a >
3665 SCRIPT: S++, // <script> ...
3666 SCRIPT_ENDING: S++ // <script> ... <
3667 }
3668
3669 sax.XML_ENTITIES = {
3670 'amp': '&',
3671 'gt': '>',
3672 'lt': '<',
3673 'quot': '"',
3674 'apos': "'"
3675 }
3676
3677 sax.ENTITIES = {
3678 'amp': '&',
3679 'gt': '>',
3680 'lt': '<',
3681 'quot': '"',
3682 'apos': "'",
3683 'AElig': 198,
3684 'Aacute': 193,
3685 'Acirc': 194,
3686 'Agrave': 192,
3687 'Aring': 197,
3688 'Atilde': 195,
3689 'Auml': 196,
3690 'Ccedil': 199,
3691 'ETH': 208,
3692 'Eacute': 201,
3693 'Ecirc': 202,
3694 'Egrave': 200,
3695 'Euml': 203,
3696 'Iacute': 205,
3697 'Icirc': 206,
3698 'Igrave': 204,
3699 'Iuml': 207,
3700 'Ntilde': 209,
3701 'Oacute': 211,
3702 'Ocirc': 212,
3703 'Ograve': 210,
3704 'Oslash': 216,
3705 'Otilde': 213,
3706 'Ouml': 214,
3707 'THORN': 222,
3708 'Uacute': 218,
3709 'Ucirc': 219,
3710 'Ugrave': 217,
3711 'Uuml': 220,
3712 'Yacute': 221,
3713 'aacute': 225,
3714 'acirc': 226,
3715 'aelig': 230,
3716 'agrave': 224,
3717 'aring': 229,
3718 'atilde': 227,
3719 'auml': 228,
3720 'ccedil': 231,
3721 'eacute': 233,
3722 'ecirc': 234,
3723 'egrave': 232,
3724 'eth': 240,
3725 'euml': 235,
3726 'iacute': 237,
3727 'icirc': 238,
3728 'igrave': 236,
3729 'iuml': 239,
3730 'ntilde': 241,
3731 'oacute': 243,
3732 'ocirc': 244,
3733 'ograve': 242,
3734 'oslash': 248,
3735 'otilde': 245,
3736 'ouml': 246,
3737 'szlig': 223,
3738 'thorn': 254,
3739 'uacute': 250,
3740 'ucirc': 251,
3741 'ugrave': 249,
3742 'uuml': 252,
3743 'yacute': 253,
3744 'yuml': 255,
3745 'copy': 169,
3746 'reg': 174,
3747 'nbsp': 160,
3748 'iexcl': 161,
3749 'cent': 162,
3750 'pound': 163,
3751 'curren': 164,
3752 'yen': 165,
3753 'brvbar': 166,
3754 'sect': 167,
3755 'uml': 168,
3756 'ordf': 170,
3757 'laquo': 171,
3758 'not': 172,
3759 'shy': 173,
3760 'macr': 175,
3761 'deg': 176,
3762 'plusmn': 177,
3763 'sup1': 185,
3764 'sup2': 178,
3765 'sup3': 179,
3766 'acute': 180,
3767 'micro': 181,
3768 'para': 182,
3769 'middot': 183,
3770 'cedil': 184,
3771 'ordm': 186,
3772 'raquo': 187,
3773 'frac14': 188,
3774 'frac12': 189,
3775 'frac34': 190,
3776 'iquest': 191,
3777 'times': 215,
3778 'divide': 247,
3779 'OElig': 338,
3780 'oelig': 339,
3781 'Scaron': 352,
3782 'scaron': 353,
3783 'Yuml': 376,
3784 'fnof': 402,
3785 'circ': 710,
3786 'tilde': 732,
3787 'Alpha': 913,
3788 'Beta': 914,
3789 'Gamma': 915,
3790 'Delta': 916,
3791 'Epsilon': 917,
3792 'Zeta': 918,
3793 'Eta': 919,
3794 'Theta': 920,
3795 'Iota': 921,
3796 'Kappa': 922,
3797 'Lambda': 923,
3798 'Mu': 924,
3799 'Nu': 925,
3800 'Xi': 926,
3801 'Omicron': 927,
3802 'Pi': 928,
3803 'Rho': 929,
3804 'Sigma': 931,
3805 'Tau': 932,
3806 'Upsilon': 933,
3807 'Phi': 934,
3808 'Chi': 935,
3809 'Psi': 936,
3810 'Omega': 937,
3811 'alpha': 945,
3812 'beta': 946,
3813 'gamma': 947,
3814 'delta': 948,
3815 'epsilon': 949,
3816 'zeta': 950,
3817 'eta': 951,
3818 'theta': 952,
3819 'iota': 953,
3820 'kappa': 954,
3821 'lambda': 955,
3822 'mu': 956,
3823 'nu': 957,
3824 'xi': 958,
3825 'omicron': 959,
3826 'pi': 960,
3827 'rho': 961,
3828 'sigmaf': 962,
3829 'sigma': 963,
3830 'tau': 964,
3831 'upsilon': 965,
3832 'phi': 966,
3833 'chi': 967,
3834 'psi': 968,
3835 'omega': 969,
3836 'thetasym': 977,
3837 'upsih': 978,
3838 'piv': 982,
3839 'ensp': 8194,
3840 'emsp': 8195,
3841 'thinsp': 8201,
3842 'zwnj': 8204,
3843 'zwj': 8205,
3844 'lrm': 8206,
3845 'rlm': 8207,
3846 'ndash': 8211,
3847 'mdash': 8212,
3848 'lsquo': 8216,
3849 'rsquo': 8217,
3850 'sbquo': 8218,
3851 'ldquo': 8220,
3852 'rdquo': 8221,
3853 'bdquo': 8222,
3854 'dagger': 8224,
3855 'Dagger': 8225,
3856 'bull': 8226,
3857 'hellip': 8230,
3858 'permil': 8240,
3859 'prime': 8242,
3860 'Prime': 8243,
3861 'lsaquo': 8249,
3862 'rsaquo': 8250,
3863 'oline': 8254,
3864 'frasl': 8260,
3865 'euro': 8364,
3866 'image': 8465,
3867 'weierp': 8472,
3868 'real': 8476,
3869 'trade': 8482,
3870 'alefsym': 8501,
3871 'larr': 8592,
3872 'uarr': 8593,
3873 'rarr': 8594,
3874 'darr': 8595,
3875 'harr': 8596,
3876 'crarr': 8629,
3877 'lArr': 8656,
3878 'uArr': 8657,
3879 'rArr': 8658,
3880 'dArr': 8659,
3881 'hArr': 8660,
3882 'forall': 8704,
3883 'part': 8706,
3884 'exist': 8707,
3885 'empty': 8709,
3886 'nabla': 8711,
3887 'isin': 8712,
3888 'notin': 8713,
3889 'ni': 8715,
3890 'prod': 8719,
3891 'sum': 8721,
3892 'minus': 8722,
3893 'lowast': 8727,
3894 'radic': 8730,
3895 'prop': 8733,
3896 'infin': 8734,
3897 'ang': 8736,
3898 'and': 8743,
3899 'or': 8744,
3900 'cap': 8745,
3901 'cup': 8746,
3902 'int': 8747,
3903 'there4': 8756,
3904 'sim': 8764,
3905 'cong': 8773,
3906 'asymp': 8776,
3907 'ne': 8800,
3908 'equiv': 8801,
3909 'le': 8804,
3910 'ge': 8805,
3911 'sub': 8834,
3912 'sup': 8835,
3913 'nsub': 8836,
3914 'sube': 8838,
3915 'supe': 8839,
3916 'oplus': 8853,
3917 'otimes': 8855,
3918 'perp': 8869,
3919 'sdot': 8901,
3920 'lceil': 8968,
3921 'rceil': 8969,
3922 'lfloor': 8970,
3923 'rfloor': 8971,
3924 'lang': 9001,
3925 'rang': 9002,
3926 'loz': 9674,
3927 'spades': 9824,
3928 'clubs': 9827,
3929 'hearts': 9829,
3930 'diams': 9830
3931 }
3932
3933 Object.keys(sax.ENTITIES).forEach(function (key) {
3934 var e = sax.ENTITIES[key]
3935 var s = typeof e === 'number' ? String.fromCharCode(e) : e
3936 sax.ENTITIES[key] = s
3937 })
3938
3939 for (var s in sax.STATE) {
3940 sax.STATE[sax.STATE[s]] = s
3941 }
3942
3943 // shorthand
3944 S = sax.STATE
3945
3946 function emit (parser, event, data) {
3947 parser[event] && parser[event](data)
3948 }
3949
3950 function emitNode (parser, nodeType, data) {
3951 if (parser.textNode) closeText(parser)
3952 emit(parser, nodeType, data)
3953 }
3954
3955 function closeText (parser) {
3956 parser.textNode = textopts(parser.opt, parser.textNode)
3957 if (parser.textNode) emit(parser, 'ontext', parser.textNode)
3958 parser.textNode = ''
3959 }
3960
3961 function textopts (opt, text) {
3962 if (opt.trim) text = text.trim()
3963 if (opt.normalize) text = text.replace(/\s+/g, ' ')
3964 return text
3965 }
3966
3967 function error (parser, er) {
3968 closeText(parser)
3969 if (parser.trackPosition) {
3970 er += '\nLine: ' + parser.line +
3971 '\nColumn: ' + parser.column +
3972 '\nChar: ' + parser.c
3973 }
3974 er = new Error(er)
3975 parser.error = er
3976 emit(parser, 'onerror', er)
3977 return parser
3978 }
3979
3980 function end (parser) {
3981 if (parser.sawRoot && !parser.closedRoot) strictFail(parser, 'Unclosed root tag')
3982 if ((parser.state !== S.BEGIN) &&
3983 (parser.state !== S.BEGIN_WHITESPACE) &&
3984 (parser.state !== S.TEXT)) {
3985 error(parser, 'Unexpected end')
3986 }
3987 closeText(parser)
3988 parser.c = ''
3989 parser.closed = true
3990 emit(parser, 'onend')
3991 SAXParser.call(parser, parser.strict, parser.opt)
3992 return parser
3993 }
3994
3995 function strictFail (parser, message) {
3996 if (typeof parser !== 'object' || !(parser instanceof SAXParser)) {
3997 throw new Error('bad call to strictFail')
3998 }
3999 if (parser.strict) {
4000 error(parser, message)
4001 }
4002 }
4003
4004 function newTag (parser) {
4005 if (!parser.strict) parser.tagName = parser.tagName[parser.looseCase]()
4006 var parent = parser.tags[parser.tags.length - 1] || parser
4007 var tag = parser.tag = { name: parser.tagName, attributes: {} }
4008
4009 // will be overridden if tag contails an xmlns="foo" or xmlns:foo="bar"
4010 if (parser.opt.xmlns) {
4011 tag.ns = parent.ns
4012 }
4013 parser.attribList.length = 0
4014 emitNode(parser, 'onopentagstart', tag)
4015 }
4016
4017 function qname (name, attribute) {
4018 var i = name.indexOf(':')
4019 var qualName = i < 0 ? [ '', name ] : name.split(':')
4020 var prefix = qualName[0]
4021 var local = qualName[1]
4022
4023 // <x "xmlns"="http://foo">
4024 if (attribute && name === 'xmlns') {
4025 prefix = 'xmlns'
4026 local = ''
4027 }
4028
4029 return { prefix: prefix, local: local }
4030 }
4031
4032 function attrib (parser) {
4033 if (!parser.strict) {
4034 parser.attribName = parser.attribName[parser.looseCase]()
4035 }
4036
4037 if (parser.attribList.indexOf(parser.attribName) !== -1 ||
4038 parser.tag.attributes.hasOwnProperty(parser.attribName)) {
4039 parser.attribName = parser.attribValue = ''
4040 return
4041 }
4042
4043 if (parser.opt.xmlns) {
4044 var qn = qname(parser.attribName, true)
4045 var prefix = qn.prefix
4046 var local = qn.local
4047
4048 if (prefix === 'xmlns') {
4049 // namespace binding attribute. push the binding into scope
4050 if (local === 'xml' && parser.attribValue !== XML_NAMESPACE) {
4051 strictFail(parser,
4052 'xml: prefix must be bound to ' + XML_NAMESPACE + '\n' +
4053 'Actual: ' + parser.attribValue)
4054 } else if (local === 'xmlns' && parser.attribValue !== XMLNS_NAMESPACE) {
4055 strictFail(parser,
4056 'xmlns: prefix must be bound to ' + XMLNS_NAMESPACE + '\n' +
4057 'Actual: ' + parser.attribValue)
4058 } else {
4059 var tag = parser.tag
4060 var parent = parser.tags[parser.tags.length - 1] || parser
4061 if (tag.ns === parent.ns) {
4062 tag.ns = Object.create(parent.ns)
4063 }
4064 tag.ns[local] = parser.attribValue
4065 }
4066 }
4067
4068 // defer onattribute events until all attributes have been seen
4069 // so any new bindings can take effect. preserve attribute order
4070 // so deferred events can be emitted in document order
4071 parser.attribList.push([parser.attribName, parser.attribValue])
4072 } else {
4073 // in non-xmlns mode, we can emit the event right away
4074 parser.tag.attributes[parser.attribName] = parser.attribValue
4075 emitNode(parser, 'onattribute', {
4076 name: parser.attribName,
4077 value: parser.attribValue
4078 })
4079 }
4080
4081 parser.attribName = parser.attribValue = ''
4082 }
4083
4084 function openTag (parser, selfClosing) {
4085 if (parser.opt.xmlns) {
4086 // emit namespace binding events
4087 var tag = parser.tag
4088
4089 // add namespace info to tag
4090 var qn = qname(parser.tagName)
4091 tag.prefix = qn.prefix
4092 tag.local = qn.local
4093 tag.uri = tag.ns[qn.prefix] || ''
4094
4095 if (tag.prefix && !tag.uri) {
4096 strictFail(parser, 'Unbound namespace prefix: ' +
4097 JSON.stringify(parser.tagName))
4098 tag.uri = qn.prefix
4099 }
4100
4101 var parent = parser.tags[parser.tags.length - 1] || parser
4102 if (tag.ns && parent.ns !== tag.ns) {
4103 Object.keys(tag.ns).forEach(function (p) {
4104 emitNode(parser, 'onopennamespace', {
4105 prefix: p,
4106 uri: tag.ns[p]
4107 })
4108 })
4109 }
4110
4111 // handle deferred onattribute events
4112 // Note: do not apply default ns to attributes:
4113 // http://www.w3.org/TR/REC-xml-names/#defaulting
4114 for (var i = 0, l = parser.attribList.length; i < l; i++) {
4115 var nv = parser.attribList[i]
4116 var name = nv[0]
4117 var value = nv[1]
4118 var qualName = qname(name, true)
4119 var prefix = qualName.prefix
4120 var local = qualName.local
4121 var uri = prefix === '' ? '' : (tag.ns[prefix] || '')
4122 var a = {
4123 name: name,
4124 value: value,
4125 prefix: prefix,
4126 local: local,
4127 uri: uri
4128 }
4129
4130 // if there's any attributes with an undefined namespace,
4131 // then fail on them now.
4132 if (prefix && prefix !== 'xmlns' && !uri) {
4133 strictFail(parser, 'Unbound namespace prefix: ' +
4134 JSON.stringify(prefix))
4135 a.uri = prefix
4136 }
4137 parser.tag.attributes[name] = a
4138 emitNode(parser, 'onattribute', a)
4139 }
4140 parser.attribList.length = 0
4141 }
4142
4143 parser.tag.isSelfClosing = !!selfClosing
4144
4145 // process the tag
4146 parser.sawRoot = true
4147 parser.tags.push(parser.tag)
4148 emitNode(parser, 'onopentag', parser.tag)
4149 if (!selfClosing) {
4150 // special case for <script> in non-strict mode.
4151 if (!parser.noscript && parser.tagName.toLowerCase() === 'script') {
4152 parser.state = S.SCRIPT
4153 } else {
4154 parser.state = S.TEXT
4155 }
4156 parser.tag = null
4157 parser.tagName = ''
4158 }
4159 parser.attribName = parser.attribValue = ''
4160 parser.attribList.length = 0
4161 }
4162
4163 function closeTag (parser) {
4164 if (!parser.tagName) {
4165 strictFail(parser, 'Weird empty close tag.')
4166 parser.textNode += '</>'
4167 parser.state = S.TEXT
4168 return
4169 }
4170
4171 if (parser.script) {
4172 if (parser.tagName !== 'script') {
4173 parser.script += '</' + parser.tagName + '>'
4174 parser.tagName = ''
4175 parser.state = S.SCRIPT
4176 return
4177 }
4178 emitNode(parser, 'onscript', parser.script)
4179 parser.script = ''
4180 }
4181
4182 // first make sure that the closing tag actually exists.
4183 // <a><b></c></b></a> will close everything, otherwise.
4184 var t = parser.tags.length
4185 var tagName = parser.tagName
4186 if (!parser.strict) {
4187 tagName = tagName[parser.looseCase]()
4188 }
4189 var closeTo = tagName
4190 while (t--) {
4191 var close = parser.tags[t]
4192 if (close.name !== closeTo) {
4193 // fail the first time in strict mode
4194 strictFail(parser, 'Unexpected close tag')
4195 } else {
4196 break
4197 }
4198 }
4199
4200 // didn't find it. we already failed for strict, so just abort.
4201 if (t < 0) {
4202 strictFail(parser, 'Unmatched closing tag: ' + parser.tagName)
4203 parser.textNode += '</' + parser.tagName + '>'
4204 parser.state = S.TEXT
4205 return
4206 }
4207 parser.tagName = tagName
4208 var s = parser.tags.length
4209 while (s-- > t) {
4210 var tag = parser.tag = parser.tags.pop()
4211 parser.tagName = parser.tag.name
4212 emitNode(parser, 'onclosetag', parser.tagName)
4213
4214 var x = {}
4215 for (var i in tag.ns) {
4216 x[i] = tag.ns[i]
4217 }
4218
4219 var parent = parser.tags[parser.tags.length - 1] || parser
4220 if (parser.opt.xmlns && tag.ns !== parent.ns) {
4221 // remove namespace bindings introduced by tag
4222 Object.keys(tag.ns).forEach(function (p) {
4223 var n = tag.ns[p]
4224 emitNode(parser, 'onclosenamespace', { prefix: p, uri: n })
4225 })
4226 }
4227 }
4228 if (t === 0) parser.closedRoot = true
4229 parser.tagName = parser.attribValue = parser.attribName = ''
4230 parser.attribList.length = 0
4231 parser.state = S.TEXT
4232 }
4233
4234 function parseEntity (parser) {
4235 var entity = parser.entity
4236 var entityLC = entity.toLowerCase()
4237 var num
4238 var numStr = ''
4239
4240 if (parser.ENTITIES[entity]) {
4241 return parser.ENTITIES[entity]
4242 }
4243 if (parser.ENTITIES[entityLC]) {
4244 return parser.ENTITIES[entityLC]
4245 }
4246 entity = entityLC
4247 if (entity.charAt(0) === '#') {
4248 if (entity.charAt(1) === 'x') {
4249 entity = entity.slice(2)
4250 num = parseInt(entity, 16)
4251 numStr = num.toString(16)
4252 } else {
4253 entity = entity.slice(1)
4254 num = parseInt(entity, 10)
4255 numStr = num.toString(10)
4256 }
4257 }
4258 entity = entity.replace(/^0+/, '')
4259 if (numStr.toLowerCase() !== entity) {
4260 strictFail(parser, 'Invalid character entity')
4261 return '&' + parser.entity + ';'
4262 }
4263
4264 return String.fromCodePoint(num)
4265 }
4266
4267 function beginWhiteSpace (parser, c) {
4268 if (c === '<') {
4269 parser.state = S.OPEN_WAKA
4270 parser.startTagPosition = parser.position
4271 } else if (not(whitespace, c)) {
4272 // have to process this as a text node.
4273 // weird, but happens.
4274 strictFail(parser, 'Non-whitespace before first tag.')
4275 parser.textNode = c
4276 parser.state = S.TEXT
4277 }
4278 }
4279
4280 function charAt (chunk, i) {
4281 var result = ''
4282 if (i < chunk.length) {
4283 result = chunk.charAt(i)
4284 }
4285 return result
4286 }
4287
4288 function write (chunk) {
4289 var parser = this
4290 if (this.error) {
4291 throw this.error
4292 }
4293 if (parser.closed) {
4294 return error(parser,
4295 'Cannot write after close. Assign an onready handler.')
4296 }
4297 if (chunk === null) {
4298 return end(parser)
4299 }
4300 if (typeof chunk === 'object') {
4301 chunk = chunk.toString()
4302 }
4303 var i = 0
4304 var c = ''
4305 while (true) {
4306 c = charAt(chunk, i++)
4307 parser.c = c
4308 if (!c) {
4309 break
4310 }
4311 if (parser.trackPosition) {
4312 parser.position++
4313 if (c === '\n') {
4314 parser.line++
4315 parser.column = 0
4316 } else {
4317 parser.column++
4318 }
4319 }
4320 switch (parser.state) {
4321 case S.BEGIN:
4322 parser.state = S.BEGIN_WHITESPACE
4323 if (c === '\uFEFF') {
4324 continue
4325 }
4326 beginWhiteSpace(parser, c)
4327 continue
4328
4329 case S.BEGIN_WHITESPACE:
4330 beginWhiteSpace(parser, c)
4331 continue
4332
4333 case S.TEXT:
4334 if (parser.sawRoot && !parser.closedRoot) {
4335 var starti = i - 1
4336 while (c && c !== '<' && c !== '&') {
4337 c = charAt(chunk, i++)
4338 if (c && parser.trackPosition) {
4339 parser.position++
4340 if (c === '\n') {
4341 parser.line++
4342 parser.column = 0
4343 } else {
4344 parser.column++
4345 }
4346 }
4347 }
4348 parser.textNode += chunk.substring(starti, i - 1)
4349 }
4350 if (c === '<' && !(parser.sawRoot && parser.closedRoot && !parser.strict)) {
4351 parser.state = S.OPEN_WAKA
4352 parser.startTagPosition = parser.position
4353 } else {
4354 if (not(whitespace, c) && (!parser.sawRoot || parser.closedRoot)) {
4355 strictFail(parser, 'Text data outside of root node.')
4356 }
4357 if (c === '&') {
4358 parser.state = S.TEXT_ENTITY
4359 } else {
4360 parser.textNode += c
4361 }
4362 }
4363 continue
4364
4365 case S.SCRIPT:
4366 // only non-strict
4367 if (c === '<') {
4368 parser.state = S.SCRIPT_ENDING
4369 } else {
4370 parser.script += c
4371 }
4372 continue
4373
4374 case S.SCRIPT_ENDING:
4375 if (c === '/') {
4376 parser.state = S.CLOSE_TAG
4377 } else {
4378 parser.script += '<' + c
4379 parser.state = S.SCRIPT
4380 }
4381 continue
4382
4383 case S.OPEN_WAKA:
4384 // either a /, ?, !, or text is coming next.
4385 if (c === '!') {
4386 parser.state = S.SGML_DECL
4387 parser.sgmlDecl = ''
4388 } else if (is(whitespace, c)) {
4389 // wait for it...
4390 } else if (is(nameStart, c)) {
4391 parser.state = S.OPEN_TAG
4392 parser.tagName = c
4393 } else if (c === '/') {
4394 parser.state = S.CLOSE_TAG
4395 parser.tagName = ''
4396 } else if (c === '?') {
4397 parser.state = S.PROC_INST
4398 parser.procInstName = parser.procInstBody = ''
4399 } else {
4400 strictFail(parser, 'Unencoded <')
4401 // if there was some whitespace, then add that in.
4402 if (parser.startTagPosition + 1 < parser.position) {
4403 var pad = parser.position - parser.startTagPosition
4404 c = new Array(pad).join(' ') + c
4405 }
4406 parser.textNode += '<' + c
4407 parser.state = S.TEXT
4408 }
4409 continue
4410
4411 case S.SGML_DECL:
4412 if ((parser.sgmlDecl + c).toUpperCase() === CDATA) {
4413 emitNode(parser, 'onopencdata')
4414 parser.state = S.CDATA
4415 parser.sgmlDecl = ''
4416 parser.cdata = ''
4417 } else if (parser.sgmlDecl + c === '--') {
4418 parser.state = S.COMMENT
4419 parser.comment = ''
4420 parser.sgmlDecl = ''
4421 } else if ((parser.sgmlDecl + c).toUpperCase() === DOCTYPE) {
4422 parser.state = S.DOCTYPE
4423 if (parser.doctype || parser.sawRoot) {
4424 strictFail(parser,
4425 'Inappropriately located doctype declaration')
4426 }
4427 parser.doctype = ''
4428 parser.sgmlDecl = ''
4429 } else if (c === '>') {
4430 emitNode(parser, 'onsgmldeclaration', parser.sgmlDecl)
4431 parser.sgmlDecl = ''
4432 parser.state = S.TEXT
4433 } else if (is(quote, c)) {
4434 parser.state = S.SGML_DECL_QUOTED
4435 parser.sgmlDecl += c
4436 } else {
4437 parser.sgmlDecl += c
4438 }
4439 continue
4440
4441 case S.SGML_DECL_QUOTED:
4442 if (c === parser.q) {
4443 parser.state = S.SGML_DECL
4444 parser.q = ''
4445 }
4446 parser.sgmlDecl += c
4447 continue
4448
4449 case S.DOCTYPE:
4450 if (c === '>') {
4451 parser.state = S.TEXT
4452 emitNode(parser, 'ondoctype', parser.doctype)
4453 parser.doctype = true // just remember that we saw it.
4454 } else {
4455 parser.doctype += c
4456 if (c === '[') {
4457 parser.state = S.DOCTYPE_DTD
4458 } else if (is(quote, c)) {
4459 parser.state = S.DOCTYPE_QUOTED
4460 parser.q = c
4461 }
4462 }
4463 continue
4464
4465 case S.DOCTYPE_QUOTED:
4466 parser.doctype += c
4467 if (c === parser.q) {
4468 parser.q = ''
4469 parser.state = S.DOCTYPE
4470 }
4471 continue
4472
4473 case S.DOCTYPE_DTD:
4474 parser.doctype += c
4475 if (c === ']') {
4476 parser.state = S.DOCTYPE
4477 } else if (is(quote, c)) {
4478 parser.state = S.DOCTYPE_DTD_QUOTED
4479 parser.q = c
4480 }
4481 continue
4482
4483 case S.DOCTYPE_DTD_QUOTED:
4484 parser.doctype += c
4485 if (c === parser.q) {
4486 parser.state = S.DOCTYPE_DTD
4487 parser.q = ''
4488 }
4489 continue
4490
4491 case S.COMMENT:
4492 if (c === '-') {
4493 parser.state = S.COMMENT_ENDING
4494 } else {
4495 parser.comment += c
4496 }
4497 continue
4498
4499 case S.COMMENT_ENDING:
4500 if (c === '-') {
4501 parser.state = S.COMMENT_ENDED
4502 parser.comment = textopts(parser.opt, parser.comment)
4503 if (parser.comment) {
4504 emitNode(parser, 'oncomment', parser.comment)
4505 }
4506 parser.comment = ''
4507 } else {
4508 parser.comment += '-' + c
4509 parser.state = S.COMMENT
4510 }
4511 continue
4512
4513 case S.COMMENT_ENDED:
4514 if (c !== '>') {
4515 strictFail(parser, 'Malformed comment')
4516 // allow <!-- blah -- bloo --> in non-strict mode,
4517 // which is a comment of " blah -- bloo "
4518 parser.comment += '--' + c
4519 parser.state = S.COMMENT
4520 } else {
4521 parser.state = S.TEXT
4522 }
4523 continue
4524
4525 case S.CDATA:
4526 if (c === ']') {
4527 parser.state = S.CDATA_ENDING
4528 } else {
4529 parser.cdata += c
4530 }
4531 continue
4532
4533 case S.CDATA_ENDING:
4534 if (c === ']') {
4535 parser.state = S.CDATA_ENDING_2
4536 } else {
4537 parser.cdata += ']' + c
4538 parser.state = S.CDATA
4539 }
4540 continue
4541
4542 case S.CDATA_ENDING_2:
4543 if (c === '>') {
4544 if (parser.cdata) {
4545 emitNode(parser, 'oncdata', parser.cdata)
4546 }
4547 emitNode(parser, 'onclosecdata')
4548 parser.cdata = ''
4549 parser.state = S.TEXT
4550 } else if (c === ']') {
4551 parser.cdata += ']'
4552 } else {
4553 parser.cdata += ']]' + c
4554 parser.state = S.CDATA
4555 }
4556 continue
4557
4558 case S.PROC_INST:
4559 if (c === '?') {
4560 parser.state = S.PROC_INST_ENDING
4561 } else if (is(whitespace, c)) {
4562 parser.state = S.PROC_INST_BODY
4563 } else {
4564 parser.procInstName += c
4565 }
4566 continue
4567
4568 case S.PROC_INST_BODY:
4569 if (!parser.procInstBody && is(whitespace, c)) {
4570 continue
4571 } else if (c === '?') {
4572 parser.state = S.PROC_INST_ENDING
4573 } else {
4574 parser.procInstBody += c
4575 }
4576 continue
4577
4578 case S.PROC_INST_ENDING:
4579 if (c === '>') {
4580 emitNode(parser, 'onprocessinginstruction', {
4581 name: parser.procInstName,
4582 body: parser.procInstBody
4583 })
4584 parser.procInstName = parser.procInstBody = ''
4585 parser.state = S.TEXT
4586 } else {
4587 parser.procInstBody += '?' + c
4588 parser.state = S.PROC_INST_BODY
4589 }
4590 continue
4591
4592 case S.OPEN_TAG:
4593 if (is(nameBody, c)) {
4594 parser.tagName += c
4595 } else {
4596 newTag(parser)
4597 if (c === '>') {
4598 openTag(parser)
4599 } else if (c === '/') {
4600 parser.state = S.OPEN_TAG_SLASH
4601 } else {
4602 if (not(whitespace, c)) {
4603 strictFail(parser, 'Invalid character in tag name')
4604 }
4605 parser.state = S.ATTRIB
4606 }
4607 }
4608 continue
4609
4610 case S.OPEN_TAG_SLASH:
4611 if (c === '>') {
4612 openTag(parser, true)
4613 closeTag(parser)
4614 } else {
4615 strictFail(parser, 'Forward-slash in opening tag not followed by >')
4616 parser.state = S.ATTRIB
4617 }
4618 continue
4619
4620 case S.ATTRIB:
4621 // haven't read the attribute name yet.
4622 if (is(whitespace, c)) {
4623 continue
4624 } else if (c === '>') {
4625 openTag(parser)
4626 } else if (c === '/') {
4627 parser.state = S.OPEN_TAG_SLASH
4628 } else if (is(nameStart, c)) {
4629 parser.attribName = c
4630 parser.attribValue = ''
4631 parser.state = S.ATTRIB_NAME
4632 } else {
4633 strictFail(parser, 'Invalid attribute name')
4634 }
4635 continue
4636
4637 case S.ATTRIB_NAME:
4638 if (c === '=') {
4639 parser.state = S.ATTRIB_VALUE
4640 } else if (c === '>') {
4641 strictFail(parser, 'Attribute without value')
4642 parser.attribValue = parser.attribName
4643 attrib(parser)
4644 openTag(parser)
4645 } else if (is(whitespace, c)) {
4646 parser.state = S.ATTRIB_NAME_SAW_WHITE
4647 } else if (is(nameBody, c)) {
4648 parser.attribName += c
4649 } else {
4650 strictFail(parser, 'Invalid attribute name')
4651 }
4652 continue
4653
4654 case S.ATTRIB_NAME_SAW_WHITE:
4655 if (c === '=') {
4656 parser.state = S.ATTRIB_VALUE
4657 } else if (is(whitespace, c)) {
4658 continue
4659 } else {
4660 strictFail(parser, 'Attribute without value')
4661 parser.tag.attributes[parser.attribName] = ''
4662 parser.attribValue = ''
4663 emitNode(parser, 'onattribute', {
4664 name: parser.attribName,
4665 value: ''
4666 })
4667 parser.attribName = ''
4668 if (c === '>') {
4669 openTag(parser)
4670 } else if (is(nameStart, c)) {
4671 parser.attribName = c
4672 parser.state = S.ATTRIB_NAME
4673 } else {
4674 strictFail(parser, 'Invalid attribute name')
4675 parser.state = S.ATTRIB
4676 }
4677 }
4678 continue
4679
4680 case S.ATTRIB_VALUE:
4681 if (is(whitespace, c)) {
4682 continue
4683 } else if (is(quote, c)) {
4684 parser.q = c
4685 parser.state = S.ATTRIB_VALUE_QUOTED
4686 } else {
4687 strictFail(parser, 'Unquoted attribute value')
4688 parser.state = S.ATTRIB_VALUE_UNQUOTED
4689 parser.attribValue = c
4690 }
4691 continue
4692
4693 case S.ATTRIB_VALUE_QUOTED:
4694 if (c !== parser.q) {
4695 if (c === '&') {
4696 parser.state = S.ATTRIB_VALUE_ENTITY_Q
4697 } else {
4698 parser.attribValue += c
4699 }
4700 continue
4701 }
4702 attrib(parser)
4703 parser.q = ''
4704 parser.state = S.ATTRIB_VALUE_CLOSED
4705 continue
4706
4707 case S.ATTRIB_VALUE_CLOSED:
4708 if (is(whitespace, c)) {
4709 parser.state = S.ATTRIB
4710 } else if (c === '>') {
4711 openTag(parser)
4712 } else if (c === '/') {
4713 parser.state = S.OPEN_TAG_SLASH
4714 } else if (is(nameStart, c)) {
4715 strictFail(parser, 'No whitespace between attributes')
4716 parser.attribName = c
4717 parser.attribValue = ''
4718 parser.state = S.ATTRIB_NAME
4719 } else {
4720 strictFail(parser, 'Invalid attribute name')
4721 }
4722 continue
4723
4724 case S.ATTRIB_VALUE_UNQUOTED:
4725 if (not(attribEnd, c)) {
4726 if (c === '&') {
4727 parser.state = S.ATTRIB_VALUE_ENTITY_U
4728 } else {
4729 parser.attribValue += c
4730 }
4731 continue
4732 }
4733 attrib(parser)
4734 if (c === '>') {
4735 openTag(parser)
4736 } else {
4737 parser.state = S.ATTRIB
4738 }
4739 continue
4740
4741 case S.CLOSE_TAG:
4742 if (!parser.tagName) {
4743 if (is(whitespace, c)) {
4744 continue
4745 } else if (not(nameStart, c)) {
4746 if (parser.script) {
4747 parser.script += '</' + c
4748 parser.state = S.SCRIPT
4749 } else {
4750 strictFail(parser, 'Invalid tagname in closing tag.')
4751 }
4752 } else {
4753 parser.tagName = c
4754 }
4755 } else if (c === '>') {
4756 closeTag(parser)
4757 } else if (is(nameBody, c)) {
4758 parser.tagName += c
4759 } else if (parser.script) {
4760 parser.script += '</' + parser.tagName
4761 parser.tagName = ''
4762 parser.state = S.SCRIPT
4763 } else {
4764 if (not(whitespace, c)) {
4765 strictFail(parser, 'Invalid tagname in closing tag')
4766 }
4767 parser.state = S.CLOSE_TAG_SAW_WHITE
4768 }
4769 continue
4770
4771 case S.CLOSE_TAG_SAW_WHITE:
4772 if (is(whitespace, c)) {
4773 continue
4774 }
4775 if (c === '>') {
4776 closeTag(parser)
4777 } else {
4778 strictFail(parser, 'Invalid characters in closing tag')
4779 }
4780 continue
4781
4782 case S.TEXT_ENTITY:
4783 case S.ATTRIB_VALUE_ENTITY_Q:
4784 case S.ATTRIB_VALUE_ENTITY_U:
4785 var returnState
4786 var buffer
4787 switch (parser.state) {
4788 case S.TEXT_ENTITY:
4789 returnState = S.TEXT
4790 buffer = 'textNode'
4791 break
4792
4793 case S.ATTRIB_VALUE_ENTITY_Q:
4794 returnState = S.ATTRIB_VALUE_QUOTED
4795 buffer = 'attribValue'
4796 break
4797
4798 case S.ATTRIB_VALUE_ENTITY_U:
4799 returnState = S.ATTRIB_VALUE_UNQUOTED
4800 buffer = 'attribValue'
4801 break
4802 }
4803
4804 if (c === ';') {
4805 parser[buffer] += parseEntity(parser)
4806 parser.entity = ''
4807 parser.state = returnState
4808 } else if (is(parser.entity.length ? entityBody : entityStart, c)) {
4809 parser.entity += c
4810 } else {
4811 strictFail(parser, 'Invalid character in entity name')
4812 parser[buffer] += '&' + parser.entity + c
4813 parser.entity = ''
4814 parser.state = returnState
4815 }
4816
4817 continue
4818
4819 default:
4820 throw new Error(parser, 'Unknown state: ' + parser.state)
4821 }
4822 } // while
4823
4824 if (parser.position >= parser.bufferCheckPosition) {
4825 checkBufferLength(parser)
4826 }
4827 return parser
4828 }
4829
4830 /*! http://mths.be/fromcodepoint v0.1.0 by @mathias */
4831 if (!String.fromCodePoint) {
4832 (function () {
4833 var stringFromCharCode = String.fromCharCode
4834 var floor = Math.floor
4835 var fromCodePoint = function () {
4836 var MAX_SIZE = 0x4000
4837 var codeUnits = []
4838 var highSurrogate
4839 var lowSurrogate
4840 var index = -1
4841 var length = arguments.length
4842 if (!length) {
4843 return ''
4844 }
4845 var result = ''
4846 while (++index < length) {
4847 var codePoint = Number(arguments[index])
4848 if (
4849 !isFinite(codePoint) || // `NaN`, `+Infinity`, or `-Infinity`
4850 codePoint < 0 || // not a valid Unicode code point
4851 codePoint > 0x10FFFF || // not a valid Unicode code point
4852 floor(codePoint) !== codePoint // not an integer
4853 ) {
4854 throw RangeError('Invalid code point: ' + codePoint)
4855 }
4856 if (codePoint <= 0xFFFF) { // BMP code point
4857 codeUnits.push(codePoint)
4858 } else { // Astral code point; split in surrogate halves
4859 // http://mathiasbynens.be/notes/javascript-encoding#surrogate-formulae
4860 codePoint -= 0x10000
4861 highSurrogate = (codePoint >> 10) + 0xD800
4862 lowSurrogate = (codePoint % 0x400) + 0xDC00
4863 codeUnits.push(highSurrogate, lowSurrogate)
4864 }
4865 if (index + 1 === length || codeUnits.length > MAX_SIZE) {
4866 result += stringFromCharCode.apply(null, codeUnits)
4867 codeUnits.length = 0
4868 }
4869 }
4870 return result
4871 }
4872 if (Object.defineProperty) {
4873 Object.defineProperty(String, 'fromCodePoint', {
4874 value: fromCodePoint,
4875 configurable: true,
4876 writable: true
4877 })
4878 } else {
4879 String.fromCodePoint = fromCodePoint
4880 }
4881 }())
4882 }
4883 })( false ? this.sax = {} : exports)
4884
4885 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(28).Buffer))
4886
4887/***/ }),
4888/* 28 */
4889/***/ (function(module, exports, __webpack_require__) {
4890
4891 /* WEBPACK VAR INJECTION */(function(global) {/*!
4892 * The buffer module from node.js, for the browser.
4893 *
4894 * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
4895 * @license MIT
4896 */
4897 /* eslint-disable no-proto */
4898
4899 'use strict'
4900
4901 var base64 = __webpack_require__(29)
4902 var ieee754 = __webpack_require__(30)
4903 var isArray = __webpack_require__(31)
4904
4905 exports.Buffer = Buffer
4906 exports.SlowBuffer = SlowBuffer
4907 exports.INSPECT_MAX_BYTES = 50
4908
4909 /**
4910 * If `Buffer.TYPED_ARRAY_SUPPORT`:
4911 * === true Use Uint8Array implementation (fastest)
4912 * === false Use Object implementation (most compatible, even IE6)
4913 *
4914 * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
4915 * Opera 11.6+, iOS 4.2+.
4916 *
4917 * Due to various browser bugs, sometimes the Object implementation will be used even
4918 * when the browser supports typed arrays.
4919 *
4920 * Note:
4921 *
4922 * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
4923 * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
4924 *
4925 * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
4926 *
4927 * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
4928 * incorrect length in some situations.
4929
4930 * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
4931 * get the Object implementation, which is slower but behaves correctly.
4932 */
4933 Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
4934 ? global.TYPED_ARRAY_SUPPORT
4935 : typedArraySupport()
4936
4937 /*
4938 * Export kMaxLength after typed array support is determined.
4939 */
4940 exports.kMaxLength = kMaxLength()
4941
4942 function typedArraySupport () {
4943 try {
4944 var arr = new Uint8Array(1)
4945 arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
4946 return arr.foo() === 42 && // typed array instances can be augmented
4947 typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
4948 arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
4949 } catch (e) {
4950 return false
4951 }
4952 }
4953
4954 function kMaxLength () {
4955 return Buffer.TYPED_ARRAY_SUPPORT
4956 ? 0x7fffffff
4957 : 0x3fffffff
4958 }
4959
4960 function createBuffer (that, length) {
4961 if (kMaxLength() < length) {
4962 throw new RangeError('Invalid typed array length')
4963 }
4964 if (Buffer.TYPED_ARRAY_SUPPORT) {
4965 // Return an augmented `Uint8Array` instance, for best performance
4966 that = new Uint8Array(length)
4967 that.__proto__ = Buffer.prototype
4968 } else {
4969 // Fallback: Return an object instance of the Buffer class
4970 if (that === null) {
4971 that = new Buffer(length)
4972 }
4973 that.length = length
4974 }
4975
4976 return that
4977 }
4978
4979 /**
4980 * The Buffer constructor returns instances of `Uint8Array` that have their
4981 * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
4982 * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
4983 * and the `Uint8Array` methods. Square bracket notation works as expected -- it
4984 * returns a single octet.
4985 *
4986 * The `Uint8Array` prototype remains unmodified.
4987 */
4988
4989 function Buffer (arg, encodingOrOffset, length) {
4990 if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
4991 return new Buffer(arg, encodingOrOffset, length)
4992 }
4993
4994 // Common case.
4995 if (typeof arg === 'number') {
4996 if (typeof encodingOrOffset === 'string') {
4997 throw new Error(
4998 'If encoding is specified then the first argument must be a string'
4999 )
5000 }
5001 return allocUnsafe(this, arg)
5002 }
5003 return from(this, arg, encodingOrOffset, length)
5004 }
5005
5006 Buffer.poolSize = 8192 // not used by this implementation
5007
5008 // TODO: Legacy, not needed anymore. Remove in next major version.
5009 Buffer._augment = function (arr) {
5010 arr.__proto__ = Buffer.prototype
5011 return arr
5012 }
5013
5014 function from (that, value, encodingOrOffset, length) {
5015 if (typeof value === 'number') {
5016 throw new TypeError('"value" argument must not be a number')
5017 }
5018
5019 if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
5020 return fromArrayBuffer(that, value, encodingOrOffset, length)
5021 }
5022
5023 if (typeof value === 'string') {
5024 return fromString(that, value, encodingOrOffset)
5025 }
5026
5027 return fromObject(that, value)
5028 }
5029
5030 /**
5031 * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
5032 * if value is a number.
5033 * Buffer.from(str[, encoding])
5034 * Buffer.from(array)
5035 * Buffer.from(buffer)
5036 * Buffer.from(arrayBuffer[, byteOffset[, length]])
5037 **/
5038 Buffer.from = function (value, encodingOrOffset, length) {
5039 return from(null, value, encodingOrOffset, length)
5040 }
5041
5042 if (Buffer.TYPED_ARRAY_SUPPORT) {
5043 Buffer.prototype.__proto__ = Uint8Array.prototype
5044 Buffer.__proto__ = Uint8Array
5045 if (typeof Symbol !== 'undefined' && Symbol.species &&
5046 Buffer[Symbol.species] === Buffer) {
5047 // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
5048 Object.defineProperty(Buffer, Symbol.species, {
5049 value: null,
5050 configurable: true
5051 })
5052 }
5053 }
5054
5055 function assertSize (size) {
5056 if (typeof size !== 'number') {
5057 throw new TypeError('"size" argument must be a number')
5058 } else if (size < 0) {
5059 throw new RangeError('"size" argument must not be negative')
5060 }
5061 }
5062
5063 function alloc (that, size, fill, encoding) {
5064 assertSize(size)
5065 if (size <= 0) {
5066 return createBuffer(that, size)
5067 }
5068 if (fill !== undefined) {
5069 // Only pay attention to encoding if it's a string. This
5070 // prevents accidentally sending in a number that would
5071 // be interpretted as a start offset.
5072 return typeof encoding === 'string'
5073 ? createBuffer(that, size).fill(fill, encoding)
5074 : createBuffer(that, size).fill(fill)
5075 }
5076 return createBuffer(that, size)
5077 }
5078
5079 /**
5080 * Creates a new filled Buffer instance.
5081 * alloc(size[, fill[, encoding]])
5082 **/
5083 Buffer.alloc = function (size, fill, encoding) {
5084 return alloc(null, size, fill, encoding)
5085 }
5086
5087 function allocUnsafe (that, size) {
5088 assertSize(size)
5089 that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
5090 if (!Buffer.TYPED_ARRAY_SUPPORT) {
5091 for (var i = 0; i < size; ++i) {
5092 that[i] = 0
5093 }
5094 }
5095 return that
5096 }
5097
5098 /**
5099 * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
5100 * */
5101 Buffer.allocUnsafe = function (size) {
5102 return allocUnsafe(null, size)
5103 }
5104 /**
5105 * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
5106 */
5107 Buffer.allocUnsafeSlow = function (size) {
5108 return allocUnsafe(null, size)
5109 }
5110
5111 function fromString (that, string, encoding) {
5112 if (typeof encoding !== 'string' || encoding === '') {
5113 encoding = 'utf8'
5114 }
5115
5116 if (!Buffer.isEncoding(encoding)) {
5117 throw new TypeError('"encoding" must be a valid string encoding')
5118 }
5119
5120 var length = byteLength(string, encoding) | 0
5121 that = createBuffer(that, length)
5122
5123 var actual = that.write(string, encoding)
5124
5125 if (actual !== length) {
5126 // Writing a hex string, for example, that contains invalid characters will
5127 // cause everything after the first invalid character to be ignored. (e.g.
5128 // 'abxxcd' will be treated as 'ab')
5129 that = that.slice(0, actual)
5130 }
5131
5132 return that
5133 }
5134
5135 function fromArrayLike (that, array) {
5136 var length = array.length < 0 ? 0 : checked(array.length) | 0
5137 that = createBuffer(that, length)
5138 for (var i = 0; i < length; i += 1) {
5139 that[i] = array[i] & 255
5140 }
5141 return that
5142 }
5143
5144 function fromArrayBuffer (that, array, byteOffset, length) {
5145 array.byteLength // this throws if `array` is not a valid ArrayBuffer
5146
5147 if (byteOffset < 0 || array.byteLength < byteOffset) {
5148 throw new RangeError('\'offset\' is out of bounds')
5149 }
5150
5151 if (array.byteLength < byteOffset + (length || 0)) {
5152 throw new RangeError('\'length\' is out of bounds')
5153 }
5154
5155 if (byteOffset === undefined && length === undefined) {
5156 array = new Uint8Array(array)
5157 } else if (length === undefined) {
5158 array = new Uint8Array(array, byteOffset)
5159 } else {
5160 array = new Uint8Array(array, byteOffset, length)
5161 }
5162
5163 if (Buffer.TYPED_ARRAY_SUPPORT) {
5164 // Return an augmented `Uint8Array` instance, for best performance
5165 that = array
5166 that.__proto__ = Buffer.prototype
5167 } else {
5168 // Fallback: Return an object instance of the Buffer class
5169 that = fromArrayLike(that, array)
5170 }
5171 return that
5172 }
5173
5174 function fromObject (that, obj) {
5175 if (Buffer.isBuffer(obj)) {
5176 var len = checked(obj.length) | 0
5177 that = createBuffer(that, len)
5178
5179 if (that.length === 0) {
5180 return that
5181 }
5182
5183 obj.copy(that, 0, 0, len)
5184 return that
5185 }
5186
5187 if (obj) {
5188 if ((typeof ArrayBuffer !== 'undefined' &&
5189 obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
5190 if (typeof obj.length !== 'number' || isnan(obj.length)) {
5191 return createBuffer(that, 0)
5192 }
5193 return fromArrayLike(that, obj)
5194 }
5195
5196 if (obj.type === 'Buffer' && isArray(obj.data)) {
5197 return fromArrayLike(that, obj.data)
5198 }
5199 }
5200
5201 throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
5202 }
5203
5204 function checked (length) {
5205 // Note: cannot use `length < kMaxLength()` here because that fails when
5206 // length is NaN (which is otherwise coerced to zero.)
5207 if (length >= kMaxLength()) {
5208 throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
5209 'size: 0x' + kMaxLength().toString(16) + ' bytes')
5210 }
5211 return length | 0
5212 }
5213
5214 function SlowBuffer (length) {
5215 if (+length != length) { // eslint-disable-line eqeqeq
5216 length = 0
5217 }
5218 return Buffer.alloc(+length)
5219 }
5220
5221 Buffer.isBuffer = function isBuffer (b) {
5222 return !!(b != null && b._isBuffer)
5223 }
5224
5225 Buffer.compare = function compare (a, b) {
5226 if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
5227 throw new TypeError('Arguments must be Buffers')
5228 }
5229
5230 if (a === b) return 0
5231
5232 var x = a.length
5233 var y = b.length
5234
5235 for (var i = 0, len = Math.min(x, y); i < len; ++i) {
5236 if (a[i] !== b[i]) {
5237 x = a[i]
5238 y = b[i]
5239 break
5240 }
5241 }
5242
5243 if (x < y) return -1
5244 if (y < x) return 1
5245 return 0
5246 }
5247
5248 Buffer.isEncoding = function isEncoding (encoding) {
5249 switch (String(encoding).toLowerCase()) {
5250 case 'hex':
5251 case 'utf8':
5252 case 'utf-8':
5253 case 'ascii':
5254 case 'latin1':
5255 case 'binary':
5256 case 'base64':
5257 case 'ucs2':
5258 case 'ucs-2':
5259 case 'utf16le':
5260 case 'utf-16le':
5261 return true
5262 default:
5263 return false
5264 }
5265 }
5266
5267 Buffer.concat = function concat (list, length) {
5268 if (!isArray(list)) {
5269 throw new TypeError('"list" argument must be an Array of Buffers')
5270 }
5271
5272 if (list.length === 0) {
5273 return Buffer.alloc(0)
5274 }
5275
5276 var i
5277 if (length === undefined) {
5278 length = 0
5279 for (i = 0; i < list.length; ++i) {
5280 length += list[i].length
5281 }
5282 }
5283
5284 var buffer = Buffer.allocUnsafe(length)
5285 var pos = 0
5286 for (i = 0; i < list.length; ++i) {
5287 var buf = list[i]
5288 if (!Buffer.isBuffer(buf)) {
5289 throw new TypeError('"list" argument must be an Array of Buffers')
5290 }
5291 buf.copy(buffer, pos)
5292 pos += buf.length
5293 }
5294 return buffer
5295 }
5296
5297 function byteLength (string, encoding) {
5298 if (Buffer.isBuffer(string)) {
5299 return string.length
5300 }
5301 if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
5302 (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
5303 return string.byteLength
5304 }
5305 if (typeof string !== 'string') {
5306 string = '' + string
5307 }
5308
5309 var len = string.length
5310 if (len === 0) return 0
5311
5312 // Use a for loop to avoid recursion
5313 var loweredCase = false
5314 for (;;) {
5315 switch (encoding) {
5316 case 'ascii':
5317 case 'latin1':
5318 case 'binary':
5319 return len
5320 case 'utf8':
5321 case 'utf-8':
5322 case undefined:
5323 return utf8ToBytes(string).length
5324 case 'ucs2':
5325 case 'ucs-2':
5326 case 'utf16le':
5327 case 'utf-16le':
5328 return len * 2
5329 case 'hex':
5330 return len >>> 1
5331 case 'base64':
5332 return base64ToBytes(string).length
5333 default:
5334 if (loweredCase) return utf8ToBytes(string).length // assume utf8
5335 encoding = ('' + encoding).toLowerCase()
5336 loweredCase = true
5337 }
5338 }
5339 }
5340 Buffer.byteLength = byteLength
5341
5342 function slowToString (encoding, start, end) {
5343 var loweredCase = false
5344
5345 // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
5346 // property of a typed array.
5347
5348 // This behaves neither like String nor Uint8Array in that we set start/end
5349 // to their upper/lower bounds if the value passed is out of range.
5350 // undefined is handled specially as per ECMA-262 6th Edition,
5351 // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
5352 if (start === undefined || start < 0) {
5353 start = 0
5354 }
5355 // Return early if start > this.length. Done here to prevent potential uint32
5356 // coercion fail below.
5357 if (start > this.length) {
5358 return ''
5359 }
5360
5361 if (end === undefined || end > this.length) {
5362 end = this.length
5363 }
5364
5365 if (end <= 0) {
5366 return ''
5367 }
5368
5369 // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
5370 end >>>= 0
5371 start >>>= 0
5372
5373 if (end <= start) {
5374 return ''
5375 }
5376
5377 if (!encoding) encoding = 'utf8'
5378
5379 while (true) {
5380 switch (encoding) {
5381 case 'hex':
5382 return hexSlice(this, start, end)
5383
5384 case 'utf8':
5385 case 'utf-8':
5386 return utf8Slice(this, start, end)
5387
5388 case 'ascii':
5389 return asciiSlice(this, start, end)
5390
5391 case 'latin1':
5392 case 'binary':
5393 return latin1Slice(this, start, end)
5394
5395 case 'base64':
5396 return base64Slice(this, start, end)
5397
5398 case 'ucs2':
5399 case 'ucs-2':
5400 case 'utf16le':
5401 case 'utf-16le':
5402 return utf16leSlice(this, start, end)
5403
5404 default:
5405 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5406 encoding = (encoding + '').toLowerCase()
5407 loweredCase = true
5408 }
5409 }
5410 }
5411
5412 // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
5413 // Buffer instances.
5414 Buffer.prototype._isBuffer = true
5415
5416 function swap (b, n, m) {
5417 var i = b[n]
5418 b[n] = b[m]
5419 b[m] = i
5420 }
5421
5422 Buffer.prototype.swap16 = function swap16 () {
5423 var len = this.length
5424 if (len % 2 !== 0) {
5425 throw new RangeError('Buffer size must be a multiple of 16-bits')
5426 }
5427 for (var i = 0; i < len; i += 2) {
5428 swap(this, i, i + 1)
5429 }
5430 return this
5431 }
5432
5433 Buffer.prototype.swap32 = function swap32 () {
5434 var len = this.length
5435 if (len % 4 !== 0) {
5436 throw new RangeError('Buffer size must be a multiple of 32-bits')
5437 }
5438 for (var i = 0; i < len; i += 4) {
5439 swap(this, i, i + 3)
5440 swap(this, i + 1, i + 2)
5441 }
5442 return this
5443 }
5444
5445 Buffer.prototype.swap64 = function swap64 () {
5446 var len = this.length
5447 if (len % 8 !== 0) {
5448 throw new RangeError('Buffer size must be a multiple of 64-bits')
5449 }
5450 for (var i = 0; i < len; i += 8) {
5451 swap(this, i, i + 7)
5452 swap(this, i + 1, i + 6)
5453 swap(this, i + 2, i + 5)
5454 swap(this, i + 3, i + 4)
5455 }
5456 return this
5457 }
5458
5459 Buffer.prototype.toString = function toString () {
5460 var length = this.length | 0
5461 if (length === 0) return ''
5462 if (arguments.length === 0) return utf8Slice(this, 0, length)
5463 return slowToString.apply(this, arguments)
5464 }
5465
5466 Buffer.prototype.equals = function equals (b) {
5467 if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
5468 if (this === b) return true
5469 return Buffer.compare(this, b) === 0
5470 }
5471
5472 Buffer.prototype.inspect = function inspect () {
5473 var str = ''
5474 var max = exports.INSPECT_MAX_BYTES
5475 if (this.length > 0) {
5476 str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
5477 if (this.length > max) str += ' ... '
5478 }
5479 return '<Buffer ' + str + '>'
5480 }
5481
5482 Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
5483 if (!Buffer.isBuffer(target)) {
5484 throw new TypeError('Argument must be a Buffer')
5485 }
5486
5487 if (start === undefined) {
5488 start = 0
5489 }
5490 if (end === undefined) {
5491 end = target ? target.length : 0
5492 }
5493 if (thisStart === undefined) {
5494 thisStart = 0
5495 }
5496 if (thisEnd === undefined) {
5497 thisEnd = this.length
5498 }
5499
5500 if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
5501 throw new RangeError('out of range index')
5502 }
5503
5504 if (thisStart >= thisEnd && start >= end) {
5505 return 0
5506 }
5507 if (thisStart >= thisEnd) {
5508 return -1
5509 }
5510 if (start >= end) {
5511 return 1
5512 }
5513
5514 start >>>= 0
5515 end >>>= 0
5516 thisStart >>>= 0
5517 thisEnd >>>= 0
5518
5519 if (this === target) return 0
5520
5521 var x = thisEnd - thisStart
5522 var y = end - start
5523 var len = Math.min(x, y)
5524
5525 var thisCopy = this.slice(thisStart, thisEnd)
5526 var targetCopy = target.slice(start, end)
5527
5528 for (var i = 0; i < len; ++i) {
5529 if (thisCopy[i] !== targetCopy[i]) {
5530 x = thisCopy[i]
5531 y = targetCopy[i]
5532 break
5533 }
5534 }
5535
5536 if (x < y) return -1
5537 if (y < x) return 1
5538 return 0
5539 }
5540
5541 // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
5542 // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
5543 //
5544 // Arguments:
5545 // - buffer - a Buffer to search
5546 // - val - a string, Buffer, or number
5547 // - byteOffset - an index into `buffer`; will be clamped to an int32
5548 // - encoding - an optional encoding, relevant is val is a string
5549 // - dir - true for indexOf, false for lastIndexOf
5550 function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
5551 // Empty buffer means no match
5552 if (buffer.length === 0) return -1
5553
5554 // Normalize byteOffset
5555 if (typeof byteOffset === 'string') {
5556 encoding = byteOffset
5557 byteOffset = 0
5558 } else if (byteOffset > 0x7fffffff) {
5559 byteOffset = 0x7fffffff
5560 } else if (byteOffset < -0x80000000) {
5561 byteOffset = -0x80000000
5562 }
5563 byteOffset = +byteOffset // Coerce to Number.
5564 if (isNaN(byteOffset)) {
5565 // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
5566 byteOffset = dir ? 0 : (buffer.length - 1)
5567 }
5568
5569 // Normalize byteOffset: negative offsets start from the end of the buffer
5570 if (byteOffset < 0) byteOffset = buffer.length + byteOffset
5571 if (byteOffset >= buffer.length) {
5572 if (dir) return -1
5573 else byteOffset = buffer.length - 1
5574 } else if (byteOffset < 0) {
5575 if (dir) byteOffset = 0
5576 else return -1
5577 }
5578
5579 // Normalize val
5580 if (typeof val === 'string') {
5581 val = Buffer.from(val, encoding)
5582 }
5583
5584 // Finally, search either indexOf (if dir is true) or lastIndexOf
5585 if (Buffer.isBuffer(val)) {
5586 // Special case: looking for empty string/buffer always fails
5587 if (val.length === 0) {
5588 return -1
5589 }
5590 return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
5591 } else if (typeof val === 'number') {
5592 val = val & 0xFF // Search for a byte value [0-255]
5593 if (Buffer.TYPED_ARRAY_SUPPORT &&
5594 typeof Uint8Array.prototype.indexOf === 'function') {
5595 if (dir) {
5596 return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
5597 } else {
5598 return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
5599 }
5600 }
5601 return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
5602 }
5603
5604 throw new TypeError('val must be string, number or Buffer')
5605 }
5606
5607 function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
5608 var indexSize = 1
5609 var arrLength = arr.length
5610 var valLength = val.length
5611
5612 if (encoding !== undefined) {
5613 encoding = String(encoding).toLowerCase()
5614 if (encoding === 'ucs2' || encoding === 'ucs-2' ||
5615 encoding === 'utf16le' || encoding === 'utf-16le') {
5616 if (arr.length < 2 || val.length < 2) {
5617 return -1
5618 }
5619 indexSize = 2
5620 arrLength /= 2
5621 valLength /= 2
5622 byteOffset /= 2
5623 }
5624 }
5625
5626 function read (buf, i) {
5627 if (indexSize === 1) {
5628 return buf[i]
5629 } else {
5630 return buf.readUInt16BE(i * indexSize)
5631 }
5632 }
5633
5634 var i
5635 if (dir) {
5636 var foundIndex = -1
5637 for (i = byteOffset; i < arrLength; i++) {
5638 if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
5639 if (foundIndex === -1) foundIndex = i
5640 if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
5641 } else {
5642 if (foundIndex !== -1) i -= i - foundIndex
5643 foundIndex = -1
5644 }
5645 }
5646 } else {
5647 if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
5648 for (i = byteOffset; i >= 0; i--) {
5649 var found = true
5650 for (var j = 0; j < valLength; j++) {
5651 if (read(arr, i + j) !== read(val, j)) {
5652 found = false
5653 break
5654 }
5655 }
5656 if (found) return i
5657 }
5658 }
5659
5660 return -1
5661 }
5662
5663 Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
5664 return this.indexOf(val, byteOffset, encoding) !== -1
5665 }
5666
5667 Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
5668 return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
5669 }
5670
5671 Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
5672 return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
5673 }
5674
5675 function hexWrite (buf, string, offset, length) {
5676 offset = Number(offset) || 0
5677 var remaining = buf.length - offset
5678 if (!length) {
5679 length = remaining
5680 } else {
5681 length = Number(length)
5682 if (length > remaining) {
5683 length = remaining
5684 }
5685 }
5686
5687 // must be an even number of digits
5688 var strLen = string.length
5689 if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
5690
5691 if (length > strLen / 2) {
5692 length = strLen / 2
5693 }
5694 for (var i = 0; i < length; ++i) {
5695 var parsed = parseInt(string.substr(i * 2, 2), 16)
5696 if (isNaN(parsed)) return i
5697 buf[offset + i] = parsed
5698 }
5699 return i
5700 }
5701
5702 function utf8Write (buf, string, offset, length) {
5703 return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
5704 }
5705
5706 function asciiWrite (buf, string, offset, length) {
5707 return blitBuffer(asciiToBytes(string), buf, offset, length)
5708 }
5709
5710 function latin1Write (buf, string, offset, length) {
5711 return asciiWrite(buf, string, offset, length)
5712 }
5713
5714 function base64Write (buf, string, offset, length) {
5715 return blitBuffer(base64ToBytes(string), buf, offset, length)
5716 }
5717
5718 function ucs2Write (buf, string, offset, length) {
5719 return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
5720 }
5721
5722 Buffer.prototype.write = function write (string, offset, length, encoding) {
5723 // Buffer#write(string)
5724 if (offset === undefined) {
5725 encoding = 'utf8'
5726 length = this.length
5727 offset = 0
5728 // Buffer#write(string, encoding)
5729 } else if (length === undefined && typeof offset === 'string') {
5730 encoding = offset
5731 length = this.length
5732 offset = 0
5733 // Buffer#write(string, offset[, length][, encoding])
5734 } else if (isFinite(offset)) {
5735 offset = offset | 0
5736 if (isFinite(length)) {
5737 length = length | 0
5738 if (encoding === undefined) encoding = 'utf8'
5739 } else {
5740 encoding = length
5741 length = undefined
5742 }
5743 // legacy write(string, encoding, offset, length) - remove in v0.13
5744 } else {
5745 throw new Error(
5746 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
5747 )
5748 }
5749
5750 var remaining = this.length - offset
5751 if (length === undefined || length > remaining) length = remaining
5752
5753 if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
5754 throw new RangeError('Attempt to write outside buffer bounds')
5755 }
5756
5757 if (!encoding) encoding = 'utf8'
5758
5759 var loweredCase = false
5760 for (;;) {
5761 switch (encoding) {
5762 case 'hex':
5763 return hexWrite(this, string, offset, length)
5764
5765 case 'utf8':
5766 case 'utf-8':
5767 return utf8Write(this, string, offset, length)
5768
5769 case 'ascii':
5770 return asciiWrite(this, string, offset, length)
5771
5772 case 'latin1':
5773 case 'binary':
5774 return latin1Write(this, string, offset, length)
5775
5776 case 'base64':
5777 // Warning: maxLength not taken into account in base64Write
5778 return base64Write(this, string, offset, length)
5779
5780 case 'ucs2':
5781 case 'ucs-2':
5782 case 'utf16le':
5783 case 'utf-16le':
5784 return ucs2Write(this, string, offset, length)
5785
5786 default:
5787 if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
5788 encoding = ('' + encoding).toLowerCase()
5789 loweredCase = true
5790 }
5791 }
5792 }
5793
5794 Buffer.prototype.toJSON = function toJSON () {
5795 return {
5796 type: 'Buffer',
5797 data: Array.prototype.slice.call(this._arr || this, 0)
5798 }
5799 }
5800
5801 function base64Slice (buf, start, end) {
5802 if (start === 0 && end === buf.length) {
5803 return base64.fromByteArray(buf)
5804 } else {
5805 return base64.fromByteArray(buf.slice(start, end))
5806 }
5807 }
5808
5809 function utf8Slice (buf, start, end) {
5810 end = Math.min(buf.length, end)
5811 var res = []
5812
5813 var i = start
5814 while (i < end) {
5815 var firstByte = buf[i]
5816 var codePoint = null
5817 var bytesPerSequence = (firstByte > 0xEF) ? 4
5818 : (firstByte > 0xDF) ? 3
5819 : (firstByte > 0xBF) ? 2
5820 : 1
5821
5822 if (i + bytesPerSequence <= end) {
5823 var secondByte, thirdByte, fourthByte, tempCodePoint
5824
5825 switch (bytesPerSequence) {
5826 case 1:
5827 if (firstByte < 0x80) {
5828 codePoint = firstByte
5829 }
5830 break
5831 case 2:
5832 secondByte = buf[i + 1]
5833 if ((secondByte & 0xC0) === 0x80) {
5834 tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
5835 if (tempCodePoint > 0x7F) {
5836 codePoint = tempCodePoint
5837 }
5838 }
5839 break
5840 case 3:
5841 secondByte = buf[i + 1]
5842 thirdByte = buf[i + 2]
5843 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
5844 tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
5845 if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
5846 codePoint = tempCodePoint
5847 }
5848 }
5849 break
5850 case 4:
5851 secondByte = buf[i + 1]
5852 thirdByte = buf[i + 2]
5853 fourthByte = buf[i + 3]
5854 if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
5855 tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
5856 if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
5857 codePoint = tempCodePoint
5858 }
5859 }
5860 }
5861 }
5862
5863 if (codePoint === null) {
5864 // we did not generate a valid codePoint so insert a
5865 // replacement char (U+FFFD) and advance only 1 byte
5866 codePoint = 0xFFFD
5867 bytesPerSequence = 1
5868 } else if (codePoint > 0xFFFF) {
5869 // encode to utf16 (surrogate pair dance)
5870 codePoint -= 0x10000
5871 res.push(codePoint >>> 10 & 0x3FF | 0xD800)
5872 codePoint = 0xDC00 | codePoint & 0x3FF
5873 }
5874
5875 res.push(codePoint)
5876 i += bytesPerSequence
5877 }
5878
5879 return decodeCodePointsArray(res)
5880 }
5881
5882 // Based on http://stackoverflow.com/a/22747272/680742, the browser with
5883 // the lowest limit is Chrome, with 0x10000 args.
5884 // We go 1 magnitude less, for safety
5885 var MAX_ARGUMENTS_LENGTH = 0x1000
5886
5887 function decodeCodePointsArray (codePoints) {
5888 var len = codePoints.length
5889 if (len <= MAX_ARGUMENTS_LENGTH) {
5890 return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
5891 }
5892
5893 // Decode in chunks to avoid "call stack size exceeded".
5894 var res = ''
5895 var i = 0
5896 while (i < len) {
5897 res += String.fromCharCode.apply(
5898 String,
5899 codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
5900 )
5901 }
5902 return res
5903 }
5904
5905 function asciiSlice (buf, start, end) {
5906 var ret = ''
5907 end = Math.min(buf.length, end)
5908
5909 for (var i = start; i < end; ++i) {
5910 ret += String.fromCharCode(buf[i] & 0x7F)
5911 }
5912 return ret
5913 }
5914
5915 function latin1Slice (buf, start, end) {
5916 var ret = ''
5917 end = Math.min(buf.length, end)
5918
5919 for (var i = start; i < end; ++i) {
5920 ret += String.fromCharCode(buf[i])
5921 }
5922 return ret
5923 }
5924
5925 function hexSlice (buf, start, end) {
5926 var len = buf.length
5927
5928 if (!start || start < 0) start = 0
5929 if (!end || end < 0 || end > len) end = len
5930
5931 var out = ''
5932 for (var i = start; i < end; ++i) {
5933 out += toHex(buf[i])
5934 }
5935 return out
5936 }
5937
5938 function utf16leSlice (buf, start, end) {
5939 var bytes = buf.slice(start, end)
5940 var res = ''
5941 for (var i = 0; i < bytes.length; i += 2) {
5942 res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
5943 }
5944 return res
5945 }
5946
5947 Buffer.prototype.slice = function slice (start, end) {
5948 var len = this.length
5949 start = ~~start
5950 end = end === undefined ? len : ~~end
5951
5952 if (start < 0) {
5953 start += len
5954 if (start < 0) start = 0
5955 } else if (start > len) {
5956 start = len
5957 }
5958
5959 if (end < 0) {
5960 end += len
5961 if (end < 0) end = 0
5962 } else if (end > len) {
5963 end = len
5964 }
5965
5966 if (end < start) end = start
5967
5968 var newBuf
5969 if (Buffer.TYPED_ARRAY_SUPPORT) {
5970 newBuf = this.subarray(start, end)
5971 newBuf.__proto__ = Buffer.prototype
5972 } else {
5973 var sliceLen = end - start
5974 newBuf = new Buffer(sliceLen, undefined)
5975 for (var i = 0; i < sliceLen; ++i) {
5976 newBuf[i] = this[i + start]
5977 }
5978 }
5979
5980 return newBuf
5981 }
5982
5983 /*
5984 * Need to make sure that buffer isn't trying to write out of bounds.
5985 */
5986 function checkOffset (offset, ext, length) {
5987 if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
5988 if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
5989 }
5990
5991 Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
5992 offset = offset | 0
5993 byteLength = byteLength | 0
5994 if (!noAssert) checkOffset(offset, byteLength, this.length)
5995
5996 var val = this[offset]
5997 var mul = 1
5998 var i = 0
5999 while (++i < byteLength && (mul *= 0x100)) {
6000 val += this[offset + i] * mul
6001 }
6002
6003 return val
6004 }
6005
6006 Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
6007 offset = offset | 0
6008 byteLength = byteLength | 0
6009 if (!noAssert) {
6010 checkOffset(offset, byteLength, this.length)
6011 }
6012
6013 var val = this[offset + --byteLength]
6014 var mul = 1
6015 while (byteLength > 0 && (mul *= 0x100)) {
6016 val += this[offset + --byteLength] * mul
6017 }
6018
6019 return val
6020 }
6021
6022 Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
6023 if (!noAssert) checkOffset(offset, 1, this.length)
6024 return this[offset]
6025 }
6026
6027 Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
6028 if (!noAssert) checkOffset(offset, 2, this.length)
6029 return this[offset] | (this[offset + 1] << 8)
6030 }
6031
6032 Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
6033 if (!noAssert) checkOffset(offset, 2, this.length)
6034 return (this[offset] << 8) | this[offset + 1]
6035 }
6036
6037 Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
6038 if (!noAssert) checkOffset(offset, 4, this.length)
6039
6040 return ((this[offset]) |
6041 (this[offset + 1] << 8) |
6042 (this[offset + 2] << 16)) +
6043 (this[offset + 3] * 0x1000000)
6044 }
6045
6046 Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
6047 if (!noAssert) checkOffset(offset, 4, this.length)
6048
6049 return (this[offset] * 0x1000000) +
6050 ((this[offset + 1] << 16) |
6051 (this[offset + 2] << 8) |
6052 this[offset + 3])
6053 }
6054
6055 Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
6056 offset = offset | 0
6057 byteLength = byteLength | 0
6058 if (!noAssert) checkOffset(offset, byteLength, this.length)
6059
6060 var val = this[offset]
6061 var mul = 1
6062 var i = 0
6063 while (++i < byteLength && (mul *= 0x100)) {
6064 val += this[offset + i] * mul
6065 }
6066 mul *= 0x80
6067
6068 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6069
6070 return val
6071 }
6072
6073 Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
6074 offset = offset | 0
6075 byteLength = byteLength | 0
6076 if (!noAssert) checkOffset(offset, byteLength, this.length)
6077
6078 var i = byteLength
6079 var mul = 1
6080 var val = this[offset + --i]
6081 while (i > 0 && (mul *= 0x100)) {
6082 val += this[offset + --i] * mul
6083 }
6084 mul *= 0x80
6085
6086 if (val >= mul) val -= Math.pow(2, 8 * byteLength)
6087
6088 return val
6089 }
6090
6091 Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
6092 if (!noAssert) checkOffset(offset, 1, this.length)
6093 if (!(this[offset] & 0x80)) return (this[offset])
6094 return ((0xff - this[offset] + 1) * -1)
6095 }
6096
6097 Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
6098 if (!noAssert) checkOffset(offset, 2, this.length)
6099 var val = this[offset] | (this[offset + 1] << 8)
6100 return (val & 0x8000) ? val | 0xFFFF0000 : val
6101 }
6102
6103 Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
6104 if (!noAssert) checkOffset(offset, 2, this.length)
6105 var val = this[offset + 1] | (this[offset] << 8)
6106 return (val & 0x8000) ? val | 0xFFFF0000 : val
6107 }
6108
6109 Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
6110 if (!noAssert) checkOffset(offset, 4, this.length)
6111
6112 return (this[offset]) |
6113 (this[offset + 1] << 8) |
6114 (this[offset + 2] << 16) |
6115 (this[offset + 3] << 24)
6116 }
6117
6118 Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
6119 if (!noAssert) checkOffset(offset, 4, this.length)
6120
6121 return (this[offset] << 24) |
6122 (this[offset + 1] << 16) |
6123 (this[offset + 2] << 8) |
6124 (this[offset + 3])
6125 }
6126
6127 Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
6128 if (!noAssert) checkOffset(offset, 4, this.length)
6129 return ieee754.read(this, offset, true, 23, 4)
6130 }
6131
6132 Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
6133 if (!noAssert) checkOffset(offset, 4, this.length)
6134 return ieee754.read(this, offset, false, 23, 4)
6135 }
6136
6137 Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
6138 if (!noAssert) checkOffset(offset, 8, this.length)
6139 return ieee754.read(this, offset, true, 52, 8)
6140 }
6141
6142 Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
6143 if (!noAssert) checkOffset(offset, 8, this.length)
6144 return ieee754.read(this, offset, false, 52, 8)
6145 }
6146
6147 function checkInt (buf, value, offset, ext, max, min) {
6148 if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
6149 if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
6150 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6151 }
6152
6153 Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
6154 value = +value
6155 offset = offset | 0
6156 byteLength = byteLength | 0
6157 if (!noAssert) {
6158 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6159 checkInt(this, value, offset, byteLength, maxBytes, 0)
6160 }
6161
6162 var mul = 1
6163 var i = 0
6164 this[offset] = value & 0xFF
6165 while (++i < byteLength && (mul *= 0x100)) {
6166 this[offset + i] = (value / mul) & 0xFF
6167 }
6168
6169 return offset + byteLength
6170 }
6171
6172 Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
6173 value = +value
6174 offset = offset | 0
6175 byteLength = byteLength | 0
6176 if (!noAssert) {
6177 var maxBytes = Math.pow(2, 8 * byteLength) - 1
6178 checkInt(this, value, offset, byteLength, maxBytes, 0)
6179 }
6180
6181 var i = byteLength - 1
6182 var mul = 1
6183 this[offset + i] = value & 0xFF
6184 while (--i >= 0 && (mul *= 0x100)) {
6185 this[offset + i] = (value / mul) & 0xFF
6186 }
6187
6188 return offset + byteLength
6189 }
6190
6191 Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
6192 value = +value
6193 offset = offset | 0
6194 if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
6195 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6196 this[offset] = (value & 0xff)
6197 return offset + 1
6198 }
6199
6200 function objectWriteUInt16 (buf, value, offset, littleEndian) {
6201 if (value < 0) value = 0xffff + value + 1
6202 for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
6203 buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
6204 (littleEndian ? i : 1 - i) * 8
6205 }
6206 }
6207
6208 Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
6209 value = +value
6210 offset = offset | 0
6211 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6212 if (Buffer.TYPED_ARRAY_SUPPORT) {
6213 this[offset] = (value & 0xff)
6214 this[offset + 1] = (value >>> 8)
6215 } else {
6216 objectWriteUInt16(this, value, offset, true)
6217 }
6218 return offset + 2
6219 }
6220
6221 Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
6222 value = +value
6223 offset = offset | 0
6224 if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
6225 if (Buffer.TYPED_ARRAY_SUPPORT) {
6226 this[offset] = (value >>> 8)
6227 this[offset + 1] = (value & 0xff)
6228 } else {
6229 objectWriteUInt16(this, value, offset, false)
6230 }
6231 return offset + 2
6232 }
6233
6234 function objectWriteUInt32 (buf, value, offset, littleEndian) {
6235 if (value < 0) value = 0xffffffff + value + 1
6236 for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
6237 buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
6238 }
6239 }
6240
6241 Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
6242 value = +value
6243 offset = offset | 0
6244 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6245 if (Buffer.TYPED_ARRAY_SUPPORT) {
6246 this[offset + 3] = (value >>> 24)
6247 this[offset + 2] = (value >>> 16)
6248 this[offset + 1] = (value >>> 8)
6249 this[offset] = (value & 0xff)
6250 } else {
6251 objectWriteUInt32(this, value, offset, true)
6252 }
6253 return offset + 4
6254 }
6255
6256 Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
6257 value = +value
6258 offset = offset | 0
6259 if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
6260 if (Buffer.TYPED_ARRAY_SUPPORT) {
6261 this[offset] = (value >>> 24)
6262 this[offset + 1] = (value >>> 16)
6263 this[offset + 2] = (value >>> 8)
6264 this[offset + 3] = (value & 0xff)
6265 } else {
6266 objectWriteUInt32(this, value, offset, false)
6267 }
6268 return offset + 4
6269 }
6270
6271 Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
6272 value = +value
6273 offset = offset | 0
6274 if (!noAssert) {
6275 var limit = Math.pow(2, 8 * byteLength - 1)
6276
6277 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6278 }
6279
6280 var i = 0
6281 var mul = 1
6282 var sub = 0
6283 this[offset] = value & 0xFF
6284 while (++i < byteLength && (mul *= 0x100)) {
6285 if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
6286 sub = 1
6287 }
6288 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6289 }
6290
6291 return offset + byteLength
6292 }
6293
6294 Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
6295 value = +value
6296 offset = offset | 0
6297 if (!noAssert) {
6298 var limit = Math.pow(2, 8 * byteLength - 1)
6299
6300 checkInt(this, value, offset, byteLength, limit - 1, -limit)
6301 }
6302
6303 var i = byteLength - 1
6304 var mul = 1
6305 var sub = 0
6306 this[offset + i] = value & 0xFF
6307 while (--i >= 0 && (mul *= 0x100)) {
6308 if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
6309 sub = 1
6310 }
6311 this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
6312 }
6313
6314 return offset + byteLength
6315 }
6316
6317 Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
6318 value = +value
6319 offset = offset | 0
6320 if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
6321 if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
6322 if (value < 0) value = 0xff + value + 1
6323 this[offset] = (value & 0xff)
6324 return offset + 1
6325 }
6326
6327 Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
6328 value = +value
6329 offset = offset | 0
6330 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6331 if (Buffer.TYPED_ARRAY_SUPPORT) {
6332 this[offset] = (value & 0xff)
6333 this[offset + 1] = (value >>> 8)
6334 } else {
6335 objectWriteUInt16(this, value, offset, true)
6336 }
6337 return offset + 2
6338 }
6339
6340 Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
6341 value = +value
6342 offset = offset | 0
6343 if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
6344 if (Buffer.TYPED_ARRAY_SUPPORT) {
6345 this[offset] = (value >>> 8)
6346 this[offset + 1] = (value & 0xff)
6347 } else {
6348 objectWriteUInt16(this, value, offset, false)
6349 }
6350 return offset + 2
6351 }
6352
6353 Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
6354 value = +value
6355 offset = offset | 0
6356 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6357 if (Buffer.TYPED_ARRAY_SUPPORT) {
6358 this[offset] = (value & 0xff)
6359 this[offset + 1] = (value >>> 8)
6360 this[offset + 2] = (value >>> 16)
6361 this[offset + 3] = (value >>> 24)
6362 } else {
6363 objectWriteUInt32(this, value, offset, true)
6364 }
6365 return offset + 4
6366 }
6367
6368 Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
6369 value = +value
6370 offset = offset | 0
6371 if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
6372 if (value < 0) value = 0xffffffff + value + 1
6373 if (Buffer.TYPED_ARRAY_SUPPORT) {
6374 this[offset] = (value >>> 24)
6375 this[offset + 1] = (value >>> 16)
6376 this[offset + 2] = (value >>> 8)
6377 this[offset + 3] = (value & 0xff)
6378 } else {
6379 objectWriteUInt32(this, value, offset, false)
6380 }
6381 return offset + 4
6382 }
6383
6384 function checkIEEE754 (buf, value, offset, ext, max, min) {
6385 if (offset + ext > buf.length) throw new RangeError('Index out of range')
6386 if (offset < 0) throw new RangeError('Index out of range')
6387 }
6388
6389 function writeFloat (buf, value, offset, littleEndian, noAssert) {
6390 if (!noAssert) {
6391 checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
6392 }
6393 ieee754.write(buf, value, offset, littleEndian, 23, 4)
6394 return offset + 4
6395 }
6396
6397 Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
6398 return writeFloat(this, value, offset, true, noAssert)
6399 }
6400
6401 Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
6402 return writeFloat(this, value, offset, false, noAssert)
6403 }
6404
6405 function writeDouble (buf, value, offset, littleEndian, noAssert) {
6406 if (!noAssert) {
6407 checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
6408 }
6409 ieee754.write(buf, value, offset, littleEndian, 52, 8)
6410 return offset + 8
6411 }
6412
6413 Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
6414 return writeDouble(this, value, offset, true, noAssert)
6415 }
6416
6417 Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
6418 return writeDouble(this, value, offset, false, noAssert)
6419 }
6420
6421 // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
6422 Buffer.prototype.copy = function copy (target, targetStart, start, end) {
6423 if (!start) start = 0
6424 if (!end && end !== 0) end = this.length
6425 if (targetStart >= target.length) targetStart = target.length
6426 if (!targetStart) targetStart = 0
6427 if (end > 0 && end < start) end = start
6428
6429 // Copy 0 bytes; we're done
6430 if (end === start) return 0
6431 if (target.length === 0 || this.length === 0) return 0
6432
6433 // Fatal error conditions
6434 if (targetStart < 0) {
6435 throw new RangeError('targetStart out of bounds')
6436 }
6437 if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
6438 if (end < 0) throw new RangeError('sourceEnd out of bounds')
6439
6440 // Are we oob?
6441 if (end > this.length) end = this.length
6442 if (target.length - targetStart < end - start) {
6443 end = target.length - targetStart + start
6444 }
6445
6446 var len = end - start
6447 var i
6448
6449 if (this === target && start < targetStart && targetStart < end) {
6450 // descending copy from end
6451 for (i = len - 1; i >= 0; --i) {
6452 target[i + targetStart] = this[i + start]
6453 }
6454 } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
6455 // ascending copy from start
6456 for (i = 0; i < len; ++i) {
6457 target[i + targetStart] = this[i + start]
6458 }
6459 } else {
6460 Uint8Array.prototype.set.call(
6461 target,
6462 this.subarray(start, start + len),
6463 targetStart
6464 )
6465 }
6466
6467 return len
6468 }
6469
6470 // Usage:
6471 // buffer.fill(number[, offset[, end]])
6472 // buffer.fill(buffer[, offset[, end]])
6473 // buffer.fill(string[, offset[, end]][, encoding])
6474 Buffer.prototype.fill = function fill (val, start, end, encoding) {
6475 // Handle string cases:
6476 if (typeof val === 'string') {
6477 if (typeof start === 'string') {
6478 encoding = start
6479 start = 0
6480 end = this.length
6481 } else if (typeof end === 'string') {
6482 encoding = end
6483 end = this.length
6484 }
6485 if (val.length === 1) {
6486 var code = val.charCodeAt(0)
6487 if (code < 256) {
6488 val = code
6489 }
6490 }
6491 if (encoding !== undefined && typeof encoding !== 'string') {
6492 throw new TypeError('encoding must be a string')
6493 }
6494 if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
6495 throw new TypeError('Unknown encoding: ' + encoding)
6496 }
6497 } else if (typeof val === 'number') {
6498 val = val & 255
6499 }
6500
6501 // Invalid ranges are not set to a default, so can range check early.
6502 if (start < 0 || this.length < start || this.length < end) {
6503 throw new RangeError('Out of range index')
6504 }
6505
6506 if (end <= start) {
6507 return this
6508 }
6509
6510 start = start >>> 0
6511 end = end === undefined ? this.length : end >>> 0
6512
6513 if (!val) val = 0
6514
6515 var i
6516 if (typeof val === 'number') {
6517 for (i = start; i < end; ++i) {
6518 this[i] = val
6519 }
6520 } else {
6521 var bytes = Buffer.isBuffer(val)
6522 ? val
6523 : utf8ToBytes(new Buffer(val, encoding).toString())
6524 var len = bytes.length
6525 for (i = 0; i < end - start; ++i) {
6526 this[i + start] = bytes[i % len]
6527 }
6528 }
6529
6530 return this
6531 }
6532
6533 // HELPER FUNCTIONS
6534 // ================
6535
6536 var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
6537
6538 function base64clean (str) {
6539 // Node strips out invalid characters like \n and \t from the string, base64-js does not
6540 str = stringtrim(str).replace(INVALID_BASE64_RE, '')
6541 // Node converts strings with length < 2 to ''
6542 if (str.length < 2) return ''
6543 // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
6544 while (str.length % 4 !== 0) {
6545 str = str + '='
6546 }
6547 return str
6548 }
6549
6550 function stringtrim (str) {
6551 if (str.trim) return str.trim()
6552 return str.replace(/^\s+|\s+$/g, '')
6553 }
6554
6555 function toHex (n) {
6556 if (n < 16) return '0' + n.toString(16)
6557 return n.toString(16)
6558 }
6559
6560 function utf8ToBytes (string, units) {
6561 units = units || Infinity
6562 var codePoint
6563 var length = string.length
6564 var leadSurrogate = null
6565 var bytes = []
6566
6567 for (var i = 0; i < length; ++i) {
6568 codePoint = string.charCodeAt(i)
6569
6570 // is surrogate component
6571 if (codePoint > 0xD7FF && codePoint < 0xE000) {
6572 // last char was a lead
6573 if (!leadSurrogate) {
6574 // no lead yet
6575 if (codePoint > 0xDBFF) {
6576 // unexpected trail
6577 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6578 continue
6579 } else if (i + 1 === length) {
6580 // unpaired lead
6581 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6582 continue
6583 }
6584
6585 // valid lead
6586 leadSurrogate = codePoint
6587
6588 continue
6589 }
6590
6591 // 2 leads in a row
6592 if (codePoint < 0xDC00) {
6593 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6594 leadSurrogate = codePoint
6595 continue
6596 }
6597
6598 // valid surrogate pair
6599 codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
6600 } else if (leadSurrogate) {
6601 // valid bmp char, but last char was a lead
6602 if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
6603 }
6604
6605 leadSurrogate = null
6606
6607 // encode utf8
6608 if (codePoint < 0x80) {
6609 if ((units -= 1) < 0) break
6610 bytes.push(codePoint)
6611 } else if (codePoint < 0x800) {
6612 if ((units -= 2) < 0) break
6613 bytes.push(
6614 codePoint >> 0x6 | 0xC0,
6615 codePoint & 0x3F | 0x80
6616 )
6617 } else if (codePoint < 0x10000) {
6618 if ((units -= 3) < 0) break
6619 bytes.push(
6620 codePoint >> 0xC | 0xE0,
6621 codePoint >> 0x6 & 0x3F | 0x80,
6622 codePoint & 0x3F | 0x80
6623 )
6624 } else if (codePoint < 0x110000) {
6625 if ((units -= 4) < 0) break
6626 bytes.push(
6627 codePoint >> 0x12 | 0xF0,
6628 codePoint >> 0xC & 0x3F | 0x80,
6629 codePoint >> 0x6 & 0x3F | 0x80,
6630 codePoint & 0x3F | 0x80
6631 )
6632 } else {
6633 throw new Error('Invalid code point')
6634 }
6635 }
6636
6637 return bytes
6638 }
6639
6640 function asciiToBytes (str) {
6641 var byteArray = []
6642 for (var i = 0; i < str.length; ++i) {
6643 // Node's code seems to be doing this and not & 0x7F..
6644 byteArray.push(str.charCodeAt(i) & 0xFF)
6645 }
6646 return byteArray
6647 }
6648
6649 function utf16leToBytes (str, units) {
6650 var c, hi, lo
6651 var byteArray = []
6652 for (var i = 0; i < str.length; ++i) {
6653 if ((units -= 2) < 0) break
6654
6655 c = str.charCodeAt(i)
6656 hi = c >> 8
6657 lo = c % 256
6658 byteArray.push(lo)
6659 byteArray.push(hi)
6660 }
6661
6662 return byteArray
6663 }
6664
6665 function base64ToBytes (str) {
6666 return base64.toByteArray(base64clean(str))
6667 }
6668
6669 function blitBuffer (src, dst, offset, length) {
6670 for (var i = 0; i < length; ++i) {
6671 if ((i + offset >= dst.length) || (i >= src.length)) break
6672 dst[i + offset] = src[i]
6673 }
6674 return i
6675 }
6676
6677 function isnan (val) {
6678 return val !== val // eslint-disable-line no-self-compare
6679 }
6680
6681 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
6682
6683/***/ }),
6684/* 29 */
6685/***/ (function(module, exports) {
6686
6687 'use strict'
6688
6689 exports.byteLength = byteLength
6690 exports.toByteArray = toByteArray
6691 exports.fromByteArray = fromByteArray
6692
6693 var lookup = []
6694 var revLookup = []
6695 var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
6696
6697 var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
6698 for (var i = 0, len = code.length; i < len; ++i) {
6699 lookup[i] = code[i]
6700 revLookup[code.charCodeAt(i)] = i
6701 }
6702
6703 // Support decoding URL-safe base64 strings, as Node.js does.
6704 // See: https://en.wikipedia.org/wiki/Base64#URL_applications
6705 revLookup['-'.charCodeAt(0)] = 62
6706 revLookup['_'.charCodeAt(0)] = 63
6707
6708 function getLens (b64) {
6709 var len = b64.length
6710
6711 if (len % 4 > 0) {
6712 throw new Error('Invalid string. Length must be a multiple of 4')
6713 }
6714
6715 // Trim off extra bytes after placeholder bytes are found
6716 // See: https://github.com/beatgammit/base64-js/issues/42
6717 var validLen = b64.indexOf('=')
6718 if (validLen === -1) validLen = len
6719
6720 var placeHoldersLen = validLen === len
6721 ? 0
6722 : 4 - (validLen % 4)
6723
6724 return [validLen, placeHoldersLen]
6725 }
6726
6727 // base64 is 4/3 + up to two characters of the original data
6728 function byteLength (b64) {
6729 var lens = getLens(b64)
6730 var validLen = lens[0]
6731 var placeHoldersLen = lens[1]
6732 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
6733 }
6734
6735 function _byteLength (b64, validLen, placeHoldersLen) {
6736 return ((validLen + placeHoldersLen) * 3 / 4) - placeHoldersLen
6737 }
6738
6739 function toByteArray (b64) {
6740 var tmp
6741 var lens = getLens(b64)
6742 var validLen = lens[0]
6743 var placeHoldersLen = lens[1]
6744
6745 var arr = new Arr(_byteLength(b64, validLen, placeHoldersLen))
6746
6747 var curByte = 0
6748
6749 // if there are placeholders, only get up to the last complete 4 chars
6750 var len = placeHoldersLen > 0
6751 ? validLen - 4
6752 : validLen
6753
6754 var i
6755 for (i = 0; i < len; i += 4) {
6756 tmp =
6757 (revLookup[b64.charCodeAt(i)] << 18) |
6758 (revLookup[b64.charCodeAt(i + 1)] << 12) |
6759 (revLookup[b64.charCodeAt(i + 2)] << 6) |
6760 revLookup[b64.charCodeAt(i + 3)]
6761 arr[curByte++] = (tmp >> 16) & 0xFF
6762 arr[curByte++] = (tmp >> 8) & 0xFF
6763 arr[curByte++] = tmp & 0xFF
6764 }
6765
6766 if (placeHoldersLen === 2) {
6767 tmp =
6768 (revLookup[b64.charCodeAt(i)] << 2) |
6769 (revLookup[b64.charCodeAt(i + 1)] >> 4)
6770 arr[curByte++] = tmp & 0xFF
6771 }
6772
6773 if (placeHoldersLen === 1) {
6774 tmp =
6775 (revLookup[b64.charCodeAt(i)] << 10) |
6776 (revLookup[b64.charCodeAt(i + 1)] << 4) |
6777 (revLookup[b64.charCodeAt(i + 2)] >> 2)
6778 arr[curByte++] = (tmp >> 8) & 0xFF
6779 arr[curByte++] = tmp & 0xFF
6780 }
6781
6782 return arr
6783 }
6784
6785 function tripletToBase64 (num) {
6786 return lookup[num >> 18 & 0x3F] +
6787 lookup[num >> 12 & 0x3F] +
6788 lookup[num >> 6 & 0x3F] +
6789 lookup[num & 0x3F]
6790 }
6791
6792 function encodeChunk (uint8, start, end) {
6793 var tmp
6794 var output = []
6795 for (var i = start; i < end; i += 3) {
6796 tmp =
6797 ((uint8[i] << 16) & 0xFF0000) +
6798 ((uint8[i + 1] << 8) & 0xFF00) +
6799 (uint8[i + 2] & 0xFF)
6800 output.push(tripletToBase64(tmp))
6801 }
6802 return output.join('')
6803 }
6804
6805 function fromByteArray (uint8) {
6806 var tmp
6807 var len = uint8.length
6808 var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
6809 var parts = []
6810 var maxChunkLength = 16383 // must be multiple of 3
6811
6812 // go through the array every three bytes, we'll deal with trailing stuff later
6813 for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
6814 parts.push(encodeChunk(
6815 uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)
6816 ))
6817 }
6818
6819 // pad the end with zeros, but make sure to not forget the extra bytes
6820 if (extraBytes === 1) {
6821 tmp = uint8[len - 1]
6822 parts.push(
6823 lookup[tmp >> 2] +
6824 lookup[(tmp << 4) & 0x3F] +
6825 '=='
6826 )
6827 } else if (extraBytes === 2) {
6828 tmp = (uint8[len - 2] << 8) + uint8[len - 1]
6829 parts.push(
6830 lookup[tmp >> 10] +
6831 lookup[(tmp >> 4) & 0x3F] +
6832 lookup[(tmp << 2) & 0x3F] +
6833 '='
6834 )
6835 }
6836
6837 return parts.join('')
6838 }
6839
6840
6841/***/ }),
6842/* 30 */
6843/***/ (function(module, exports) {
6844
6845 exports.read = function (buffer, offset, isLE, mLen, nBytes) {
6846 var e, m
6847 var eLen = (nBytes * 8) - mLen - 1
6848 var eMax = (1 << eLen) - 1
6849 var eBias = eMax >> 1
6850 var nBits = -7
6851 var i = isLE ? (nBytes - 1) : 0
6852 var d = isLE ? -1 : 1
6853 var s = buffer[offset + i]
6854
6855 i += d
6856
6857 e = s & ((1 << (-nBits)) - 1)
6858 s >>= (-nBits)
6859 nBits += eLen
6860 for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}
6861
6862 m = e & ((1 << (-nBits)) - 1)
6863 e >>= (-nBits)
6864 nBits += mLen
6865 for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}
6866
6867 if (e === 0) {
6868 e = 1 - eBias
6869 } else if (e === eMax) {
6870 return m ? NaN : ((s ? -1 : 1) * Infinity)
6871 } else {
6872 m = m + Math.pow(2, mLen)
6873 e = e - eBias
6874 }
6875 return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
6876 }
6877
6878 exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
6879 var e, m, c
6880 var eLen = (nBytes * 8) - mLen - 1
6881 var eMax = (1 << eLen) - 1
6882 var eBias = eMax >> 1
6883 var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
6884 var i = isLE ? 0 : (nBytes - 1)
6885 var d = isLE ? 1 : -1
6886 var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
6887
6888 value = Math.abs(value)
6889
6890 if (isNaN(value) || value === Infinity) {
6891 m = isNaN(value) ? 1 : 0
6892 e = eMax
6893 } else {
6894 e = Math.floor(Math.log(value) / Math.LN2)
6895 if (value * (c = Math.pow(2, -e)) < 1) {
6896 e--
6897 c *= 2
6898 }
6899 if (e + eBias >= 1) {
6900 value += rt / c
6901 } else {
6902 value += rt * Math.pow(2, 1 - eBias)
6903 }
6904 if (value * c >= 2) {
6905 e++
6906 c /= 2
6907 }
6908
6909 if (e + eBias >= eMax) {
6910 m = 0
6911 e = eMax
6912 } else if (e + eBias >= 1) {
6913 m = ((value * c) - 1) * Math.pow(2, mLen)
6914 e = e + eBias
6915 } else {
6916 m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
6917 e = 0
6918 }
6919 }
6920
6921 for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
6922
6923 e = (e << mLen) | m
6924 eLen += mLen
6925 for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
6926
6927 buffer[offset + i - d] |= s * 128
6928 }
6929
6930
6931/***/ }),
6932/* 31 */
6933/***/ (function(module, exports) {
6934
6935 var toString = {}.toString;
6936
6937 module.exports = Array.isArray || function (arr) {
6938 return toString.call(arr) == '[object Array]';
6939 };
6940
6941
6942/***/ }),
6943/* 32 */
6944/***/ (function(module, exports, __webpack_require__) {
6945
6946 // Copyright Joyent, Inc. and other Node contributors.
6947 //
6948 // Permission is hereby granted, free of charge, to any person obtaining a
6949 // copy of this software and associated documentation files (the
6950 // "Software"), to deal in the Software without restriction, including
6951 // without limitation the rights to use, copy, modify, merge, publish,
6952 // distribute, sublicense, and/or sell copies of the Software, and to permit
6953 // persons to whom the Software is furnished to do so, subject to the
6954 // following conditions:
6955 //
6956 // The above copyright notice and this permission notice shall be included
6957 // in all copies or substantial portions of the Software.
6958 //
6959 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
6960 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
6961 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
6962 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
6963 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
6964 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
6965 // USE OR OTHER DEALINGS IN THE SOFTWARE.
6966
6967 module.exports = Stream;
6968
6969 var EE = __webpack_require__(33).EventEmitter;
6970 var inherits = __webpack_require__(34);
6971
6972 inherits(Stream, EE);
6973 Stream.Readable = __webpack_require__(35);
6974 Stream.Writable = __webpack_require__(54);
6975 Stream.Duplex = __webpack_require__(55);
6976 Stream.Transform = __webpack_require__(56);
6977 Stream.PassThrough = __webpack_require__(57);
6978
6979 // Backwards-compat with node 0.4.x
6980 Stream.Stream = Stream;
6981
6982
6983
6984 // old-style streams. Note that the pipe method (the only relevant
6985 // part of this class) is overridden in the Readable class.
6986
6987 function Stream() {
6988 EE.call(this);
6989 }
6990
6991 Stream.prototype.pipe = function(dest, options) {
6992 var source = this;
6993
6994 function ondata(chunk) {
6995 if (dest.writable) {
6996 if (false === dest.write(chunk) && source.pause) {
6997 source.pause();
6998 }
6999 }
7000 }
7001
7002 source.on('data', ondata);
7003
7004 function ondrain() {
7005 if (source.readable && source.resume) {
7006 source.resume();
7007 }
7008 }
7009
7010 dest.on('drain', ondrain);
7011
7012 // If the 'end' option is not supplied, dest.end() will be called when
7013 // source gets the 'end' or 'close' events. Only dest.end() once.
7014 if (!dest._isStdio && (!options || options.end !== false)) {
7015 source.on('end', onend);
7016 source.on('close', onclose);
7017 }
7018
7019 var didOnEnd = false;
7020 function onend() {
7021 if (didOnEnd) return;
7022 didOnEnd = true;
7023
7024 dest.end();
7025 }
7026
7027
7028 function onclose() {
7029 if (didOnEnd) return;
7030 didOnEnd = true;
7031
7032 if (typeof dest.destroy === 'function') dest.destroy();
7033 }
7034
7035 // don't leave dangling pipes when there are errors.
7036 function onerror(er) {
7037 cleanup();
7038 if (EE.listenerCount(this, 'error') === 0) {
7039 throw er; // Unhandled stream error in pipe.
7040 }
7041 }
7042
7043 source.on('error', onerror);
7044 dest.on('error', onerror);
7045
7046 // remove all the event listeners that were added.
7047 function cleanup() {
7048 source.removeListener('data', ondata);
7049 dest.removeListener('drain', ondrain);
7050
7051 source.removeListener('end', onend);
7052 source.removeListener('close', onclose);
7053
7054 source.removeListener('error', onerror);
7055 dest.removeListener('error', onerror);
7056
7057 source.removeListener('end', cleanup);
7058 source.removeListener('close', cleanup);
7059
7060 dest.removeListener('close', cleanup);
7061 }
7062
7063 source.on('end', cleanup);
7064 source.on('close', cleanup);
7065
7066 dest.on('close', cleanup);
7067
7068 dest.emit('pipe', source);
7069
7070 // Allow for unix-like usage: A.pipe(B).pipe(C)
7071 return dest;
7072 };
7073
7074
7075/***/ }),
7076/* 33 */
7077/***/ (function(module, exports) {
7078
7079 // Copyright Joyent, Inc. and other Node contributors.
7080 //
7081 // Permission is hereby granted, free of charge, to any person obtaining a
7082 // copy of this software and associated documentation files (the
7083 // "Software"), to deal in the Software without restriction, including
7084 // without limitation the rights to use, copy, modify, merge, publish,
7085 // distribute, sublicense, and/or sell copies of the Software, and to permit
7086 // persons to whom the Software is furnished to do so, subject to the
7087 // following conditions:
7088 //
7089 // The above copyright notice and this permission notice shall be included
7090 // in all copies or substantial portions of the Software.
7091 //
7092 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7093 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7094 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7095 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7096 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7097 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7098 // USE OR OTHER DEALINGS IN THE SOFTWARE.
7099
7100 function EventEmitter() {
7101 this._events = this._events || {};
7102 this._maxListeners = this._maxListeners || undefined;
7103 }
7104 module.exports = EventEmitter;
7105
7106 // Backwards-compat with node 0.10.x
7107 EventEmitter.EventEmitter = EventEmitter;
7108
7109 EventEmitter.prototype._events = undefined;
7110 EventEmitter.prototype._maxListeners = undefined;
7111
7112 // By default EventEmitters will print a warning if more than 10 listeners are
7113 // added to it. This is a useful default which helps finding memory leaks.
7114 EventEmitter.defaultMaxListeners = 10;
7115
7116 // Obviously not all Emitters should be limited to 10. This function allows
7117 // that to be increased. Set to zero for unlimited.
7118 EventEmitter.prototype.setMaxListeners = function(n) {
7119 if (!isNumber(n) || n < 0 || isNaN(n))
7120 throw TypeError('n must be a positive number');
7121 this._maxListeners = n;
7122 return this;
7123 };
7124
7125 EventEmitter.prototype.emit = function(type) {
7126 var er, handler, len, args, i, listeners;
7127
7128 if (!this._events)
7129 this._events = {};
7130
7131 // If there is no 'error' event listener then throw.
7132 if (type === 'error') {
7133 if (!this._events.error ||
7134 (isObject(this._events.error) && !this._events.error.length)) {
7135 er = arguments[1];
7136 if (er instanceof Error) {
7137 throw er; // Unhandled 'error' event
7138 } else {
7139 // At least give some kind of context to the user
7140 var err = new Error('Uncaught, unspecified "error" event. (' + er + ')');
7141 err.context = er;
7142 throw err;
7143 }
7144 }
7145 }
7146
7147 handler = this._events[type];
7148
7149 if (isUndefined(handler))
7150 return false;
7151
7152 if (isFunction(handler)) {
7153 switch (arguments.length) {
7154 // fast cases
7155 case 1:
7156 handler.call(this);
7157 break;
7158 case 2:
7159 handler.call(this, arguments[1]);
7160 break;
7161 case 3:
7162 handler.call(this, arguments[1], arguments[2]);
7163 break;
7164 // slower
7165 default:
7166 args = Array.prototype.slice.call(arguments, 1);
7167 handler.apply(this, args);
7168 }
7169 } else if (isObject(handler)) {
7170 args = Array.prototype.slice.call(arguments, 1);
7171 listeners = handler.slice();
7172 len = listeners.length;
7173 for (i = 0; i < len; i++)
7174 listeners[i].apply(this, args);
7175 }
7176
7177 return true;
7178 };
7179
7180 EventEmitter.prototype.addListener = function(type, listener) {
7181 var m;
7182
7183 if (!isFunction(listener))
7184 throw TypeError('listener must be a function');
7185
7186 if (!this._events)
7187 this._events = {};
7188
7189 // To avoid recursion in the case that type === "newListener"! Before
7190 // adding it to the listeners, first emit "newListener".
7191 if (this._events.newListener)
7192 this.emit('newListener', type,
7193 isFunction(listener.listener) ?
7194 listener.listener : listener);
7195
7196 if (!this._events[type])
7197 // Optimize the case of one listener. Don't need the extra array object.
7198 this._events[type] = listener;
7199 else if (isObject(this._events[type]))
7200 // If we've already got an array, just append.
7201 this._events[type].push(listener);
7202 else
7203 // Adding the second element, need to change to array.
7204 this._events[type] = [this._events[type], listener];
7205
7206 // Check for listener leak
7207 if (isObject(this._events[type]) && !this._events[type].warned) {
7208 if (!isUndefined(this._maxListeners)) {
7209 m = this._maxListeners;
7210 } else {
7211 m = EventEmitter.defaultMaxListeners;
7212 }
7213
7214 if (m && m > 0 && this._events[type].length > m) {
7215 this._events[type].warned = true;
7216 console.error('(node) warning: possible EventEmitter memory ' +
7217 'leak detected. %d listeners added. ' +
7218 'Use emitter.setMaxListeners() to increase limit.',
7219 this._events[type].length);
7220 if (typeof console.trace === 'function') {
7221 // not supported in IE 10
7222 console.trace();
7223 }
7224 }
7225 }
7226
7227 return this;
7228 };
7229
7230 EventEmitter.prototype.on = EventEmitter.prototype.addListener;
7231
7232 EventEmitter.prototype.once = function(type, listener) {
7233 if (!isFunction(listener))
7234 throw TypeError('listener must be a function');
7235
7236 var fired = false;
7237
7238 function g() {
7239 this.removeListener(type, g);
7240
7241 if (!fired) {
7242 fired = true;
7243 listener.apply(this, arguments);
7244 }
7245 }
7246
7247 g.listener = listener;
7248 this.on(type, g);
7249
7250 return this;
7251 };
7252
7253 // emits a 'removeListener' event iff the listener was removed
7254 EventEmitter.prototype.removeListener = function(type, listener) {
7255 var list, position, length, i;
7256
7257 if (!isFunction(listener))
7258 throw TypeError('listener must be a function');
7259
7260 if (!this._events || !this._events[type])
7261 return this;
7262
7263 list = this._events[type];
7264 length = list.length;
7265 position = -1;
7266
7267 if (list === listener ||
7268 (isFunction(list.listener) && list.listener === listener)) {
7269 delete this._events[type];
7270 if (this._events.removeListener)
7271 this.emit('removeListener', type, listener);
7272
7273 } else if (isObject(list)) {
7274 for (i = length; i-- > 0;) {
7275 if (list[i] === listener ||
7276 (list[i].listener && list[i].listener === listener)) {
7277 position = i;
7278 break;
7279 }
7280 }
7281
7282 if (position < 0)
7283 return this;
7284
7285 if (list.length === 1) {
7286 list.length = 0;
7287 delete this._events[type];
7288 } else {
7289 list.splice(position, 1);
7290 }
7291
7292 if (this._events.removeListener)
7293 this.emit('removeListener', type, listener);
7294 }
7295
7296 return this;
7297 };
7298
7299 EventEmitter.prototype.removeAllListeners = function(type) {
7300 var key, listeners;
7301
7302 if (!this._events)
7303 return this;
7304
7305 // not listening for removeListener, no need to emit
7306 if (!this._events.removeListener) {
7307 if (arguments.length === 0)
7308 this._events = {};
7309 else if (this._events[type])
7310 delete this._events[type];
7311 return this;
7312 }
7313
7314 // emit removeListener for all listeners on all events
7315 if (arguments.length === 0) {
7316 for (key in this._events) {
7317 if (key === 'removeListener') continue;
7318 this.removeAllListeners(key);
7319 }
7320 this.removeAllListeners('removeListener');
7321 this._events = {};
7322 return this;
7323 }
7324
7325 listeners = this._events[type];
7326
7327 if (isFunction(listeners)) {
7328 this.removeListener(type, listeners);
7329 } else if (listeners) {
7330 // LIFO order
7331 while (listeners.length)
7332 this.removeListener(type, listeners[listeners.length - 1]);
7333 }
7334 delete this._events[type];
7335
7336 return this;
7337 };
7338
7339 EventEmitter.prototype.listeners = function(type) {
7340 var ret;
7341 if (!this._events || !this._events[type])
7342 ret = [];
7343 else if (isFunction(this._events[type]))
7344 ret = [this._events[type]];
7345 else
7346 ret = this._events[type].slice();
7347 return ret;
7348 };
7349
7350 EventEmitter.prototype.listenerCount = function(type) {
7351 if (this._events) {
7352 var evlistener = this._events[type];
7353
7354 if (isFunction(evlistener))
7355 return 1;
7356 else if (evlistener)
7357 return evlistener.length;
7358 }
7359 return 0;
7360 };
7361
7362 EventEmitter.listenerCount = function(emitter, type) {
7363 return emitter.listenerCount(type);
7364 };
7365
7366 function isFunction(arg) {
7367 return typeof arg === 'function';
7368 }
7369
7370 function isNumber(arg) {
7371 return typeof arg === 'number';
7372 }
7373
7374 function isObject(arg) {
7375 return typeof arg === 'object' && arg !== null;
7376 }
7377
7378 function isUndefined(arg) {
7379 return arg === void 0;
7380 }
7381
7382
7383/***/ }),
7384/* 34 */
7385/***/ (function(module, exports) {
7386
7387 if (typeof Object.create === 'function') {
7388 // implementation from standard node.js 'util' module
7389 module.exports = function inherits(ctor, superCtor) {
7390 if (superCtor) {
7391 ctor.super_ = superCtor
7392 ctor.prototype = Object.create(superCtor.prototype, {
7393 constructor: {
7394 value: ctor,
7395 enumerable: false,
7396 writable: true,
7397 configurable: true
7398 }
7399 })
7400 }
7401 };
7402 } else {
7403 // old school shim for old browsers
7404 module.exports = function inherits(ctor, superCtor) {
7405 if (superCtor) {
7406 ctor.super_ = superCtor
7407 var TempCtor = function () {}
7408 TempCtor.prototype = superCtor.prototype
7409 ctor.prototype = new TempCtor()
7410 ctor.prototype.constructor = ctor
7411 }
7412 }
7413 }
7414
7415
7416/***/ }),
7417/* 35 */
7418/***/ (function(module, exports, __webpack_require__) {
7419
7420 exports = module.exports = __webpack_require__(36);
7421 exports.Stream = exports;
7422 exports.Readable = exports;
7423 exports.Writable = __webpack_require__(47);
7424 exports.Duplex = __webpack_require__(46);
7425 exports.Transform = __webpack_require__(52);
7426 exports.PassThrough = __webpack_require__(53);
7427
7428
7429/***/ }),
7430/* 36 */
7431/***/ (function(module, exports, __webpack_require__) {
7432
7433 /* WEBPACK VAR INJECTION */(function(global, process) {// Copyright Joyent, Inc. and other Node contributors.
7434 //
7435 // Permission is hereby granted, free of charge, to any person obtaining a
7436 // copy of this software and associated documentation files (the
7437 // "Software"), to deal in the Software without restriction, including
7438 // without limitation the rights to use, copy, modify, merge, publish,
7439 // distribute, sublicense, and/or sell copies of the Software, and to permit
7440 // persons to whom the Software is furnished to do so, subject to the
7441 // following conditions:
7442 //
7443 // The above copyright notice and this permission notice shall be included
7444 // in all copies or substantial portions of the Software.
7445 //
7446 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
7447 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
7448 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
7449 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
7450 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
7451 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
7452 // USE OR OTHER DEALINGS IN THE SOFTWARE.
7453
7454 'use strict';
7455
7456 /*<replacement>*/
7457
7458 var pna = __webpack_require__(38);
7459 /*</replacement>*/
7460
7461 module.exports = Readable;
7462
7463 /*<replacement>*/
7464 var isArray = __webpack_require__(31);
7465 /*</replacement>*/
7466
7467 /*<replacement>*/
7468 var Duplex;
7469 /*</replacement>*/
7470
7471 Readable.ReadableState = ReadableState;
7472
7473 /*<replacement>*/
7474 var EE = __webpack_require__(33).EventEmitter;
7475
7476 var EElistenerCount = function (emitter, type) {
7477 return emitter.listeners(type).length;
7478 };
7479 /*</replacement>*/
7480
7481 /*<replacement>*/
7482 var Stream = __webpack_require__(39);
7483 /*</replacement>*/
7484
7485 /*<replacement>*/
7486
7487 var Buffer = __webpack_require__(40).Buffer;
7488 var OurUint8Array = global.Uint8Array || function () {};
7489 function _uint8ArrayToBuffer(chunk) {
7490 return Buffer.from(chunk);
7491 }
7492 function _isUint8Array(obj) {
7493 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
7494 }
7495
7496 /*</replacement>*/
7497
7498 /*<replacement>*/
7499 var util = Object.create(__webpack_require__(41));
7500 util.inherits = __webpack_require__(34);
7501 /*</replacement>*/
7502
7503 /*<replacement>*/
7504 var debugUtil = __webpack_require__(42);
7505 var debug = void 0;
7506 if (debugUtil && debugUtil.debuglog) {
7507 debug = debugUtil.debuglog('stream');
7508 } else {
7509 debug = function () {};
7510 }
7511 /*</replacement>*/
7512
7513 var BufferList = __webpack_require__(43);
7514 var destroyImpl = __webpack_require__(45);
7515 var StringDecoder;
7516
7517 util.inherits(Readable, Stream);
7518
7519 var kProxyEvents = ['error', 'close', 'destroy', 'pause', 'resume'];
7520
7521 function prependListener(emitter, event, fn) {
7522 // Sadly this is not cacheable as some libraries bundle their own
7523 // event emitter implementation with them.
7524 if (typeof emitter.prependListener === 'function') return emitter.prependListener(event, fn);
7525
7526 // This is a hack to make sure that our error handler is attached before any
7527 // userland ones. NEVER DO THIS. This is here only because this code needs
7528 // to continue to work with older versions of Node.js that do not include
7529 // the prependListener() method. The goal is to eventually remove this hack.
7530 if (!emitter._events || !emitter._events[event]) emitter.on(event, fn);else if (isArray(emitter._events[event])) emitter._events[event].unshift(fn);else emitter._events[event] = [fn, emitter._events[event]];
7531 }
7532
7533 function ReadableState(options, stream) {
7534 Duplex = Duplex || __webpack_require__(46);
7535
7536 options = options || {};
7537
7538 // Duplex streams are both readable and writable, but share
7539 // the same options object.
7540 // However, some cases require setting options to different
7541 // values for the readable and the writable sides of the duplex stream.
7542 // These options can be provided separately as readableXXX and writableXXX.
7543 var isDuplex = stream instanceof Duplex;
7544
7545 // object stream flag. Used to make read(n) ignore n and to
7546 // make all the buffer merging and length checks go away
7547 this.objectMode = !!options.objectMode;
7548
7549 if (isDuplex) this.objectMode = this.objectMode || !!options.readableObjectMode;
7550
7551 // the point at which it stops calling _read() to fill the buffer
7552 // Note: 0 is a valid value, means "don't call _read preemptively ever"
7553 var hwm = options.highWaterMark;
7554 var readableHwm = options.readableHighWaterMark;
7555 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
7556
7557 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (readableHwm || readableHwm === 0)) this.highWaterMark = readableHwm;else this.highWaterMark = defaultHwm;
7558
7559 // cast to ints.
7560 this.highWaterMark = Math.floor(this.highWaterMark);
7561
7562 // A linked list is used to store data chunks instead of an array because the
7563 // linked list can remove elements from the beginning faster than
7564 // array.shift()
7565 this.buffer = new BufferList();
7566 this.length = 0;
7567 this.pipes = null;
7568 this.pipesCount = 0;
7569 this.flowing = null;
7570 this.ended = false;
7571 this.endEmitted = false;
7572 this.reading = false;
7573
7574 // a flag to be able to tell if the event 'readable'/'data' is emitted
7575 // immediately, or on a later tick. We set this to true at first, because
7576 // any actions that shouldn't happen until "later" should generally also
7577 // not happen before the first read call.
7578 this.sync = true;
7579
7580 // whenever we return null, then we set a flag to say
7581 // that we're awaiting a 'readable' event emission.
7582 this.needReadable = false;
7583 this.emittedReadable = false;
7584 this.readableListening = false;
7585 this.resumeScheduled = false;
7586
7587 // has it been destroyed
7588 this.destroyed = false;
7589
7590 // Crypto is kind of old and crusty. Historically, its default string
7591 // encoding is 'binary' so we have to make this configurable.
7592 // Everything else in the universe uses 'utf8', though.
7593 this.defaultEncoding = options.defaultEncoding || 'utf8';
7594
7595 // the number of writers that are awaiting a drain event in .pipe()s
7596 this.awaitDrain = 0;
7597
7598 // if true, a maybeReadMore has been scheduled
7599 this.readingMore = false;
7600
7601 this.decoder = null;
7602 this.encoding = null;
7603 if (options.encoding) {
7604 if (!StringDecoder) StringDecoder = __webpack_require__(51).StringDecoder;
7605 this.decoder = new StringDecoder(options.encoding);
7606 this.encoding = options.encoding;
7607 }
7608 }
7609
7610 function Readable(options) {
7611 Duplex = Duplex || __webpack_require__(46);
7612
7613 if (!(this instanceof Readable)) return new Readable(options);
7614
7615 this._readableState = new ReadableState(options, this);
7616
7617 // legacy
7618 this.readable = true;
7619
7620 if (options) {
7621 if (typeof options.read === 'function') this._read = options.read;
7622
7623 if (typeof options.destroy === 'function') this._destroy = options.destroy;
7624 }
7625
7626 Stream.call(this);
7627 }
7628
7629 Object.defineProperty(Readable.prototype, 'destroyed', {
7630 get: function () {
7631 if (this._readableState === undefined) {
7632 return false;
7633 }
7634 return this._readableState.destroyed;
7635 },
7636 set: function (value) {
7637 // we ignore the value if the stream
7638 // has not been initialized yet
7639 if (!this._readableState) {
7640 return;
7641 }
7642
7643 // backward compatibility, the user is explicitly
7644 // managing destroyed
7645 this._readableState.destroyed = value;
7646 }
7647 });
7648
7649 Readable.prototype.destroy = destroyImpl.destroy;
7650 Readable.prototype._undestroy = destroyImpl.undestroy;
7651 Readable.prototype._destroy = function (err, cb) {
7652 this.push(null);
7653 cb(err);
7654 };
7655
7656 // Manually shove something into the read() buffer.
7657 // This returns true if the highWaterMark has not been hit yet,
7658 // similar to how Writable.write() returns true if you should
7659 // write() some more.
7660 Readable.prototype.push = function (chunk, encoding) {
7661 var state = this._readableState;
7662 var skipChunkCheck;
7663
7664 if (!state.objectMode) {
7665 if (typeof chunk === 'string') {
7666 encoding = encoding || state.defaultEncoding;
7667 if (encoding !== state.encoding) {
7668 chunk = Buffer.from(chunk, encoding);
7669 encoding = '';
7670 }
7671 skipChunkCheck = true;
7672 }
7673 } else {
7674 skipChunkCheck = true;
7675 }
7676
7677 return readableAddChunk(this, chunk, encoding, false, skipChunkCheck);
7678 };
7679
7680 // Unshift should *always* be something directly out of read()
7681 Readable.prototype.unshift = function (chunk) {
7682 return readableAddChunk(this, chunk, null, true, false);
7683 };
7684
7685 function readableAddChunk(stream, chunk, encoding, addToFront, skipChunkCheck) {
7686 var state = stream._readableState;
7687 if (chunk === null) {
7688 state.reading = false;
7689 onEofChunk(stream, state);
7690 } else {
7691 var er;
7692 if (!skipChunkCheck) er = chunkInvalid(state, chunk);
7693 if (er) {
7694 stream.emit('error', er);
7695 } else if (state.objectMode || chunk && chunk.length > 0) {
7696 if (typeof chunk !== 'string' && !state.objectMode && Object.getPrototypeOf(chunk) !== Buffer.prototype) {
7697 chunk = _uint8ArrayToBuffer(chunk);
7698 }
7699
7700 if (addToFront) {
7701 if (state.endEmitted) stream.emit('error', new Error('stream.unshift() after end event'));else addChunk(stream, state, chunk, true);
7702 } else if (state.ended) {
7703 stream.emit('error', new Error('stream.push() after EOF'));
7704 } else {
7705 state.reading = false;
7706 if (state.decoder && !encoding) {
7707 chunk = state.decoder.write(chunk);
7708 if (state.objectMode || chunk.length !== 0) addChunk(stream, state, chunk, false);else maybeReadMore(stream, state);
7709 } else {
7710 addChunk(stream, state, chunk, false);
7711 }
7712 }
7713 } else if (!addToFront) {
7714 state.reading = false;
7715 }
7716 }
7717
7718 return needMoreData(state);
7719 }
7720
7721 function addChunk(stream, state, chunk, addToFront) {
7722 if (state.flowing && state.length === 0 && !state.sync) {
7723 stream.emit('data', chunk);
7724 stream.read(0);
7725 } else {
7726 // update the buffer info.
7727 state.length += state.objectMode ? 1 : chunk.length;
7728 if (addToFront) state.buffer.unshift(chunk);else state.buffer.push(chunk);
7729
7730 if (state.needReadable) emitReadable(stream);
7731 }
7732 maybeReadMore(stream, state);
7733 }
7734
7735 function chunkInvalid(state, chunk) {
7736 var er;
7737 if (!_isUint8Array(chunk) && typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
7738 er = new TypeError('Invalid non-string/buffer chunk');
7739 }
7740 return er;
7741 }
7742
7743 // if it's past the high water mark, we can push in some more.
7744 // Also, if we have no data yet, we can stand some
7745 // more bytes. This is to work around cases where hwm=0,
7746 // such as the repl. Also, if the push() triggered a
7747 // readable event, and the user called read(largeNumber) such that
7748 // needReadable was set, then we ought to push more, so that another
7749 // 'readable' event will be triggered.
7750 function needMoreData(state) {
7751 return !state.ended && (state.needReadable || state.length < state.highWaterMark || state.length === 0);
7752 }
7753
7754 Readable.prototype.isPaused = function () {
7755 return this._readableState.flowing === false;
7756 };
7757
7758 // backwards compatibility.
7759 Readable.prototype.setEncoding = function (enc) {
7760 if (!StringDecoder) StringDecoder = __webpack_require__(51).StringDecoder;
7761 this._readableState.decoder = new StringDecoder(enc);
7762 this._readableState.encoding = enc;
7763 return this;
7764 };
7765
7766 // Don't raise the hwm > 8MB
7767 var MAX_HWM = 0x800000;
7768 function computeNewHighWaterMark(n) {
7769 if (n >= MAX_HWM) {
7770 n = MAX_HWM;
7771 } else {
7772 // Get the next highest power of 2 to prevent increasing hwm excessively in
7773 // tiny amounts
7774 n--;
7775 n |= n >>> 1;
7776 n |= n >>> 2;
7777 n |= n >>> 4;
7778 n |= n >>> 8;
7779 n |= n >>> 16;
7780 n++;
7781 }
7782 return n;
7783 }
7784
7785 // This function is designed to be inlinable, so please take care when making
7786 // changes to the function body.
7787 function howMuchToRead(n, state) {
7788 if (n <= 0 || state.length === 0 && state.ended) return 0;
7789 if (state.objectMode) return 1;
7790 if (n !== n) {
7791 // Only flow one buffer at a time
7792 if (state.flowing && state.length) return state.buffer.head.data.length;else return state.length;
7793 }
7794 // If we're asking for more than the current hwm, then raise the hwm.
7795 if (n > state.highWaterMark) state.highWaterMark = computeNewHighWaterMark(n);
7796 if (n <= state.length) return n;
7797 // Don't have enough
7798 if (!state.ended) {
7799 state.needReadable = true;
7800 return 0;
7801 }
7802 return state.length;
7803 }
7804
7805 // you can override either this method, or the async _read(n) below.
7806 Readable.prototype.read = function (n) {
7807 debug('read', n);
7808 n = parseInt(n, 10);
7809 var state = this._readableState;
7810 var nOrig = n;
7811
7812 if (n !== 0) state.emittedReadable = false;
7813
7814 // if we're doing read(0) to trigger a readable event, but we
7815 // already have a bunch of data in the buffer, then just trigger
7816 // the 'readable' event and move on.
7817 if (n === 0 && state.needReadable && (state.length >= state.highWaterMark || state.ended)) {
7818 debug('read: emitReadable', state.length, state.ended);
7819 if (state.length === 0 && state.ended) endReadable(this);else emitReadable(this);
7820 return null;
7821 }
7822
7823 n = howMuchToRead(n, state);
7824
7825 // if we've ended, and we're now clear, then finish it up.
7826 if (n === 0 && state.ended) {
7827 if (state.length === 0) endReadable(this);
7828 return null;
7829 }
7830
7831 // All the actual chunk generation logic needs to be
7832 // *below* the call to _read. The reason is that in certain
7833 // synthetic stream cases, such as passthrough streams, _read
7834 // may be a completely synchronous operation which may change
7835 // the state of the read buffer, providing enough data when
7836 // before there was *not* enough.
7837 //
7838 // So, the steps are:
7839 // 1. Figure out what the state of things will be after we do
7840 // a read from the buffer.
7841 //
7842 // 2. If that resulting state will trigger a _read, then call _read.
7843 // Note that this may be asynchronous, or synchronous. Yes, it is
7844 // deeply ugly to write APIs this way, but that still doesn't mean
7845 // that the Readable class should behave improperly, as streams are
7846 // designed to be sync/async agnostic.
7847 // Take note if the _read call is sync or async (ie, if the read call
7848 // has returned yet), so that we know whether or not it's safe to emit
7849 // 'readable' etc.
7850 //
7851 // 3. Actually pull the requested chunks out of the buffer and return.
7852
7853 // if we need a readable event, then we need to do some reading.
7854 var doRead = state.needReadable;
7855 debug('need readable', doRead);
7856
7857 // if we currently have less than the highWaterMark, then also read some
7858 if (state.length === 0 || state.length - n < state.highWaterMark) {
7859 doRead = true;
7860 debug('length less than watermark', doRead);
7861 }
7862
7863 // however, if we've ended, then there's no point, and if we're already
7864 // reading, then it's unnecessary.
7865 if (state.ended || state.reading) {
7866 doRead = false;
7867 debug('reading or ended', doRead);
7868 } else if (doRead) {
7869 debug('do read');
7870 state.reading = true;
7871 state.sync = true;
7872 // if the length is currently zero, then we *need* a readable event.
7873 if (state.length === 0) state.needReadable = true;
7874 // call internal read method
7875 this._read(state.highWaterMark);
7876 state.sync = false;
7877 // If _read pushed data synchronously, then `reading` will be false,
7878 // and we need to re-evaluate how much data we can return to the user.
7879 if (!state.reading) n = howMuchToRead(nOrig, state);
7880 }
7881
7882 var ret;
7883 if (n > 0) ret = fromList(n, state);else ret = null;
7884
7885 if (ret === null) {
7886 state.needReadable = true;
7887 n = 0;
7888 } else {
7889 state.length -= n;
7890 }
7891
7892 if (state.length === 0) {
7893 // If we have nothing in the buffer, then we want to know
7894 // as soon as we *do* get something into the buffer.
7895 if (!state.ended) state.needReadable = true;
7896
7897 // If we tried to read() past the EOF, then emit end on the next tick.
7898 if (nOrig !== n && state.ended) endReadable(this);
7899 }
7900
7901 if (ret !== null) this.emit('data', ret);
7902
7903 return ret;
7904 };
7905
7906 function onEofChunk(stream, state) {
7907 if (state.ended) return;
7908 if (state.decoder) {
7909 var chunk = state.decoder.end();
7910 if (chunk && chunk.length) {
7911 state.buffer.push(chunk);
7912 state.length += state.objectMode ? 1 : chunk.length;
7913 }
7914 }
7915 state.ended = true;
7916
7917 // emit 'readable' now to make sure it gets picked up.
7918 emitReadable(stream);
7919 }
7920
7921 // Don't emit readable right away in sync mode, because this can trigger
7922 // another read() call => stack overflow. This way, it might trigger
7923 // a nextTick recursion warning, but that's not so bad.
7924 function emitReadable(stream) {
7925 var state = stream._readableState;
7926 state.needReadable = false;
7927 if (!state.emittedReadable) {
7928 debug('emitReadable', state.flowing);
7929 state.emittedReadable = true;
7930 if (state.sync) pna.nextTick(emitReadable_, stream);else emitReadable_(stream);
7931 }
7932 }
7933
7934 function emitReadable_(stream) {
7935 debug('emit readable');
7936 stream.emit('readable');
7937 flow(stream);
7938 }
7939
7940 // at this point, the user has presumably seen the 'readable' event,
7941 // and called read() to consume some data. that may have triggered
7942 // in turn another _read(n) call, in which case reading = true if
7943 // it's in progress.
7944 // However, if we're not ended, or reading, and the length < hwm,
7945 // then go ahead and try to read some more preemptively.
7946 function maybeReadMore(stream, state) {
7947 if (!state.readingMore) {
7948 state.readingMore = true;
7949 pna.nextTick(maybeReadMore_, stream, state);
7950 }
7951 }
7952
7953 function maybeReadMore_(stream, state) {
7954 var len = state.length;
7955 while (!state.reading && !state.flowing && !state.ended && state.length < state.highWaterMark) {
7956 debug('maybeReadMore read 0');
7957 stream.read(0);
7958 if (len === state.length)
7959 // didn't get any data, stop spinning.
7960 break;else len = state.length;
7961 }
7962 state.readingMore = false;
7963 }
7964
7965 // abstract method. to be overridden in specific implementation classes.
7966 // call cb(er, data) where data is <= n in length.
7967 // for virtual (non-string, non-buffer) streams, "length" is somewhat
7968 // arbitrary, and perhaps not very meaningful.
7969 Readable.prototype._read = function (n) {
7970 this.emit('error', new Error('_read() is not implemented'));
7971 };
7972
7973 Readable.prototype.pipe = function (dest, pipeOpts) {
7974 var src = this;
7975 var state = this._readableState;
7976
7977 switch (state.pipesCount) {
7978 case 0:
7979 state.pipes = dest;
7980 break;
7981 case 1:
7982 state.pipes = [state.pipes, dest];
7983 break;
7984 default:
7985 state.pipes.push(dest);
7986 break;
7987 }
7988 state.pipesCount += 1;
7989 debug('pipe count=%d opts=%j', state.pipesCount, pipeOpts);
7990
7991 var doEnd = (!pipeOpts || pipeOpts.end !== false) && dest !== process.stdout && dest !== process.stderr;
7992
7993 var endFn = doEnd ? onend : unpipe;
7994 if (state.endEmitted) pna.nextTick(endFn);else src.once('end', endFn);
7995
7996 dest.on('unpipe', onunpipe);
7997 function onunpipe(readable, unpipeInfo) {
7998 debug('onunpipe');
7999 if (readable === src) {
8000 if (unpipeInfo && unpipeInfo.hasUnpiped === false) {
8001 unpipeInfo.hasUnpiped = true;
8002 cleanup();
8003 }
8004 }
8005 }
8006
8007 function onend() {
8008 debug('onend');
8009 dest.end();
8010 }
8011
8012 // when the dest drains, it reduces the awaitDrain counter
8013 // on the source. This would be more elegant with a .once()
8014 // handler in flow(), but adding and removing repeatedly is
8015 // too slow.
8016 var ondrain = pipeOnDrain(src);
8017 dest.on('drain', ondrain);
8018
8019 var cleanedUp = false;
8020 function cleanup() {
8021 debug('cleanup');
8022 // cleanup event handlers once the pipe is broken
8023 dest.removeListener('close', onclose);
8024 dest.removeListener('finish', onfinish);
8025 dest.removeListener('drain', ondrain);
8026 dest.removeListener('error', onerror);
8027 dest.removeListener('unpipe', onunpipe);
8028 src.removeListener('end', onend);
8029 src.removeListener('end', unpipe);
8030 src.removeListener('data', ondata);
8031
8032 cleanedUp = true;
8033
8034 // if the reader is waiting for a drain event from this
8035 // specific writer, then it would cause it to never start
8036 // flowing again.
8037 // So, if this is awaiting a drain, then we just call it now.
8038 // If we don't know, then assume that we are waiting for one.
8039 if (state.awaitDrain && (!dest._writableState || dest._writableState.needDrain)) ondrain();
8040 }
8041
8042 // If the user pushes more data while we're writing to dest then we'll end up
8043 // in ondata again. However, we only want to increase awaitDrain once because
8044 // dest will only emit one 'drain' event for the multiple writes.
8045 // => Introduce a guard on increasing awaitDrain.
8046 var increasedAwaitDrain = false;
8047 src.on('data', ondata);
8048 function ondata(chunk) {
8049 debug('ondata');
8050 increasedAwaitDrain = false;
8051 var ret = dest.write(chunk);
8052 if (false === ret && !increasedAwaitDrain) {
8053 // If the user unpiped during `dest.write()`, it is possible
8054 // to get stuck in a permanently paused state if that write
8055 // also returned false.
8056 // => Check whether `dest` is still a piping destination.
8057 if ((state.pipesCount === 1 && state.pipes === dest || state.pipesCount > 1 && indexOf(state.pipes, dest) !== -1) && !cleanedUp) {
8058 debug('false write response, pause', src._readableState.awaitDrain);
8059 src._readableState.awaitDrain++;
8060 increasedAwaitDrain = true;
8061 }
8062 src.pause();
8063 }
8064 }
8065
8066 // if the dest has an error, then stop piping into it.
8067 // however, don't suppress the throwing behavior for this.
8068 function onerror(er) {
8069 debug('onerror', er);
8070 unpipe();
8071 dest.removeListener('error', onerror);
8072 if (EElistenerCount(dest, 'error') === 0) dest.emit('error', er);
8073 }
8074
8075 // Make sure our error handler is attached before userland ones.
8076 prependListener(dest, 'error', onerror);
8077
8078 // Both close and finish should trigger unpipe, but only once.
8079 function onclose() {
8080 dest.removeListener('finish', onfinish);
8081 unpipe();
8082 }
8083 dest.once('close', onclose);
8084 function onfinish() {
8085 debug('onfinish');
8086 dest.removeListener('close', onclose);
8087 unpipe();
8088 }
8089 dest.once('finish', onfinish);
8090
8091 function unpipe() {
8092 debug('unpipe');
8093 src.unpipe(dest);
8094 }
8095
8096 // tell the dest that it's being piped to
8097 dest.emit('pipe', src);
8098
8099 // start the flow if it hasn't been started already.
8100 if (!state.flowing) {
8101 debug('pipe resume');
8102 src.resume();
8103 }
8104
8105 return dest;
8106 };
8107
8108 function pipeOnDrain(src) {
8109 return function () {
8110 var state = src._readableState;
8111 debug('pipeOnDrain', state.awaitDrain);
8112 if (state.awaitDrain) state.awaitDrain--;
8113 if (state.awaitDrain === 0 && EElistenerCount(src, 'data')) {
8114 state.flowing = true;
8115 flow(src);
8116 }
8117 };
8118 }
8119
8120 Readable.prototype.unpipe = function (dest) {
8121 var state = this._readableState;
8122 var unpipeInfo = { hasUnpiped: false };
8123
8124 // if we're not piping anywhere, then do nothing.
8125 if (state.pipesCount === 0) return this;
8126
8127 // just one destination. most common case.
8128 if (state.pipesCount === 1) {
8129 // passed in one, but it's not the right one.
8130 if (dest && dest !== state.pipes) return this;
8131
8132 if (!dest) dest = state.pipes;
8133
8134 // got a match.
8135 state.pipes = null;
8136 state.pipesCount = 0;
8137 state.flowing = false;
8138 if (dest) dest.emit('unpipe', this, unpipeInfo);
8139 return this;
8140 }
8141
8142 // slow case. multiple pipe destinations.
8143
8144 if (!dest) {
8145 // remove all.
8146 var dests = state.pipes;
8147 var len = state.pipesCount;
8148 state.pipes = null;
8149 state.pipesCount = 0;
8150 state.flowing = false;
8151
8152 for (var i = 0; i < len; i++) {
8153 dests[i].emit('unpipe', this, unpipeInfo);
8154 }return this;
8155 }
8156
8157 // try to find the right one.
8158 var index = indexOf(state.pipes, dest);
8159 if (index === -1) return this;
8160
8161 state.pipes.splice(index, 1);
8162 state.pipesCount -= 1;
8163 if (state.pipesCount === 1) state.pipes = state.pipes[0];
8164
8165 dest.emit('unpipe', this, unpipeInfo);
8166
8167 return this;
8168 };
8169
8170 // set up data events if they are asked for
8171 // Ensure readable listeners eventually get something
8172 Readable.prototype.on = function (ev, fn) {
8173 var res = Stream.prototype.on.call(this, ev, fn);
8174
8175 if (ev === 'data') {
8176 // Start flowing on next tick if stream isn't explicitly paused
8177 if (this._readableState.flowing !== false) this.resume();
8178 } else if (ev === 'readable') {
8179 var state = this._readableState;
8180 if (!state.endEmitted && !state.readableListening) {
8181 state.readableListening = state.needReadable = true;
8182 state.emittedReadable = false;
8183 if (!state.reading) {
8184 pna.nextTick(nReadingNextTick, this);
8185 } else if (state.length) {
8186 emitReadable(this);
8187 }
8188 }
8189 }
8190
8191 return res;
8192 };
8193 Readable.prototype.addListener = Readable.prototype.on;
8194
8195 function nReadingNextTick(self) {
8196 debug('readable nexttick read 0');
8197 self.read(0);
8198 }
8199
8200 // pause() and resume() are remnants of the legacy readable stream API
8201 // If the user uses them, then switch into old mode.
8202 Readable.prototype.resume = function () {
8203 var state = this._readableState;
8204 if (!state.flowing) {
8205 debug('resume');
8206 state.flowing = true;
8207 resume(this, state);
8208 }
8209 return this;
8210 };
8211
8212 function resume(stream, state) {
8213 if (!state.resumeScheduled) {
8214 state.resumeScheduled = true;
8215 pna.nextTick(resume_, stream, state);
8216 }
8217 }
8218
8219 function resume_(stream, state) {
8220 if (!state.reading) {
8221 debug('resume read 0');
8222 stream.read(0);
8223 }
8224
8225 state.resumeScheduled = false;
8226 state.awaitDrain = 0;
8227 stream.emit('resume');
8228 flow(stream);
8229 if (state.flowing && !state.reading) stream.read(0);
8230 }
8231
8232 Readable.prototype.pause = function () {
8233 debug('call pause flowing=%j', this._readableState.flowing);
8234 if (false !== this._readableState.flowing) {
8235 debug('pause');
8236 this._readableState.flowing = false;
8237 this.emit('pause');
8238 }
8239 return this;
8240 };
8241
8242 function flow(stream) {
8243 var state = stream._readableState;
8244 debug('flow', state.flowing);
8245 while (state.flowing && stream.read() !== null) {}
8246 }
8247
8248 // wrap an old-style stream as the async data source.
8249 // This is *not* part of the readable stream interface.
8250 // It is an ugly unfortunate mess of history.
8251 Readable.prototype.wrap = function (stream) {
8252 var _this = this;
8253
8254 var state = this._readableState;
8255 var paused = false;
8256
8257 stream.on('end', function () {
8258 debug('wrapped end');
8259 if (state.decoder && !state.ended) {
8260 var chunk = state.decoder.end();
8261 if (chunk && chunk.length) _this.push(chunk);
8262 }
8263
8264 _this.push(null);
8265 });
8266
8267 stream.on('data', function (chunk) {
8268 debug('wrapped data');
8269 if (state.decoder) chunk = state.decoder.write(chunk);
8270
8271 // don't skip over falsy values in objectMode
8272 if (state.objectMode && (chunk === null || chunk === undefined)) return;else if (!state.objectMode && (!chunk || !chunk.length)) return;
8273
8274 var ret = _this.push(chunk);
8275 if (!ret) {
8276 paused = true;
8277 stream.pause();
8278 }
8279 });
8280
8281 // proxy all the other methods.
8282 // important when wrapping filters and duplexes.
8283 for (var i in stream) {
8284 if (this[i] === undefined && typeof stream[i] === 'function') {
8285 this[i] = function (method) {
8286 return function () {
8287 return stream[method].apply(stream, arguments);
8288 };
8289 }(i);
8290 }
8291 }
8292
8293 // proxy certain important events.
8294 for (var n = 0; n < kProxyEvents.length; n++) {
8295 stream.on(kProxyEvents[n], this.emit.bind(this, kProxyEvents[n]));
8296 }
8297
8298 // when we try to consume some more bytes, simply unpause the
8299 // underlying stream.
8300 this._read = function (n) {
8301 debug('wrapped _read', n);
8302 if (paused) {
8303 paused = false;
8304 stream.resume();
8305 }
8306 };
8307
8308 return this;
8309 };
8310
8311 Object.defineProperty(Readable.prototype, 'readableHighWaterMark', {
8312 // making it explicit this property is not enumerable
8313 // because otherwise some prototype manipulation in
8314 // userland will fail
8315 enumerable: false,
8316 get: function () {
8317 return this._readableState.highWaterMark;
8318 }
8319 });
8320
8321 // exposed for testing purposes only.
8322 Readable._fromList = fromList;
8323
8324 // Pluck off n bytes from an array of buffers.
8325 // Length is the combined lengths of all the buffers in the list.
8326 // This function is designed to be inlinable, so please take care when making
8327 // changes to the function body.
8328 function fromList(n, state) {
8329 // nothing buffered
8330 if (state.length === 0) return null;
8331
8332 var ret;
8333 if (state.objectMode) ret = state.buffer.shift();else if (!n || n >= state.length) {
8334 // read it all, truncate the list
8335 if (state.decoder) ret = state.buffer.join('');else if (state.buffer.length === 1) ret = state.buffer.head.data;else ret = state.buffer.concat(state.length);
8336 state.buffer.clear();
8337 } else {
8338 // read part of list
8339 ret = fromListPartial(n, state.buffer, state.decoder);
8340 }
8341
8342 return ret;
8343 }
8344
8345 // Extracts only enough buffered data to satisfy the amount requested.
8346 // This function is designed to be inlinable, so please take care when making
8347 // changes to the function body.
8348 function fromListPartial(n, list, hasStrings) {
8349 var ret;
8350 if (n < list.head.data.length) {
8351 // slice is the same for buffers and strings
8352 ret = list.head.data.slice(0, n);
8353 list.head.data = list.head.data.slice(n);
8354 } else if (n === list.head.data.length) {
8355 // first chunk is a perfect match
8356 ret = list.shift();
8357 } else {
8358 // result spans more than one buffer
8359 ret = hasStrings ? copyFromBufferString(n, list) : copyFromBuffer(n, list);
8360 }
8361 return ret;
8362 }
8363
8364 // Copies a specified amount of characters from the list of buffered data
8365 // chunks.
8366 // This function is designed to be inlinable, so please take care when making
8367 // changes to the function body.
8368 function copyFromBufferString(n, list) {
8369 var p = list.head;
8370 var c = 1;
8371 var ret = p.data;
8372 n -= ret.length;
8373 while (p = p.next) {
8374 var str = p.data;
8375 var nb = n > str.length ? str.length : n;
8376 if (nb === str.length) ret += str;else ret += str.slice(0, n);
8377 n -= nb;
8378 if (n === 0) {
8379 if (nb === str.length) {
8380 ++c;
8381 if (p.next) list.head = p.next;else list.head = list.tail = null;
8382 } else {
8383 list.head = p;
8384 p.data = str.slice(nb);
8385 }
8386 break;
8387 }
8388 ++c;
8389 }
8390 list.length -= c;
8391 return ret;
8392 }
8393
8394 // Copies a specified amount of bytes from the list of buffered data chunks.
8395 // This function is designed to be inlinable, so please take care when making
8396 // changes to the function body.
8397 function copyFromBuffer(n, list) {
8398 var ret = Buffer.allocUnsafe(n);
8399 var p = list.head;
8400 var c = 1;
8401 p.data.copy(ret);
8402 n -= p.data.length;
8403 while (p = p.next) {
8404 var buf = p.data;
8405 var nb = n > buf.length ? buf.length : n;
8406 buf.copy(ret, ret.length - n, 0, nb);
8407 n -= nb;
8408 if (n === 0) {
8409 if (nb === buf.length) {
8410 ++c;
8411 if (p.next) list.head = p.next;else list.head = list.tail = null;
8412 } else {
8413 list.head = p;
8414 p.data = buf.slice(nb);
8415 }
8416 break;
8417 }
8418 ++c;
8419 }
8420 list.length -= c;
8421 return ret;
8422 }
8423
8424 function endReadable(stream) {
8425 var state = stream._readableState;
8426
8427 // If we get here before consuming all the bytes, then that is a
8428 // bug in node. Should never happen.
8429 if (state.length > 0) throw new Error('"endReadable()" called on non-empty stream');
8430
8431 if (!state.endEmitted) {
8432 state.ended = true;
8433 pna.nextTick(endReadableNT, state, stream);
8434 }
8435 }
8436
8437 function endReadableNT(state, stream) {
8438 // Check that we didn't get one last unshift.
8439 if (!state.endEmitted && state.length === 0) {
8440 state.endEmitted = true;
8441 stream.readable = false;
8442 stream.emit('end');
8443 }
8444 }
8445
8446 function indexOf(xs, x) {
8447 for (var i = 0, l = xs.length; i < l; i++) {
8448 if (xs[i] === x) return i;
8449 }
8450 return -1;
8451 }
8452 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(37)))
8453
8454/***/ }),
8455/* 37 */
8456/***/ (function(module, exports) {
8457
8458 // shim for using process in browser
8459 var process = module.exports = {};
8460
8461 // cached from whatever global is present so that test runners that stub it
8462 // don't break things. But we need to wrap it in a try catch in case it is
8463 // wrapped in strict mode code which doesn't define any globals. It's inside a
8464 // function because try/catches deoptimize in certain engines.
8465
8466 var cachedSetTimeout;
8467 var cachedClearTimeout;
8468
8469 function defaultSetTimout() {
8470 throw new Error('setTimeout has not been defined');
8471 }
8472 function defaultClearTimeout () {
8473 throw new Error('clearTimeout has not been defined');
8474 }
8475 (function () {
8476 try {
8477 if (typeof setTimeout === 'function') {
8478 cachedSetTimeout = setTimeout;
8479 } else {
8480 cachedSetTimeout = defaultSetTimout;
8481 }
8482 } catch (e) {
8483 cachedSetTimeout = defaultSetTimout;
8484 }
8485 try {
8486 if (typeof clearTimeout === 'function') {
8487 cachedClearTimeout = clearTimeout;
8488 } else {
8489 cachedClearTimeout = defaultClearTimeout;
8490 }
8491 } catch (e) {
8492 cachedClearTimeout = defaultClearTimeout;
8493 }
8494 } ())
8495 function runTimeout(fun) {
8496 if (cachedSetTimeout === setTimeout) {
8497 //normal enviroments in sane situations
8498 return setTimeout(fun, 0);
8499 }
8500 // if setTimeout wasn't available but was latter defined
8501 if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
8502 cachedSetTimeout = setTimeout;
8503 return setTimeout(fun, 0);
8504 }
8505 try {
8506 // when when somebody has screwed with setTimeout but no I.E. maddness
8507 return cachedSetTimeout(fun, 0);
8508 } catch(e){
8509 try {
8510 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
8511 return cachedSetTimeout.call(null, fun, 0);
8512 } catch(e){
8513 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
8514 return cachedSetTimeout.call(this, fun, 0);
8515 }
8516 }
8517
8518
8519 }
8520 function runClearTimeout(marker) {
8521 if (cachedClearTimeout === clearTimeout) {
8522 //normal enviroments in sane situations
8523 return clearTimeout(marker);
8524 }
8525 // if clearTimeout wasn't available but was latter defined
8526 if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
8527 cachedClearTimeout = clearTimeout;
8528 return clearTimeout(marker);
8529 }
8530 try {
8531 // when when somebody has screwed with setTimeout but no I.E. maddness
8532 return cachedClearTimeout(marker);
8533 } catch (e){
8534 try {
8535 // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
8536 return cachedClearTimeout.call(null, marker);
8537 } catch (e){
8538 // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
8539 // Some versions of I.E. have different rules for clearTimeout vs setTimeout
8540 return cachedClearTimeout.call(this, marker);
8541 }
8542 }
8543
8544
8545
8546 }
8547 var queue = [];
8548 var draining = false;
8549 var currentQueue;
8550 var queueIndex = -1;
8551
8552 function cleanUpNextTick() {
8553 if (!draining || !currentQueue) {
8554 return;
8555 }
8556 draining = false;
8557 if (currentQueue.length) {
8558 queue = currentQueue.concat(queue);
8559 } else {
8560 queueIndex = -1;
8561 }
8562 if (queue.length) {
8563 drainQueue();
8564 }
8565 }
8566
8567 function drainQueue() {
8568 if (draining) {
8569 return;
8570 }
8571 var timeout = runTimeout(cleanUpNextTick);
8572 draining = true;
8573
8574 var len = queue.length;
8575 while(len) {
8576 currentQueue = queue;
8577 queue = [];
8578 while (++queueIndex < len) {
8579 if (currentQueue) {
8580 currentQueue[queueIndex].run();
8581 }
8582 }
8583 queueIndex = -1;
8584 len = queue.length;
8585 }
8586 currentQueue = null;
8587 draining = false;
8588 runClearTimeout(timeout);
8589 }
8590
8591 process.nextTick = function (fun) {
8592 var args = new Array(arguments.length - 1);
8593 if (arguments.length > 1) {
8594 for (var i = 1; i < arguments.length; i++) {
8595 args[i - 1] = arguments[i];
8596 }
8597 }
8598 queue.push(new Item(fun, args));
8599 if (queue.length === 1 && !draining) {
8600 runTimeout(drainQueue);
8601 }
8602 };
8603
8604 // v8 likes predictible objects
8605 function Item(fun, array) {
8606 this.fun = fun;
8607 this.array = array;
8608 }
8609 Item.prototype.run = function () {
8610 this.fun.apply(null, this.array);
8611 };
8612 process.title = 'browser';
8613 process.browser = true;
8614 process.env = {};
8615 process.argv = [];
8616 process.version = ''; // empty string to avoid regexp issues
8617 process.versions = {};
8618
8619 function noop() {}
8620
8621 process.on = noop;
8622 process.addListener = noop;
8623 process.once = noop;
8624 process.off = noop;
8625 process.removeListener = noop;
8626 process.removeAllListeners = noop;
8627 process.emit = noop;
8628 process.prependListener = noop;
8629 process.prependOnceListener = noop;
8630
8631 process.listeners = function (name) { return [] }
8632
8633 process.binding = function (name) {
8634 throw new Error('process.binding is not supported');
8635 };
8636
8637 process.cwd = function () { return '/' };
8638 process.chdir = function (dir) {
8639 throw new Error('process.chdir is not supported');
8640 };
8641 process.umask = function() { return 0; };
8642
8643
8644/***/ }),
8645/* 38 */
8646/***/ (function(module, exports, __webpack_require__) {
8647
8648 /* WEBPACK VAR INJECTION */(function(process) {'use strict';
8649
8650 if (typeof process === 'undefined' ||
8651 !process.version ||
8652 process.version.indexOf('v0.') === 0 ||
8653 process.version.indexOf('v1.') === 0 && process.version.indexOf('v1.8.') !== 0) {
8654 module.exports = { nextTick: nextTick };
8655 } else {
8656 module.exports = process
8657 }
8658
8659 function nextTick(fn, arg1, arg2, arg3) {
8660 if (typeof fn !== 'function') {
8661 throw new TypeError('"callback" argument must be a function');
8662 }
8663 var len = arguments.length;
8664 var args, i;
8665 switch (len) {
8666 case 0:
8667 case 1:
8668 return process.nextTick(fn);
8669 case 2:
8670 return process.nextTick(function afterTickOne() {
8671 fn.call(null, arg1);
8672 });
8673 case 3:
8674 return process.nextTick(function afterTickTwo() {
8675 fn.call(null, arg1, arg2);
8676 });
8677 case 4:
8678 return process.nextTick(function afterTickThree() {
8679 fn.call(null, arg1, arg2, arg3);
8680 });
8681 default:
8682 args = new Array(len - 1);
8683 i = 0;
8684 while (i < args.length) {
8685 args[i++] = arguments[i];
8686 }
8687 return process.nextTick(function afterTick() {
8688 fn.apply(null, args);
8689 });
8690 }
8691 }
8692
8693
8694 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(37)))
8695
8696/***/ }),
8697/* 39 */
8698/***/ (function(module, exports, __webpack_require__) {
8699
8700 module.exports = __webpack_require__(33).EventEmitter;
8701
8702
8703/***/ }),
8704/* 40 */
8705/***/ (function(module, exports, __webpack_require__) {
8706
8707 /* eslint-disable node/no-deprecated-api */
8708 var buffer = __webpack_require__(28)
8709 var Buffer = buffer.Buffer
8710
8711 // alternative to using Object.keys for old browsers
8712 function copyProps (src, dst) {
8713 for (var key in src) {
8714 dst[key] = src[key]
8715 }
8716 }
8717 if (Buffer.from && Buffer.alloc && Buffer.allocUnsafe && Buffer.allocUnsafeSlow) {
8718 module.exports = buffer
8719 } else {
8720 // Copy properties from require('buffer')
8721 copyProps(buffer, exports)
8722 exports.Buffer = SafeBuffer
8723 }
8724
8725 function SafeBuffer (arg, encodingOrOffset, length) {
8726 return Buffer(arg, encodingOrOffset, length)
8727 }
8728
8729 // Copy static methods from Buffer
8730 copyProps(Buffer, SafeBuffer)
8731
8732 SafeBuffer.from = function (arg, encodingOrOffset, length) {
8733 if (typeof arg === 'number') {
8734 throw new TypeError('Argument must not be a number')
8735 }
8736 return Buffer(arg, encodingOrOffset, length)
8737 }
8738
8739 SafeBuffer.alloc = function (size, fill, encoding) {
8740 if (typeof size !== 'number') {
8741 throw new TypeError('Argument must be a number')
8742 }
8743 var buf = Buffer(size)
8744 if (fill !== undefined) {
8745 if (typeof encoding === 'string') {
8746 buf.fill(fill, encoding)
8747 } else {
8748 buf.fill(fill)
8749 }
8750 } else {
8751 buf.fill(0)
8752 }
8753 return buf
8754 }
8755
8756 SafeBuffer.allocUnsafe = function (size) {
8757 if (typeof size !== 'number') {
8758 throw new TypeError('Argument must be a number')
8759 }
8760 return Buffer(size)
8761 }
8762
8763 SafeBuffer.allocUnsafeSlow = function (size) {
8764 if (typeof size !== 'number') {
8765 throw new TypeError('Argument must be a number')
8766 }
8767 return buffer.SlowBuffer(size)
8768 }
8769
8770
8771/***/ }),
8772/* 41 */
8773/***/ (function(module, exports, __webpack_require__) {
8774
8775 /* WEBPACK VAR INJECTION */(function(Buffer) {// Copyright Joyent, Inc. and other Node contributors.
8776 //
8777 // Permission is hereby granted, free of charge, to any person obtaining a
8778 // copy of this software and associated documentation files (the
8779 // "Software"), to deal in the Software without restriction, including
8780 // without limitation the rights to use, copy, modify, merge, publish,
8781 // distribute, sublicense, and/or sell copies of the Software, and to permit
8782 // persons to whom the Software is furnished to do so, subject to the
8783 // following conditions:
8784 //
8785 // The above copyright notice and this permission notice shall be included
8786 // in all copies or substantial portions of the Software.
8787 //
8788 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
8789 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
8790 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
8791 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
8792 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
8793 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
8794 // USE OR OTHER DEALINGS IN THE SOFTWARE.
8795
8796 // NOTE: These type checking functions intentionally don't use `instanceof`
8797 // because it is fragile and can be easily faked with `Object.create()`.
8798
8799 function isArray(arg) {
8800 if (Array.isArray) {
8801 return Array.isArray(arg);
8802 }
8803 return objectToString(arg) === '[object Array]';
8804 }
8805 exports.isArray = isArray;
8806
8807 function isBoolean(arg) {
8808 return typeof arg === 'boolean';
8809 }
8810 exports.isBoolean = isBoolean;
8811
8812 function isNull(arg) {
8813 return arg === null;
8814 }
8815 exports.isNull = isNull;
8816
8817 function isNullOrUndefined(arg) {
8818 return arg == null;
8819 }
8820 exports.isNullOrUndefined = isNullOrUndefined;
8821
8822 function isNumber(arg) {
8823 return typeof arg === 'number';
8824 }
8825 exports.isNumber = isNumber;
8826
8827 function isString(arg) {
8828 return typeof arg === 'string';
8829 }
8830 exports.isString = isString;
8831
8832 function isSymbol(arg) {
8833 return typeof arg === 'symbol';
8834 }
8835 exports.isSymbol = isSymbol;
8836
8837 function isUndefined(arg) {
8838 return arg === void 0;
8839 }
8840 exports.isUndefined = isUndefined;
8841
8842 function isRegExp(re) {
8843 return objectToString(re) === '[object RegExp]';
8844 }
8845 exports.isRegExp = isRegExp;
8846
8847 function isObject(arg) {
8848 return typeof arg === 'object' && arg !== null;
8849 }
8850 exports.isObject = isObject;
8851
8852 function isDate(d) {
8853 return objectToString(d) === '[object Date]';
8854 }
8855 exports.isDate = isDate;
8856
8857 function isError(e) {
8858 return (objectToString(e) === '[object Error]' || e instanceof Error);
8859 }
8860 exports.isError = isError;
8861
8862 function isFunction(arg) {
8863 return typeof arg === 'function';
8864 }
8865 exports.isFunction = isFunction;
8866
8867 function isPrimitive(arg) {
8868 return arg === null ||
8869 typeof arg === 'boolean' ||
8870 typeof arg === 'number' ||
8871 typeof arg === 'string' ||
8872 typeof arg === 'symbol' || // ES6 symbol
8873 typeof arg === 'undefined';
8874 }
8875 exports.isPrimitive = isPrimitive;
8876
8877 exports.isBuffer = Buffer.isBuffer;
8878
8879 function objectToString(o) {
8880 return Object.prototype.toString.call(o);
8881 }
8882
8883 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(28).Buffer))
8884
8885/***/ }),
8886/* 42 */
8887/***/ (function(module, exports) {
8888
8889 /* (ignored) */
8890
8891/***/ }),
8892/* 43 */
8893/***/ (function(module, exports, __webpack_require__) {
8894
8895 'use strict';
8896
8897 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8898
8899 var Buffer = __webpack_require__(40).Buffer;
8900 var util = __webpack_require__(44);
8901
8902 function copyBuffer(src, target, offset) {
8903 src.copy(target, offset);
8904 }
8905
8906 module.exports = function () {
8907 function BufferList() {
8908 _classCallCheck(this, BufferList);
8909
8910 this.head = null;
8911 this.tail = null;
8912 this.length = 0;
8913 }
8914
8915 BufferList.prototype.push = function push(v) {
8916 var entry = { data: v, next: null };
8917 if (this.length > 0) this.tail.next = entry;else this.head = entry;
8918 this.tail = entry;
8919 ++this.length;
8920 };
8921
8922 BufferList.prototype.unshift = function unshift(v) {
8923 var entry = { data: v, next: this.head };
8924 if (this.length === 0) this.tail = entry;
8925 this.head = entry;
8926 ++this.length;
8927 };
8928
8929 BufferList.prototype.shift = function shift() {
8930 if (this.length === 0) return;
8931 var ret = this.head.data;
8932 if (this.length === 1) this.head = this.tail = null;else this.head = this.head.next;
8933 --this.length;
8934 return ret;
8935 };
8936
8937 BufferList.prototype.clear = function clear() {
8938 this.head = this.tail = null;
8939 this.length = 0;
8940 };
8941
8942 BufferList.prototype.join = function join(s) {
8943 if (this.length === 0) return '';
8944 var p = this.head;
8945 var ret = '' + p.data;
8946 while (p = p.next) {
8947 ret += s + p.data;
8948 }return ret;
8949 };
8950
8951 BufferList.prototype.concat = function concat(n) {
8952 if (this.length === 0) return Buffer.alloc(0);
8953 if (this.length === 1) return this.head.data;
8954 var ret = Buffer.allocUnsafe(n >>> 0);
8955 var p = this.head;
8956 var i = 0;
8957 while (p) {
8958 copyBuffer(p.data, ret, i);
8959 i += p.data.length;
8960 p = p.next;
8961 }
8962 return ret;
8963 };
8964
8965 return BufferList;
8966 }();
8967
8968 if (util && util.inspect && util.inspect.custom) {
8969 module.exports.prototype[util.inspect.custom] = function () {
8970 var obj = util.inspect({ length: this.length });
8971 return this.constructor.name + ' ' + obj;
8972 };
8973 }
8974
8975/***/ }),
8976/* 44 */
8977/***/ (function(module, exports) {
8978
8979 /* (ignored) */
8980
8981/***/ }),
8982/* 45 */
8983/***/ (function(module, exports, __webpack_require__) {
8984
8985 'use strict';
8986
8987 /*<replacement>*/
8988
8989 var pna = __webpack_require__(38);
8990 /*</replacement>*/
8991
8992 // undocumented cb() API, needed for core, not for public API
8993 function destroy(err, cb) {
8994 var _this = this;
8995
8996 var readableDestroyed = this._readableState && this._readableState.destroyed;
8997 var writableDestroyed = this._writableState && this._writableState.destroyed;
8998
8999 if (readableDestroyed || writableDestroyed) {
9000 if (cb) {
9001 cb(err);
9002 } else if (err && (!this._writableState || !this._writableState.errorEmitted)) {
9003 pna.nextTick(emitErrorNT, this, err);
9004 }
9005 return this;
9006 }
9007
9008 // we set destroyed to true before firing error callbacks in order
9009 // to make it re-entrance safe in case destroy() is called within callbacks
9010
9011 if (this._readableState) {
9012 this._readableState.destroyed = true;
9013 }
9014
9015 // if this is a duplex stream mark the writable part as destroyed as well
9016 if (this._writableState) {
9017 this._writableState.destroyed = true;
9018 }
9019
9020 this._destroy(err || null, function (err) {
9021 if (!cb && err) {
9022 pna.nextTick(emitErrorNT, _this, err);
9023 if (_this._writableState) {
9024 _this._writableState.errorEmitted = true;
9025 }
9026 } else if (cb) {
9027 cb(err);
9028 }
9029 });
9030
9031 return this;
9032 }
9033
9034 function undestroy() {
9035 if (this._readableState) {
9036 this._readableState.destroyed = false;
9037 this._readableState.reading = false;
9038 this._readableState.ended = false;
9039 this._readableState.endEmitted = false;
9040 }
9041
9042 if (this._writableState) {
9043 this._writableState.destroyed = false;
9044 this._writableState.ended = false;
9045 this._writableState.ending = false;
9046 this._writableState.finished = false;
9047 this._writableState.errorEmitted = false;
9048 }
9049 }
9050
9051 function emitErrorNT(self, err) {
9052 self.emit('error', err);
9053 }
9054
9055 module.exports = {
9056 destroy: destroy,
9057 undestroy: undestroy
9058 };
9059
9060/***/ }),
9061/* 46 */
9062/***/ (function(module, exports, __webpack_require__) {
9063
9064 // Copyright Joyent, Inc. and other Node contributors.
9065 //
9066 // Permission is hereby granted, free of charge, to any person obtaining a
9067 // copy of this software and associated documentation files (the
9068 // "Software"), to deal in the Software without restriction, including
9069 // without limitation the rights to use, copy, modify, merge, publish,
9070 // distribute, sublicense, and/or sell copies of the Software, and to permit
9071 // persons to whom the Software is furnished to do so, subject to the
9072 // following conditions:
9073 //
9074 // The above copyright notice and this permission notice shall be included
9075 // in all copies or substantial portions of the Software.
9076 //
9077 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9078 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9079 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9080 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9081 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9082 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9083 // USE OR OTHER DEALINGS IN THE SOFTWARE.
9084
9085 // a duplex stream is just a stream that is both readable and writable.
9086 // Since JS doesn't have multiple prototypal inheritance, this class
9087 // prototypally inherits from Readable, and then parasitically from
9088 // Writable.
9089
9090 'use strict';
9091
9092 /*<replacement>*/
9093
9094 var pna = __webpack_require__(38);
9095 /*</replacement>*/
9096
9097 /*<replacement>*/
9098 var objectKeys = Object.keys || function (obj) {
9099 var keys = [];
9100 for (var key in obj) {
9101 keys.push(key);
9102 }return keys;
9103 };
9104 /*</replacement>*/
9105
9106 module.exports = Duplex;
9107
9108 /*<replacement>*/
9109 var util = Object.create(__webpack_require__(41));
9110 util.inherits = __webpack_require__(34);
9111 /*</replacement>*/
9112
9113 var Readable = __webpack_require__(36);
9114 var Writable = __webpack_require__(47);
9115
9116 util.inherits(Duplex, Readable);
9117
9118 {
9119 // avoid scope creep, the keys array can then be collected
9120 var keys = objectKeys(Writable.prototype);
9121 for (var v = 0; v < keys.length; v++) {
9122 var method = keys[v];
9123 if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
9124 }
9125 }
9126
9127 function Duplex(options) {
9128 if (!(this instanceof Duplex)) return new Duplex(options);
9129
9130 Readable.call(this, options);
9131 Writable.call(this, options);
9132
9133 if (options && options.readable === false) this.readable = false;
9134
9135 if (options && options.writable === false) this.writable = false;
9136
9137 this.allowHalfOpen = true;
9138 if (options && options.allowHalfOpen === false) this.allowHalfOpen = false;
9139
9140 this.once('end', onend);
9141 }
9142
9143 Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
9144 // making it explicit this property is not enumerable
9145 // because otherwise some prototype manipulation in
9146 // userland will fail
9147 enumerable: false,
9148 get: function () {
9149 return this._writableState.highWaterMark;
9150 }
9151 });
9152
9153 // the no-half-open enforcer
9154 function onend() {
9155 // if we allow half-open state, or if the writable side ended,
9156 // then we're ok.
9157 if (this.allowHalfOpen || this._writableState.ended) return;
9158
9159 // no more data can be written.
9160 // But allow more writes to happen in this tick.
9161 pna.nextTick(onEndNT, this);
9162 }
9163
9164 function onEndNT(self) {
9165 self.end();
9166 }
9167
9168 Object.defineProperty(Duplex.prototype, 'destroyed', {
9169 get: function () {
9170 if (this._readableState === undefined || this._writableState === undefined) {
9171 return false;
9172 }
9173 return this._readableState.destroyed && this._writableState.destroyed;
9174 },
9175 set: function (value) {
9176 // we ignore the value if the stream
9177 // has not been initialized yet
9178 if (this._readableState === undefined || this._writableState === undefined) {
9179 return;
9180 }
9181
9182 // backward compatibility, the user is explicitly
9183 // managing destroyed
9184 this._readableState.destroyed = value;
9185 this._writableState.destroyed = value;
9186 }
9187 });
9188
9189 Duplex.prototype._destroy = function (err, cb) {
9190 this.push(null);
9191 this.end();
9192
9193 pna.nextTick(cb, err);
9194 };
9195
9196/***/ }),
9197/* 47 */
9198/***/ (function(module, exports, __webpack_require__) {
9199
9200 /* WEBPACK VAR INJECTION */(function(process, setImmediate, global) {// Copyright Joyent, Inc. and other Node contributors.
9201 //
9202 // Permission is hereby granted, free of charge, to any person obtaining a
9203 // copy of this software and associated documentation files (the
9204 // "Software"), to deal in the Software without restriction, including
9205 // without limitation the rights to use, copy, modify, merge, publish,
9206 // distribute, sublicense, and/or sell copies of the Software, and to permit
9207 // persons to whom the Software is furnished to do so, subject to the
9208 // following conditions:
9209 //
9210 // The above copyright notice and this permission notice shall be included
9211 // in all copies or substantial portions of the Software.
9212 //
9213 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
9214 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
9215 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
9216 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
9217 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
9218 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
9219 // USE OR OTHER DEALINGS IN THE SOFTWARE.
9220
9221 // A bit simpler than readable streams.
9222 // Implement an async ._write(chunk, encoding, cb), and it'll handle all
9223 // the drain event emission and buffering.
9224
9225 'use strict';
9226
9227 /*<replacement>*/
9228
9229 var pna = __webpack_require__(38);
9230 /*</replacement>*/
9231
9232 module.exports = Writable;
9233
9234 /* <replacement> */
9235 function WriteReq(chunk, encoding, cb) {
9236 this.chunk = chunk;
9237 this.encoding = encoding;
9238 this.callback = cb;
9239 this.next = null;
9240 }
9241
9242 // It seems a linked list but it is not
9243 // there will be only 2 of these for each stream
9244 function CorkedRequest(state) {
9245 var _this = this;
9246
9247 this.next = null;
9248 this.entry = null;
9249 this.finish = function () {
9250 onCorkedFinish(_this, state);
9251 };
9252 }
9253 /* </replacement> */
9254
9255 /*<replacement>*/
9256 var asyncWrite = !process.browser && ['v0.10', 'v0.9.'].indexOf(process.version.slice(0, 5)) > -1 ? setImmediate : pna.nextTick;
9257 /*</replacement>*/
9258
9259 /*<replacement>*/
9260 var Duplex;
9261 /*</replacement>*/
9262
9263 Writable.WritableState = WritableState;
9264
9265 /*<replacement>*/
9266 var util = Object.create(__webpack_require__(41));
9267 util.inherits = __webpack_require__(34);
9268 /*</replacement>*/
9269
9270 /*<replacement>*/
9271 var internalUtil = {
9272 deprecate: __webpack_require__(50)
9273 };
9274 /*</replacement>*/
9275
9276 /*<replacement>*/
9277 var Stream = __webpack_require__(39);
9278 /*</replacement>*/
9279
9280 /*<replacement>*/
9281
9282 var Buffer = __webpack_require__(40).Buffer;
9283 var OurUint8Array = global.Uint8Array || function () {};
9284 function _uint8ArrayToBuffer(chunk) {
9285 return Buffer.from(chunk);
9286 }
9287 function _isUint8Array(obj) {
9288 return Buffer.isBuffer(obj) || obj instanceof OurUint8Array;
9289 }
9290
9291 /*</replacement>*/
9292
9293 var destroyImpl = __webpack_require__(45);
9294
9295 util.inherits(Writable, Stream);
9296
9297 function nop() {}
9298
9299 function WritableState(options, stream) {
9300 Duplex = Duplex || __webpack_require__(46);
9301
9302 options = options || {};
9303
9304 // Duplex streams are both readable and writable, but share
9305 // the same options object.
9306 // However, some cases require setting options to different
9307 // values for the readable and the writable sides of the duplex stream.
9308 // These options can be provided separately as readableXXX and writableXXX.
9309 var isDuplex = stream instanceof Duplex;
9310
9311 // object stream flag to indicate whether or not this stream
9312 // contains buffers or objects.
9313 this.objectMode = !!options.objectMode;
9314
9315 if (isDuplex) this.objectMode = this.objectMode || !!options.writableObjectMode;
9316
9317 // the point at which write() starts returning false
9318 // Note: 0 is a valid value, means that we always return false if
9319 // the entire buffer is not flushed immediately on write()
9320 var hwm = options.highWaterMark;
9321 var writableHwm = options.writableHighWaterMark;
9322 var defaultHwm = this.objectMode ? 16 : 16 * 1024;
9323
9324 if (hwm || hwm === 0) this.highWaterMark = hwm;else if (isDuplex && (writableHwm || writableHwm === 0)) this.highWaterMark = writableHwm;else this.highWaterMark = defaultHwm;
9325
9326 // cast to ints.
9327 this.highWaterMark = Math.floor(this.highWaterMark);
9328
9329 // if _final has been called
9330 this.finalCalled = false;
9331
9332 // drain event flag.
9333 this.needDrain = false;
9334 // at the start of calling end()
9335 this.ending = false;
9336 // when end() has been called, and returned
9337 this.ended = false;
9338 // when 'finish' is emitted
9339 this.finished = false;
9340
9341 // has it been destroyed
9342 this.destroyed = false;
9343
9344 // should we decode strings into buffers before passing to _write?
9345 // this is here so that some node-core streams can optimize string
9346 // handling at a lower level.
9347 var noDecode = options.decodeStrings === false;
9348 this.decodeStrings = !noDecode;
9349
9350 // Crypto is kind of old and crusty. Historically, its default string
9351 // encoding is 'binary' so we have to make this configurable.
9352 // Everything else in the universe uses 'utf8', though.
9353 this.defaultEncoding = options.defaultEncoding || 'utf8';
9354
9355 // not an actual buffer we keep track of, but a measurement
9356 // of how much we're waiting to get pushed to some underlying
9357 // socket or file.
9358 this.length = 0;
9359
9360 // a flag to see when we're in the middle of a write.
9361 this.writing = false;
9362
9363 // when true all writes will be buffered until .uncork() call
9364 this.corked = 0;
9365
9366 // a flag to be able to tell if the onwrite cb is called immediately,
9367 // or on a later tick. We set this to true at first, because any
9368 // actions that shouldn't happen until "later" should generally also
9369 // not happen before the first write call.
9370 this.sync = true;
9371
9372 // a flag to know if we're processing previously buffered items, which
9373 // may call the _write() callback in the same tick, so that we don't
9374 // end up in an overlapped onwrite situation.
9375 this.bufferProcessing = false;
9376
9377 // the callback that's passed to _write(chunk,cb)
9378 this.onwrite = function (er) {
9379 onwrite(stream, er);
9380 };
9381
9382 // the callback that the user supplies to write(chunk,encoding,cb)
9383 this.writecb = null;
9384
9385 // the amount that is being written when _write is called.
9386 this.writelen = 0;
9387
9388 this.bufferedRequest = null;
9389 this.lastBufferedRequest = null;
9390
9391 // number of pending user-supplied write callbacks
9392 // this must be 0 before 'finish' can be emitted
9393 this.pendingcb = 0;
9394
9395 // emit prefinish if the only thing we're waiting for is _write cbs
9396 // This is relevant for synchronous Transform streams
9397 this.prefinished = false;
9398
9399 // True if the error was already emitted and should not be thrown again
9400 this.errorEmitted = false;
9401
9402 // count buffered requests
9403 this.bufferedRequestCount = 0;
9404
9405 // allocate the first CorkedRequest, there is always
9406 // one allocated and free to use, and we maintain at most two
9407 this.corkedRequestsFree = new CorkedRequest(this);
9408 }
9409
9410 WritableState.prototype.getBuffer = function getBuffer() {
9411 var current = this.bufferedRequest;
9412 var out = [];
9413 while (current) {
9414 out.push(current);
9415 current = current.next;
9416 }
9417 return out;
9418 };
9419
9420 (function () {
9421 try {
9422 Object.defineProperty(WritableState.prototype, 'buffer', {
9423 get: internalUtil.deprecate(function () {
9424 return this.getBuffer();
9425 }, '_writableState.buffer is deprecated. Use _writableState.getBuffer ' + 'instead.', 'DEP0003')
9426 });
9427 } catch (_) {}
9428 })();
9429
9430 // Test _writableState for inheritance to account for Duplex streams,
9431 // whose prototype chain only points to Readable.
9432 var realHasInstance;
9433 if (typeof Symbol === 'function' && Symbol.hasInstance && typeof Function.prototype[Symbol.hasInstance] === 'function') {
9434 realHasInstance = Function.prototype[Symbol.hasInstance];
9435 Object.defineProperty(Writable, Symbol.hasInstance, {
9436 value: function (object) {
9437 if (realHasInstance.call(this, object)) return true;
9438 if (this !== Writable) return false;
9439
9440 return object && object._writableState instanceof WritableState;
9441 }
9442 });
9443 } else {
9444 realHasInstance = function (object) {
9445 return object instanceof this;
9446 };
9447 }
9448
9449 function Writable(options) {
9450 Duplex = Duplex || __webpack_require__(46);
9451
9452 // Writable ctor is applied to Duplexes, too.
9453 // `realHasInstance` is necessary because using plain `instanceof`
9454 // would return false, as no `_writableState` property is attached.
9455
9456 // Trying to use the custom `instanceof` for Writable here will also break the
9457 // Node.js LazyTransform implementation, which has a non-trivial getter for
9458 // `_writableState` that would lead to infinite recursion.
9459 if (!realHasInstance.call(Writable, this) && !(this instanceof Duplex)) {
9460 return new Writable(options);
9461 }
9462
9463 this._writableState = new WritableState(options, this);
9464
9465 // legacy.
9466 this.writable = true;
9467
9468 if (options) {
9469 if (typeof options.write === 'function') this._write = options.write;
9470
9471 if (typeof options.writev === 'function') this._writev = options.writev;
9472
9473 if (typeof options.destroy === 'function') this._destroy = options.destroy;
9474
9475 if (typeof options.final === 'function') this._final = options.final;
9476 }
9477
9478 Stream.call(this);
9479 }
9480
9481 // Otherwise people can pipe Writable streams, which is just wrong.
9482 Writable.prototype.pipe = function () {
9483 this.emit('error', new Error('Cannot pipe, not readable'));
9484 };
9485
9486 function writeAfterEnd(stream, cb) {
9487 var er = new Error('write after end');
9488 // TODO: defer error events consistently everywhere, not just the cb
9489 stream.emit('error', er);
9490 pna.nextTick(cb, er);
9491 }
9492
9493 // Checks that a user-supplied chunk is valid, especially for the particular
9494 // mode the stream is in. Currently this means that `null` is never accepted
9495 // and undefined/non-string values are only allowed in object mode.
9496 function validChunk(stream, state, chunk, cb) {
9497 var valid = true;
9498 var er = false;
9499
9500 if (chunk === null) {
9501 er = new TypeError('May not write null values to stream');
9502 } else if (typeof chunk !== 'string' && chunk !== undefined && !state.objectMode) {
9503 er = new TypeError('Invalid non-string/buffer chunk');
9504 }
9505 if (er) {
9506 stream.emit('error', er);
9507 pna.nextTick(cb, er);
9508 valid = false;
9509 }
9510 return valid;
9511 }
9512
9513 Writable.prototype.write = function (chunk, encoding, cb) {
9514 var state = this._writableState;
9515 var ret = false;
9516 var isBuf = !state.objectMode && _isUint8Array(chunk);
9517
9518 if (isBuf && !Buffer.isBuffer(chunk)) {
9519 chunk = _uint8ArrayToBuffer(chunk);
9520 }
9521
9522 if (typeof encoding === 'function') {
9523 cb = encoding;
9524 encoding = null;
9525 }
9526
9527 if (isBuf) encoding = 'buffer';else if (!encoding) encoding = state.defaultEncoding;
9528
9529 if (typeof cb !== 'function') cb = nop;
9530
9531 if (state.ended) writeAfterEnd(this, cb);else if (isBuf || validChunk(this, state, chunk, cb)) {
9532 state.pendingcb++;
9533 ret = writeOrBuffer(this, state, isBuf, chunk, encoding, cb);
9534 }
9535
9536 return ret;
9537 };
9538
9539 Writable.prototype.cork = function () {
9540 var state = this._writableState;
9541
9542 state.corked++;
9543 };
9544
9545 Writable.prototype.uncork = function () {
9546 var state = this._writableState;
9547
9548 if (state.corked) {
9549 state.corked--;
9550
9551 if (!state.writing && !state.corked && !state.finished && !state.bufferProcessing && state.bufferedRequest) clearBuffer(this, state);
9552 }
9553 };
9554
9555 Writable.prototype.setDefaultEncoding = function setDefaultEncoding(encoding) {
9556 // node::ParseEncoding() requires lower case.
9557 if (typeof encoding === 'string') encoding = encoding.toLowerCase();
9558 if (!(['hex', 'utf8', 'utf-8', 'ascii', 'binary', 'base64', 'ucs2', 'ucs-2', 'utf16le', 'utf-16le', 'raw'].indexOf((encoding + '').toLowerCase()) > -1)) throw new TypeError('Unknown encoding: ' + encoding);
9559 this._writableState.defaultEncoding = encoding;
9560 return this;
9561 };
9562
9563 function decodeChunk(state, chunk, encoding) {
9564 if (!state.objectMode && state.decodeStrings !== false && typeof chunk === 'string') {
9565 chunk = Buffer.from(chunk, encoding);
9566 }
9567 return chunk;
9568 }
9569
9570 Object.defineProperty(Writable.prototype, 'writableHighWaterMark', {
9571 // making it explicit this property is not enumerable
9572 // because otherwise some prototype manipulation in
9573 // userland will fail
9574 enumerable: false,
9575 get: function () {
9576 return this._writableState.highWaterMark;
9577 }
9578 });
9579
9580 // if we're already writing something, then just put this
9581 // in the queue, and wait our turn. Otherwise, call _write
9582 // If we return false, then we need a drain event, so set that flag.
9583 function writeOrBuffer(stream, state, isBuf, chunk, encoding, cb) {
9584 if (!isBuf) {
9585 var newChunk = decodeChunk(state, chunk, encoding);
9586 if (chunk !== newChunk) {
9587 isBuf = true;
9588 encoding = 'buffer';
9589 chunk = newChunk;
9590 }
9591 }
9592 var len = state.objectMode ? 1 : chunk.length;
9593
9594 state.length += len;
9595
9596 var ret = state.length < state.highWaterMark;
9597 // we must ensure that previous needDrain will not be reset to false.
9598 if (!ret) state.needDrain = true;
9599
9600 if (state.writing || state.corked) {
9601 var last = state.lastBufferedRequest;
9602 state.lastBufferedRequest = {
9603 chunk: chunk,
9604 encoding: encoding,
9605 isBuf: isBuf,
9606 callback: cb,
9607 next: null
9608 };
9609 if (last) {
9610 last.next = state.lastBufferedRequest;
9611 } else {
9612 state.bufferedRequest = state.lastBufferedRequest;
9613 }
9614 state.bufferedRequestCount += 1;
9615 } else {
9616 doWrite(stream, state, false, len, chunk, encoding, cb);
9617 }
9618
9619 return ret;
9620 }
9621
9622 function doWrite(stream, state, writev, len, chunk, encoding, cb) {
9623 state.writelen = len;
9624 state.writecb = cb;
9625 state.writing = true;
9626 state.sync = true;
9627 if (writev) stream._writev(chunk, state.onwrite);else stream._write(chunk, encoding, state.onwrite);
9628 state.sync = false;
9629 }
9630
9631 function onwriteError(stream, state, sync, er, cb) {
9632 --state.pendingcb;
9633
9634 if (sync) {
9635 // defer the callback if we are being called synchronously
9636 // to avoid piling up things on the stack
9637 pna.nextTick(cb, er);
9638 // this can emit finish, and it will always happen
9639 // after error
9640 pna.nextTick(finishMaybe, stream, state);
9641 stream._writableState.errorEmitted = true;
9642 stream.emit('error', er);
9643 } else {
9644 // the caller expect this to happen before if
9645 // it is async
9646 cb(er);
9647 stream._writableState.errorEmitted = true;
9648 stream.emit('error', er);
9649 // this can emit finish, but finish must
9650 // always follow error
9651 finishMaybe(stream, state);
9652 }
9653 }
9654
9655 function onwriteStateUpdate(state) {
9656 state.writing = false;
9657 state.writecb = null;
9658 state.length -= state.writelen;
9659 state.writelen = 0;
9660 }
9661
9662 function onwrite(stream, er) {
9663 var state = stream._writableState;
9664 var sync = state.sync;
9665 var cb = state.writecb;
9666
9667 onwriteStateUpdate(state);
9668
9669 if (er) onwriteError(stream, state, sync, er, cb);else {
9670 // Check if we're actually ready to finish, but don't emit yet
9671 var finished = needFinish(state);
9672
9673 if (!finished && !state.corked && !state.bufferProcessing && state.bufferedRequest) {
9674 clearBuffer(stream, state);
9675 }
9676
9677 if (sync) {
9678 /*<replacement>*/
9679 asyncWrite(afterWrite, stream, state, finished, cb);
9680 /*</replacement>*/
9681 } else {
9682 afterWrite(stream, state, finished, cb);
9683 }
9684 }
9685 }
9686
9687 function afterWrite(stream, state, finished, cb) {
9688 if (!finished) onwriteDrain(stream, state);
9689 state.pendingcb--;
9690 cb();
9691 finishMaybe(stream, state);
9692 }
9693
9694 // Must force callback to be called on nextTick, so that we don't
9695 // emit 'drain' before the write() consumer gets the 'false' return
9696 // value, and has a chance to attach a 'drain' listener.
9697 function onwriteDrain(stream, state) {
9698 if (state.length === 0 && state.needDrain) {
9699 state.needDrain = false;
9700 stream.emit('drain');
9701 }
9702 }
9703
9704 // if there's something in the buffer waiting, then process it
9705 function clearBuffer(stream, state) {
9706 state.bufferProcessing = true;
9707 var entry = state.bufferedRequest;
9708
9709 if (stream._writev && entry && entry.next) {
9710 // Fast case, write everything using _writev()
9711 var l = state.bufferedRequestCount;
9712 var buffer = new Array(l);
9713 var holder = state.corkedRequestsFree;
9714 holder.entry = entry;
9715
9716 var count = 0;
9717 var allBuffers = true;
9718 while (entry) {
9719 buffer[count] = entry;
9720 if (!entry.isBuf) allBuffers = false;
9721 entry = entry.next;
9722 count += 1;
9723 }
9724 buffer.allBuffers = allBuffers;
9725
9726 doWrite(stream, state, true, state.length, buffer, '', holder.finish);
9727
9728 // doWrite is almost always async, defer these to save a bit of time
9729 // as the hot path ends with doWrite
9730 state.pendingcb++;
9731 state.lastBufferedRequest = null;
9732 if (holder.next) {
9733 state.corkedRequestsFree = holder.next;
9734 holder.next = null;
9735 } else {
9736 state.corkedRequestsFree = new CorkedRequest(state);
9737 }
9738 state.bufferedRequestCount = 0;
9739 } else {
9740 // Slow case, write chunks one-by-one
9741 while (entry) {
9742 var chunk = entry.chunk;
9743 var encoding = entry.encoding;
9744 var cb = entry.callback;
9745 var len = state.objectMode ? 1 : chunk.length;
9746
9747 doWrite(stream, state, false, len, chunk, encoding, cb);
9748 entry = entry.next;
9749 state.bufferedRequestCount--;
9750 // if we didn't call the onwrite immediately, then
9751 // it means that we need to wait until it does.
9752 // also, that means that the chunk and cb are currently
9753 // being processed, so move the buffer counter past them.
9754 if (state.writing) {
9755 break;
9756 }
9757 }
9758
9759 if (entry === null) state.lastBufferedRequest = null;
9760 }
9761
9762 state.bufferedRequest = entry;
9763 state.bufferProcessing = false;
9764 }
9765
9766 Writable.prototype._write = function (chunk, encoding, cb) {
9767 cb(new Error('_write() is not implemented'));
9768 };
9769
9770 Writable.prototype._writev = null;
9771
9772 Writable.prototype.end = function (chunk, encoding, cb) {
9773 var state = this._writableState;
9774
9775 if (typeof chunk === 'function') {
9776 cb = chunk;
9777 chunk = null;
9778 encoding = null;
9779 } else if (typeof encoding === 'function') {
9780 cb = encoding;
9781 encoding = null;
9782 }
9783
9784 if (chunk !== null && chunk !== undefined) this.write(chunk, encoding);
9785
9786 // .end() fully uncorks
9787 if (state.corked) {
9788 state.corked = 1;
9789 this.uncork();
9790 }
9791
9792 // ignore unnecessary end() calls.
9793 if (!state.ending && !state.finished) endWritable(this, state, cb);
9794 };
9795
9796 function needFinish(state) {
9797 return state.ending && state.length === 0 && state.bufferedRequest === null && !state.finished && !state.writing;
9798 }
9799 function callFinal(stream, state) {
9800 stream._final(function (err) {
9801 state.pendingcb--;
9802 if (err) {
9803 stream.emit('error', err);
9804 }
9805 state.prefinished = true;
9806 stream.emit('prefinish');
9807 finishMaybe(stream, state);
9808 });
9809 }
9810 function prefinish(stream, state) {
9811 if (!state.prefinished && !state.finalCalled) {
9812 if (typeof stream._final === 'function') {
9813 state.pendingcb++;
9814 state.finalCalled = true;
9815 pna.nextTick(callFinal, stream, state);
9816 } else {
9817 state.prefinished = true;
9818 stream.emit('prefinish');
9819 }
9820 }
9821 }
9822
9823 function finishMaybe(stream, state) {
9824 var need = needFinish(state);
9825 if (need) {
9826 prefinish(stream, state);
9827 if (state.pendingcb === 0) {
9828 state.finished = true;
9829 stream.emit('finish');
9830 }
9831 }
9832 return need;
9833 }
9834
9835 function endWritable(stream, state, cb) {
9836 state.ending = true;
9837 finishMaybe(stream, state);
9838 if (cb) {
9839 if (state.finished) pna.nextTick(cb);else stream.once('finish', cb);
9840 }
9841 state.ended = true;
9842 stream.writable = false;
9843 }
9844
9845 function onCorkedFinish(corkReq, state, err) {
9846 var entry = corkReq.entry;
9847 corkReq.entry = null;
9848 while (entry) {
9849 var cb = entry.callback;
9850 state.pendingcb--;
9851 cb(err);
9852 entry = entry.next;
9853 }
9854 if (state.corkedRequestsFree) {
9855 state.corkedRequestsFree.next = corkReq;
9856 } else {
9857 state.corkedRequestsFree = corkReq;
9858 }
9859 }
9860
9861 Object.defineProperty(Writable.prototype, 'destroyed', {
9862 get: function () {
9863 if (this._writableState === undefined) {
9864 return false;
9865 }
9866 return this._writableState.destroyed;
9867 },
9868 set: function (value) {
9869 // we ignore the value if the stream
9870 // has not been initialized yet
9871 if (!this._writableState) {
9872 return;
9873 }
9874
9875 // backward compatibility, the user is explicitly
9876 // managing destroyed
9877 this._writableState.destroyed = value;
9878 }
9879 });
9880
9881 Writable.prototype.destroy = destroyImpl.destroy;
9882 Writable.prototype._undestroy = destroyImpl.undestroy;
9883 Writable.prototype._destroy = function (err, cb) {
9884 this.end();
9885 cb(err);
9886 };
9887 /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(37), __webpack_require__(48).setImmediate, (function() { return this; }())))
9888
9889/***/ }),
9890/* 48 */
9891/***/ (function(module, exports, __webpack_require__) {
9892
9893 /* WEBPACK VAR INJECTION */(function(global) {var scope = (typeof global !== "undefined" && global) ||
9894 (typeof self !== "undefined" && self) ||
9895 window;
9896 var apply = Function.prototype.apply;
9897
9898 // DOM APIs, for completeness
9899
9900 exports.setTimeout = function() {
9901 return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
9902 };
9903 exports.setInterval = function() {
9904 return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
9905 };
9906 exports.clearTimeout =
9907 exports.clearInterval = function(timeout) {
9908 if (timeout) {
9909 timeout.close();
9910 }
9911 };
9912
9913 function Timeout(id, clearFn) {
9914 this._id = id;
9915 this._clearFn = clearFn;
9916 }
9917 Timeout.prototype.unref = Timeout.prototype.ref = function() {};
9918 Timeout.prototype.close = function() {
9919 this._clearFn.call(scope, this._id);
9920 };
9921
9922 // Does not start the time, just sets up the members needed.
9923 exports.enroll = function(item, msecs) {
9924 clearTimeout(item._idleTimeoutId);
9925 item._idleTimeout = msecs;
9926 };
9927
9928 exports.unenroll = function(item) {
9929 clearTimeout(item._idleTimeoutId);
9930 item._idleTimeout = -1;
9931 };
9932
9933 exports._unrefActive = exports.active = function(item) {
9934 clearTimeout(item._idleTimeoutId);
9935
9936 var msecs = item._idleTimeout;
9937 if (msecs >= 0) {
9938 item._idleTimeoutId = setTimeout(function onTimeout() {
9939 if (item._onTimeout)
9940 item._onTimeout();
9941 }, msecs);
9942 }
9943 };
9944
9945 // setimmediate attaches itself to the global object
9946 __webpack_require__(49);
9947 // On some exotic environments, it's not clear which object `setimmediate` was
9948 // able to install onto. Search each possibility in the same order as the
9949 // `setimmediate` library.
9950 exports.setImmediate = (typeof self !== "undefined" && self.setImmediate) ||
9951 (typeof global !== "undefined" && global.setImmediate) ||
9952 (this && this.setImmediate);
9953 exports.clearImmediate = (typeof self !== "undefined" && self.clearImmediate) ||
9954 (typeof global !== "undefined" && global.clearImmediate) ||
9955 (this && this.clearImmediate);
9956
9957 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
9958
9959/***/ }),
9960/* 49 */
9961/***/ (function(module, exports, __webpack_require__) {
9962
9963 /* WEBPACK VAR INJECTION */(function(global, process) {(function (global, undefined) {
9964 "use strict";
9965
9966 if (global.setImmediate) {
9967 return;
9968 }
9969
9970 var nextHandle = 1; // Spec says greater than zero
9971 var tasksByHandle = {};
9972 var currentlyRunningATask = false;
9973 var doc = global.document;
9974 var registerImmediate;
9975
9976 function setImmediate(callback) {
9977 // Callback can either be a function or a string
9978 if (typeof callback !== "function") {
9979 callback = new Function("" + callback);
9980 }
9981 // Copy function arguments
9982 var args = new Array(arguments.length - 1);
9983 for (var i = 0; i < args.length; i++) {
9984 args[i] = arguments[i + 1];
9985 }
9986 // Store and register the task
9987 var task = { callback: callback, args: args };
9988 tasksByHandle[nextHandle] = task;
9989 registerImmediate(nextHandle);
9990 return nextHandle++;
9991 }
9992
9993 function clearImmediate(handle) {
9994 delete tasksByHandle[handle];
9995 }
9996
9997 function run(task) {
9998 var callback = task.callback;
9999 var args = task.args;
10000 switch (args.length) {
10001 case 0:
10002 callback();
10003 break;
10004 case 1:
10005 callback(args[0]);
10006 break;
10007 case 2:
10008 callback(args[0], args[1]);
10009 break;
10010 case 3:
10011 callback(args[0], args[1], args[2]);
10012 break;
10013 default:
10014 callback.apply(undefined, args);
10015 break;
10016 }
10017 }
10018
10019 function runIfPresent(handle) {
10020 // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
10021 // So if we're currently running a task, we'll need to delay this invocation.
10022 if (currentlyRunningATask) {
10023 // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
10024 // "too much recursion" error.
10025 setTimeout(runIfPresent, 0, handle);
10026 } else {
10027 var task = tasksByHandle[handle];
10028 if (task) {
10029 currentlyRunningATask = true;
10030 try {
10031 run(task);
10032 } finally {
10033 clearImmediate(handle);
10034 currentlyRunningATask = false;
10035 }
10036 }
10037 }
10038 }
10039
10040 function installNextTickImplementation() {
10041 registerImmediate = function(handle) {
10042 process.nextTick(function () { runIfPresent(handle); });
10043 };
10044 }
10045
10046 function canUsePostMessage() {
10047 // The test against `importScripts` prevents this implementation from being installed inside a web worker,
10048 // where `global.postMessage` means something completely different and can't be used for this purpose.
10049 if (global.postMessage && !global.importScripts) {
10050 var postMessageIsAsynchronous = true;
10051 var oldOnMessage = global.onmessage;
10052 global.onmessage = function() {
10053 postMessageIsAsynchronous = false;
10054 };
10055 global.postMessage("", "*");
10056 global.onmessage = oldOnMessage;
10057 return postMessageIsAsynchronous;
10058 }
10059 }
10060
10061 function installPostMessageImplementation() {
10062 // Installs an event handler on `global` for the `message` event: see
10063 // * https://developer.mozilla.org/en/DOM/window.postMessage
10064 // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
10065
10066 var messagePrefix = "setImmediate$" + Math.random() + "$";
10067 var onGlobalMessage = function(event) {
10068 if (event.source === global &&
10069 typeof event.data === "string" &&
10070 event.data.indexOf(messagePrefix) === 0) {
10071 runIfPresent(+event.data.slice(messagePrefix.length));
10072 }
10073 };
10074
10075 if (global.addEventListener) {
10076 global.addEventListener("message", onGlobalMessage, false);
10077 } else {
10078 global.attachEvent("onmessage", onGlobalMessage);
10079 }
10080
10081 registerImmediate = function(handle) {
10082 global.postMessage(messagePrefix + handle, "*");
10083 };
10084 }
10085
10086 function installMessageChannelImplementation() {
10087 var channel = new MessageChannel();
10088 channel.port1.onmessage = function(event) {
10089 var handle = event.data;
10090 runIfPresent(handle);
10091 };
10092
10093 registerImmediate = function(handle) {
10094 channel.port2.postMessage(handle);
10095 };
10096 }
10097
10098 function installReadyStateChangeImplementation() {
10099 var html = doc.documentElement;
10100 registerImmediate = function(handle) {
10101 // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
10102 // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
10103 var script = doc.createElement("script");
10104 script.onreadystatechange = function () {
10105 runIfPresent(handle);
10106 script.onreadystatechange = null;
10107 html.removeChild(script);
10108 script = null;
10109 };
10110 html.appendChild(script);
10111 };
10112 }
10113
10114 function installSetTimeoutImplementation() {
10115 registerImmediate = function(handle) {
10116 setTimeout(runIfPresent, 0, handle);
10117 };
10118 }
10119
10120 // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
10121 var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
10122 attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
10123
10124 // Don't get fooled by e.g. browserify environments.
10125 if ({}.toString.call(global.process) === "[object process]") {
10126 // For Node.js before 0.9
10127 installNextTickImplementation();
10128
10129 } else if (canUsePostMessage()) {
10130 // For non-IE10 modern browsers
10131 installPostMessageImplementation();
10132
10133 } else if (global.MessageChannel) {
10134 // For web workers, where supported
10135 installMessageChannelImplementation();
10136
10137 } else if (doc && "onreadystatechange" in doc.createElement("script")) {
10138 // For IE 6–8
10139 installReadyStateChangeImplementation();
10140
10141 } else {
10142 // For older browsers
10143 installSetTimeoutImplementation();
10144 }
10145
10146 attachTo.setImmediate = setImmediate;
10147 attachTo.clearImmediate = clearImmediate;
10148 }(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
10149
10150 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }()), __webpack_require__(37)))
10151
10152/***/ }),
10153/* 50 */
10154/***/ (function(module, exports) {
10155
10156 /* WEBPACK VAR INJECTION */(function(global) {
10157 /**
10158 * Module exports.
10159 */
10160
10161 module.exports = deprecate;
10162
10163 /**
10164 * Mark that a method should not be used.
10165 * Returns a modified function which warns once by default.
10166 *
10167 * If `localStorage.noDeprecation = true` is set, then it is a no-op.
10168 *
10169 * If `localStorage.throwDeprecation = true` is set, then deprecated functions
10170 * will throw an Error when invoked.
10171 *
10172 * If `localStorage.traceDeprecation = true` is set, then deprecated functions
10173 * will invoke `console.trace()` instead of `console.error()`.
10174 *
10175 * @param {Function} fn - the function to deprecate
10176 * @param {String} msg - the string to print to the console when `fn` is invoked
10177 * @returns {Function} a new "deprecated" version of `fn`
10178 * @api public
10179 */
10180
10181 function deprecate (fn, msg) {
10182 if (config('noDeprecation')) {
10183 return fn;
10184 }
10185
10186 var warned = false;
10187 function deprecated() {
10188 if (!warned) {
10189 if (config('throwDeprecation')) {
10190 throw new Error(msg);
10191 } else if (config('traceDeprecation')) {
10192 console.trace(msg);
10193 } else {
10194 console.warn(msg);
10195 }
10196 warned = true;
10197 }
10198 return fn.apply(this, arguments);
10199 }
10200
10201 return deprecated;
10202 }
10203
10204 /**
10205 * Checks `localStorage` for boolean values for the given `name`.
10206 *
10207 * @param {String} name
10208 * @returns {Boolean}
10209 * @api private
10210 */
10211
10212 function config (name) {
10213 // accessing global.localStorage can trigger a DOMException in sandboxed iframes
10214 try {
10215 if (!global.localStorage) return false;
10216 } catch (_) {
10217 return false;
10218 }
10219 var val = global.localStorage[name];
10220 if (null == val) return false;
10221 return String(val).toLowerCase() === 'true';
10222 }
10223
10224 /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
10225
10226/***/ }),
10227/* 51 */
10228/***/ (function(module, exports, __webpack_require__) {
10229
10230 // Copyright Joyent, Inc. and other Node contributors.
10231 //
10232 // Permission is hereby granted, free of charge, to any person obtaining a
10233 // copy of this software and associated documentation files (the
10234 // "Software"), to deal in the Software without restriction, including
10235 // without limitation the rights to use, copy, modify, merge, publish,
10236 // distribute, sublicense, and/or sell copies of the Software, and to permit
10237 // persons to whom the Software is furnished to do so, subject to the
10238 // following conditions:
10239 //
10240 // The above copyright notice and this permission notice shall be included
10241 // in all copies or substantial portions of the Software.
10242 //
10243 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10244 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10245 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10246 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10247 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10248 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10249 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10250
10251 'use strict';
10252
10253 /*<replacement>*/
10254
10255 var Buffer = __webpack_require__(40).Buffer;
10256 /*</replacement>*/
10257
10258 var isEncoding = Buffer.isEncoding || function (encoding) {
10259 encoding = '' + encoding;
10260 switch (encoding && encoding.toLowerCase()) {
10261 case 'hex':case 'utf8':case 'utf-8':case 'ascii':case 'binary':case 'base64':case 'ucs2':case 'ucs-2':case 'utf16le':case 'utf-16le':case 'raw':
10262 return true;
10263 default:
10264 return false;
10265 }
10266 };
10267
10268 function _normalizeEncoding(enc) {
10269 if (!enc) return 'utf8';
10270 var retried;
10271 while (true) {
10272 switch (enc) {
10273 case 'utf8':
10274 case 'utf-8':
10275 return 'utf8';
10276 case 'ucs2':
10277 case 'ucs-2':
10278 case 'utf16le':
10279 case 'utf-16le':
10280 return 'utf16le';
10281 case 'latin1':
10282 case 'binary':
10283 return 'latin1';
10284 case 'base64':
10285 case 'ascii':
10286 case 'hex':
10287 return enc;
10288 default:
10289 if (retried) return; // undefined
10290 enc = ('' + enc).toLowerCase();
10291 retried = true;
10292 }
10293 }
10294 };
10295
10296 // Do not cache `Buffer.isEncoding` when checking encoding names as some
10297 // modules monkey-patch it to support additional encodings
10298 function normalizeEncoding(enc) {
10299 var nenc = _normalizeEncoding(enc);
10300 if (typeof nenc !== 'string' && (Buffer.isEncoding === isEncoding || !isEncoding(enc))) throw new Error('Unknown encoding: ' + enc);
10301 return nenc || enc;
10302 }
10303
10304 // StringDecoder provides an interface for efficiently splitting a series of
10305 // buffers into a series of JS strings without breaking apart multi-byte
10306 // characters.
10307 exports.StringDecoder = StringDecoder;
10308 function StringDecoder(encoding) {
10309 this.encoding = normalizeEncoding(encoding);
10310 var nb;
10311 switch (this.encoding) {
10312 case 'utf16le':
10313 this.text = utf16Text;
10314 this.end = utf16End;
10315 nb = 4;
10316 break;
10317 case 'utf8':
10318 this.fillLast = utf8FillLast;
10319 nb = 4;
10320 break;
10321 case 'base64':
10322 this.text = base64Text;
10323 this.end = base64End;
10324 nb = 3;
10325 break;
10326 default:
10327 this.write = simpleWrite;
10328 this.end = simpleEnd;
10329 return;
10330 }
10331 this.lastNeed = 0;
10332 this.lastTotal = 0;
10333 this.lastChar = Buffer.allocUnsafe(nb);
10334 }
10335
10336 StringDecoder.prototype.write = function (buf) {
10337 if (buf.length === 0) return '';
10338 var r;
10339 var i;
10340 if (this.lastNeed) {
10341 r = this.fillLast(buf);
10342 if (r === undefined) return '';
10343 i = this.lastNeed;
10344 this.lastNeed = 0;
10345 } else {
10346 i = 0;
10347 }
10348 if (i < buf.length) return r ? r + this.text(buf, i) : this.text(buf, i);
10349 return r || '';
10350 };
10351
10352 StringDecoder.prototype.end = utf8End;
10353
10354 // Returns only complete characters in a Buffer
10355 StringDecoder.prototype.text = utf8Text;
10356
10357 // Attempts to complete a partial non-UTF-8 character using bytes from a Buffer
10358 StringDecoder.prototype.fillLast = function (buf) {
10359 if (this.lastNeed <= buf.length) {
10360 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, this.lastNeed);
10361 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
10362 }
10363 buf.copy(this.lastChar, this.lastTotal - this.lastNeed, 0, buf.length);
10364 this.lastNeed -= buf.length;
10365 };
10366
10367 // Checks the type of a UTF-8 byte, whether it's ASCII, a leading byte, or a
10368 // continuation byte. If an invalid byte is detected, -2 is returned.
10369 function utf8CheckByte(byte) {
10370 if (byte <= 0x7F) return 0;else if (byte >> 5 === 0x06) return 2;else if (byte >> 4 === 0x0E) return 3;else if (byte >> 3 === 0x1E) return 4;
10371 return byte >> 6 === 0x02 ? -1 : -2;
10372 }
10373
10374 // Checks at most 3 bytes at the end of a Buffer in order to detect an
10375 // incomplete multi-byte UTF-8 character. The total number of bytes (2, 3, or 4)
10376 // needed to complete the UTF-8 character (if applicable) are returned.
10377 function utf8CheckIncomplete(self, buf, i) {
10378 var j = buf.length - 1;
10379 if (j < i) return 0;
10380 var nb = utf8CheckByte(buf[j]);
10381 if (nb >= 0) {
10382 if (nb > 0) self.lastNeed = nb - 1;
10383 return nb;
10384 }
10385 if (--j < i || nb === -2) return 0;
10386 nb = utf8CheckByte(buf[j]);
10387 if (nb >= 0) {
10388 if (nb > 0) self.lastNeed = nb - 2;
10389 return nb;
10390 }
10391 if (--j < i || nb === -2) return 0;
10392 nb = utf8CheckByte(buf[j]);
10393 if (nb >= 0) {
10394 if (nb > 0) {
10395 if (nb === 2) nb = 0;else self.lastNeed = nb - 3;
10396 }
10397 return nb;
10398 }
10399 return 0;
10400 }
10401
10402 // Validates as many continuation bytes for a multi-byte UTF-8 character as
10403 // needed or are available. If we see a non-continuation byte where we expect
10404 // one, we "replace" the validated continuation bytes we've seen so far with
10405 // a single UTF-8 replacement character ('\ufffd'), to match v8's UTF-8 decoding
10406 // behavior. The continuation byte check is included three times in the case
10407 // where all of the continuation bytes for a character exist in the same buffer.
10408 // It is also done this way as a slight performance increase instead of using a
10409 // loop.
10410 function utf8CheckExtraBytes(self, buf, p) {
10411 if ((buf[0] & 0xC0) !== 0x80) {
10412 self.lastNeed = 0;
10413 return '\ufffd';
10414 }
10415 if (self.lastNeed > 1 && buf.length > 1) {
10416 if ((buf[1] & 0xC0) !== 0x80) {
10417 self.lastNeed = 1;
10418 return '\ufffd';
10419 }
10420 if (self.lastNeed > 2 && buf.length > 2) {
10421 if ((buf[2] & 0xC0) !== 0x80) {
10422 self.lastNeed = 2;
10423 return '\ufffd';
10424 }
10425 }
10426 }
10427 }
10428
10429 // Attempts to complete a multi-byte UTF-8 character using bytes from a Buffer.
10430 function utf8FillLast(buf) {
10431 var p = this.lastTotal - this.lastNeed;
10432 var r = utf8CheckExtraBytes(this, buf, p);
10433 if (r !== undefined) return r;
10434 if (this.lastNeed <= buf.length) {
10435 buf.copy(this.lastChar, p, 0, this.lastNeed);
10436 return this.lastChar.toString(this.encoding, 0, this.lastTotal);
10437 }
10438 buf.copy(this.lastChar, p, 0, buf.length);
10439 this.lastNeed -= buf.length;
10440 }
10441
10442 // Returns all complete UTF-8 characters in a Buffer. If the Buffer ended on a
10443 // partial character, the character's bytes are buffered until the required
10444 // number of bytes are available.
10445 function utf8Text(buf, i) {
10446 var total = utf8CheckIncomplete(this, buf, i);
10447 if (!this.lastNeed) return buf.toString('utf8', i);
10448 this.lastTotal = total;
10449 var end = buf.length - (total - this.lastNeed);
10450 buf.copy(this.lastChar, 0, end);
10451 return buf.toString('utf8', i, end);
10452 }
10453
10454 // For UTF-8, a replacement character is added when ending on a partial
10455 // character.
10456 function utf8End(buf) {
10457 var r = buf && buf.length ? this.write(buf) : '';
10458 if (this.lastNeed) return r + '\ufffd';
10459 return r;
10460 }
10461
10462 // UTF-16LE typically needs two bytes per character, but even if we have an even
10463 // number of bytes available, we need to check if we end on a leading/high
10464 // surrogate. In that case, we need to wait for the next two bytes in order to
10465 // decode the last character properly.
10466 function utf16Text(buf, i) {
10467 if ((buf.length - i) % 2 === 0) {
10468 var r = buf.toString('utf16le', i);
10469 if (r) {
10470 var c = r.charCodeAt(r.length - 1);
10471 if (c >= 0xD800 && c <= 0xDBFF) {
10472 this.lastNeed = 2;
10473 this.lastTotal = 4;
10474 this.lastChar[0] = buf[buf.length - 2];
10475 this.lastChar[1] = buf[buf.length - 1];
10476 return r.slice(0, -1);
10477 }
10478 }
10479 return r;
10480 }
10481 this.lastNeed = 1;
10482 this.lastTotal = 2;
10483 this.lastChar[0] = buf[buf.length - 1];
10484 return buf.toString('utf16le', i, buf.length - 1);
10485 }
10486
10487 // For UTF-16LE we do not explicitly append special replacement characters if we
10488 // end on a partial character, we simply let v8 handle that.
10489 function utf16End(buf) {
10490 var r = buf && buf.length ? this.write(buf) : '';
10491 if (this.lastNeed) {
10492 var end = this.lastTotal - this.lastNeed;
10493 return r + this.lastChar.toString('utf16le', 0, end);
10494 }
10495 return r;
10496 }
10497
10498 function base64Text(buf, i) {
10499 var n = (buf.length - i) % 3;
10500 if (n === 0) return buf.toString('base64', i);
10501 this.lastNeed = 3 - n;
10502 this.lastTotal = 3;
10503 if (n === 1) {
10504 this.lastChar[0] = buf[buf.length - 1];
10505 } else {
10506 this.lastChar[0] = buf[buf.length - 2];
10507 this.lastChar[1] = buf[buf.length - 1];
10508 }
10509 return buf.toString('base64', i, buf.length - n);
10510 }
10511
10512 function base64End(buf) {
10513 var r = buf && buf.length ? this.write(buf) : '';
10514 if (this.lastNeed) return r + this.lastChar.toString('base64', 0, 3 - this.lastNeed);
10515 return r;
10516 }
10517
10518 // Pass bytes on through for single-byte encodings (e.g. ascii, latin1, hex)
10519 function simpleWrite(buf) {
10520 return buf.toString(this.encoding);
10521 }
10522
10523 function simpleEnd(buf) {
10524 return buf && buf.length ? this.write(buf) : '';
10525 }
10526
10527/***/ }),
10528/* 52 */
10529/***/ (function(module, exports, __webpack_require__) {
10530
10531 // Copyright Joyent, Inc. and other Node contributors.
10532 //
10533 // Permission is hereby granted, free of charge, to any person obtaining a
10534 // copy of this software and associated documentation files (the
10535 // "Software"), to deal in the Software without restriction, including
10536 // without limitation the rights to use, copy, modify, merge, publish,
10537 // distribute, sublicense, and/or sell copies of the Software, and to permit
10538 // persons to whom the Software is furnished to do so, subject to the
10539 // following conditions:
10540 //
10541 // The above copyright notice and this permission notice shall be included
10542 // in all copies or substantial portions of the Software.
10543 //
10544 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10545 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10546 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10547 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10548 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10549 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10550 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10551
10552 // a transform stream is a readable/writable stream where you do
10553 // something with the data. Sometimes it's called a "filter",
10554 // but that's not a great name for it, since that implies a thing where
10555 // some bits pass through, and others are simply ignored. (That would
10556 // be a valid example of a transform, of course.)
10557 //
10558 // While the output is causally related to the input, it's not a
10559 // necessarily symmetric or synchronous transformation. For example,
10560 // a zlib stream might take multiple plain-text writes(), and then
10561 // emit a single compressed chunk some time in the future.
10562 //
10563 // Here's how this works:
10564 //
10565 // The Transform stream has all the aspects of the readable and writable
10566 // stream classes. When you write(chunk), that calls _write(chunk,cb)
10567 // internally, and returns false if there's a lot of pending writes
10568 // buffered up. When you call read(), that calls _read(n) until
10569 // there's enough pending readable data buffered up.
10570 //
10571 // In a transform stream, the written data is placed in a buffer. When
10572 // _read(n) is called, it transforms the queued up data, calling the
10573 // buffered _write cb's as it consumes chunks. If consuming a single
10574 // written chunk would result in multiple output chunks, then the first
10575 // outputted bit calls the readcb, and subsequent chunks just go into
10576 // the read buffer, and will cause it to emit 'readable' if necessary.
10577 //
10578 // This way, back-pressure is actually determined by the reading side,
10579 // since _read has to be called to start processing a new chunk. However,
10580 // a pathological inflate type of transform can cause excessive buffering
10581 // here. For example, imagine a stream where every byte of input is
10582 // interpreted as an integer from 0-255, and then results in that many
10583 // bytes of output. Writing the 4 bytes {ff,ff,ff,ff} would result in
10584 // 1kb of data being output. In this case, you could write a very small
10585 // amount of input, and end up with a very large amount of output. In
10586 // such a pathological inflating mechanism, there'd be no way to tell
10587 // the system to stop doing the transform. A single 4MB write could
10588 // cause the system to run out of memory.
10589 //
10590 // However, even in such a pathological case, only a single written chunk
10591 // would be consumed, and then the rest would wait (un-transformed) until
10592 // the results of the previous transformed chunk were consumed.
10593
10594 'use strict';
10595
10596 module.exports = Transform;
10597
10598 var Duplex = __webpack_require__(46);
10599
10600 /*<replacement>*/
10601 var util = Object.create(__webpack_require__(41));
10602 util.inherits = __webpack_require__(34);
10603 /*</replacement>*/
10604
10605 util.inherits(Transform, Duplex);
10606
10607 function afterTransform(er, data) {
10608 var ts = this._transformState;
10609 ts.transforming = false;
10610
10611 var cb = ts.writecb;
10612
10613 if (!cb) {
10614 return this.emit('error', new Error('write callback called multiple times'));
10615 }
10616
10617 ts.writechunk = null;
10618 ts.writecb = null;
10619
10620 if (data != null) // single equals check for both `null` and `undefined`
10621 this.push(data);
10622
10623 cb(er);
10624
10625 var rs = this._readableState;
10626 rs.reading = false;
10627 if (rs.needReadable || rs.length < rs.highWaterMark) {
10628 this._read(rs.highWaterMark);
10629 }
10630 }
10631
10632 function Transform(options) {
10633 if (!(this instanceof Transform)) return new Transform(options);
10634
10635 Duplex.call(this, options);
10636
10637 this._transformState = {
10638 afterTransform: afterTransform.bind(this),
10639 needTransform: false,
10640 transforming: false,
10641 writecb: null,
10642 writechunk: null,
10643 writeencoding: null
10644 };
10645
10646 // start out asking for a readable event once data is transformed.
10647 this._readableState.needReadable = true;
10648
10649 // we have implemented the _read method, and done the other things
10650 // that Readable wants before the first _read call, so unset the
10651 // sync guard flag.
10652 this._readableState.sync = false;
10653
10654 if (options) {
10655 if (typeof options.transform === 'function') this._transform = options.transform;
10656
10657 if (typeof options.flush === 'function') this._flush = options.flush;
10658 }
10659
10660 // When the writable side finishes, then flush out anything remaining.
10661 this.on('prefinish', prefinish);
10662 }
10663
10664 function prefinish() {
10665 var _this = this;
10666
10667 if (typeof this._flush === 'function') {
10668 this._flush(function (er, data) {
10669 done(_this, er, data);
10670 });
10671 } else {
10672 done(this, null, null);
10673 }
10674 }
10675
10676 Transform.prototype.push = function (chunk, encoding) {
10677 this._transformState.needTransform = false;
10678 return Duplex.prototype.push.call(this, chunk, encoding);
10679 };
10680
10681 // This is the part where you do stuff!
10682 // override this function in implementation classes.
10683 // 'chunk' is an input chunk.
10684 //
10685 // Call `push(newChunk)` to pass along transformed output
10686 // to the readable side. You may call 'push' zero or more times.
10687 //
10688 // Call `cb(err)` when you are done with this chunk. If you pass
10689 // an error, then that'll put the hurt on the whole operation. If you
10690 // never call cb(), then you'll never get another chunk.
10691 Transform.prototype._transform = function (chunk, encoding, cb) {
10692 throw new Error('_transform() is not implemented');
10693 };
10694
10695 Transform.prototype._write = function (chunk, encoding, cb) {
10696 var ts = this._transformState;
10697 ts.writecb = cb;
10698 ts.writechunk = chunk;
10699 ts.writeencoding = encoding;
10700 if (!ts.transforming) {
10701 var rs = this._readableState;
10702 if (ts.needTransform || rs.needReadable || rs.length < rs.highWaterMark) this._read(rs.highWaterMark);
10703 }
10704 };
10705
10706 // Doesn't matter what the args are here.
10707 // _transform does all the work.
10708 // That we got here means that the readable side wants more data.
10709 Transform.prototype._read = function (n) {
10710 var ts = this._transformState;
10711
10712 if (ts.writechunk !== null && ts.writecb && !ts.transforming) {
10713 ts.transforming = true;
10714 this._transform(ts.writechunk, ts.writeencoding, ts.afterTransform);
10715 } else {
10716 // mark that we need a transform, so that any data that comes in
10717 // will get processed, now that we've asked for it.
10718 ts.needTransform = true;
10719 }
10720 };
10721
10722 Transform.prototype._destroy = function (err, cb) {
10723 var _this2 = this;
10724
10725 Duplex.prototype._destroy.call(this, err, function (err2) {
10726 cb(err2);
10727 _this2.emit('close');
10728 });
10729 };
10730
10731 function done(stream, er, data) {
10732 if (er) return stream.emit('error', er);
10733
10734 if (data != null) // single equals check for both `null` and `undefined`
10735 stream.push(data);
10736
10737 // if there's nothing in the write buffer, then that means
10738 // that nothing more will ever be provided
10739 if (stream._writableState.length) throw new Error('Calling transform done when ws.length != 0');
10740
10741 if (stream._transformState.transforming) throw new Error('Calling transform done when still transforming');
10742
10743 return stream.push(null);
10744 }
10745
10746/***/ }),
10747/* 53 */
10748/***/ (function(module, exports, __webpack_require__) {
10749
10750 // Copyright Joyent, Inc. and other Node contributors.
10751 //
10752 // Permission is hereby granted, free of charge, to any person obtaining a
10753 // copy of this software and associated documentation files (the
10754 // "Software"), to deal in the Software without restriction, including
10755 // without limitation the rights to use, copy, modify, merge, publish,
10756 // distribute, sublicense, and/or sell copies of the Software, and to permit
10757 // persons to whom the Software is furnished to do so, subject to the
10758 // following conditions:
10759 //
10760 // The above copyright notice and this permission notice shall be included
10761 // in all copies or substantial portions of the Software.
10762 //
10763 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10764 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10765 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10766 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10767 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10768 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10769 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10770
10771 // a passthrough stream.
10772 // basically just the most minimal sort of Transform stream.
10773 // Every written chunk gets output as-is.
10774
10775 'use strict';
10776
10777 module.exports = PassThrough;
10778
10779 var Transform = __webpack_require__(52);
10780
10781 /*<replacement>*/
10782 var util = Object.create(__webpack_require__(41));
10783 util.inherits = __webpack_require__(34);
10784 /*</replacement>*/
10785
10786 util.inherits(PassThrough, Transform);
10787
10788 function PassThrough(options) {
10789 if (!(this instanceof PassThrough)) return new PassThrough(options);
10790
10791 Transform.call(this, options);
10792 }
10793
10794 PassThrough.prototype._transform = function (chunk, encoding, cb) {
10795 cb(null, chunk);
10796 };
10797
10798/***/ }),
10799/* 54 */
10800/***/ (function(module, exports, __webpack_require__) {
10801
10802 module.exports = __webpack_require__(47);
10803
10804
10805/***/ }),
10806/* 55 */
10807/***/ (function(module, exports, __webpack_require__) {
10808
10809 module.exports = __webpack_require__(46);
10810
10811
10812/***/ }),
10813/* 56 */
10814/***/ (function(module, exports, __webpack_require__) {
10815
10816 module.exports = __webpack_require__(35).Transform
10817
10818
10819/***/ }),
10820/* 57 */
10821/***/ (function(module, exports, __webpack_require__) {
10822
10823 module.exports = __webpack_require__(35).PassThrough
10824
10825
10826/***/ }),
10827/* 58 */
10828/***/ (function(module, exports, __webpack_require__) {
10829
10830 // Copyright Joyent, Inc. and other Node contributors.
10831 //
10832 // Permission is hereby granted, free of charge, to any person obtaining a
10833 // copy of this software and associated documentation files (the
10834 // "Software"), to deal in the Software without restriction, including
10835 // without limitation the rights to use, copy, modify, merge, publish,
10836 // distribute, sublicense, and/or sell copies of the Software, and to permit
10837 // persons to whom the Software is furnished to do so, subject to the
10838 // following conditions:
10839 //
10840 // The above copyright notice and this permission notice shall be included
10841 // in all copies or substantial portions of the Software.
10842 //
10843 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
10844 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10845 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
10846 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
10847 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
10848 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
10849 // USE OR OTHER DEALINGS IN THE SOFTWARE.
10850
10851 var Buffer = __webpack_require__(28).Buffer;
10852
10853 var isBufferEncoding = Buffer.isEncoding
10854 || function(encoding) {
10855 switch (encoding && encoding.toLowerCase()) {
10856 case 'hex': case 'utf8': case 'utf-8': case 'ascii': case 'binary': case 'base64': case 'ucs2': case 'ucs-2': case 'utf16le': case 'utf-16le': case 'raw': return true;
10857 default: return false;
10858 }
10859 }
10860
10861
10862 function assertEncoding(encoding) {
10863 if (encoding && !isBufferEncoding(encoding)) {
10864 throw new Error('Unknown encoding: ' + encoding);
10865 }
10866 }
10867
10868 // StringDecoder provides an interface for efficiently splitting a series of
10869 // buffers into a series of JS strings without breaking apart multi-byte
10870 // characters. CESU-8 is handled as part of the UTF-8 encoding.
10871 //
10872 // @TODO Handling all encodings inside a single object makes it very difficult
10873 // to reason about this code, so it should be split up in the future.
10874 // @TODO There should be a utf8-strict encoding that rejects invalid UTF-8 code
10875 // points as used by CESU-8.
10876 var StringDecoder = exports.StringDecoder = function(encoding) {
10877 this.encoding = (encoding || 'utf8').toLowerCase().replace(/[-_]/, '');
10878 assertEncoding(encoding);
10879 switch (this.encoding) {
10880 case 'utf8':
10881 // CESU-8 represents each of Surrogate Pair by 3-bytes
10882 this.surrogateSize = 3;
10883 break;
10884 case 'ucs2':
10885 case 'utf16le':
10886 // UTF-16 represents each of Surrogate Pair by 2-bytes
10887 this.surrogateSize = 2;
10888 this.detectIncompleteChar = utf16DetectIncompleteChar;
10889 break;
10890 case 'base64':
10891 // Base-64 stores 3 bytes in 4 chars, and pads the remainder.
10892 this.surrogateSize = 3;
10893 this.detectIncompleteChar = base64DetectIncompleteChar;
10894 break;
10895 default:
10896 this.write = passThroughWrite;
10897 return;
10898 }
10899
10900 // Enough space to store all bytes of a single character. UTF-8 needs 4
10901 // bytes, but CESU-8 may require up to 6 (3 bytes per surrogate).
10902 this.charBuffer = new Buffer(6);
10903 // Number of bytes received for the current incomplete multi-byte character.
10904 this.charReceived = 0;
10905 // Number of bytes expected for the current incomplete multi-byte character.
10906 this.charLength = 0;
10907 };
10908
10909
10910 // write decodes the given buffer and returns it as JS string that is
10911 // guaranteed to not contain any partial multi-byte characters. Any partial
10912 // character found at the end of the buffer is buffered up, and will be
10913 // returned when calling write again with the remaining bytes.
10914 //
10915 // Note: Converting a Buffer containing an orphan surrogate to a String
10916 // currently works, but converting a String to a Buffer (via `new Buffer`, or
10917 // Buffer#write) will replace incomplete surrogates with the unicode
10918 // replacement character. See https://codereview.chromium.org/121173009/ .
10919 StringDecoder.prototype.write = function(buffer) {
10920 var charStr = '';
10921 // if our last write ended with an incomplete multibyte character
10922 while (this.charLength) {
10923 // determine how many remaining bytes this buffer has to offer for this char
10924 var available = (buffer.length >= this.charLength - this.charReceived) ?
10925 this.charLength - this.charReceived :
10926 buffer.length;
10927
10928 // add the new bytes to the char buffer
10929 buffer.copy(this.charBuffer, this.charReceived, 0, available);
10930 this.charReceived += available;
10931
10932 if (this.charReceived < this.charLength) {
10933 // still not enough chars in this buffer? wait for more ...
10934 return '';
10935 }
10936
10937 // remove bytes belonging to the current character from the buffer
10938 buffer = buffer.slice(available, buffer.length);
10939
10940 // get the character that was split
10941 charStr = this.charBuffer.slice(0, this.charLength).toString(this.encoding);
10942
10943 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
10944 var charCode = charStr.charCodeAt(charStr.length - 1);
10945 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
10946 this.charLength += this.surrogateSize;
10947 charStr = '';
10948 continue;
10949 }
10950 this.charReceived = this.charLength = 0;
10951
10952 // if there are no more bytes in this buffer, just emit our char
10953 if (buffer.length === 0) {
10954 return charStr;
10955 }
10956 break;
10957 }
10958
10959 // determine and set charLength / charReceived
10960 this.detectIncompleteChar(buffer);
10961
10962 var end = buffer.length;
10963 if (this.charLength) {
10964 // buffer the incomplete character bytes we got
10965 buffer.copy(this.charBuffer, 0, buffer.length - this.charReceived, end);
10966 end -= this.charReceived;
10967 }
10968
10969 charStr += buffer.toString(this.encoding, 0, end);
10970
10971 var end = charStr.length - 1;
10972 var charCode = charStr.charCodeAt(end);
10973 // CESU-8: lead surrogate (D800-DBFF) is also the incomplete character
10974 if (charCode >= 0xD800 && charCode <= 0xDBFF) {
10975 var size = this.surrogateSize;
10976 this.charLength += size;
10977 this.charReceived += size;
10978 this.charBuffer.copy(this.charBuffer, size, 0, size);
10979 buffer.copy(this.charBuffer, 0, 0, size);
10980 return charStr.substring(0, end);
10981 }
10982
10983 // or just emit the charStr
10984 return charStr;
10985 };
10986
10987 // detectIncompleteChar determines if there is an incomplete UTF-8 character at
10988 // the end of the given buffer. If so, it sets this.charLength to the byte
10989 // length that character, and sets this.charReceived to the number of bytes
10990 // that are available for this character.
10991 StringDecoder.prototype.detectIncompleteChar = function(buffer) {
10992 // determine how many bytes we have to check at the end of this buffer
10993 var i = (buffer.length >= 3) ? 3 : buffer.length;
10994
10995 // Figure out if one of the last i bytes of our buffer announces an
10996 // incomplete char.
10997 for (; i > 0; i--) {
10998 var c = buffer[buffer.length - i];
10999
11000 // See http://en.wikipedia.org/wiki/UTF-8#Description
11001
11002 // 110XXXXX
11003 if (i == 1 && c >> 5 == 0x06) {
11004 this.charLength = 2;
11005 break;
11006 }
11007
11008 // 1110XXXX
11009 if (i <= 2 && c >> 4 == 0x0E) {
11010 this.charLength = 3;
11011 break;
11012 }
11013
11014 // 11110XXX
11015 if (i <= 3 && c >> 3 == 0x1E) {
11016 this.charLength = 4;
11017 break;
11018 }
11019 }
11020 this.charReceived = i;
11021 };
11022
11023 StringDecoder.prototype.end = function(buffer) {
11024 var res = '';
11025 if (buffer && buffer.length)
11026 res = this.write(buffer);
11027
11028 if (this.charReceived) {
11029 var cr = this.charReceived;
11030 var buf = this.charBuffer;
11031 var enc = this.encoding;
11032 res += buf.slice(0, cr).toString(enc);
11033 }
11034
11035 return res;
11036 };
11037
11038 function passThroughWrite(buffer) {
11039 return buffer.toString(this.encoding);
11040 }
11041
11042 function utf16DetectIncompleteChar(buffer) {
11043 this.charReceived = buffer.length % 2;
11044 this.charLength = this.charReceived ? 2 : 0;
11045 }
11046
11047 function base64DetectIncompleteChar(buffer) {
11048 this.charReceived = buffer.length % 3;
11049 this.charLength = this.charReceived ? 3 : 0;
11050 }
11051
11052
11053/***/ }),
11054/* 59 */
11055/***/ (function(module, exports) {
11056
11057 // Generated by CoffeeScript 1.12.7
11058 (function() {
11059 "use strict";
11060 exports.stripBOM = function(str) {
11061 if (str[0] === '\uFEFF') {
11062 return str.substring(1);
11063 } else {
11064 return str;
11065 }
11066 };
11067
11068 }).call(this);
11069
11070
11071/***/ }),
11072/* 60 */
11073/***/ (function(module, exports) {
11074
11075 // Generated by CoffeeScript 1.12.7
11076 (function() {
11077 "use strict";
11078 var prefixMatch;
11079
11080 prefixMatch = new RegExp(/(?!xmlns)^.*:/);
11081
11082 exports.normalize = function(str) {
11083 return str.toLowerCase();
11084 };
11085
11086 exports.firstCharLowerCase = function(str) {
11087 return str.charAt(0).toLowerCase() + str.slice(1);
11088 };
11089
11090 exports.stripPrefix = function(str) {
11091 return str.replace(prefixMatch, '');
11092 };
11093
11094 exports.parseNumbers = function(str) {
11095 if (!isNaN(str)) {
11096 str = str % 1 === 0 ? parseInt(str, 10) : parseFloat(str);
11097 }
11098 return str;
11099 };
11100
11101 exports.parseBooleans = function(str) {
11102 if (/^(?:true|false)$/i.test(str)) {
11103 str = str.toLowerCase() === 'true';
11104 }
11105 return str;
11106 };
11107
11108 }).call(this);
11109
11110
11111/***/ })
11112/******/ ]);
\No newline at end of file